Merge lp:~axwalk/juju-core/startinstance-param-struct into lp:~go-bot/juju-core/trunk

Proposed by Andrew Wilkins
Status: Merged
Approved by: Andrew Wilkins
Approved revision: no longer in the source branch.
Merged at revision: 2418
Proposed branch: lp:~axwalk/juju-core/startinstance-param-struct
Merge into: lp:~go-bot/juju-core/trunk
Diff against target: 740 lines (+129/-127)
18 files modified
environs/broker.go (+16/-4)
environs/jujutest/livetests.go (+4/-1)
juju/testing/instance.go (+5/-1)
provider/azure/environ.go (+7/-10)
provider/common/bootstrap.go (+5/-1)
provider/common/mock_test.go (+2/-6)
provider/dummy/environs.go (+21/-24)
provider/ec2/ec2.go (+10/-12)
provider/joyent/environ_instance.go (+2/-6)
provider/local/environ.go (+10/-12)
provider/maas/environ.go (+7/-9)
provider/manual/environ.go (+1/-3)
provider/openstack/provider.go (+10/-12)
worker/provisioner/kvm-broker.go (+7/-13)
worker/provisioner/kvm-broker_test.go (+5/-1)
worker/provisioner/lxc-broker.go (+7/-10)
worker/provisioner/lxc-broker_test.go (+5/-1)
worker/provisioner/provisioner_task.go (+5/-1)
To merge this branch: bzr merge lp:~axwalk/juju-core/startinstance-param-struct
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+210738@code.launchpad.net

Commit message

Refactor StartInstance to take param struct

This is in preparation for adding an optional
argument to StartInstance that names the
principal unit initially assigned to the
machine. No functional changes here, just
refactoring.

https://codereview.appspot.com/75130046/

Description of the change

Refactor StartInstance to take param struct

This is in preparation for adding an optional
argument to StartInstance that names the
principal unit initially assigned to the
machine. No functional changes here, just
refactoring.

https://codereview.appspot.com/75130046/

To post a comment you must log in.
Revision history for this message
Andrew Wilkins (axwalk) wrote :

Reviewers: mp+210738_code.launchpad.net,

Message:
Please take a look.

Description:
Refactor StartInstance to take param struct

This is in preparation for adding an optional
argument to StartInstance that names the
principal unit initially assigned to the
machine. No functional changes here, just
refactoring.

https://code.launchpad.net/~axwalk/juju-core/startinstance-param-struct/+merge/210738

(do not edit description out of merge proposal)

Please review this at https://codereview.appspot.com/75130046/

Affected files (+131, -127 lines):
   A [revision details]
   M environs/broker.go
   M environs/jujutest/livetests.go
   M juju/testing/instance.go
   M provider/azure/environ.go
   M provider/common/bootstrap.go
   M provider/common/mock_test.go
   M provider/dummy/environs.go
   M provider/ec2/ec2.go
   M provider/joyent/environ_instance.go
   M provider/local/environ.go
   M provider/maas/environ.go
   M provider/manual/environ.go
   M provider/openstack/provider.go
   M worker/provisioner/kvm-broker.go
   M worker/provisioner/kvm-broker_test.go
   M worker/provisioner/lxc-broker.go
   M worker/provisioner/lxc-broker_test.go
   M worker/provisioner/provisioner_task.go

Revision history for this message
Ian Booth (wallyworld) wrote :

LGTM. Seems like a good change regardless of whether extra params are
added or not.

