Merge lp:~axwalk/juju-core/lp1237709-bootstrap-placement into lp:~go-bot/juju-core/trunk
- lp1237709-bootstrap-placement
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2674 |
Proposed branch: | lp:~axwalk/juju-core/lp1237709-bootstrap-placement |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
1076 lines (+155/-109) 33 files modified
cmd/juju/bootstrap.go (+24/-2) cmd/juju/bootstrap_test.go (+11/-5) cmd/juju/cmd_test.go (+0/-5) cmd/juju/deploy_test.go (+3/-0) cmd/plugins/juju-restore/restore.go (+2/-1) environs/bootstrap/bootstrap.go (+2/-3) environs/bootstrap/bootstrap_test.go (+25/-15) environs/interface.go (+12/-4) environs/jujutest/livetests.go (+2/-2) environs/jujutest/tests.go (+2/-3) environs/open_test.go (+1/-2) instance/placement.go (+1/-1) juju/apiconn_test.go (+2/-3) juju/conn_test.go (+6/-6) juju/testing/conn.go (+1/-2) provider/azure/environ.go (+2/-2) provider/common/bootstrap.go (+4/-4) provider/common/bootstrap_test.go (+13/-8) provider/common/mock_test.go (+2/-1) provider/dummy/environs.go (+7/-7) provider/ec2/ec2.go (+2/-2) provider/ec2/local_test.go (+4/-4) provider/joyent/environ.go (+2/-2) provider/joyent/local_test.go (+3/-3) provider/local/config_test.go (+2/-2) provider/local/environ.go (+2/-2) provider/local/environ_test.go (+1/-1) provider/maas/environ.go (+2/-2) provider/maas/environ_whitebox_test.go (+4/-4) provider/manual/environ.go (+2/-1) provider/openstack/live_test.go (+1/-2) provider/openstack/local_test.go (+6/-6) provider/openstack/provider.go (+2/-2) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1237709-bootstrap-placement |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+216971@code.launchpad.net |
Commit message
Support placement directives on bootstrap
juju bootstrap will accept a single, optional
positional argument that will be parsed as a
placement directive. We currently only allow
unscoped placement directives at bootstrap.
Description of the change
Support placement directives on bootstrap
juju bootstrap will accept a single, optional
positional argument that will be parsed as a
placement directive. We currently only allow
unscoped placement directives at bootstrap.
Andrew Wilkins (axwalk) wrote : | # |
Ian Booth (wallyworld) wrote : | # |
LGTM with a suggestion.
Also a drive by fix for
// Directive is a scope-specific placement idrective
would be great.
https:/
File cmd/juju/
https:/
cmd/juju/
What happens if there's a different error other than
ErrPlacementSco
In that case we should just return that other error shouldn't we? ie
there's a difference between an unsupported placement directive and a
placement directive that doesn't parse due to some other error. Even if
there's no other error that can be returned (yet), reworking the
conditional would make it explicit that we are only interested in a
specific case.
Andrew Wilkins (axwalk) wrote : | # |
Please take a look.
https:/
File cmd/juju/
https:/
cmd/juju/
On 2014/04/24 03:10:01, wallyworld wrote:
> What happens if there's a different error other than
ErrPlacementSco
> In that case we should just return that other error shouldn't we? ie
there's a
> difference between an unsupported placement directive and a placement
directive
> that doesn't parse due to some other error. Even if there's no other
error that
> can be returned (yet), reworking the conditional would make it
explicit that we
> are only interested in a specific case.
There are other errors, but they're not meaningful to us if we don't
support scoped placements. For example, lxc:non-numeric will fail to
parse, but we bootstrap doesn't care about why; it only cares that
"lxc:anything" is not supported by bootstrap.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~axwalk/juju-core/lp1237709-bootstrap-placement into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
Preview Diff
1 | === modified file 'cmd/juju/bootstrap.go' |
2 | --- cmd/juju/bootstrap.go 2014-04-18 13:49:33 +0000 |
3 | +++ cmd/juju/bootstrap.go 2014-04-24 03:34:13 +0000 |
4 | @@ -14,9 +14,11 @@ |
5 | "launchpad.net/juju-core/cmd" |
6 | "launchpad.net/juju-core/cmd/envcmd" |
7 | "launchpad.net/juju-core/constraints" |
8 | + "launchpad.net/juju-core/environs" |
9 | "launchpad.net/juju-core/environs/bootstrap" |
10 | "launchpad.net/juju-core/environs/imagemetadata" |
11 | "launchpad.net/juju-core/environs/tools" |
12 | + "launchpad.net/juju-core/instance" |
13 | "launchpad.net/juju-core/provider" |
14 | ) |
15 | |
16 | @@ -64,11 +66,13 @@ |
17 | UploadTools bool |
18 | Series []string |
19 | MetadataSource string |
20 | + Placement string |
21 | } |
22 | |
23 | func (c *BootstrapCommand) Info() *cmd.Info { |
24 | return &cmd.Info{ |
25 | Name: "bootstrap", |
26 | + Args: "[placement]", |
27 | Purpose: "start up an environment from scratch", |
28 | Doc: bootstrapDoc, |
29 | } |
30 | @@ -90,7 +94,22 @@ |
31 | if len(c.Series) > 0 && !c.UploadTools { |
32 | return fmt.Errorf("--series requires --upload-tools") |
33 | } |
34 | - return cmd.CheckEmpty(args) |
35 | + // Parse the placement directive. Bootstrap currently only |
36 | + // supports provider-specific placement directives. |
37 | + placement, err := cmd.ZeroOrOneArgs(args) |
38 | + if err != nil { |
39 | + return err |
40 | + } |
41 | + if placement == "" { |
42 | + return nil |
43 | + } |
44 | + _, err = instance.ParsePlacement(placement) |
45 | + if err != instance.ErrPlacementScopeMissing { |
46 | + // We only support unscoped placement directives for bootstrap. |
47 | + return fmt.Errorf("unsupported bootstrap placement directive %q", placement) |
48 | + } |
49 | + c.Placement = placement |
50 | + return nil |
51 | } |
52 | |
53 | // Run connects to the environment specified on the command line and bootstraps |
54 | @@ -153,7 +172,10 @@ |
55 | return err |
56 | } |
57 | } |
58 | - return bootstrap.Bootstrap(ctx, environ, c.Constraints) |
59 | + return bootstrap.Bootstrap(ctx, environ, environs.BootstrapParams{ |
60 | + Constraints: c.Constraints, |
61 | + Placement: c.Placement, |
62 | + }) |
63 | } |
64 | |
65 | type seriesVar struct { |
66 | |
67 | === modified file 'cmd/juju/bootstrap_test.go' |
68 | --- cmd/juju/bootstrap_test.go 2014-04-21 23:10:05 +0000 |
69 | +++ cmd/juju/bootstrap_test.go 2014-04-24 03:34:13 +0000 |
70 | @@ -193,6 +193,7 @@ |
71 | // will be uploaded before running the test. |
72 | uploads []string |
73 | constraints constraints.Value |
74 | + placement string |
75 | hostArch string |
76 | } |
77 | |
78 | @@ -271,7 +272,8 @@ |
79 | |
80 | opBootstrap := (<-opc).(dummy.OpBootstrap) |
81 | c.Check(opBootstrap.Env, gc.Equals, "peckham") |
82 | - c.Check(opBootstrap.Constraints, gc.DeepEquals, test.constraints) |
83 | + c.Check(opBootstrap.Args.Constraints, gc.DeepEquals, test.constraints) |
84 | + c.Check(opBootstrap.Args.Placement, gc.Equals, test.placement) |
85 | |
86 | store, err := configstore.Default() |
87 | c.Assert(err, gc.IsNil) |
88 | @@ -287,10 +289,6 @@ |
89 | var bootstrapTests = []bootstrapTest{{ |
90 | info: "no args, no error, no uploads, no constraints", |
91 | }, { |
92 | - info: "bad arg", |
93 | - args: []string{"twiddle"}, |
94 | - err: `unrecognized args: \["twiddle"\]`, |
95 | -}, { |
96 | info: "bad --constraints", |
97 | args: []string{"--constraints", "bad=wrong"}, |
98 | err: `invalid value "bad=wrong" for flag --constraints: unknown constraint "bad"`, |
99 | @@ -372,6 +370,14 @@ |
100 | "1.2.3.5-raring-amd64", |
101 | "1.2.3.5-%LTS%-amd64", |
102 | }, |
103 | +}, { |
104 | + info: "placement", |
105 | + args: []string{"something"}, |
106 | + placement: "something", |
107 | +}, { |
108 | + info: "invalid placement: ssh", |
109 | + args: []string{"ssh:someplace"}, |
110 | + err: `unsupported bootstrap placement directive "ssh:someplace"`, |
111 | }} |
112 | |
113 | func (s *BootstrapSuite) TestBootstrapTwice(c *gc.C) { |
114 | |
115 | === modified file 'cmd/juju/cmd_test.go' |
116 | --- cmd/juju/cmd_test.go 2014-03-28 12:28:30 +0000 |
117 | +++ cmd/juju/cmd_test.go 2014-04-24 03:34:13 +0000 |
118 | @@ -114,11 +114,6 @@ |
119 | testInit(c, com, args, "") |
120 | os.Setenv(osenv.JujuEnvEnvKey, oldenv) |
121 | assertConnName(c, com, "walthamstow") |
122 | - |
123 | - com, args = cmdFunc() |
124 | - if _, ok := com.(*StatusCommand); !ok { |
125 | - testInit(c, com, append(args, "hotdog"), "unrecognized args.*") |
126 | - } |
127 | } |
128 | } |
129 | |
130 | |
131 | === modified file 'cmd/juju/deploy_test.go' |
132 | --- cmd/juju/deploy_test.go 2014-04-14 12:36:13 +0000 |
133 | +++ cmd/juju/deploy_test.go 2014-04-24 03:34:13 +0000 |
134 | @@ -37,6 +37,9 @@ |
135 | args: nil, |
136 | err: `no charm specified`, |
137 | }, { |
138 | + args: []string{"charm-name", "service-name", "hotdog"}, |
139 | + err: `unrecognized args: \["hotdog"\]`, |
140 | + }, { |
141 | args: []string{"craz~ness"}, |
142 | err: `invalid charm name "craz~ness"`, |
143 | }, { |
144 | |
145 | === modified file 'cmd/plugins/juju-restore/restore.go' |
146 | --- cmd/plugins/juju-restore/restore.go 2014-04-12 05:53:58 +0000 |
147 | +++ cmd/plugins/juju-restore/restore.go 2014-04-24 03:34:13 +0000 |
148 | @@ -254,7 +254,8 @@ |
149 | // error-prone) or we could provide a --no-check flag to make |
150 | // it go ahead anyway without the check. |
151 | |
152 | - if err := bootstrap.Bootstrap(ctx, env, cons); err != nil { |
153 | + args := environs.BootstrapParams{Constraints: cons} |
154 | + if err := bootstrap.Bootstrap(ctx, env, args); err != nil { |
155 | return nil, fmt.Errorf("cannot bootstrap new instance: %v", err) |
156 | } |
157 | return env, nil |
158 | |
159 | === modified file 'environs/bootstrap/bootstrap.go' |
160 | --- environs/bootstrap/bootstrap.go 2014-04-17 10:09:39 +0000 |
161 | +++ environs/bootstrap/bootstrap.go 2014-04-24 03:34:13 +0000 |
162 | @@ -8,7 +8,6 @@ |
163 | |
164 | "github.com/juju/loggo" |
165 | |
166 | - "launchpad.net/juju-core/constraints" |
167 | "launchpad.net/juju-core/environs" |
168 | coretools "launchpad.net/juju-core/tools" |
169 | "launchpad.net/juju-core/utils/ssh" |
170 | @@ -20,7 +19,7 @@ |
171 | // Bootstrap bootstraps the given environment. The supplied constraints are |
172 | // used to provision the instance, and are also set within the bootstrapped |
173 | // environment. |
174 | -func Bootstrap(ctx environs.BootstrapContext, environ environs.Environ, cons constraints.Value) error { |
175 | +func Bootstrap(ctx environs.BootstrapContext, environ environs.Environ, args environs.BootstrapParams) error { |
176 | cfg := environ.Config() |
177 | if secret := cfg.AdminSecret(); secret == "" { |
178 | return fmt.Errorf("environment configuration has no admin-secret") |
179 | @@ -45,7 +44,7 @@ |
180 | } |
181 | logger.Debugf("environment %q supports service/machine networks: %v", environ.Name(), environ.SupportNetworks()) |
182 | logger.Infof("bootstrapping environment %q", environ.Name()) |
183 | - return environ.Bootstrap(ctx, cons) |
184 | + return environ.Bootstrap(ctx, args) |
185 | } |
186 | |
187 | // SetBootstrapTools returns the newest tools from the given tools list, |
188 | |
189 | === modified file 'environs/bootstrap/bootstrap_test.go' |
190 | --- environs/bootstrap/bootstrap_test.go 2014-04-17 09:42:34 +0000 |
191 | +++ environs/bootstrap/bootstrap_test.go 2014-04-24 03:34:13 +0000 |
192 | @@ -70,20 +70,20 @@ |
193 | env.cfg = cfg |
194 | } |
195 | |
196 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
197 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
198 | c.Assert(err, gc.ErrorMatches, "environment configuration has no admin-secret") |
199 | |
200 | fixEnv("admin-secret", "whatever") |
201 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
202 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
203 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-cert") |
204 | |
205 | fixEnv("ca-cert", coretesting.CACert) |
206 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
207 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
208 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-private-key") |
209 | |
210 | fixEnv("ca-private-key", coretesting.CAKey) |
211 | uploadTools(c, env) |
212 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
213 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
214 | c.Assert(err, gc.IsNil) |
215 | } |
216 | |
217 | @@ -96,20 +96,30 @@ |
218 | func (s *bootstrapSuite) TestBootstrapEmptyConstraints(c *gc.C) { |
219 | env := newEnviron("foo", useDefaultKeys, nil) |
220 | s.setDummyStorage(c, env) |
221 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
222 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
223 | c.Assert(err, gc.IsNil) |
224 | c.Assert(env.bootstrapCount, gc.Equals, 1) |
225 | - c.Assert(env.constraints, gc.DeepEquals, constraints.Value{}) |
226 | + c.Assert(env.args, gc.DeepEquals, environs.BootstrapParams{}) |
227 | } |
228 | |
229 | func (s *bootstrapSuite) TestBootstrapSpecifiedConstraints(c *gc.C) { |
230 | env := newEnviron("foo", useDefaultKeys, nil) |
231 | s.setDummyStorage(c, env) |
232 | cons := constraints.MustParse("cpu-cores=2 mem=4G") |
233 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, cons) |
234 | - c.Assert(err, gc.IsNil) |
235 | - c.Assert(env.bootstrapCount, gc.Equals, 1) |
236 | - c.Assert(env.constraints, gc.DeepEquals, cons) |
237 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{Constraints: cons}) |
238 | + c.Assert(err, gc.IsNil) |
239 | + c.Assert(env.bootstrapCount, gc.Equals, 1) |
240 | + c.Assert(env.args.Constraints, gc.DeepEquals, cons) |
241 | +} |
242 | + |
243 | +func (s *bootstrapSuite) TestBootstrapSpecifiedPlacement(c *gc.C) { |
244 | + env := newEnviron("foo", useDefaultKeys, nil) |
245 | + s.setDummyStorage(c, env) |
246 | + placement := "directive" |
247 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{Placement: placement}) |
248 | + c.Assert(err, gc.IsNil) |
249 | + c.Assert(env.bootstrapCount, gc.Equals, 1) |
250 | + c.Assert(env.args.Placement, gc.DeepEquals, placement) |
251 | } |
252 | |
253 | var bootstrapSetAgentVersionTests = []envtesting.BootstrapToolsTest{ |
254 | @@ -179,7 +189,7 @@ |
255 | if test.Arch != "" { |
256 | cons = constraints.MustParse("arch=" + test.Arch) |
257 | } |
258 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, cons) |
259 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{Constraints: cons}) |
260 | if test.Err != "" { |
261 | c.Check(err, gc.NotNil) |
262 | if err != nil { |
263 | @@ -206,7 +216,7 @@ |
264 | env := newEnviron("foo", useDefaultKeys, nil) |
265 | s.setDummyStorage(c, env) |
266 | envtesting.RemoveFakeTools(c, env.Storage()) |
267 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
268 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
269 | // bootstrap.Bootstrap leaves it to the provider to |
270 | // locate bootstrap tools. |
271 | c.Assert(err, gc.IsNil) |
272 | @@ -479,7 +489,7 @@ |
273 | |
274 | // The following fields are filled in when Bootstrap is called. |
275 | bootstrapCount int |
276 | - constraints constraints.Value |
277 | + args environs.BootstrapParams |
278 | storage storage.Storage |
279 | } |
280 | |
281 | @@ -525,9 +535,9 @@ |
282 | return e.name |
283 | } |
284 | |
285 | -func (e *bootstrapEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
286 | +func (e *bootstrapEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
287 | e.bootstrapCount++ |
288 | - e.constraints = cons |
289 | + e.args = args |
290 | return nil |
291 | } |
292 | |
293 | |
294 | === modified file 'environs/interface.go' |
295 | --- environs/interface.go 2014-04-22 09:23:39 +0000 |
296 | +++ environs/interface.go 2014-04-24 03:34:13 +0000 |
297 | @@ -65,6 +65,17 @@ |
298 | Config() *config.Config |
299 | } |
300 | |
301 | +// BootstrapParams holds the parameters for bootstrapping an environment. |
302 | +type BootstrapParams struct { |
303 | + // Constraints are used to choose the initial instance specification, |
304 | + // and will be stored in the new environment's state. |
305 | + Constraints constraints.Value |
306 | + |
307 | + // Placement, if non-empty, holds an environment-specific placement |
308 | + // directive used to choose the initial instance. |
309 | + Placement string |
310 | +} |
311 | + |
312 | // An Environ represents a juju environment as specified |
313 | // in the environments.yaml file. |
314 | // |
315 | @@ -91,13 +102,10 @@ |
316 | // environment via the juju package, the password hash will be |
317 | // automatically replaced by the real password. |
318 | // |
319 | - // The supplied constraints are used to choose the initial instance |
320 | - // specification, and will be stored in the new environment's state. |
321 | - // |
322 | // Bootstrap is responsible for selecting the appropriate tools, |
323 | // and setting the agent-version configuration attribute prior to |
324 | // bootstrapping the environment. |
325 | - Bootstrap(ctx BootstrapContext, cons constraints.Value) error |
326 | + Bootstrap(ctx BootstrapContext, params BootstrapParams) error |
327 | |
328 | // StateInfo returns information on the state initialized |
329 | // by Bootstrap. |
330 | |
331 | === modified file 'environs/jujutest/livetests.go' |
332 | --- environs/jujutest/livetests.go 2014-04-22 09:23:39 +0000 |
333 | +++ environs/jujutest/livetests.go 2014-04-24 03:34:13 +0000 |
334 | @@ -139,7 +139,7 @@ |
335 | envtesting.UploadFakeTools(c, t.Env.Storage()) |
336 | err := bootstrap.EnsureNotBootstrapped(t.Env) |
337 | c.Assert(err, gc.IsNil) |
338 | - err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, cons) |
339 | + err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, environs.BootstrapParams{Constraints: cons}) |
340 | c.Assert(err, gc.IsNil) |
341 | t.bootstrapped = true |
342 | } |
343 | @@ -917,7 +917,7 @@ |
344 | err = storageCopy(dummyStorage, currentName, envStorage, otherName) |
345 | c.Assert(err, gc.IsNil) |
346 | |
347 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
348 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
349 | c.Assert(err, gc.IsNil) |
350 | |
351 | conn, err := juju.NewConn(env) |
352 | |
353 | === modified file 'environs/jujutest/tests.go' |
354 | --- environs/jujutest/tests.go 2014-04-14 12:36:13 +0000 |
355 | +++ environs/jujutest/tests.go 2014-04-24 03:34:13 +0000 |
356 | @@ -12,7 +12,6 @@ |
357 | jc "github.com/juju/testing/checkers" |
358 | gc "launchpad.net/gocheck" |
359 | |
360 | - "launchpad.net/juju-core/constraints" |
361 | "launchpad.net/juju-core/environs" |
362 | "launchpad.net/juju-core/environs/bootstrap" |
363 | "launchpad.net/juju-core/environs/config" |
364 | @@ -133,7 +132,7 @@ |
365 | envtesting.UploadFakeTools(c, e.Storage()) |
366 | err := bootstrap.EnsureNotBootstrapped(e) |
367 | c.Assert(err, gc.IsNil) |
368 | - err = bootstrap.Bootstrap(coretesting.Context(c), e, constraints.Value{}) |
369 | + err = bootstrap.Bootstrap(coretesting.Context(c), e, environs.BootstrapParams{}) |
370 | c.Assert(err, gc.IsNil) |
371 | |
372 | info, apiInfo, err := e.StateInfo() |
373 | @@ -161,7 +160,7 @@ |
374 | |
375 | err = bootstrap.EnsureNotBootstrapped(e3) |
376 | c.Assert(err, gc.IsNil) |
377 | - err = bootstrap.Bootstrap(coretesting.Context(c), e3, constraints.Value{}) |
378 | + err = bootstrap.Bootstrap(coretesting.Context(c), e3, environs.BootstrapParams{}) |
379 | c.Assert(err, gc.IsNil) |
380 | |
381 | err = bootstrap.EnsureNotBootstrapped(e3) |
382 | |
383 | === modified file 'environs/open_test.go' |
384 | --- environs/open_test.go 2014-04-14 12:36:13 +0000 |
385 | +++ environs/open_test.go 2014-04-24 03:34:13 +0000 |
386 | @@ -10,7 +10,6 @@ |
387 | gc "launchpad.net/gocheck" |
388 | |
389 | "launchpad.net/juju-core/cert" |
390 | - "launchpad.net/juju-core/constraints" |
391 | "launchpad.net/juju-core/environs" |
392 | "launchpad.net/juju-core/environs/bootstrap" |
393 | "launchpad.net/juju-core/environs/config" |
394 | @@ -41,7 +40,7 @@ |
395 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
396 | c.Assert(err, gc.IsNil) |
397 | envtesting.UploadFakeTools(c, env.Storage()) |
398 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
399 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
400 | c.Assert(err, gc.IsNil) |
401 | } |
402 | |
403 | |
404 | === modified file 'instance/placement.go' |
405 | --- instance/placement.go 2014-04-23 05:38:27 +0000 |
406 | +++ instance/placement.go 2014-04-24 03:34:13 +0000 |
407 | @@ -28,7 +28,7 @@ |
408 | // If Scope is empty, then it must be inferred from the context. |
409 | Scope string |
410 | |
411 | - // Directive is a scope-specific placement idrective. |
412 | + // Directive is a scope-specific placement directive. |
413 | // |
414 | // For MachineScope or a container scope, this may be empty or |
415 | // the ID of an existing machine. |
416 | |
417 | === modified file 'juju/apiconn_test.go' |
418 | --- juju/apiconn_test.go 2014-04-22 14:34:29 +0000 |
419 | +++ juju/apiconn_test.go 2014-04-24 03:34:13 +0000 |
420 | @@ -11,7 +11,6 @@ |
421 | jc "github.com/juju/testing/checkers" |
422 | gc "launchpad.net/gocheck" |
423 | |
424 | - "launchpad.net/juju-core/constraints" |
425 | "launchpad.net/juju-core/environs" |
426 | "launchpad.net/juju-core/environs/bootstrap" |
427 | "launchpad.net/juju-core/environs/config" |
428 | @@ -53,7 +52,7 @@ |
429 | c.Assert(err, gc.IsNil) |
430 | |
431 | envtesting.UploadFakeTools(c, env.Storage()) |
432 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
433 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
434 | c.Assert(err, gc.IsNil) |
435 | |
436 | cfg = env.Config() |
437 | @@ -601,7 +600,7 @@ |
438 | c.Assert(err, gc.IsNil) |
439 | defer dummy.Reset() |
440 | envtesting.UploadFakeTools(c, env.Storage()) |
441 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
442 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
443 | c.Assert(err, gc.IsNil) |
444 | |
445 | // Note: if we get Bootstrap to start caching the API endpoint |
446 | |
447 | === modified file 'juju/conn_test.go' |
448 | --- juju/conn_test.go 2014-04-14 12:36:13 +0000 |
449 | +++ juju/conn_test.go 2014-04-24 03:34:13 +0000 |
450 | @@ -70,7 +70,7 @@ |
451 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
452 | c.Assert(err, gc.IsNil) |
453 | envtesting.UploadFakeTools(c, env.Storage()) |
454 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
455 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
456 | c.Assert(err, gc.IsNil) |
457 | |
458 | attrs := env.Config().AllAttrs() |
459 | @@ -90,7 +90,7 @@ |
460 | env, err := environs.PrepareFromName(envName, ctx, store) |
461 | c.Assert(err, gc.IsNil) |
462 | envtesting.UploadFakeTools(c, env.Storage()) |
463 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
464 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
465 | c.Assert(err, gc.IsNil) |
466 | } |
467 | |
468 | @@ -136,7 +136,7 @@ |
469 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
470 | c.Assert(err, gc.IsNil) |
471 | envtesting.UploadFakeTools(c, env.Storage()) |
472 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
473 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
474 | c.Assert(err, gc.IsNil) |
475 | info, _, err := env.StateInfo() |
476 | c.Assert(err, gc.IsNil) |
477 | @@ -180,7 +180,7 @@ |
478 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
479 | c.Assert(err, gc.IsNil) |
480 | envtesting.UploadFakeTools(c, env.Storage()) |
481 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
482 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
483 | c.Assert(err, gc.IsNil) |
484 | |
485 | // Make a new Conn, which will push the secrets. |
486 | @@ -217,7 +217,7 @@ |
487 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
488 | c.Assert(err, gc.IsNil) |
489 | envtesting.UploadFakeTools(c, env.Storage()) |
490 | - err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
491 | + err = bootstrap.Bootstrap(ctx, env, environs.BootstrapParams{}) |
492 | c.Assert(err, gc.IsNil) |
493 | |
494 | // Check that Bootstrap has correctly used a hash |
495 | @@ -272,7 +272,7 @@ |
496 | environ, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
497 | c.Assert(err, gc.IsNil) |
498 | envtesting.UploadFakeTools(c, environ.Storage()) |
499 | - err = bootstrap.Bootstrap(ctx, environ, constraints.Value{}) |
500 | + err = bootstrap.Bootstrap(ctx, environ, environs.BootstrapParams{}) |
501 | c.Assert(err, gc.IsNil) |
502 | s.conn, err = juju.NewConn(environ) |
503 | c.Assert(err, gc.IsNil) |
504 | |
505 | === modified file 'juju/testing/conn.go' |
506 | --- juju/testing/conn.go 2014-04-11 17:51:58 +0000 |
507 | +++ juju/testing/conn.go 2014-04-24 03:34:13 +0000 |
508 | @@ -14,7 +14,6 @@ |
509 | |
510 | "launchpad.net/juju-core/agent" |
511 | "launchpad.net/juju-core/charm" |
512 | - "launchpad.net/juju-core/constraints" |
513 | "launchpad.net/juju-core/environs" |
514 | "launchpad.net/juju-core/environs/bootstrap" |
515 | "launchpad.net/juju-core/environs/config" |
516 | @@ -220,7 +219,7 @@ |
517 | |
518 | // Upload tools for both preferred and fake default series |
519 | envtesting.MustUploadFakeToolsVersions(environ.Storage(), versions...) |
520 | - c.Assert(bootstrap.Bootstrap(ctx, environ, constraints.Value{}), gc.IsNil) |
521 | + c.Assert(bootstrap.Bootstrap(ctx, environ, environs.BootstrapParams{}), gc.IsNil) |
522 | |
523 | s.BackingState = environ.(GetStater).GetStateInAPIServer() |
524 | |
525 | |
526 | === modified file 'provider/azure/environ.go' |
527 | --- provider/azure/environ.go 2014-04-22 09:38:55 +0000 |
528 | +++ provider/azure/environ.go 2014-04-24 03:34:13 +0000 |
529 | @@ -260,7 +260,7 @@ |
530 | } |
531 | |
532 | // Bootstrap is specified in the Environ interface. |
533 | -func (env *azureEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) (err error) { |
534 | +func (env *azureEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) (err error) { |
535 | // The creation of the affinity group and the virtual network is specific to the Azure provider. |
536 | err = env.createAffinityGroup() |
537 | if err != nil { |
538 | @@ -282,7 +282,7 @@ |
539 | env.deleteVirtualNetwork() |
540 | } |
541 | }() |
542 | - err = common.Bootstrap(ctx, env, cons) |
543 | + err = common.Bootstrap(ctx, env, args) |
544 | return err |
545 | } |
546 | |
547 | |
548 | === modified file 'provider/common/bootstrap.go' |
549 | --- provider/common/bootstrap.go 2014-04-11 11:51:08 +0000 |
550 | +++ provider/common/bootstrap.go 2014-04-24 03:34:13 +0000 |
551 | @@ -15,7 +15,6 @@ |
552 | |
553 | coreCloudinit "launchpad.net/juju-core/cloudinit" |
554 | "launchpad.net/juju-core/cloudinit/sshinit" |
555 | - "launchpad.net/juju-core/constraints" |
556 | "launchpad.net/juju-core/environs" |
557 | "launchpad.net/juju-core/environs/bootstrap" |
558 | "launchpad.net/juju-core/environs/cloudinit" |
559 | @@ -33,7 +32,7 @@ |
560 | // Bootstrap is a common implementation of the Bootstrap method defined on |
561 | // environs.Environ; we strongly recommend that this implementation be used |
562 | // when writing a new provider. |
563 | -func Bootstrap(ctx environs.BootstrapContext, env environs.Environ, cons constraints.Value) (err error) { |
564 | +func Bootstrap(ctx environs.BootstrapContext, env environs.Environ, args environs.BootstrapParams) (err error) { |
565 | // TODO make safe in the case of racing Bootstraps |
566 | // If two Bootstraps are called concurrently, there's |
567 | // no way to make sure that only one succeeds. |
568 | @@ -42,7 +41,7 @@ |
569 | defer func() { handleBootstrapError(err, ctx, inst, env) }() |
570 | |
571 | // First thing, ensure we have tools otherwise there's no point. |
572 | - selectedTools, err := EnsureBootstrapTools(ctx, env, config.PreferredSeries(env.Config()), cons.Arch) |
573 | + selectedTools, err := EnsureBootstrapTools(ctx, env, config.PreferredSeries(env.Config()), args.Constraints.Arch) |
574 | if err != nil { |
575 | return err |
576 | } |
577 | @@ -64,9 +63,10 @@ |
578 | |
579 | fmt.Fprintln(ctx.GetStderr(), "Launching instance") |
580 | inst, hw, _, err := env.StartInstance(environs.StartInstanceParams{ |
581 | - Constraints: cons, |
582 | + Constraints: args.Constraints, |
583 | Tools: selectedTools, |
584 | MachineConfig: machineConfig, |
585 | + Placement: args.Placement, |
586 | }) |
587 | if err != nil { |
588 | return fmt.Errorf("cannot start bootstrap instance: %v", err) |
589 | |
590 | === modified file 'provider/common/bootstrap_test.go' |
591 | --- provider/common/bootstrap_test.go 2014-04-18 16:37:28 +0000 |
592 | +++ provider/common/bootstrap_test.go 2014-04-24 03:34:13 +0000 |
593 | @@ -76,13 +76,15 @@ |
594 | } |
595 | |
596 | func (s *BootstrapSuite) TestCannotStartInstance(c *gc.C) { |
597 | + checkPlacement := "directive" |
598 | checkCons := constraints.MustParse("mem=8G") |
599 | |
600 | startInstance := func( |
601 | - cons constraints.Value, _, _ []string, possibleTools tools.List, mcfg *cloudinit.MachineConfig, |
602 | + placement string, cons constraints.Value, _, _ []string, possibleTools tools.List, mcfg *cloudinit.MachineConfig, |
603 | ) ( |
604 | instance.Instance, *instance.HardwareCharacteristics, []network.Info, error, |
605 | ) { |
606 | + c.Assert(placement, gc.DeepEquals, checkPlacement) |
607 | c.Assert(cons, gc.DeepEquals, checkCons) |
608 | c.Assert(mcfg, gc.DeepEquals, environs.NewBootstrapMachineConfig(mcfg.SystemPrivateSSHKey)) |
609 | return nil, nil, nil, fmt.Errorf("meh, not started") |
610 | @@ -95,7 +97,10 @@ |
611 | } |
612 | |
613 | ctx := coretesting.Context(c) |
614 | - err := common.Bootstrap(ctx, env, checkCons) |
615 | + err := common.Bootstrap(ctx, env, environs.BootstrapParams{ |
616 | + Constraints: checkCons, |
617 | + Placement: checkPlacement, |
618 | + }) |
619 | c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started") |
620 | } |
621 | |
622 | @@ -104,7 +109,7 @@ |
623 | stor := &mockStorage{Storage: innerStorage} |
624 | |
625 | startInstance := func( |
626 | - _ constraints.Value, _, _ []string, _ tools.List, _ *cloudinit.MachineConfig, |
627 | + _ string, _ constraints.Value, _, _ []string, _ tools.List, _ *cloudinit.MachineConfig, |
628 | ) ( |
629 | instance.Instance, *instance.HardwareCharacteristics, []network.Info, error, |
630 | ) { |
631 | @@ -126,7 +131,7 @@ |
632 | } |
633 | |
634 | ctx := coretesting.Context(c) |
635 | - err := common.Bootstrap(ctx, env, constraints.Value{}) |
636 | + err := common.Bootstrap(ctx, env, environs.BootstrapParams{}) |
637 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") |
638 | c.Assert(stopped, gc.HasLen, 1) |
639 | c.Assert(stopped[0].Id(), gc.Equals, instance.Id("i-blah")) |
640 | @@ -137,7 +142,7 @@ |
641 | stor := &mockStorage{Storage: innerStorage} |
642 | |
643 | startInstance := func( |
644 | - _ constraints.Value, _, _ []string, _ tools.List, _ *cloudinit.MachineConfig, |
645 | + _ string, _ constraints.Value, _, _ []string, _ tools.List, _ *cloudinit.MachineConfig, |
646 | ) ( |
647 | instance.Instance, *instance.HardwareCharacteristics, []network.Info, error, |
648 | ) { |
649 | @@ -163,7 +168,7 @@ |
650 | } |
651 | |
652 | ctx := coretesting.Context(c) |
653 | - err := common.Bootstrap(ctx, env, constraints.Value{}) |
654 | + err := common.Bootstrap(ctx, env, environs.BootstrapParams{}) |
655 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") |
656 | c.Assert(stopped, gc.HasLen, 1) |
657 | c.Assert(stopped[0].Id(), gc.Equals, instance.Id("i-blah")) |
658 | @@ -178,7 +183,7 @@ |
659 | checkHardware := instance.MustParseHardware("mem=2T") |
660 | |
661 | startInstance := func( |
662 | - _ constraints.Value, _, _ []string, _ tools.List, mcfg *cloudinit.MachineConfig, |
663 | + _ string, _ constraints.Value, _, _ []string, _ tools.List, mcfg *cloudinit.MachineConfig, |
664 | ) ( |
665 | instance.Instance, *instance.HardwareCharacteristics, []network.Info, error, |
666 | ) { |
667 | @@ -206,7 +211,7 @@ |
668 | } |
669 | originalAuthKeys := env.Config().AuthorizedKeys() |
670 | ctx := coretesting.Context(c) |
671 | - err := common.Bootstrap(ctx, env, constraints.Value{}) |
672 | + err := common.Bootstrap(ctx, env, environs.BootstrapParams{}) |
673 | c.Assert(err, gc.IsNil) |
674 | |
675 | authKeys := env.Config().AuthorizedKeys() |
676 | |
677 | === modified file 'provider/common/mock_test.go' |
678 | --- provider/common/mock_test.go 2014-04-18 16:37:28 +0000 |
679 | +++ provider/common/mock_test.go 2014-04-24 03:34:13 +0000 |
680 | @@ -18,7 +18,7 @@ |
681 | ) |
682 | |
683 | type allInstancesFunc func() ([]instance.Instance, error) |
684 | -type startInstanceFunc func(constraints.Value, []string, []string, tools.List, *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, []network.Info, error) |
685 | +type startInstanceFunc func(string, constraints.Value, []string, []string, tools.List, *cloudinit.MachineConfig) (instance.Instance, *instance.HardwareCharacteristics, []network.Info, error) |
686 | type stopInstancesFunc func([]instance.Instance) error |
687 | type getToolsSourcesFunc func() ([]simplestreams.DataSource, error) |
688 | type configFunc func() *config.Config |
689 | @@ -52,6 +52,7 @@ |
690 | } |
691 | func (env *mockEnviron) StartInstance(args environs.StartInstanceParams) (instance.Instance, *instance.HardwareCharacteristics, []network.Info, error) { |
692 | return env.startInstance( |
693 | + args.Placement, |
694 | args.Constraints, |
695 | args.MachineConfig.IncludeNetworks, |
696 | args.MachineConfig.ExcludeNetworks, |
697 | |
698 | === modified file 'provider/dummy/environs.go' |
699 | --- provider/dummy/environs.go 2014-04-22 09:23:39 +0000 |
700 | +++ provider/dummy/environs.go 2014-04-24 03:34:13 +0000 |
701 | @@ -98,9 +98,9 @@ |
702 | type Operation interface{} |
703 | |
704 | type OpBootstrap struct { |
705 | - Context environs.BootstrapContext |
706 | - Env string |
707 | - Constraints constraints.Value |
708 | + Context environs.BootstrapContext |
709 | + Env string |
710 | + Args environs.BootstrapParams |
711 | } |
712 | |
713 | type OpDestroy struct { |
714 | @@ -562,8 +562,8 @@ |
715 | storage.NewStorageSimpleStreamsDataSource("cloud storage", e.Storage(), storage.BaseToolsPath)}, nil |
716 | } |
717 | |
718 | -func (e *environ) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
719 | - selectedTools, err := common.EnsureBootstrapTools(ctx, e, config.PreferredSeries(e.Config()), cons.Arch) |
720 | +func (e *environ) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
721 | + selectedTools, err := common.EnsureBootstrapTools(ctx, e, config.PreferredSeries(e.Config()), args.Constraints.Arch) |
722 | if err != nil { |
723 | return err |
724 | } |
725 | @@ -615,7 +615,7 @@ |
726 | if err != nil { |
727 | panic(err) |
728 | } |
729 | - if err := st.SetEnvironConstraints(cons); err != nil { |
730 | + if err := st.SetEnvironConstraints(args.Constraints); err != nil { |
731 | panic(err) |
732 | } |
733 | if err := st.SetAdminMongoPassword(utils.UserPasswordHash(password, utils.CompatSalt)); err != nil { |
734 | @@ -632,7 +632,7 @@ |
735 | estate.apiState = st |
736 | } |
737 | estate.bootstrapped = true |
738 | - estate.ops <- OpBootstrap{Context: ctx, Env: e.name, Constraints: cons} |
739 | + estate.ops <- OpBootstrap{Context: ctx, Env: e.name, Args: args} |
740 | return nil |
741 | } |
742 | |
743 | |
744 | === modified file 'provider/ec2/ec2.go' |
745 | --- provider/ec2/ec2.go 2014-04-22 09:23:39 +0000 |
746 | +++ provider/ec2/ec2.go 2014-04-24 03:34:13 +0000 |
747 | @@ -323,8 +323,8 @@ |
748 | return stor |
749 | } |
750 | |
751 | -func (e *environ) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
752 | - return common.Bootstrap(ctx, e, cons) |
753 | +func (e *environ) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
754 | + return common.Bootstrap(ctx, e, args) |
755 | } |
756 | |
757 | func (e *environ) StateInfo() (*state.Info, *api.Info, error) { |
758 | |
759 | === modified file 'provider/ec2/local_test.go' |
760 | --- provider/ec2/local_test.go 2014-04-22 09:23:39 +0000 |
761 | +++ provider/ec2/local_test.go 2014-04-24 03:34:13 +0000 |
762 | @@ -218,7 +218,7 @@ |
763 | func (t *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { |
764 | env := t.Prepare(c) |
765 | envtesting.UploadFakeTools(c, env.Storage()) |
766 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
767 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
768 | c.Assert(err, gc.IsNil) |
769 | |
770 | // check that the state holds the id of the bootstrap machine. |
771 | @@ -303,7 +303,7 @@ |
772 | func (t *localServerSuite) TestInstanceStatus(c *gc.C) { |
773 | env := t.Prepare(c) |
774 | envtesting.UploadFakeTools(c, env.Storage()) |
775 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
776 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
777 | c.Assert(err, gc.IsNil) |
778 | t.srv.ec2srv.SetInitialInstanceState(ec2test.Terminated) |
779 | inst, _ := testing.AssertStartInstance(c, env, "1") |
780 | @@ -314,7 +314,7 @@ |
781 | func (t *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { |
782 | env := t.Prepare(c) |
783 | envtesting.UploadFakeTools(c, env.Storage()) |
784 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
785 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
786 | c.Assert(err, gc.IsNil) |
787 | _, hc := testing.AssertStartInstance(c, env, "1") |
788 | c.Check(*hc.Arch, gc.Equals, "amd64") |
789 | @@ -326,7 +326,7 @@ |
790 | func (t *localServerSuite) TestAddresses(c *gc.C) { |
791 | env := t.Prepare(c) |
792 | envtesting.UploadFakeTools(c, env.Storage()) |
793 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
794 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
795 | c.Assert(err, gc.IsNil) |
796 | inst, _ := testing.AssertStartInstance(c, env, "1") |
797 | c.Assert(err, gc.IsNil) |
798 | |
799 | === modified file 'provider/joyent/environ.go' |
800 | --- provider/joyent/environ.go 2014-04-22 09:38:55 +0000 |
801 | +++ provider/joyent/environ.go 2014-04-24 03:34:13 +0000 |
802 | @@ -154,8 +154,8 @@ |
803 | return environs.EmptyStorage |
804 | } |
805 | |
806 | -func (env *joyentEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
807 | - return common.Bootstrap(ctx, env, cons) |
808 | +func (env *joyentEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
809 | + return common.Bootstrap(ctx, env, args) |
810 | } |
811 | |
812 | func (env *joyentEnviron) StateInfo() (*state.Info, *api.Info, error) { |
813 | |
814 | === modified file 'provider/joyent/local_test.go' |
815 | --- provider/joyent/local_test.go 2014-04-18 13:49:33 +0000 |
816 | +++ provider/joyent/local_test.go 2014-04-24 03:34:13 +0000 |
817 | @@ -190,7 +190,7 @@ |
818 | func (s *localServerSuite) TestStartInstance(c *gc.C) { |
819 | env := s.Prepare(c) |
820 | envtesting.UploadFakeTools(c, env.Storage()) |
821 | - err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) |
822 | + err := bootstrap.Bootstrap(bootstrapContext(c), env, environs.BootstrapParams{}) |
823 | c.Assert(err, gc.IsNil) |
824 | inst, _ := testing.AssertStartInstance(c, env, "100") |
825 | err = env.StopInstances([]instance.Instance{inst}) |
826 | @@ -200,7 +200,7 @@ |
827 | func (s *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { |
828 | env := s.Prepare(c) |
829 | envtesting.UploadFakeTools(c, env.Storage()) |
830 | - err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) |
831 | + err := bootstrap.Bootstrap(bootstrapContext(c), env, environs.BootstrapParams{}) |
832 | c.Assert(err, gc.IsNil) |
833 | _, hc := testing.AssertStartInstanceWithConstraints(c, env, "100", constraints.MustParse("mem=1024")) |
834 | c.Check(*hc.Arch, gc.Equals, "amd64") |
835 | @@ -310,7 +310,7 @@ |
836 | func (s *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { |
837 | env := s.Prepare(c) |
838 | envtesting.UploadFakeTools(c, env.Storage()) |
839 | - err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) |
840 | + err := bootstrap.Bootstrap(bootstrapContext(c), env, environs.BootstrapParams{}) |
841 | c.Assert(err, gc.IsNil) |
842 | |
843 | // check that the state holds the id of the bootstrap machine. |
844 | |
845 | === modified file 'provider/local/config_test.go' |
846 | --- provider/local/config_test.go 2014-03-25 02:18:04 +0000 |
847 | +++ provider/local/config_test.go 2014-04-24 03:34:13 +0000 |
848 | @@ -8,7 +8,7 @@ |
849 | |
850 | gc "launchpad.net/gocheck" |
851 | |
852 | - "launchpad.net/juju-core/constraints" |
853 | + "launchpad.net/juju-core/environs" |
854 | "launchpad.net/juju-core/environs/config" |
855 | "launchpad.net/juju-core/juju/osenv" |
856 | "launchpad.net/juju-core/provider" |
857 | @@ -109,6 +109,6 @@ |
858 | s.PatchValue(local.CheckIfRoot, func() bool { return true }) |
859 | env, err := local.Provider.Prepare(testing.Context(c), minimalConfig(c)) |
860 | c.Assert(err, gc.IsNil) |
861 | - err = env.Bootstrap(testing.Context(c), constraints.Value{}) |
862 | + err = env.Bootstrap(testing.Context(c), environs.BootstrapParams{}) |
863 | c.Assert(err, gc.ErrorMatches, "bootstrapping a local environment must not be done as root") |
864 | } |
865 | |
866 | === modified file 'provider/local/environ.go' |
867 | --- provider/local/environ.go 2014-04-22 09:23:39 +0000 |
868 | +++ provider/local/environ.go 2014-04-24 03:34:13 +0000 |
869 | @@ -111,7 +111,7 @@ |
870 | } |
871 | |
872 | // Bootstrap is specified in the Environ interface. |
873 | -func (env *localEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
874 | +func (env *localEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
875 | if err := ensureNotRoot(); err != nil { |
876 | return err |
877 | } |
878 | @@ -161,7 +161,7 @@ |
879 | agent.StorageDir: env.config.storageDir(), |
880 | agent.StorageAddr: env.config.storageAddr(), |
881 | } |
882 | - if err := environs.FinishMachineConfig(mcfg, cfg, cons); err != nil { |
883 | + if err := environs.FinishMachineConfig(mcfg, cfg, args.Constraints); err != nil { |
884 | return err |
885 | } |
886 | // don't write proxy settings for local machine |
887 | |
888 | === modified file 'provider/local/environ_test.go' |
889 | --- provider/local/environ_test.go 2014-04-21 23:10:05 +0000 |
890 | +++ provider/local/environ_test.go 2014-04-24 03:34:13 +0000 |
891 | @@ -169,7 +169,7 @@ |
892 | c.Assert(err, gc.IsNil) |
893 | envtesting.UploadFakeTools(c, environ.Storage()) |
894 | defer environ.Storage().RemoveAll() |
895 | - err = environ.Bootstrap(ctx, constraints.Value{}) |
896 | + err = environ.Bootstrap(ctx, environs.BootstrapParams{}) |
897 | c.Assert(err, gc.IsNil) |
898 | return environ |
899 | } |
900 | |
901 | === modified file 'provider/maas/environ.go' |
902 | --- provider/maas/environ.go 2014-04-23 09:33:46 +0000 |
903 | +++ provider/maas/environ.go 2014-04-24 03:34:13 +0000 |
904 | @@ -90,8 +90,8 @@ |
905 | } |
906 | |
907 | // Bootstrap is specified in the Environ interface. |
908 | -func (env *maasEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
909 | - return common.Bootstrap(ctx, env, cons) |
910 | +func (env *maasEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
911 | + return common.Bootstrap(ctx, env, args) |
912 | } |
913 | |
914 | // StateInfo is specified in the Environ interface. |
915 | |
916 | === modified file 'provider/maas/environ_whitebox_test.go' |
917 | --- provider/maas/environ_whitebox_test.go 2014-04-23 09:33:46 +0000 |
918 | +++ provider/maas/environ_whitebox_test.go 2014-04-24 03:34:13 +0000 |
919 | @@ -199,7 +199,7 @@ |
920 | lshwXML, err := suite.generateHWTemplate(map[string]string{"aa:bb:cc:dd:ee:f0": "eth0"}) |
921 | c.Assert(err, gc.IsNil) |
922 | suite.testMAASObject.TestServer.AddNodeDetails("node0", lshwXML) |
923 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
924 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
925 | c.Assert(err, gc.IsNil) |
926 | // The bootstrap node has been acquired and started. |
927 | operations := suite.testMAASObject.TestServer.NodeOperations() |
928 | @@ -496,7 +496,7 @@ |
929 | lshwXML, err := suite.generateHWTemplate(map[string]string{"aa:bb:cc:dd:ee:f0": "eth0"}) |
930 | c.Assert(err, gc.IsNil) |
931 | suite.testMAASObject.TestServer.AddNodeDetails("thenode", lshwXML) |
932 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
933 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
934 | c.Assert(err, gc.IsNil) |
935 | } |
936 | |
937 | @@ -512,7 +512,7 @@ |
938 | c.Assert(err, gc.IsNil) |
939 | err = env.SetConfig(cfg) |
940 | c.Assert(err, gc.IsNil) |
941 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
942 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
943 | stripped := strings.Replace(err.Error(), "\n", "", -1) |
944 | c.Check(stripped, |
945 | gc.Matches, |
946 | @@ -522,7 +522,7 @@ |
947 | func (suite *environSuite) TestBootstrapFailsIfNoNodes(c *gc.C) { |
948 | suite.setupFakeTools(c) |
949 | env := suite.makeEnviron() |
950 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
951 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
952 | // Since there are no nodes, the attempt to allocate one returns a |
953 | // 409: Conflict. |
954 | c.Check(err, gc.ErrorMatches, ".*409.*") |
955 | |
956 | === modified file 'provider/manual/environ.go' |
957 | --- provider/manual/environ.go 2014-04-22 09:23:39 +0000 |
958 | +++ provider/manual/environ.go 2014-04-24 03:34:13 +0000 |
959 | @@ -102,7 +102,7 @@ |
960 | return false |
961 | } |
962 | |
963 | -func (e *manualEnviron) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
964 | +func (e *manualEnviron) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
965 | // Set "use-sshstorage" to false, so agents know not to use sshstorage. |
966 | cfg, err := e.Config().Apply(map[string]interface{}{"use-sshstorage": false}) |
967 | if err != nil { |
968 | @@ -112,6 +112,7 @@ |
969 | return err |
970 | } |
971 | envConfig := e.envConfig() |
972 | + // TODO(axw) consider how we can use placement to override bootstrap-host. |
973 | host := envConfig.bootstrapHost() |
974 | hc, series, err := manual.DetectSeriesAndHardwareCharacteristics(host) |
975 | if err != nil { |
976 | |
977 | === modified file 'provider/openstack/live_test.go' |
978 | --- provider/openstack/live_test.go 2014-02-18 02:53:44 +0000 |
979 | +++ provider/openstack/live_test.go 2014-04-24 03:34:13 +0000 |
980 | @@ -14,7 +14,6 @@ |
981 | "launchpad.net/goose/identity" |
982 | "launchpad.net/goose/nova" |
983 | |
984 | - "launchpad.net/juju-core/constraints" |
985 | "launchpad.net/juju-core/environs" |
986 | "launchpad.net/juju-core/environs/bootstrap" |
987 | "launchpad.net/juju-core/environs/config" |
988 | @@ -230,7 +229,7 @@ |
989 | c.Assert(env, gc.NotNil) |
990 | defer env.Destroy() |
991 | // Bootstrap and start an instance. |
992 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
993 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
994 | c.Assert(err, gc.IsNil) |
995 | inst, _ := jujutesting.AssertStartInstance(c, env, "100") |
996 | // Check whether the instance has the default security group assigned. |
997 | |
998 | === modified file 'provider/openstack/local_test.go' |
999 | --- provider/openstack/local_test.go 2014-04-22 10:04:16 +0000 |
1000 | +++ provider/openstack/local_test.go 2014-04-24 03:34:13 +0000 |
1001 | @@ -232,7 +232,7 @@ |
1002 | c.Assert(err, gc.IsNil) |
1003 | env, err := environs.New(cfg) |
1004 | c.Assert(err, gc.IsNil) |
1005 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1006 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
1007 | c.Assert(err, gc.ErrorMatches, "(.|\n)*cannot allocate a public IP as needed(.|\n)*") |
1008 | } |
1009 | |
1010 | @@ -261,7 +261,7 @@ |
1011 | c.Assert(err, gc.IsNil) |
1012 | env, err := environs.Prepare(cfg, coretesting.Context(c), s.ConfigStore) |
1013 | c.Assert(err, gc.IsNil) |
1014 | - err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1015 | + err = bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
1016 | c.Assert(err, gc.IsNil) |
1017 | inst, _ := testing.AssertStartInstance(c, env, "100") |
1018 | err = env.StopInstances([]instance.Instance{inst}) |
1019 | @@ -270,7 +270,7 @@ |
1020 | |
1021 | func (s *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { |
1022 | env := s.Prepare(c) |
1023 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1024 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
1025 | c.Assert(err, gc.IsNil) |
1026 | _, hc := testing.AssertStartInstanceWithConstraints(c, env, "100", constraints.MustParse("mem=1024")) |
1027 | c.Check(*hc.Arch, gc.Equals, "amd64") |
1028 | @@ -574,7 +574,7 @@ |
1029 | // It should be moved to environs.jujutests.Tests. |
1030 | func (s *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { |
1031 | env := s.Prepare(c) |
1032 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1033 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
1034 | c.Assert(err, gc.IsNil) |
1035 | |
1036 | // check that the state holds the id of the bootstrap machine. |
1037 | @@ -933,7 +933,7 @@ |
1038 | openstack.UseTestImageData(metadataStorage, s.cred) |
1039 | defer openstack.RemoveTestImageData(metadataStorage) |
1040 | |
1041 | - err = bootstrap.Bootstrap(coretesting.Context(c), s.env, constraints.Value{}) |
1042 | + err = bootstrap.Bootstrap(coretesting.Context(c), s.env, environs.BootstrapParams{}) |
1043 | c.Assert(err, gc.IsNil) |
1044 | } |
1045 | |
1046 | @@ -1076,7 +1076,7 @@ |
1047 | |
1048 | func (s *localServerSuite) TestAllInstancesIgnoresOtherMachines(c *gc.C) { |
1049 | env := s.Prepare(c) |
1050 | - err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1051 | + err := bootstrap.Bootstrap(coretesting.Context(c), env, environs.BootstrapParams{}) |
1052 | c.Assert(err, gc.IsNil) |
1053 | |
1054 | // Check that we see 1 instance in the environment |
1055 | |
1056 | === modified file 'provider/openstack/provider.go' |
1057 | --- provider/openstack/provider.go 2014-04-22 09:23:39 +0000 |
1058 | +++ provider/openstack/provider.go 2014-04-24 03:34:13 +0000 |
1059 | @@ -566,7 +566,7 @@ |
1060 | return stor |
1061 | } |
1062 | |
1063 | -func (e *environ) Bootstrap(ctx environs.BootstrapContext, cons constraints.Value) error { |
1064 | +func (e *environ) Bootstrap(ctx environs.BootstrapContext, args environs.BootstrapParams) error { |
1065 | // The client's authentication may have been reset when finding tools if the agent-version |
1066 | // attribute was updated so we need to re-authenticate. This will be a no-op if already authenticated. |
1067 | // An authenticated client is needed for the URL() call below. |
1068 | @@ -574,7 +574,7 @@ |
1069 | if err != nil { |
1070 | return err |
1071 | } |
1072 | - return common.Bootstrap(ctx, e, cons) |
1073 | + return common.Bootstrap(ctx, e, args) |
1074 | } |
1075 | |
1076 | func (e *environ) StateInfo() (*state.Info, *api.Info, error) { |
Reviewers: mp+216971_ code.launchpad. net,
Message:
Please take a look.
Description:
Support placement directives on bootstrap
juju bootstrap will accept a single, optional
positional argument that will be parsed as a
placement directive. We currently only allow
unscoped placement directives at bootstrap.
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1237709- bootstrap- placement/ +merge/ 216971
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/91740043/
Affected files (+156, -108 lines): bootstrap. go bootstrap_ test.go cmd_test. go deploy_ test.go juju-restore/ restore. go bootstrap/ bootstrap. go bootstrap/ bootstrap_ test.go interface. go jujutest/ livetests. go jujutest/ tests.go open_test. go test.go conn.go azure/environ. go common/ bootstrap. go common/ bootstrap_ test.go common/ mock_test. go dummy/environs. go ec2/local_ test.go joyent/ environ. go joyent/ local_test. go local/config_ test.go local/environ. go local/environ_ test.go maas/environ. go maas/environ_ whitebox_ test.go manual/ environ. go openstack/ live_test. go openstack/ local_test. go openstack/ provider. go
A [revision details]
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/juju/
M cmd/plugins/
M environs/
M environs/
M environs/
M environs/
M environs/
M environs/
M juju/apiconn_
M juju/conn_test.go
M juju/testing/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/ec2/ec2.go
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/
M provider/