| Left: | ||
| Right: |
| OLD | NEW |
|---|---|
| 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" |
| 11 ) | 11 ) |
| 12 | 12 |
| 13 // machineConfig represents initialization information for a new juju machine. | 13 // machineConfig represents initialization information for a new juju machine. |
| 14 // Creation of cloudinit data from this struct is largely provider-independent, | 14 // Creation of cloudinit data from this struct is largely provider-independent, |
| 15 // but we'll keep it internal until we need to factor it out. | 15 // but we'll keep it internal until we need to factor it out. |
| 16 type machineConfig struct { | 16 type machineConfig struct { |
| 17 // provisioner specifies whether the new machine will run a provisioning agent. | 17 // provisioner specifies whether the new machine will run a provisioning agent. |
| 18 provisioner bool | 18 provisioner bool |
| 19 | 19 |
| 20 // machiner specifies whether the new machine will run a machine agent. | |
| 21 machiner bool | |
|
fwereade
2012/07/16 23:07:36
I think this field is redundant: we should always
dfc
2012/07/17 00:53:22
SGTM. We can always add it back if we find a host
| |
| 22 | |
| 20 // zookeeper specifies whether the new machine will run a zookeeper inst ance. | 23 // zookeeper specifies whether the new machine will run a zookeeper inst ance. |
| 21 zookeeper bool | 24 zookeeper bool |
| 22 | 25 |
| 23 // instanceIdAccessor holds bash code that evaluates to the current inst ance id. | 26 // instanceIdAccessor holds bash code that evaluates to the current inst ance id. |
| 24 instanceIdAccessor string | 27 instanceIdAccessor string |
| 25 | 28 |
| 26 // providerType identifies the provider type so the host | 29 // providerType identifies the provider type so the host |
| 27 // knows which kind of provider to use. | 30 // knows which kind of provider to use. |
| 28 providerType string | 31 providerType string |
| 29 | 32 |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 106 if cfg.zookeeper { | 109 if cfg.zookeeper { |
| 107 addScripts(c, | 110 addScripts(c, |
| 108 jujutools+"/jujud initzk"+ | 111 jujutools+"/jujud initzk"+ |
| 109 " --instance-id "+cfg.instanceIdAccessor+ | 112 " --instance-id "+cfg.instanceIdAccessor+ |
| 110 " --env-type "+shquote(cfg.providerType)+ | 113 " --env-type "+shquote(cfg.providerType)+ |
| 111 " --zookeeper-servers localhost"+zkPortSuffix+ | 114 " --zookeeper-servers localhost"+zkPortSuffix+ |
| 112 debugFlag, | 115 debugFlag, |
| 113 ) | 116 ) |
| 114 } | 117 } |
| 115 | 118 |
| 116 // TODO start machine agent | |
|
fwereade
2012/07/16 23:07:36
Total bikeshedding: the MA feels to me more fundam
dfc
2012/07/17 00:53:22
I thought so too, but when I raised the question a
dfc
2012/07/17 00:53:22
I think this was discussed as far back as UDS-Q. P
| |
| 117 | |
| 118 if cfg.provisioner { | 119 if cfg.provisioner { |
| 119 svc := upstart.NewService("jujud-provisioning") | 120 svc := upstart.NewService("jujud-provisioning") |
| 120 // TODO(rogerpeppe) change upstart.Conf.Cmd to []string so that | 121 // TODO(rogerpeppe) change upstart.Conf.Cmd to []string so that |
| 121 // we don't have to second-guess upstart's quoting rules. | 122 // we don't have to second-guess upstart's quoting rules. |
| 122 conf := &upstart.Conf{ | 123 conf := &upstart.Conf{ |
| 123 Service: *svc, | 124 Service: *svc, |
| 124 Desc: "juju provisioning agent", | 125 Desc: "juju provisioning agent", |
| 125 Cmd: jujutools + "/jujud provisioning" + | 126 Cmd: jujutools + "/jujud provisioning" + |
| 126 " --zookeeper-servers " + fmt.Sprintf("'%s'", cf g.zookeeperHostAddrs()) + | 127 " --zookeeper-servers " + fmt.Sprintf("'%s'", cf g.zookeeperHostAddrs()) + |
| 127 " --log-file /var/log/juju/provision-agent.log" + | 128 " --log-file /var/log/juju/provision-agent.log" + |
| 128 debugFlag, | 129 debugFlag, |
| 129 } | 130 } |
| 130 cmds, err := conf.InstallCommands() | 131 cmds, err := conf.InstallCommands() |
| 131 if err != nil { | 132 if err != nil { |
| 132 return nil, fmt.Errorf("cannot make cloudinit provisioni ng agent upstart script: %v", err) | 133 return nil, fmt.Errorf("cannot make cloudinit provisioni ng agent upstart script: %v", err) |
| 133 } | 134 } |
| 134 addScripts(c, cmds...) | 135 addScripts(c, cmds...) |
| 135 } | 136 } |
| 136 | 137 |
| 138 if cfg.machiner { | |
| 139 svc := upstart.NewService("jujud-machine-agent") | |
| 140 // TODO(rogerpeppe) change upstart.Conf.Cmd to []string so that | |
| 141 // we don't have to second-guess upstart's quoting rules. | |
|
fwereade
2012/07/16 23:07:36
Not really relevant to this CL, but don't we have
dfc
2012/07/17 00:53:22
Rog ? Should I just drop these two TODO's, or open
| |
| 142 conf := &upstart.Conf{ | |
|
rog
2012/07/16 11:29:39
i think it's worth factoring out this code, especi
dfc
2012/07/17 00:53:22
Done.
| |
| 143 Service: *svc, | |
| 144 Desc: "juju machine agent", | |
| 145 Cmd: jujutools + "/jujud machine" + | |
| 146 fmt.Sprintf(" --zookeeper-servers '%s'", cfg.zoo keeperHostAddrs()) + | |
| 147 fmt.Sprintf(" --machine-id %d", cfg.machineId) + | |
| 148 " --log-file /var/log/juju/machine-agent.log" + | |
| 149 debugFlag, | |
| 150 } | |
| 151 cmds, err := conf.InstallCommands() | |
| 152 if err != nil { | |
| 153 return nil, fmt.Errorf("cannot make cloudinit machine ag ent upstart script: %v", err) | |
| 154 } | |
| 155 addScripts(c, cmds...) | |
| 156 } | |
| 157 | |
| 137 // general options | 158 // general options |
| 159 | |
| 160 // general options | |
| 138 c.SetAptUpgrade(true) | 161 c.SetAptUpgrade(true) |
| 139 c.SetAptUpdate(true) | 162 c.SetAptUpdate(true) |
| 140 c.SetOutput(cloudinit.OutAll, "| tee -a /var/log/cloud-init-output.log", "") | 163 c.SetOutput(cloudinit.OutAll, "| tee -a /var/log/cloud-init-output.log", "") |
| 141 return c, nil | 164 return c, nil |
| 142 } | 165 } |
| 143 | 166 |
| 144 // versionDir converts a tools URL into a name | 167 // versionDir converts a tools URL into a name |
| 145 // to use as a directory for storing the tools executables in | 168 // to use as a directory for storing the tools executables in |
| 146 // by using the last element stripped of its extension. | 169 // by using the last element stripped of its extension. |
| 147 func versionDir(toolsURL string) string { | 170 func versionDir(toolsURL string) string { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 182 if cfg.instanceIdAccessor == "" { | 205 if cfg.instanceIdAccessor == "" { |
| 183 return requiresError("instance id accessor") | 206 return requiresError("instance id accessor") |
| 184 } | 207 } |
| 185 } else { | 208 } else { |
| 186 if cfg.stateInfo == nil || len(cfg.stateInfo.Addrs) == 0 { | 209 if cfg.stateInfo == nil || len(cfg.stateInfo.Addrs) == 0 { |
| 187 return requiresError("zookeeper hosts") | 210 return requiresError("zookeeper hosts") |
| 188 } | 211 } |
| 189 } | 212 } |
| 190 return nil | 213 return nil |
| 191 } | 214 } |
| OLD | NEW |