https://codereview.appspot.com/75130046/

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'environs/broker.go'
2--- environs/broker.go 2013-08-22 22:24:54 +0000
3+++ environs/broker.go 2014-03-13 05:11:53 +0000
4@@ -10,6 +10,21 @@
5 "launchpad.net/juju-core/tools"
6 )
7
8+// StartInstanceParams holds parameters for the
9+// InstanceBroker.StartInstace method.
10+type StartInstanceParams struct {
11+ // Constraints is a set of constraints on
12+ // the kind of instance to create.
13+ Constraints constraints.Value
14+
15+ // Tools is a list of tools that may be used
16+ // to start a Juju agent on the machine.
17+ Tools tools.List
18+
19+ // MachineConfig describes the machine's configuration.
20+ MachineConfig *cloudinit.MachineConfig
21+}
22+
23 // TODO(wallyworld) - we want this in the environs/instance package but import loops
24 // stop that from being possible right now.
25 type InstanceBroker interface {
26@@ -19,10 +34,7 @@
27 // unique within an environment, is used by juju to protect against the
28 // consequences of multiple instances being started with the same machine
29 // id.
30- StartInstance(
31- cons constraints.Value, possibleTools tools.List,
32- machineConfig *cloudinit.MachineConfig,
33- ) (instance.Instance, *instance.HardwareCharacteristics, error)
34+ StartInstance(args StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error)
35
36 // StopInstances shuts down the given instances.
37 StopInstances([]instance.Instance) error
38
39=== modified file 'environs/jujutest/livetests.go'
40--- environs/jujutest/livetests.go 2014-03-10 20:22:44 +0000
41+++ environs/jujutest/livetests.go 2014-03-13 05:11:53 +0000
42@@ -859,7 +859,10 @@
43
44 t.PrepareOnce(c)
45 possibleTools := envtesting.AssertUploadFakeToolsVersions(c, t.Env.Storage(), version.MustParseBinary("5.4.5-precise-amd64"))
46- inst, _, err := t.Env.StartInstance(constraints.Value{}, possibleTools, machineConfig)
47+ inst, _, err := t.Env.StartInstance(environs.StartInstanceParams{
48+ Tools: possibleTools,
49+ MachineConfig: machineConfig,
50+ })
51 if inst != nil {
52 err := t.Env.StopInstances([]instance.Instance{inst})
53 c.Check(err, gc.IsNil)
54
55=== modified file 'juju/testing/instance.go'
56--- juju/testing/instance.go 2013-09-30 19:40:06 +0000
57+++ juju/testing/instance.go 2014-03-13 05:11:53 +0000
58@@ -98,5 +98,9 @@
59 stateInfo := FakeStateInfo(machineId)
60 apiInfo := FakeAPIInfo(machineId)
61 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stateInfo, apiInfo)
62- return env.StartInstance(cons, possibleTools, machineConfig)
63+ return env.StartInstance(environs.StartInstanceParams{
64+ Constraints: cons,
65+ Tools: possibleTools,
66+ MachineConfig: machineConfig,
67+ })
68 }
69
70=== modified file 'provider/azure/environ.go'
71--- provider/azure/environ.go 2014-03-03 10:10:44 +0000
72+++ provider/azure/environ.go 2014-03-13 05:11:53 +0000
73@@ -13,7 +13,6 @@
74
75 "launchpad.net/juju-core/constraints"
76 "launchpad.net/juju-core/environs"
77- "launchpad.net/juju-core/environs/cloudinit"
78 "launchpad.net/juju-core/environs/config"
79 "launchpad.net/juju-core/environs/imagemetadata"
80 "launchpad.net/juju-core/environs/instances"
81@@ -24,7 +23,6 @@
82 "launchpad.net/juju-core/provider/common"
83 "launchpad.net/juju-core/state"
84 "launchpad.net/juju-core/state/api"
85- "launchpad.net/juju-core/tools"
86 "launchpad.net/juju-core/utils/parallel"
87 )
88
89@@ -363,24 +361,23 @@
90 }
91
92 // StartInstance is specified in the InstanceBroker interface.
93-func (env *azureEnviron) StartInstance(cons constraints.Value, possibleTools tools.List,
94- machineConfig *cloudinit.MachineConfig) (_ instance.Instance, _ *instance.HardwareCharacteristics, err error) {
95+func (env *azureEnviron) StartInstance(args environs.StartInstanceParams) (_ instance.Instance, _ *instance.HardwareCharacteristics, err error) {
96
97 // Declaring "err" in the function signature so that we can "defer"
98 // any cleanup that needs to run during error returns.
99
100- err = environs.FinishMachineConfig(machineConfig, env.Config(), cons)
101+ err = environs.FinishMachineConfig(args.MachineConfig, env.Config(), args.Constraints)
102 if err != nil {
103 return nil, nil, err
104 }
105
106 // Pick envtools. Needed for the custom data (which is what we normally
107 // call userdata).
108- machineConfig.Tools = possibleTools[0]
109- logger.Infof("picked tools %q", machineConfig.Tools)
110+ args.MachineConfig.Tools = args.Tools[0]
111+ logger.Infof("picked tools %q", args.MachineConfig.Tools)
112
113 // Compose userdata.
114- userData, err := makeCustomData(machineConfig)
115+ userData, err := makeCustomData(args.MachineConfig)
116 if err != nil {
117 return nil, nil, fmt.Errorf("custom data: %v", err)
118 }
119@@ -409,8 +406,8 @@
120 }
121 }()
122
123- series := possibleTools.OneSeries()
124- instanceType, sourceImageName, err := env.selectInstanceTypeAndImage(cons, series, location)
125+ series := args.Tools.OneSeries()
126+ instanceType, sourceImageName, err := env.selectInstanceTypeAndImage(args.Constraints, series, location)
127 if err != nil {
128 return nil, nil, err
129 }
130
131=== modified file 'provider/common/bootstrap.go'
132--- provider/common/bootstrap.go 2014-03-10 20:22:44 +0000
133+++ provider/common/bootstrap.go 2014-03-13 05:11:53 +0000
134@@ -69,7 +69,11 @@
135 }
136
137 fmt.Fprintln(ctx.GetStderr(), "Launching instance")
138- inst, hw, err := env.StartInstance(cons, selectedTools, machineConfig)
139+ inst, hw, err := env.StartInstance(environs.StartInstanceParams{
140+ Constraints: cons,
141+ Tools: selectedTools,
142+ MachineConfig: machineConfig,
143+ })
144 if err != nil {
145 return fmt.Errorf("cannot start bootstrap instance: %v", err)
146 }
147
148=== modified file 'provider/common/mock_test.go'
149--- provider/common/mock_test.go 2014-03-03 10:10:44 +0000
150+++ provider/common/mock_test.go 2014-03-13 05:11:53 +0000
151@@ -45,12 +45,8 @@
152 func (env *mockEnviron) AllInstances() ([]instance.Instance, error) {
153 return env.allInstances()
154 }
155-func (env *mockEnviron) StartInstance(
156- cons constraints.Value, possibleTools tools.List, mcfg *cloudinit.MachineConfig,
157-) (
158- instance.Instance, *instance.HardwareCharacteristics, error,
159-) {
160- return env.startInstance(cons, possibleTools, mcfg)
161+func (env *mockEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
162+ return env.startInstance(args.Constraints, args.Tools, args.MachineConfig)
163 }
164
165 func (env *mockEnviron) StopInstances(instances []instance.Instance) error {
166
167=== modified file 'provider/dummy/environs.go'
168--- provider/dummy/environs.go 2014-03-05 19:41:34 +0000
169+++ provider/dummy/environs.go 2014-03-13 05:11:53 +0000
170@@ -38,7 +38,6 @@
171 "launchpad.net/juju-core/constraints"
172 "launchpad.net/juju-core/environs"
173 "launchpad.net/juju-core/environs/bootstrap"
174- "launchpad.net/juju-core/environs/cloudinit"
175 "launchpad.net/juju-core/environs/config"
176 "launchpad.net/juju-core/environs/imagemetadata"
177 "launchpad.net/juju-core/environs/simplestreams"
178@@ -53,7 +52,6 @@
179 "launchpad.net/juju-core/state/api"
180 "launchpad.net/juju-core/state/apiserver"
181 "launchpad.net/juju-core/testing"
182- coretools "launchpad.net/juju-core/tools"
183 "launchpad.net/juju-core/utils"
184 )
185
186@@ -677,11 +675,10 @@
187 }
188
189 // StartInstance is specified in the InstanceBroker interface.
190-func (e *environ) StartInstance(cons constraints.Value, possibleTools coretools.List,
191- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
192+func (e *environ) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
193
194 defer delay()
195- machineId := machineConfig.MachineId
196+ machineId := args.MachineConfig.MachineId
197 logger.Infof("dummy startinstance, machine %s", machineId)
198 if err := e.checkBroken("StartInstance"); err != nil {
199 return nil, nil, err
200@@ -692,20 +689,20 @@
201 }
202 estate.mu.Lock()
203 defer estate.mu.Unlock()
204- if machineConfig.MachineNonce == "" {
205+ if args.MachineConfig.MachineNonce == "" {
206 return nil, nil, fmt.Errorf("cannot start instance: missing machine nonce")
207 }
208 if _, ok := e.Config().CACert(); !ok {
209 return nil, nil, fmt.Errorf("no CA certificate in environment configuration")
210 }
211- if machineConfig.StateInfo.Tag != names.MachineTag(machineId) {
212- return nil, nil, fmt.Errorf("entity tag must match started machine")
213- }
214- if machineConfig.APIInfo.Tag != names.MachineTag(machineId) {
215- return nil, nil, fmt.Errorf("entity tag must match started machine")
216- }
217- logger.Infof("would pick tools from %s", possibleTools)
218- series := possibleTools.OneSeries()
219+ if args.MachineConfig.StateInfo.Tag != names.MachineTag(machineId) {
220+ return nil, nil, fmt.Errorf("entity tag must match started machine")
221+ }
222+ if args.MachineConfig.APIInfo.Tag != names.MachineTag(machineId) {
223+ return nil, nil, fmt.Errorf("entity tag must match started machine")
224+ }
225+ logger.Infof("would pick tools from %s", args.Tools)
226+ series := args.Tools.OneSeries()
227 i := &dummyInstance{
228 id: instance.Id(fmt.Sprintf("%s-%d", e.name, estate.maxId)),
229 ports: make(map[instance.Port]bool),
230@@ -721,12 +718,12 @@
231 // We will just assume the instance hardware characteristics exactly matches
232 // the supplied constraints (if specified).
233 hc = &instance.HardwareCharacteristics{
234- Arch: cons.Arch,
235- Mem: cons.Mem,
236- RootDisk: cons.RootDisk,
237- CpuCores: cons.CpuCores,
238- CpuPower: cons.CpuPower,
239- Tags: cons.Tags,
240+ Arch: args.Constraints.Arch,
241+ Mem: args.Constraints.Mem,
242+ RootDisk: args.Constraints.RootDisk,
243+ CpuCores: args.Constraints.CpuCores,
244+ CpuPower: args.Constraints.CpuPower,
245+ Tags: args.Constraints.Tags,
246 }
247 // Fill in some expected instance hardware characteristics if constraints not specified.
248 if hc.Arch == nil {
249@@ -751,11 +748,11 @@
250 estate.ops <- OpStartInstance{
251 Env: e.name,
252 MachineId: machineId,
253- MachineNonce: machineConfig.MachineNonce,
254- Constraints: cons,
255+ MachineNonce: args.MachineConfig.MachineNonce,
256+ Constraints: args.Constraints,
257 Instance: i,
258- Info: machineConfig.StateInfo,
259- APIInfo: machineConfig.APIInfo,
260+ Info: args.MachineConfig.StateInfo,
261+ APIInfo: args.MachineConfig.APIInfo,
262 Secret: e.ecfg().secret(),
263 }
264 return i, hc, nil
265
266=== modified file 'provider/ec2/ec2.go'
267--- provider/ec2/ec2.go 2014-03-12 11:04:20 +0000
268+++ provider/ec2/ec2.go 2014-03-13 05:11:53 +0000
269@@ -18,7 +18,6 @@
270
271 "launchpad.net/juju-core/constraints"
272 "launchpad.net/juju-core/environs"
273- "launchpad.net/juju-core/environs/cloudinit"
274 "launchpad.net/juju-core/environs/config"
275 "launchpad.net/juju-core/environs/imagemetadata"
276 "launchpad.net/juju-core/environs/instances"
277@@ -365,50 +364,49 @@
278 const ebsStorage = "ebs"
279
280 // StartInstance is specified in the InstanceBroker interface.
281-func (e *environ) StartInstance(cons constraints.Value, possibleTools tools.List,
282- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
283+func (e *environ) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
284
285- arches := possibleTools.Arches()
286+ arches := args.Tools.Arches()
287 stor := ebsStorage
288 sources, err := imagemetadata.GetMetadataSources(e)
289 if err != nil {
290 return nil, nil, err
291 }
292
293- series := possibleTools.OneSeries()
294+ series := args.Tools.OneSeries()
295 spec, err := findInstanceSpec(sources, e.Config().ImageStream(), &instances.InstanceConstraint{
296 Region: e.ecfg().region(),
297 Series: series,
298 Arches: arches,
299- Constraints: cons,
300+ Constraints: args.Constraints,
301 Storage: &stor,
302 })
303 if err != nil {
304 return nil, nil, err
305 }
306- tools, err := possibleTools.Match(tools.Filter{Arch: spec.Image.Arch})
307+ tools, err := args.Tools.Match(tools.Filter{Arch: spec.Image.Arch})
308 if err != nil {
309 return nil, nil, fmt.Errorf("chosen architecture %v not present in %v", spec.Image.Arch, arches)
310 }
311
312- machineConfig.Tools = tools[0]
313- if err := environs.FinishMachineConfig(machineConfig, e.Config(), cons); err != nil {
314+ args.MachineConfig.Tools = tools[0]
315+ if err := environs.FinishMachineConfig(args.MachineConfig, e.Config(), args.Constraints); err != nil {
316 return nil, nil, err
317 }
318
319- userData, err := environs.ComposeUserData(machineConfig)
320+ userData, err := environs.ComposeUserData(args.MachineConfig)
321 if err != nil {
322 return nil, nil, fmt.Errorf("cannot make user data: %v", err)
323 }
324 logger.Debugf("ec2 user data; %d bytes", len(userData))
325 cfg := e.Config()
326- groups, err := e.setUpGroups(machineConfig.MachineId, cfg.StatePort(), cfg.APIPort())
327+ groups, err := e.setUpGroups(args.MachineConfig.MachineId, cfg.StatePort(), cfg.APIPort())
328 if err != nil {
329 return nil, nil, fmt.Errorf("cannot set up groups: %v", err)
330 }
331 var instResp *ec2.RunInstancesResp
332
333- device, diskSize := getDiskSize(cons)
334+ device, diskSize := getDiskSize(args.Constraints)
335 for a := shortAttempt.Start(); a.Next(); {
336 instResp, err = e.ec2().RunInstances(&ec2.RunInstances{
337 ImageId: spec.Image.Id,
338
339=== modified file 'provider/joyent/environ_instance.go'
340--- provider/joyent/environ_instance.go 2014-03-10 00:10:29 +0000
341+++ provider/joyent/environ_instance.go 2014-03-13 05:11:53 +0000
342@@ -4,15 +4,11 @@
343 package joyent
344
345 import (
346- "launchpad.net/juju-core/constraints"
347- "launchpad.net/juju-core/environs/cloudinit"
348+ "launchpad.net/juju-core/environs"
349 "launchpad.net/juju-core/instance"
350- "launchpad.net/juju-core/tools"
351 )
352
353-func (env *environ) StartInstance(
354- cons constraints.Value, possibleTools tools.List, machineConf *cloudinit.MachineConfig,
355-) (
356+func (env *environ) StartInstance(args environs.StartInstanceParams) (
357 instance.Instance, *instance.HardwareCharacteristics, error,
358 ) {
359 // Please note that in order to fulfil the demands made of Instances and
360
361=== modified file 'provider/local/environ.go'
362--- provider/local/environ.go 2014-03-09 20:54:18 +0000
363+++ provider/local/environ.go 2014-03-13 05:11:53 +0000
364@@ -38,7 +38,6 @@
365 "launchpad.net/juju-core/state"
366 "launchpad.net/juju-core/state/api"
367 "launchpad.net/juju-core/state/api/params"
368- "launchpad.net/juju-core/tools"
369 "launchpad.net/juju-core/version"
370 "launchpad.net/juju-core/worker/terminationworker"
371 )
372@@ -286,24 +285,23 @@
373 }
374
375 // StartInstance is specified in the InstanceBroker interface.
376-func (env *localEnviron) StartInstance(cons constraints.Value, possibleTools tools.List,
377- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
378+func (env *localEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
379
380- series := possibleTools.OneSeries()
381- logger.Debugf("StartInstance: %q, %s", machineConfig.MachineId, series)
382- machineConfig.Tools = possibleTools[0]
383- machineConfig.MachineContainerType = env.config.container()
384- logger.Debugf("tools: %#v", machineConfig.Tools)
385+ series := args.Tools.OneSeries()
386+ logger.Debugf("StartInstance: %q, %s", args.MachineConfig.MachineId, series)
387+ args.MachineConfig.Tools = args.Tools[0]
388+ args.MachineConfig.MachineContainerType = env.config.container()
389+ logger.Debugf("tools: %#v", args.MachineConfig.Tools)
390 network := container.BridgeNetworkConfig(env.config.networkBridge())
391- if err := environs.FinishMachineConfig(machineConfig, env.config.Config, cons); err != nil {
392+ if err := environs.FinishMachineConfig(args.MachineConfig, env.config.Config, args.Constraints); err != nil {
393 return nil, nil, err
394 }
395 // TODO: evaluate the impact of setting the contstraints on the
396 // machineConfig for all machines rather than just state server nodes.
397 // This limiation is why the constraints are assigned directly here.
398- machineConfig.Constraints = cons
399- machineConfig.AgentEnvironment[agent.Namespace] = env.config.namespace()
400- inst, hardware, err := env.containerManager.StartContainer(machineConfig, series, network)
401+ args.MachineConfig.Constraints = args.Constraints
402+ args.MachineConfig.AgentEnvironment[agent.Namespace] = env.config.namespace()
403+ inst, hardware, err := env.containerManager.StartContainer(args.MachineConfig, series, network)
404 if err != nil {
405 return nil, nil, err
406 }
407
408=== modified file 'provider/maas/environ.go'
409--- provider/maas/environ.go 2014-03-03 10:10:44 +0000
410+++ provider/maas/environ.go 2014-03-13 05:11:53 +0000
411@@ -16,7 +16,6 @@
412 "launchpad.net/juju-core/agent"
413 "launchpad.net/juju-core/constraints"
414 "launchpad.net/juju-core/environs"
415- "launchpad.net/juju-core/environs/cloudinit"
416 "launchpad.net/juju-core/environs/config"
417 "launchpad.net/juju-core/environs/imagemetadata"
418 "launchpad.net/juju-core/environs/simplestreams"
419@@ -230,16 +229,15 @@
420 }
421
422 // StartInstance is specified in the InstanceBroker interface.
423-func (environ *maasEnviron) StartInstance(cons constraints.Value, possibleTools tools.List,
424- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
425+func (environ *maasEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
426
427 var inst *maasInstance
428 var err error
429- if node, tools, err := environ.acquireNode(cons, possibleTools); err != nil {
430+ if node, tools, err := environ.acquireNode(args.Constraints, args.Tools); err != nil {
431 return nil, nil, fmt.Errorf("cannot run instances: %v", err)
432 } else {
433 inst = &maasInstance{maasObject: &node, environ: environ}
434- machineConfig.Tools = tools
435+ args.MachineConfig.Tools = tools
436 }
437 defer func() {
438 if err != nil {
439@@ -258,15 +256,15 @@
440 if err != nil {
441 return nil, nil, err
442 }
443- if err := environs.FinishMachineConfig(machineConfig, environ.Config(), cons); err != nil {
444+ if err := environs.FinishMachineConfig(args.MachineConfig, environ.Config(), args.Constraints); err != nil {
445 return nil, nil, err
446 }
447 // TODO(thumper): 2013-08-28 bug 1217614
448 // The machine envronment config values are being moved to the agent config.
449 // Explicitly specify that the lxc containers use the network bridge defined above.
450- machineConfig.AgentEnvironment[agent.LxcBridge] = "br0"
451+ args.MachineConfig.AgentEnvironment[agent.LxcBridge] = "br0"
452 userdata, err := environs.ComposeUserData(
453- machineConfig,
454+ args.MachineConfig,
455 runCmd,
456 createBridgeNetwork(),
457 linkBridgeInInterfaces(),
458@@ -278,7 +276,7 @@
459 }
460 logger.Debugf("maas user data; %d bytes", len(userdata))
461
462- series := possibleTools.OneSeries()
463+ series := args.Tools.OneSeries()
464 if err := environ.startNode(*inst.maasObject, series, userdata); err != nil {
465 return nil, nil, err
466 }
467
468=== modified file 'provider/manual/environ.go'
469--- provider/manual/environ.go 2014-03-12 14:04:20 +0000
470+++ provider/manual/environ.go 2014-03-13 05:11:53 +0000
471@@ -17,7 +17,6 @@
472 "launchpad.net/juju-core/agent"
473 "launchpad.net/juju-core/constraints"
474 "launchpad.net/juju-core/environs"
475- "launchpad.net/juju-core/environs/cloudinit"
476 "launchpad.net/juju-core/environs/config"
477 "launchpad.net/juju-core/environs/httpstorage"
478 "launchpad.net/juju-core/environs/manual"
479@@ -29,7 +28,6 @@
480 "launchpad.net/juju-core/provider/common"
481 "launchpad.net/juju-core/state"
482 "launchpad.net/juju-core/state/api"
483- "launchpad.net/juju-core/tools"
484 "launchpad.net/juju-core/utils/ssh"
485 "launchpad.net/juju-core/worker/localstorage"
486 "launchpad.net/juju-core/worker/terminationworker"
487@@ -64,7 +62,7 @@
488 var errNoStartInstance = errors.New("manual provider cannot start instances")
489 var errNoStopInstance = errors.New("manual provider cannot stop instances")
490
491-func (*manualEnviron) StartInstance(constraints.Value, tools.List, *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
492+func (*manualEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
493 return nil, nil, errNoStartInstance
494 }
495
496
497=== modified file 'provider/openstack/provider.go'
498--- provider/openstack/provider.go 2014-03-12 11:04:20 +0000
499+++ provider/openstack/provider.go 2014-03-13 05:11:53 +0000
500@@ -24,7 +24,6 @@
501
502 "launchpad.net/juju-core/constraints"
503 "launchpad.net/juju-core/environs"
504- "launchpad.net/juju-core/environs/cloudinit"
505 "launchpad.net/juju-core/environs/config"
506 "launchpad.net/juju-core/environs/imagemetadata"
507 "launchpad.net/juju-core/environs/instances"
508@@ -741,31 +740,30 @@
509 }
510
511 // StartInstance is specified in the InstanceBroker interface.
512-func (e *environ) StartInstance(cons constraints.Value, possibleTools tools.List,
513- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
514+func (e *environ) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
515
516- series := possibleTools.OneSeries()
517- arches := possibleTools.Arches()
518+ series := args.Tools.OneSeries()
519+ arches := args.Tools.Arches()
520 spec, err := findInstanceSpec(e, &instances.InstanceConstraint{
521 Region: e.ecfg().region(),
522 Series: series,
523 Arches: arches,
524- Constraints: cons,
525+ Constraints: args.Constraints,
526 })
527 if err != nil {
528 return nil, nil, err
529 }
530- tools, err := possibleTools.Match(tools.Filter{Arch: spec.Image.Arch})
531+ tools, err := args.Tools.Match(tools.Filter{Arch: spec.Image.Arch})
532 if err != nil {
533 return nil, nil, fmt.Errorf("chosen architecture %v not present in %v", spec.Image.Arch, arches)
534 }
535
536- machineConfig.Tools = tools[0]
537+ args.MachineConfig.Tools = tools[0]
538
539- if err := environs.FinishMachineConfig(machineConfig, e.Config(), cons); err != nil {
540+ if err := environs.FinishMachineConfig(args.MachineConfig, e.Config(), args.Constraints); err != nil {
541 return nil, nil, err
542 }
543- userData, err := environs.ComposeUserData(machineConfig)
544+ userData, err := environs.ComposeUserData(args.MachineConfig)
545 if err != nil {
546 return nil, nil, fmt.Errorf("cannot make user data: %v", err)
547 }
548@@ -791,7 +789,7 @@
549 }
550 }
551 cfg := e.Config()
552- groups, err := e.setUpGroups(machineConfig.MachineId, cfg.StatePort(), cfg.APIPort())
553+ groups, err := e.setUpGroups(args.MachineConfig.MachineId, cfg.StatePort(), cfg.APIPort())
554 if err != nil {
555 return nil, nil, fmt.Errorf("cannot set up groups: %v", err)
556 }
557@@ -800,7 +798,7 @@
558 groupNames[i] = nova.SecurityGroupName{g.Name}
559 }
560 var opts = nova.RunServerOpts{
561- Name: e.machineFullName(machineConfig.MachineId),
562+ Name: e.machineFullName(args.MachineConfig.MachineId),
563 FlavorId: spec.InstanceType.Id,
564 ImageId: spec.Image.Id,
565 UserData: userData,
566
567=== modified file 'worker/provisioner/kvm-broker.go'
568--- worker/provisioner/kvm-broker.go 2014-03-07 03:00:24 +0000
569+++ worker/provisioner/kvm-broker.go 2014-03-13 05:11:53 +0000
570@@ -7,11 +7,9 @@
571 "github.com/juju/loggo"
572
573 "launchpad.net/juju-core/agent"
574- "launchpad.net/juju-core/constraints"
575 "launchpad.net/juju-core/container"
576 "launchpad.net/juju-core/container/kvm"
577 "launchpad.net/juju-core/environs"
578- "launchpad.net/juju-core/environs/cloudinit"
579 "launchpad.net/juju-core/instance"
580 "launchpad.net/juju-core/tools"
581 )
582@@ -50,14 +48,10 @@
583 }
584
585 // StartInstance is specified in the Broker interface.
586-func (broker *kvmBroker) StartInstance(
587- cons constraints.Value,
588- possibleTools tools.List,
589- machineConfig *cloudinit.MachineConfig,
590-) (instance.Instance, *instance.HardwareCharacteristics, error) {
591+func (broker *kvmBroker) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
592
593 // TODO: refactor common code out of the container brokers.
594- machineId := machineConfig.MachineId
595+ machineId := args.MachineConfig.MachineId
596 kvmLogger.Infof("starting kvm container for machineId: %s", machineId)
597
598 // TODO: Default to using the host network until we can configure. Yes,
599@@ -70,9 +64,9 @@
600 network := container.BridgeNetworkConfig(bridgeDevice)
601
602 // TODO: series doesn't necessarily need to be the same as the host.
603- series := possibleTools.OneSeries()
604- machineConfig.MachineContainerType = instance.KVM
605- machineConfig.Tools = possibleTools[0]
606+ series := args.Tools.OneSeries()
607+ args.MachineConfig.MachineContainerType = instance.KVM
608+ args.MachineConfig.Tools = args.Tools[0]
609
610 config, err := broker.api.ContainerConfig()
611 if err != nil {
612@@ -80,7 +74,7 @@
613 return nil, nil, err
614 }
615 if err := environs.PopulateMachineConfig(
616- machineConfig,
617+ args.MachineConfig,
618 config.ProviderType,
619 config.AuthorizedKeys,
620 config.SSLHostnameVerification,
621@@ -91,7 +85,7 @@
622 return nil, nil, err
623 }
624
625- inst, hardware, err := broker.manager.StartContainer(machineConfig, series, network)
626+ inst, hardware, err := broker.manager.StartContainer(args.MachineConfig, series, network)
627 if err != nil {
628 kvmLogger.Errorf("failed to start container: %v", err)
629 return nil, nil, err
630
631=== modified file 'worker/provisioner/kvm-broker_test.go'
632--- worker/provisioner/kvm-broker_test.go 2014-02-21 03:57:49 +0000
633+++ worker/provisioner/kvm-broker_test.go 2014-03-13 05:11:53 +0000
634@@ -86,7 +86,11 @@
635 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stateInfo, apiInfo)
636 cons := constraints.Value{}
637 possibleTools := s.broker.(coretools.HasTools).Tools()
638- kvm, _, err := s.broker.StartInstance(cons, possibleTools, machineConfig)
639+ kvm, _, err := s.broker.StartInstance(environs.StartInstanceParams{
640+ Constraints: cons,
641+ Tools: possibleTools,
642+ MachineConfig: machineConfig,
643+ })
644 c.Assert(err, gc.IsNil)
645 return kvm
646 }
647
648=== modified file 'worker/provisioner/lxc-broker.go'
649--- worker/provisioner/lxc-broker.go 2014-03-07 03:00:24 +0000
650+++ worker/provisioner/lxc-broker.go 2014-03-13 05:11:53 +0000
651@@ -7,11 +7,9 @@
652 "github.com/juju/loggo"
653
654 "launchpad.net/juju-core/agent"
655- "launchpad.net/juju-core/constraints"
656 "launchpad.net/juju-core/container"
657 "launchpad.net/juju-core/container/lxc"
658 "launchpad.net/juju-core/environs"
659- "launchpad.net/juju-core/environs/cloudinit"
660 "launchpad.net/juju-core/instance"
661 "launchpad.net/juju-core/state/api/params"
662 "launchpad.net/juju-core/tools"
663@@ -51,10 +49,9 @@
664 }
665
666 // StartInstance is specified in the Broker interface.
667-func (broker *lxcBroker) StartInstance(cons constraints.Value, possibleTools tools.List,
668- machineConfig *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, error) {
669+func (broker *lxcBroker) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, error) {
670 // TODO: refactor common code out of the container brokers.
671- machineId := machineConfig.MachineId
672+ machineId := args.MachineConfig.MachineId
673 lxcLogger.Infof("starting lxc container for machineId: %s", machineId)
674
675 // Default to using the host network until we can configure.
676@@ -64,9 +61,9 @@
677 }
678 network := container.BridgeNetworkConfig(bridgeDevice)
679
680- series := possibleTools.OneSeries()
681- machineConfig.MachineContainerType = instance.LXC
682- machineConfig.Tools = possibleTools[0]
683+ series := args.Tools.OneSeries()
684+ args.MachineConfig.MachineContainerType = instance.LXC
685+ args.MachineConfig.Tools = args.Tools[0]
686
687 config, err := broker.api.ContainerConfig()
688 if err != nil {
689@@ -74,7 +71,7 @@
690 return nil, nil, err
691 }
692 if err := environs.PopulateMachineConfig(
693- machineConfig,
694+ args.MachineConfig,
695 config.ProviderType,
696 config.AuthorizedKeys,
697 config.SSLHostnameVerification,
698@@ -85,7 +82,7 @@
699 return nil, nil, err
700 }
701
702- inst, hardware, err := broker.manager.StartContainer(machineConfig, series, network)
703+ inst, hardware, err := broker.manager.StartContainer(args.MachineConfig, series, network)
704 if err != nil {
705 lxcLogger.Errorf("failed to start container: %v", err)
706 return nil, nil, err
707
708=== modified file 'worker/provisioner/lxc-broker_test.go'
709--- worker/provisioner/lxc-broker_test.go 2014-03-12 03:05:33 +0000
710+++ worker/provisioner/lxc-broker_test.go 2014-03-13 05:11:53 +0000
711@@ -88,7 +88,11 @@
712 machineConfig := environs.NewMachineConfig(machineId, machineNonce, stateInfo, apiInfo)
713 cons := constraints.Value{}
714 possibleTools := s.broker.(coretools.HasTools).Tools()
715- lxc, _, err := s.broker.StartInstance(cons, possibleTools, machineConfig)
716+ lxc, _, err := s.broker.StartInstance(environs.StartInstanceParams{
717+ Constraints: cons,
718+ Tools: possibleTools,
719+ MachineConfig: machineConfig,
720+ })
721 c.Assert(err, gc.IsNil)
722 return lxc
723 }
724
725=== modified file 'worker/provisioner/provisioner_task.go'
726--- worker/provisioner/provisioner_task.go 2014-01-10 21:01:03 +0000
727+++ worker/provisioner/provisioner_task.go 2014-03-13 05:11:53 +0000
728@@ -395,7 +395,11 @@
729 if err != nil {
730 return err
731 }
732- inst, metadata, err := task.broker.StartInstance(cons, possibleTools, machineConfig)
733+ inst, metadata, err := task.broker.StartInstance(environs.StartInstanceParams{
734+ Constraints: cons,
735+ Tools: possibleTools,
736+ MachineConfig: machineConfig,
737+ })
738 if err != nil {
739 // Set the state to error, so the machine will be skipped next
740 // time until the error is resolved, but don't return an

Subscribers

People subscribed via source and target branches

to status/vote changes: