Merge lp:~thumper/juju-core/machine-agent-environment into lp:~go-bot/juju-core/trunk
- machine-agent-environment
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Tim Penhey |
Approved revision: | no longer in the source branch. |
Merged at revision: | 1574 |
Proposed branch: | lp:~thumper/juju-core/machine-agent-environment |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
583 lines (+142/-75) 19 files modified
cmd/juju/cmd_test.go (+6/-5) cmd/juju/deploy.go (+2/-1) cmd/juju/environmentcommand.go (+2/-1) cmd/juju/environmentcommand_test.go (+4/-2) cmd/juju/main_test.go (+10/-7) cmd/jujud/machine.go (+2/-1) cmd/jujud/upgradevalidation.go (+2/-1) environs/azure/customdata_test.go (+0/-1) environs/cloudinit.go (+5/-1) environs/cloudinit/cloudinit.go (+4/-6) environs/cloudinit/cloudinit_test.go (+24/-23) environs/cloudinit_test.go (+11/-10) environs/local/environ.go (+11/-7) environs/local/storage/worker.go (+5/-4) juju/osenv/package_test.go (+14/-0) juju/osenv/vars.go (+16/-0) juju/osenv/vars_test.go (+20/-0) upstart/service.go (+2/-4) worker/deployer/simple.go (+2/-1) |
To merge this branch: | bzr merge lp:~thumper/juju-core/machine-agent-environment |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+177707@code.launchpad.net |
Commit message
Use a map to store machine environment in config.
The MachineConfig now uses a map to store the environment
for the machine agent.
Description of the change
Use a map to store machine environment in config.
The MachineConfig now uses a map to store the environment
for the machine agent.
Tim Penhey (thumper) wrote : | # |
Ian Booth (wallyworld) wrote : | # |
LGTM with the cloudinit/cloudinit fix
https:/
File environs/
https:/
environs/
= cfg.Type()
JUJU_PROVIDER_TYPE should be a const somewhere since it's used in a few
places
https:/
File environs/
https:/
environs/
Shouldn't we look in the map to ensure the provider type is set?
Tim Penhey (thumper) wrote : | # |
https:/
File environs/
https:/
environs/
= cfg.Type()
On 2013/07/31 03:32:27, wallyworld wrote:
> JUJU_PROVIDER_TYPE should be a const somewhere since it's used in a
few places
Yes, I have been thinking about this for a while. Might as well do it
now.
https:/
File environs/
https:/
environs/
On 2013/07/31 03:32:27, wallyworld wrote:
> Shouldn't we look in the map to ensure the provider type is set?
It doesn't make it invalid like the others. So, in this case, no I
don't think so.
I felt a little uneasy making the change before that put it in there.
Tim Penhey (thumper) wrote : | # |
Please take a look.
Tim Penhey (thumper) wrote : | # |
On 2013/07/31 05:14:16, thumper wrote:
> Please take a look.
I started updating some of the call sites to use the new osenv
constants, but realised there were LOTS, so stopped.
Tim Penhey (thumper) wrote : | # |
Please take a look.
Jeroen T. Vermeulen (jtv) wrote : | # |
LGTM, except you have conflicts. Silly ones, from the looks of it:
mostly imports, but also a case where a function gained or lost an error
return.
I was expecting to see changes to more providers' tests. Don't those
need to set the provider type in various places as well?
Tim Penhey (thumper) wrote : | # |
On 2013/07/31 06:26:34, jtv.canonical wrote:
> LGTM, except you have conflicts. Silly ones, from the looks of it:
mostly
> imports, but also a case where a function gained or lost an error
return.
> I was expecting to see changes to more providers' tests. Don't those
need to
> set the provider type in various places as well?
It is handled by the generic environs function FinishMachineCo
Preview Diff
1 | === modified file 'cmd/juju/cmd_test.go' |
2 | --- cmd/juju/cmd_test.go 2013-07-11 03:25:06 +0000 |
3 | +++ cmd/juju/cmd_test.go 2013-07-31 21:52:25 +0000 |
4 | @@ -10,6 +10,7 @@ |
5 | . "launchpad.net/gocheck" |
6 | "launchpad.net/juju-core/cmd" |
7 | "launchpad.net/juju-core/environs/dummy" |
8 | + "launchpad.net/juju-core/juju/osenv" |
9 | "launchpad.net/juju-core/juju/testing" |
10 | coretesting "launchpad.net/juju-core/testing" |
11 | "launchpad.net/juju-core/testing/checkers" |
12 | @@ -106,10 +107,10 @@ |
13 | |
14 | // JUJU_ENV is the final place the environment can be overriden |
15 | com, args = cmdFunc() |
16 | - oldenv := os.Getenv("JUJU_ENV") |
17 | - os.Setenv("JUJU_ENV", "walthamstow") |
18 | + oldenv := os.Getenv(osenv.JujuEnv) |
19 | + os.Setenv(osenv.JujuEnv, "walthamstow") |
20 | testInit(c, com, args, "") |
21 | - os.Setenv("JUJU_ENV", oldenv) |
22 | + os.Setenv(osenv.JujuEnv, oldenv) |
23 | assertConnName(c, com, "walthamstow") |
24 | |
25 | com, args = cmdFunc() |
26 | @@ -196,8 +197,8 @@ |
27 | } |
28 | |
29 | func (*CmdSuite) TestDeployCommandInit(c *C) { |
30 | - defer os.Setenv("JUJU_REPOSITORY", os.Getenv("JUJU_REPOSITORY")) |
31 | - os.Setenv("JUJU_REPOSITORY", "/path/to/repo") |
32 | + defer os.Setenv(osenv.JujuRepository, os.Getenv(osenv.JujuRepository)) |
33 | + os.Setenv(osenv.JujuRepository, "/path/to/repo") |
34 | |
35 | for _, t := range deployTests { |
36 | initExpectations(t.com) |
37 | |
38 | === modified file 'cmd/juju/deploy.go' |
39 | --- cmd/juju/deploy.go 2013-07-30 14:00:53 +0000 |
40 | +++ cmd/juju/deploy.go 2013-07-31 21:52:25 +0000 |
41 | @@ -14,6 +14,7 @@ |
42 | "launchpad.net/juju-core/cmd" |
43 | "launchpad.net/juju-core/constraints" |
44 | "launchpad.net/juju-core/juju" |
45 | + "launchpad.net/juju-core/juju/osenv" |
46 | "launchpad.net/juju-core/names" |
47 | ) |
48 | |
49 | @@ -72,7 +73,7 @@ |
50 | f.BoolVar(&c.BumpRevision, "upgrade", false, "") |
51 | f.Var(&c.Config, "config", "path to yaml-formatted service config") |
52 | f.Var(constraints.ConstraintsValue{&c.Constraints}, "constraints", "set service constraints") |
53 | - f.StringVar(&c.RepoPath, "repository", os.Getenv("JUJU_REPOSITORY"), "local charm repository") |
54 | + f.StringVar(&c.RepoPath, "repository", os.Getenv(osenv.JujuRepository), "local charm repository") |
55 | } |
56 | |
57 | func (c *DeployCommand) Init(args []string) error { |
58 | |
59 | === modified file 'cmd/juju/environmentcommand.go' |
60 | --- cmd/juju/environmentcommand.go 2013-05-10 20:55:57 +0000 |
61 | +++ cmd/juju/environmentcommand.go 2013-07-31 21:52:25 +0000 |
62 | @@ -13,6 +13,7 @@ |
63 | "launchpad.net/gnuflag" |
64 | "launchpad.net/juju-core/cmd" |
65 | "launchpad.net/juju-core/environs/config" |
66 | + "launchpad.net/juju-core/juju/osenv" |
67 | ) |
68 | |
69 | const CurrentEnvironmentFilename = "current-environment" |
70 | @@ -55,7 +56,7 @@ |
71 | // JUJU_ENV environment variable. If that is set, it gets used. If it isn't |
72 | // set, look in the $JUJU_HOME/current-environment file. |
73 | func getDefaultEnvironment() string { |
74 | - defaultEnv := os.Getenv("JUJU_ENV") |
75 | + defaultEnv := os.Getenv(osenv.JujuEnv) |
76 | if defaultEnv != "" { |
77 | return defaultEnv |
78 | } |
79 | |
80 | === modified file 'cmd/juju/environmentcommand_test.go' |
81 | --- cmd/juju/environmentcommand_test.go 2013-05-10 20:55:57 +0000 |
82 | +++ cmd/juju/environmentcommand_test.go 2013-07-31 21:52:25 +0000 |
83 | @@ -8,6 +8,8 @@ |
84 | "os" |
85 | |
86 | . "launchpad.net/gocheck" |
87 | + |
88 | + "launchpad.net/juju-core/juju/osenv" |
89 | "launchpad.net/juju-core/testing" |
90 | ) |
91 | |
92 | @@ -50,13 +52,13 @@ |
93 | } |
94 | |
95 | func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentJujuEnvSet(c *C) { |
96 | - os.Setenv("JUJU_ENV", "magic") |
97 | + os.Setenv(osenv.JujuEnv, "magic") |
98 | env := getDefaultEnvironment() |
99 | c.Assert(env, Equals, "magic") |
100 | } |
101 | |
102 | func (s *EnvironmentCommandSuite) TestGetDefaultEnvironmentBothSet(c *C) { |
103 | - os.Setenv("JUJU_ENV", "magic") |
104 | + os.Setenv(osenv.JujuEnv, "magic") |
105 | err := writeCurrentEnvironment("fubar") |
106 | c.Assert(err, IsNil) |
107 | env := getDefaultEnvironment() |
108 | |
109 | === modified file 'cmd/juju/main_test.go' |
110 | --- cmd/juju/main_test.go 2013-07-26 00:58:46 +0000 |
111 | +++ cmd/juju/main_test.go 2013-07-31 21:52:25 +0000 |
112 | @@ -8,19 +8,22 @@ |
113 | "flag" |
114 | "fmt" |
115 | "io/ioutil" |
116 | + "os" |
117 | + "os/exec" |
118 | + "path/filepath" |
119 | + "strings" |
120 | + stdtesting "testing" |
121 | + |
122 | "launchpad.net/gnuflag" |
123 | . "launchpad.net/gocheck" |
124 | + "launchpad.net/loggo" |
125 | + |
126 | "launchpad.net/juju-core/cmd" |
127 | "launchpad.net/juju-core/environs/config" |
128 | _ "launchpad.net/juju-core/environs/dummy" |
129 | + "launchpad.net/juju-core/juju/osenv" |
130 | "launchpad.net/juju-core/testing" |
131 | "launchpad.net/juju-core/version" |
132 | - "launchpad.net/loggo" |
133 | - "os" |
134 | - "os/exec" |
135 | - "path/filepath" |
136 | - "strings" |
137 | - stdtesting "testing" |
138 | ) |
139 | |
140 | func TestPackage(t *stdtesting.T) { |
141 | @@ -46,7 +49,7 @@ |
142 | func badrun(c *C, exit int, args ...string) string { |
143 | localArgs := append([]string{"-test.run", "TestRunMain", "-run-main", "--", "juju"}, args...) |
144 | ps := exec.Command(os.Args[0], localArgs...) |
145 | - ps.Env = append(os.Environ(), "JUJU_HOME="+config.JujuHome()) |
146 | + ps.Env = append(os.Environ(), osenv.JujuHome+"="+config.JujuHome()) |
147 | output, err := ps.CombinedOutput() |
148 | if exit != 0 { |
149 | c.Assert(err, ErrorMatches, fmt.Sprintf("exit status %d", exit)) |
150 | |
151 | === modified file 'cmd/jujud/machine.go' |
152 | --- cmd/jujud/machine.go 2013-07-30 16:39:37 +0000 |
153 | +++ cmd/jujud/machine.go 2013-07-31 21:52:25 +0000 |
154 | @@ -17,6 +17,7 @@ |
155 | localstorage "launchpad.net/juju-core/environs/local/storage" |
156 | "launchpad.net/juju-core/environs/provider" |
157 | "launchpad.net/juju-core/instance" |
158 | + "launchpad.net/juju-core/juju/osenv" |
159 | "launchpad.net/juju-core/log" |
160 | "launchpad.net/juju-core/names" |
161 | "launchpad.net/juju-core/state" |
162 | @@ -222,7 +223,7 @@ |
163 | // containers, it is likely that we will want an LXC provisioner on a KVM |
164 | // machine, and once we get nested LXC containers, we can remove this |
165 | // check. |
166 | - providerType := os.Getenv("JUJU_PROVIDER_TYPE") |
167 | + providerType := os.Getenv(osenv.JujuProviderType) |
168 | if providerType != provider.Local && m.ContainerType() != instance.LXC { |
169 | workerName := fmt.Sprintf("%s-provisioner", provisioner.LXC) |
170 | runner.StartWorker(workerName, func() (worker.Worker, error) { |
171 | |
172 | === modified file 'cmd/jujud/upgradevalidation.go' |
173 | --- cmd/jujud/upgradevalidation.go 2013-07-30 16:30:58 +0000 |
174 | +++ cmd/jujud/upgradevalidation.go 2013-07-31 21:52:25 +0000 |
175 | @@ -14,6 +14,7 @@ |
176 | "launchpad.net/juju-core/container/lxc" |
177 | "launchpad.net/juju-core/environs/provider" |
178 | "launchpad.net/juju-core/instance" |
179 | + "launchpad.net/juju-core/juju/osenv" |
180 | "launchpad.net/juju-core/names" |
181 | "launchpad.net/juju-core/state" |
182 | "launchpad.net/juju-core/state/api" |
183 | @@ -66,7 +67,7 @@ |
184 | return err |
185 | } |
186 | containerType := state.ContainerTypeFromId(id) |
187 | - providerType := os.Getenv("JUJU_PROVIDER_TYPE") |
188 | + providerType := os.Getenv(osenv.JujuProviderType) |
189 | if providerType == provider.Local || containerType == instance.LXC { |
190 | return nil |
191 | } |
192 | |
193 | === modified file 'environs/azure/customdata_test.go' |
194 | --- environs/azure/customdata_test.go 2013-07-29 15:15:41 +0000 |
195 | +++ environs/azure/customdata_test.go 2013-07-31 21:52:25 +0000 |
196 | @@ -40,7 +40,6 @@ |
197 | Addrs: []string{"127.0.0.1:123"}, |
198 | Tag: names.MachineTag(machineID), |
199 | }, |
200 | - ProviderType: "azure", |
201 | } |
202 | } |
203 | |
204 | |
205 | === modified file 'environs/cloudinit.go' |
206 | --- environs/cloudinit.go 2013-07-19 18:26:41 +0000 |
207 | +++ environs/cloudinit.go 2013-07-31 21:52:25 +0000 |
208 | @@ -10,6 +10,7 @@ |
209 | "launchpad.net/juju-core/constraints" |
210 | "launchpad.net/juju-core/environs/cloudinit" |
211 | "launchpad.net/juju-core/environs/config" |
212 | + "launchpad.net/juju-core/juju/osenv" |
213 | "launchpad.net/juju-core/state" |
214 | "launchpad.net/juju-core/state/api" |
215 | "launchpad.net/juju-core/utils" |
216 | @@ -69,7 +70,10 @@ |
217 | return fmt.Errorf("environment configuration has no authorized-keys") |
218 | } |
219 | mcfg.AuthorizedKeys = authKeys |
220 | - mcfg.ProviderType = cfg.Type() |
221 | + if mcfg.MachineEnvironment == nil { |
222 | + mcfg.MachineEnvironment = make(map[string]string) |
223 | + } |
224 | + mcfg.MachineEnvironment[osenv.JujuProviderType] = cfg.Type() |
225 | if !mcfg.StateServer { |
226 | return nil |
227 | } |
228 | |
229 | === modified file 'environs/cloudinit/cloudinit.go' |
230 | --- environs/cloudinit/cloudinit.go 2013-07-30 16:30:58 +0000 |
231 | +++ environs/cloudinit/cloudinit.go 2013-07-31 21:52:25 +0000 |
232 | @@ -92,8 +92,9 @@ |
233 | // commands cannot work. |
234 | AuthorizedKeys string |
235 | |
236 | - // ProviderType refers to the type of the provider that created the machine. |
237 | - ProviderType string |
238 | + // MachineEnvironment defines additional environment variables to set in |
239 | + // the machine agent upstart script. |
240 | + MachineEnvironment map[string]string |
241 | |
242 | // Config holds the initial environment configuration. |
243 | Config *config.Config |
244 | @@ -292,7 +293,7 @@ |
245 | addScripts(c, fmt.Sprintf("ln -s %v %s", cfg.Tools.Version, shquote(toolsDir))) |
246 | |
247 | name := "jujud-" + tag |
248 | - conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig, cfg.ProviderType) |
249 | + conf := upstart.MachineAgentUpstartService(name, toolsDir, cfg.DataDir, "/var/log/juju/", tag, machineId, logConfig, cfg.MachineEnvironment) |
250 | cmds, err := conf.InstallCommands() |
251 | if err != nil { |
252 | return fmt.Errorf("cannot make cloud-init upstart script for the %s agent: %v", tag, err) |
253 | @@ -398,9 +399,6 @@ |
254 | if len(cfg.APIInfo.CACert) == 0 { |
255 | return fmt.Errorf("missing API CA certificate") |
256 | } |
257 | - if cfg.ProviderType == "" { |
258 | - return fmt.Errorf("missing provider type") |
259 | - } |
260 | if cfg.StateServer { |
261 | if cfg.Config == nil { |
262 | return fmt.Errorf("missing environment configuration") |
263 | |
264 | === modified file 'environs/cloudinit/cloudinit_test.go' |
265 | --- environs/cloudinit/cloudinit_test.go 2013-07-24 16:08:50 +0000 |
266 | +++ environs/cloudinit/cloudinit_test.go 2013-07-31 21:52:25 +0000 |
267 | @@ -17,6 +17,7 @@ |
268 | "launchpad.net/juju-core/environs" |
269 | "launchpad.net/juju-core/environs/cloudinit" |
270 | "launchpad.net/juju-core/environs/config" |
271 | + "launchpad.net/juju-core/juju/osenv" |
272 | "launchpad.net/juju-core/state" |
273 | "launchpad.net/juju-core/state/api" |
274 | "launchpad.net/juju-core/testing" |
275 | @@ -58,9 +59,9 @@ |
276 | { |
277 | // precise state server |
278 | cfg: cloudinit.MachineConfig{ |
279 | - MachineId: "0", |
280 | - AuthorizedKeys: "sshkey1", |
281 | - ProviderType: "dummy", |
282 | + MachineId: "0", |
283 | + AuthorizedKeys: "sshkey1", |
284 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
285 | // precise currently needs mongo from PPA |
286 | Tools: newSimpleTools("1.2.3-precise-amd64"), |
287 | StateServer: true, |
288 | @@ -116,9 +117,9 @@ |
289 | }, { |
290 | // raring state server |
291 | cfg: cloudinit.MachineConfig{ |
292 | - MachineId: "0", |
293 | - AuthorizedKeys: "sshkey1", |
294 | - ProviderType: "dummy", |
295 | + MachineId: "0", |
296 | + AuthorizedKeys: "sshkey1", |
297 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
298 | // raring provides mongo in the archive |
299 | Tools: newSimpleTools("1.2.3-raring-amd64"), |
300 | StateServer: true, |
301 | @@ -173,13 +174,13 @@ |
302 | `, |
303 | }, { |
304 | cfg: cloudinit.MachineConfig{ |
305 | - MachineId: "99", |
306 | - AuthorizedKeys: "sshkey1", |
307 | - ProviderType: "dummy", |
308 | - DataDir: environs.DataDir, |
309 | - StateServer: false, |
310 | - Tools: newSimpleTools("1.2.3-linux-amd64"), |
311 | - MachineNonce: "FAKE_NONCE", |
312 | + MachineId: "99", |
313 | + AuthorizedKeys: "sshkey1", |
314 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
315 | + DataDir: environs.DataDir, |
316 | + StateServer: false, |
317 | + Tools: newSimpleTools("1.2.3-linux-amd64"), |
318 | + MachineNonce: "FAKE_NONCE", |
319 | StateInfo: &state.Info{ |
320 | Addrs: []string{"state-addr.testing.invalid:12345"}, |
321 | Tag: "machine-99", |
322 | @@ -215,7 +216,7 @@ |
323 | MachineId: "2/lxc/1", |
324 | MachineContainerType: "lxc", |
325 | AuthorizedKeys: "sshkey1", |
326 | - ProviderType: "dummy", |
327 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
328 | DataDir: environs.DataDir, |
329 | StateServer: false, |
330 | Tools: newSimpleTools("1.2.3-linux-amd64"), |
331 | @@ -557,15 +558,15 @@ |
332 | // checked for by NewCloudInit. |
333 | func (*cloudinitSuite) TestCloudInitVerify(c *C) { |
334 | cfg := &cloudinit.MachineConfig{ |
335 | - StateServer: true, |
336 | - StateServerCert: serverCert, |
337 | - StateServerKey: serverKey, |
338 | - StatePort: 1234, |
339 | - APIPort: 1235, |
340 | - MachineId: "99", |
341 | - Tools: newSimpleTools("9.9.9-linux-arble"), |
342 | - AuthorizedKeys: "sshkey1", |
343 | - ProviderType: "dummy", |
344 | + StateServer: true, |
345 | + StateServerCert: serverCert, |
346 | + StateServerKey: serverKey, |
347 | + StatePort: 1234, |
348 | + APIPort: 1235, |
349 | + MachineId: "99", |
350 | + Tools: newSimpleTools("9.9.9-linux-arble"), |
351 | + AuthorizedKeys: "sshkey1", |
352 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
353 | StateInfo: &state.Info{ |
354 | Addrs: []string{"host:98765"}, |
355 | CACert: []byte(testing.CACert), |
356 | |
357 | === modified file 'environs/cloudinit_test.go' |
358 | --- environs/cloudinit_test.go 2013-07-24 16:08:50 +0000 |
359 | +++ environs/cloudinit_test.go 2013-07-31 21:52:25 +0000 |
360 | @@ -15,6 +15,7 @@ |
361 | "launchpad.net/juju-core/environs" |
362 | "launchpad.net/juju-core/environs/cloudinit" |
363 | "launchpad.net/juju-core/environs/config" |
364 | + "launchpad.net/juju-core/juju/osenv" |
365 | "launchpad.net/juju-core/state" |
366 | "launchpad.net/juju-core/state/api" |
367 | "launchpad.net/juju-core/testing" |
368 | @@ -42,10 +43,10 @@ |
369 | err = environs.FinishMachineConfig(mcfg, cfg, constraints.Value{}) |
370 | c.Assert(err, IsNil) |
371 | c.Assert(mcfg, DeepEquals, &cloudinit.MachineConfig{ |
372 | - AuthorizedKeys: "we-are-the-keys", |
373 | - ProviderType: "dummy", |
374 | - StateInfo: &state.Info{Tag: "not touched"}, |
375 | - APIInfo: &api.Info{Tag: "not touched"}, |
376 | + AuthorizedKeys: "we-are-the-keys", |
377 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
378 | + StateInfo: &state.Info{Tag: "not touched"}, |
379 | + APIInfo: &api.Info{Tag: "not touched"}, |
380 | }) |
381 | } |
382 | |
383 | @@ -128,12 +129,12 @@ |
384 | Password: "pw2", |
385 | CACert: []byte("CA CERT\n" + testing.CACert), |
386 | }, |
387 | - DataDir: environs.DataDir, |
388 | - Config: envConfig, |
389 | - StatePort: envConfig.StatePort(), |
390 | - APIPort: envConfig.APIPort(), |
391 | - StateServer: true, |
392 | - ProviderType: "dummy", |
393 | + DataDir: environs.DataDir, |
394 | + Config: envConfig, |
395 | + StatePort: envConfig.StatePort(), |
396 | + APIPort: envConfig.APIPort(), |
397 | + StateServer: true, |
398 | + MachineEnvironment: map[string]string{osenv.JujuProviderType: "dummy"}, |
399 | } |
400 | script1 := "script1" |
401 | script2 := "script2" |
402 | |
403 | === modified file 'environs/local/environ.go' |
404 | --- environs/local/environ.go 2013-07-30 16:39:37 +0000 |
405 | +++ environs/local/environ.go 2013-07-31 21:52:25 +0000 |
406 | @@ -21,6 +21,7 @@ |
407 | "launchpad.net/juju-core/environs/config" |
408 | "launchpad.net/juju-core/environs/localstorage" |
409 | "launchpad.net/juju-core/instance" |
410 | + "launchpad.net/juju-core/juju/osenv" |
411 | "launchpad.net/juju-core/names" |
412 | "launchpad.net/juju-core/state" |
413 | "launchpad.net/juju-core/state/api" |
414 | @@ -464,15 +465,18 @@ |
415 | toolsDir := tools.SharedToolsDir(dataDir, agentTools.Version) |
416 | logDir := env.config.logDir() |
417 | logConfig := "--debug" // TODO(thumper): specify loggo config |
418 | + machineEnvironment := map[string]string{ |
419 | + "USER": env.config.user, |
420 | + "HOME": os.Getenv("HOME"), |
421 | + osenv.JujuProviderType: env.config.Type(), |
422 | + osenv.JujuStorageDir: env.config.storageDir(), |
423 | + osenv.JujuStorageAddr: env.config.storageAddr(), |
424 | + osenv.JujuSharedStorageDir: env.config.sharedStorageDir(), |
425 | + osenv.JujuSharedStorageAddr: env.config.sharedStorageAddr(), |
426 | + } |
427 | agent := upstart.MachineAgentUpstartService( |
428 | env.machineAgentServiceName(), |
429 | - toolsDir, dataDir, logDir, tag, machineId, logConfig, env.config.Type()) |
430 | - agent.Env["USER"] = env.config.user |
431 | - agent.Env["HOME"] = os.Getenv("HOME") |
432 | - agent.Env["JUJU_STORAGE_DIR"] = env.config.storageDir() |
433 | - agent.Env["JUJU_STORAGE_ADDR"] = env.config.storageAddr() |
434 | - agent.Env["JUJU_SHARED_STORAGE_DIR"] = env.config.sharedStorageDir() |
435 | - agent.Env["JUJU_SHARED_STORAGE_ADDR"] = env.config.sharedStorageAddr() |
436 | + toolsDir, dataDir, logDir, tag, machineId, logConfig, machineEnvironment) |
437 | |
438 | agent.InitDir = upstartScriptLocation |
439 | logger.Infof("installing service %s to %s", env.machineAgentServiceName(), agent.InitDir) |
440 | |
441 | === modified file 'environs/local/storage/worker.go' |
442 | --- environs/local/storage/worker.go 2013-07-16 02:09:30 +0000 |
443 | +++ environs/local/storage/worker.go 2013-07-31 21:52:25 +0000 |
444 | @@ -7,6 +7,7 @@ |
445 | "launchpad.net/tomb" |
446 | |
447 | "launchpad.net/juju-core/environs/localstorage" |
448 | + "launchpad.net/juju-core/juju/osenv" |
449 | "launchpad.net/juju-core/worker" |
450 | ) |
451 | |
452 | @@ -36,8 +37,8 @@ |
453 | } |
454 | |
455 | func (s *storageWorker) waitForDeath() error { |
456 | - storageDir := os.Getenv("JUJU_STORAGE_DIR") |
457 | - storageAddr := os.Getenv("JUJU_STORAGE_ADDR") |
458 | + storageDir := os.Getenv(osenv.JujuStorageDir) |
459 | + storageAddr := os.Getenv(osenv.JujuStorageAddr) |
460 | logger.Infof("serving %s on %s", storageDir, storageAddr) |
461 | |
462 | storageListener, err := localstorage.Serve(storageAddr, storageDir) |
463 | @@ -47,8 +48,8 @@ |
464 | } |
465 | defer storageListener.Close() |
466 | |
467 | - sharedStorageDir := os.Getenv("JUJU_SHARED_STORAGE_DIR") |
468 | - sharedStorageAddr := os.Getenv("JUJU_SHARED_STORAGE_ADDR") |
469 | + sharedStorageDir := os.Getenv(osenv.JujuSharedStorageDir) |
470 | + sharedStorageAddr := os.Getenv(osenv.JujuSharedStorageAddr) |
471 | logger.Infof("serving %s on %s", sharedStorageDir, sharedStorageAddr) |
472 | |
473 | sharedStorageListener, err := localstorage.Serve(sharedStorageAddr, sharedStorageDir) |
474 | |
475 | === added directory 'juju/osenv' |
476 | === added file 'juju/osenv/package_test.go' |
477 | --- juju/osenv/package_test.go 1970-01-01 00:00:00 +0000 |
478 | +++ juju/osenv/package_test.go 2013-07-31 21:52:25 +0000 |
479 | @@ -0,0 +1,14 @@ |
480 | +// Copyright 2013 Canonical Ltd. |
481 | +// Licensed under the AGPLv3, see LICENCE file for details. |
482 | + |
483 | +package osenv_test |
484 | + |
485 | +import ( |
486 | + "testing" |
487 | + |
488 | + gc "launchpad.net/gocheck" |
489 | +) |
490 | + |
491 | +func Test(t *testing.T) { |
492 | + gc.TestingT(t) |
493 | +} |
494 | |
495 | === added file 'juju/osenv/vars.go' |
496 | --- juju/osenv/vars.go 1970-01-01 00:00:00 +0000 |
497 | +++ juju/osenv/vars.go 2013-07-31 21:52:25 +0000 |
498 | @@ -0,0 +1,16 @@ |
499 | +// Copyright 2013 Canonical Ltd. |
500 | +// Licensed under the AGPLv3, see LICENCE file for details. |
501 | + |
502 | +package osenv |
503 | + |
504 | +const ( |
505 | + JujuEnv = "JUJU_ENV" |
506 | + JujuHome = "JUJU_HOME" |
507 | + JujuRepository = "JUJU_REPOSITORY" |
508 | + JujuLxcBridge = "JUJU_LXC_BRIDGE" |
509 | + JujuProviderType = "JUJU_PROVIDER_TYPE" |
510 | + JujuStorageDir = "JUJU_STORAGE_DIR" |
511 | + JujuStorageAddr = "JUJU_STORAGE_ADDR" |
512 | + JujuSharedStorageDir = "JUJU_SHARED_STORAGE_DIR" |
513 | + JujuSharedStorageAddr = "JUJU_SHARED_STORAGE_ADDR" |
514 | +) |
515 | |
516 | === added file 'juju/osenv/vars_test.go' |
517 | --- juju/osenv/vars_test.go 1970-01-01 00:00:00 +0000 |
518 | +++ juju/osenv/vars_test.go 2013-07-31 21:52:25 +0000 |
519 | @@ -0,0 +1,20 @@ |
520 | +// Copyright 2013 Canonical Ltd. |
521 | +// Licensed under the AGPLv3, see LICENCE file for details. |
522 | + |
523 | +package osenv_test |
524 | + |
525 | +import ( |
526 | + gc "launchpad.net/gocheck" |
527 | + |
528 | + "launchpad.net/juju-core/testing" |
529 | +) |
530 | + |
531 | +type importSuite struct{} |
532 | + |
533 | +var _ = gc.Suite(&importSuite{}) |
534 | + |
535 | +func (*importSuite) TestDependencies(c *gc.C) { |
536 | + // This test is to ensure we don't bring in dependencies at all. |
537 | + c.Assert(testing.FindJujuCoreImports(c, "launchpad.net/juju-core/juju/osenv"), |
538 | + gc.HasLen, 0) |
539 | +} |
540 | |
541 | === modified file 'upstart/service.go' |
542 | --- upstart/service.go 2013-07-16 06:29:04 +0000 |
543 | +++ upstart/service.go 2013-07-31 21:52:25 +0000 |
544 | @@ -42,7 +42,7 @@ |
545 | |
546 | // MachineAgentUpstartService returns the upstart config for a machine agent |
547 | // based on the tag and machineId passed in. |
548 | -func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig, providerType string) *Conf { |
549 | +func MachineAgentUpstartService(name, toolsDir, dataDir, logDir, tag, machineId, logConfig string, env map[string]string) *Conf { |
550 | svc := NewService(name) |
551 | logFile := filepath.Join(logDir, tag+".log") |
552 | return &Conf{ |
553 | @@ -58,8 +58,6 @@ |
554 | " --machine-id " + machineId + |
555 | " " + logConfig, |
556 | Out: logFile, |
557 | - Env: map[string]string{ |
558 | - "JUJU_PROVIDER_TYPE": providerType, |
559 | - }, |
560 | + Env: env, |
561 | } |
562 | } |
563 | |
564 | === modified file 'worker/deployer/simple.go' |
565 | --- worker/deployer/simple.go 2013-07-30 14:00:53 +0000 |
566 | +++ worker/deployer/simple.go 2013-07-31 21:52:25 +0000 |
567 | @@ -13,6 +13,7 @@ |
568 | |
569 | "launchpad.net/juju-core/agent" |
570 | "launchpad.net/juju-core/agent/tools" |
571 | + "launchpad.net/juju-core/juju/osenv" |
572 | "launchpad.net/juju-core/log/syslog" |
573 | "launchpad.net/juju-core/names" |
574 | "launchpad.net/juju-core/state" // Only because of state.Info |
575 | @@ -148,7 +149,7 @@ |
576 | Out: logPath, |
577 | // Propagate the provider type enviroment variable. |
578 | Env: map[string]string{ |
579 | - "JUJU_PROVIDER_TYPE": os.Getenv("JUJU_PROVIDER_TYPE"), |
580 | + osenv.JujuProviderType: os.Getenv(osenv.JujuProviderType), |
581 | }, |
582 | } |
583 | return uconf.Install() |
Reviewers: mp+177707_ code.launchpad. net,
Message:
Please take a look.
Description:
Use a map to store machine environment in config.
The MachineConfig now uses a map to store the environment
for the machine agent.
https:/ /code.launchpad .net/~thumper/ juju-core/ machine- agent-environme nt/+merge/ 177707
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/12005048/
Affected files: azure/customdat a_test. go cloudinit. go cloudinit/ cloudinit. go cloudinit/ cloudinit_ test.go cloudinit_ test.go local/environ. go
A [revision details]
M environs/
M environs/
M environs/
M environs/
M environs/
M environs/
M upstart/service.go