Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(1594)

Delta Between Two Patch Sets: environs/ec2/cloudinit.go

Issue 6347044: environs/ec2: bootstrap (Closed)
Left Patch Set: environs/ec2: bootstrap Created 11 years, 8 months ago
Right Patch Set: environs/ec2: bootstrap Created 11 years, 8 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « environs/dummy/environs_test.go ('k') | environs/ec2/cloudinit_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 package ec2 1 package ec2
2 2
3 import ( 3 import (
4 "fmt" 4 "fmt"
5 "launchpad.net/juju-core/cloudinit" 5 "launchpad.net/juju-core/cloudinit"
6 "launchpad.net/juju-core/log" 6 "launchpad.net/juju-core/log"
7 "launchpad.net/juju-core/state" 7 "launchpad.net/juju-core/state"
8 "launchpad.net/juju-core/upstart" 8 "launchpad.net/juju-core/upstart"
9 "path" 9 "path"
10 "strings" 10 "strings"
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if log.Debug { 101 if log.Debug {
102 debugFlag = " --debug" 102 debugFlag = " --debug"
103 } 103 }
104 104
105 // zookeeper scripts 105 // zookeeper scripts
106 if cfg.zookeeper { 106 if cfg.zookeeper {
107 addScripts(c, 107 addScripts(c,
108 jujutools+"/jujud initzk"+ 108 jujutools+"/jujud initzk"+
109 " --instance-id "+cfg.instanceIdAccessor+ 109 " --instance-id "+cfg.instanceIdAccessor+
110 " --env-type "+shquote(cfg.providerType)+ 110 " --env-type "+shquote(cfg.providerType)+
111 » » » » " --zookeeper-servers localhost"+zkPortSuffix()+ 111 » » » » " --zookeeper-servers localhost"+zkPortSuffix+
112 debugFlag, 112 debugFlag,
113 ) 113 )
114 } 114 }
115 115
116 // TODO start machine agent 116 // TODO start machine agent
117 117
118 if cfg.provisioner { 118 if cfg.provisioner {
119 » » svc := upstart.NewService("juju-provision-agent") 119 » » svc := upstart.NewService("jujud-provisioning")
120 » » // TODO change upstart.Conf.Cmd to []string so that 120 » » // TODO(rogerpeppe) change upstart.Conf.Cmd to []string so that
121 // we don't have to second-guess upstart's quoting rules. 121 // we don't have to second-guess upstart's quoting rules.
122 conf := &upstart.Conf{ 122 conf := &upstart.Conf{
123 Service: *svc, 123 Service: *svc,
124 Desc: "juju provisioning agent", 124 Desc: "juju provisioning agent",
125 Cmd: jujutools + "/jujud provisioning" + 125 Cmd: jujutools + "/jujud provisioning" +
126 » » » » " --zookeeper-servers " + fmt.Sprintf("%q", cfg. zookeeperHostAddrs()) + 126 » » » » " --zookeeper-servers " + fmt.Sprintf("'%s'", cf g.zookeeperHostAddrs()) +
127 " --log-file /var/log/juju/provision-agent.log" + 127 " --log-file /var/log/juju/provision-agent.log" +
128 debugFlag, 128 debugFlag,
129 // TODO Out?
130 } 129 }
131 cmds, err := conf.InstallCommands() 130 cmds, err := conf.InstallCommands()
132 if err != nil { 131 if err != nil {
133 return nil, fmt.Errorf("cannot make cloudinit provisioni ng agent upstart script: %v", err) 132 return nil, fmt.Errorf("cannot make cloudinit provisioni ng agent upstart script: %v", err)
134 } 133 }
135 addScripts(c, cmds...) 134 addScripts(c, cmds...)
136 } 135 }
137 136
138 // general options 137 // general options
139 c.SetAptUpgrade(true) 138 c.SetAptUpgrade(true)
140 c.SetAptUpdate(true) 139 c.SetAptUpdate(true)
141 c.SetOutput(cloudinit.OutAll, "| tee -a /var/log/cloud-init-output.log", "") 140 c.SetOutput(cloudinit.OutAll, "| tee -a /var/log/cloud-init-output.log", "")
142 return c, nil 141 return c, nil
143 } 142 }
144 143
145 // versionDir converts a tools URL into a name 144 // versionDir converts a tools URL into a name
146 // to use as a directory for storing the tools executables in 145 // to use as a directory for storing the tools executables in
147 // by using the last element stripped of its extension. 146 // by using the last element stripped of its extension.
148 func versionDir(toolsURL string) string { 147 func versionDir(toolsURL string) string {
149 name := path.Base(toolsURL) 148 name := path.Base(toolsURL)
150 ext := path.Ext(name) 149 ext := path.Ext(name)
151 return name[:len(name)-len(ext)] 150 return name[:len(name)-len(ext)]
152 } 151 }
153 152
154 func (cfg *machineConfig) zookeeperHostAddrs() string { 153 func (cfg *machineConfig) zookeeperHostAddrs() string {
155 var hosts []string 154 var hosts []string
156 if cfg.zookeeper { 155 if cfg.zookeeper {
157 » » hosts = append(hosts, "localhost"+zkPortSuffix()) 156 » » hosts = append(hosts, "localhost"+zkPortSuffix)
158 } 157 }
159 if cfg.stateInfo != nil { 158 if cfg.stateInfo != nil {
160 hosts = append(hosts, cfg.stateInfo.Addrs...) 159 hosts = append(hosts, cfg.stateInfo.Addrs...)
161 } 160 }
162 return strings.Join(hosts, ",") 161 return strings.Join(hosts, ",")
163 } 162 }
164 163
165 // shquote quotes s so that when read by bash, no metacharacters 164 // shquote quotes s so that when read by bash, no metacharacters
166 // within s will be interpreted as such. 165 // within s will be interpreted as such.
167 func shquote(s string) string { 166 func shquote(s string) string {
(...skipping 15 matching lines...) Expand all
183 if cfg.instanceIdAccessor == "" { 182 if cfg.instanceIdAccessor == "" {
184 return requiresError("instance id accessor") 183 return requiresError("instance id accessor")
185 } 184 }
186 } else { 185 } else {
187 if cfg.stateInfo == nil || len(cfg.stateInfo.Addrs) == 0 { 186 if cfg.stateInfo == nil || len(cfg.stateInfo.Addrs) == 0 {
188 return requiresError("zookeeper hosts") 187 return requiresError("zookeeper hosts")
189 } 188 }
190 } 189 }
191 return nil 190 return nil
192 } 191 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b