Merge lp:~axwalk/juju-core/lp1279259-part1-prepare-context into lp:~go-bot/juju-core/trunk
- lp1279259-part1-prepare-context
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Andrew Wilkins | ||||
Approved revision: | no longer in the source branch. | ||||
Merged at revision: | 2335 | ||||
Proposed branch: | lp:~axwalk/juju-core/lp1279259-part1-prepare-context | ||||
Merge into: | lp:~go-bot/juju-core/trunk | ||||
Diff against target: |
1921 lines (+223/-273) 58 files modified
cmd/cmd.go (+17/-2) cmd/juju/bootstrap.go (+3/-21) cmd/juju/bootstrap_test.go (+1/-1) cmd/juju/destroyenvironment_test.go (+5/-5) cmd/juju/synctools.go (+1/-1) cmd/juju/synctools_test.go (+1/-1) cmd/plugins/juju-metadata/imagemetadata.go (+11/-4) cmd/plugins/juju-metadata/imagemetadata_test.go (+1/-1) cmd/plugins/juju-metadata/toolsmetadata_test.go (+1/-1) cmd/plugins/juju-metadata/validateimagemetadata.go (+1/-1) cmd/plugins/juju-metadata/validatetoolsmetadata.go (+1/-1) cmd/plugins/juju-restore/restore.go (+3/-26) environs/bootstrap/bootstrap_test.go (+9/-14) environs/emptystorage_test.go (+4/-2) environs/imagemetadata/urls_test.go (+1/-1) environs/interface.go (+4/-4) environs/jujutest/livetests.go (+5/-5) environs/jujutest/tests.go (+3/-7) environs/manual/bootstrap.go (+1/-1) environs/manual/bootstrap_test.go (+1/-2) environs/open.go (+6/-6) environs/open_test.go (+25/-15) environs/storage/storage_test.go (+1/-1) environs/sync/sync_test.go (+2/-2) environs/testing/bootstrap.go (+0/-23) environs/tools/storage_test.go (+2/-1) environs/tools/tools_test.go (+2/-1) environs/tools/urls_test.go (+1/-1) juju/apiconn_test.go (+3/-2) juju/conn_test.go (+18/-16) juju/testing/conn.go (+2/-2) provider/azure/environprovider.go (+1/-1) provider/common/bootstrap.go (+7/-7) provider/common/bootstrap_test.go (+19/-28) provider/dummy/config_test.go (+4/-2) provider/dummy/environs.go (+1/-1) provider/ec2/config_test.go (+4/-3) provider/ec2/ec2.go (+1/-1) provider/ec2/local_test.go (+6/-10) provider/joyent/config_test.go (+1/-1) provider/joyent/provider.go (+1/-1) provider/local/config_test.go (+2/-3) provider/local/environ.go (+2/-2) provider/local/environ_test.go (+2/-2) provider/local/environprovider.go (+1/-1) provider/local/environprovider_test.go (+2/-2) provider/maas/environ_whitebox_test.go (+5/-9) provider/maas/environprovider.go (+1/-1) provider/maas/environprovider_test.go (+4/-2) provider/manual/environ.go (+1/-1) provider/manual/environ_test.go (+1/-2) provider/manual/provider.go (+1/-1) provider/manual/provider_test.go (+4/-3) provider/openstack/config_test.go (+4/-3) provider/openstack/live_test.go (+1/-1) provider/openstack/local_test.go (+8/-12) provider/openstack/provider.go (+1/-1) state/apiserver/common/environwatcher_test.go (+2/-1) |
||||
To merge this branch: | bzr merge lp:~axwalk/juju-core/lp1279259-part1-prepare-context | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+206082@code.launchpad.net |
Commit message
Pass environs.
This is part one of fixing lp:1279259.
In this CL, we pass context to Prepare,
giving providers an opportunity to prompt
the user to initialise an environment.
Passing context was previously restricted to
Bootstrap and EnableBootstrap
insufficient, as there are many ways to prepare
an environment. It is currently possible to
successfully "Prepare" and environment, but
for the result to be unusable in the manual
provider (e.g. if the bootstrap-host address is
invalid). We should that a successfully Prepared
environment should be able to be Destroyed
(with force).
Description of the change
Pass environs.
This is part one of fixing lp:1279259.
In this CL, we pass context to Prepare,
giving providers an opportunity to prompt
the user to initialise an environment.
Passing context was previously restricted to
Bootstrap and EnableBootstrap
insufficient, as there are many ways to prepare
an environment. It is currently possible to
successfully "Prepare" and environment, but
for the result to be unusable in the manual
provider (e.g. if the bootstrap-host address is
invalid). We should that a successfully Prepared
environment should be able to be Destroyed
(with force).
The next CL will remove BootstrapStorager and fix
lp:1279259 by initialising the ubuntu user during
Prepare.
Andrew Wilkins (axwalk) wrote : | # |
Dimiter Naydenov (dimitern) wrote : | # |
The diff is missing, repropose please.
Andrew Wilkins (axwalk) wrote : | # |
Please take a look.
William Reade (fwereade) wrote : | # |
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~axwalk/juju-core/lp1279259-part1-prepare-context 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.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok 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.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.net/j...
Preview Diff
1 | === modified file 'cmd/cmd.go' | |||
2 | --- cmd/cmd.go 2013-12-19 09:15:40 +0000 | |||
3 | +++ cmd/cmd.go 2014-02-18 02:14:09 +0000 | |||
4 | @@ -112,12 +112,27 @@ | |||
5 | 112 | return filepath.Join(ctx.Dir, path) | 112 | return filepath.Join(ctx.Dir, path) |
6 | 113 | } | 113 | } |
7 | 114 | 114 | ||
9 | 115 | // InterruptNotify partially satisfies environs/bootstrap.BootstrapContext | 115 | // GetStdin satisfies environs.BootstrapContext |
10 | 116 | func (ctx *Context) GetStdin() io.Reader { | ||
11 | 117 | return ctx.Stdin | ||
12 | 118 | } | ||
13 | 119 | |||
14 | 120 | // GetStdout satisfies environs.BootstrapContext | ||
15 | 121 | func (ctx *Context) GetStdout() io.Writer { | ||
16 | 122 | return ctx.Stdout | ||
17 | 123 | } | ||
18 | 124 | |||
19 | 125 | // GetStderr satisfies environs.BootstrapContext | ||
20 | 126 | func (ctx *Context) GetStderr() io.Writer { | ||
21 | 127 | return ctx.Stderr | ||
22 | 128 | } | ||
23 | 129 | |||
24 | 130 | // InterruptNotify satisfies environs.BootstrapContext | ||
25 | 116 | func (ctx *Context) InterruptNotify(c chan<- os.Signal) { | 131 | func (ctx *Context) InterruptNotify(c chan<- os.Signal) { |
26 | 117 | signal.Notify(c, os.Interrupt) | 132 | signal.Notify(c, os.Interrupt) |
27 | 118 | } | 133 | } |
28 | 119 | 134 | ||
30 | 120 | // StopInterruptNotify partially satisfies environs/bootstrap.BootstrapContext | 135 | // StopInterruptNotify satisfies environs.BootstrapContext |
31 | 121 | func (ctx *Context) StopInterruptNotify(c chan<- os.Signal) { | 136 | func (ctx *Context) StopInterruptNotify(c chan<- os.Signal) { |
32 | 122 | signal.Stop(c) | 137 | signal.Stop(c) |
33 | 123 | } | 138 | } |
34 | 124 | 139 | ||
35 | === modified file 'cmd/juju/bootstrap.go' | |||
36 | --- cmd/juju/bootstrap.go 2014-02-11 01:35:20 +0000 | |||
37 | +++ cmd/juju/bootstrap.go 2014-02-18 02:14:09 +0000 | |||
38 | @@ -5,7 +5,6 @@ | |||
39 | 5 | 5 | ||
40 | 6 | import ( | 6 | import ( |
41 | 7 | "fmt" | 7 | "fmt" |
42 | 8 | "io" | ||
43 | 9 | "os" | 8 | "os" |
44 | 10 | "strings" | 9 | "strings" |
45 | 11 | 10 | ||
46 | @@ -97,22 +96,6 @@ | |||
47 | 97 | return cmd.CheckEmpty(args) | 96 | return cmd.CheckEmpty(args) |
48 | 98 | } | 97 | } |
49 | 99 | 98 | ||
50 | 100 | type bootstrapContext struct { | ||
51 | 101 | *cmd.Context | ||
52 | 102 | } | ||
53 | 103 | |||
54 | 104 | func (c bootstrapContext) Stdin() io.Reader { | ||
55 | 105 | return c.Context.Stdin | ||
56 | 106 | } | ||
57 | 107 | |||
58 | 108 | func (c bootstrapContext) Stdout() io.Writer { | ||
59 | 109 | return c.Context.Stdout | ||
60 | 110 | } | ||
61 | 111 | |||
62 | 112 | func (c bootstrapContext) Stderr() io.Writer { | ||
63 | 113 | return c.Context.Stderr | ||
64 | 114 | } | ||
65 | 115 | |||
66 | 116 | func destroyPreparedEnviron(env environs.Environ, store configstore.Storage, err *error, action string) { | 99 | func destroyPreparedEnviron(env environs.Environ, store configstore.Storage, err *error, action string) { |
67 | 117 | if *err == nil { | 100 | if *err == nil { |
68 | 118 | return | 101 | return |
69 | @@ -134,18 +117,17 @@ | |||
70 | 134 | if _, err := store.ReadInfo(c.EnvName); !errors.IsNotFoundError(err) { | 117 | if _, err := store.ReadInfo(c.EnvName); !errors.IsNotFoundError(err) { |
71 | 135 | existing = true | 118 | existing = true |
72 | 136 | } | 119 | } |
74 | 137 | environ, err := environs.PrepareFromName(c.EnvName, store) | 120 | environ, err := environs.PrepareFromName(c.EnvName, ctx, store) |
75 | 138 | if err != nil { | 121 | if err != nil { |
76 | 139 | return err | 122 | return err |
77 | 140 | } | 123 | } |
78 | 141 | if !existing { | 124 | if !existing { |
79 | 142 | defer destroyPreparedEnviron(environ, store, &resultErr, "Bootstrap") | 125 | defer destroyPreparedEnviron(environ, store, &resultErr, "Bootstrap") |
80 | 143 | } | 126 | } |
81 | 144 | bootstrapContext := bootstrapContext{ctx} | ||
82 | 145 | // If the environment has a special bootstrap Storage, use it wherever | 127 | // If the environment has a special bootstrap Storage, use it wherever |
83 | 146 | // we'd otherwise use environ.Storage. | 128 | // we'd otherwise use environ.Storage. |
84 | 147 | if bs, ok := environ.(environs.BootstrapStorager); ok { | 129 | if bs, ok := environ.(environs.BootstrapStorager); ok { |
86 | 148 | if err := bs.EnableBootstrapStorage(bootstrapContext); err != nil { | 130 | if err := bs.EnableBootstrapStorage(ctx); err != nil { |
87 | 149 | return errgo.Annotate(err, "failed to enable bootstrap storage") | 131 | return errgo.Annotate(err, "failed to enable bootstrap storage") |
88 | 150 | } | 132 | } |
89 | 151 | } | 133 | } |
90 | @@ -179,7 +161,7 @@ | |||
91 | 179 | return err | 161 | return err |
92 | 180 | } | 162 | } |
93 | 181 | } | 163 | } |
95 | 182 | return bootstrap.Bootstrap(bootstrapContext, environ, c.Constraints) | 164 | return bootstrap.Bootstrap(ctx, environ, c.Constraints) |
96 | 183 | } | 165 | } |
97 | 184 | 166 | ||
98 | 185 | func (c *BootstrapCommand) uploadTools(environ environs.Environ) error { | 167 | func (c *BootstrapCommand) uploadTools(environ environs.Environ) error { |
99 | 186 | 168 | ||
100 | === modified file 'cmd/juju/bootstrap_test.go' | |||
101 | --- cmd/juju/bootstrap_test.go 2014-02-03 06:58:26 +0000 | |||
102 | +++ cmd/juju/bootstrap_test.go 2014-02-18 02:14:09 +0000 | |||
103 | @@ -516,7 +516,7 @@ | |||
104 | 516 | dummy.Reset() | 516 | dummy.Reset() |
105 | 517 | store, err := configstore.Default() | 517 | store, err := configstore.Default() |
106 | 518 | c.Assert(err, gc.IsNil) | 518 | c.Assert(err, gc.IsNil) |
108 | 519 | env, err := environs.PrepareFromName("peckham", store) | 519 | env, err := environs.PrepareFromName("peckham", nullContext(), store) |
109 | 520 | c.Assert(err, gc.IsNil) | 520 | c.Assert(err, gc.IsNil) |
110 | 521 | envtesting.RemoveAllTools(c, env) | 521 | envtesting.RemoveAllTools(c, env) |
111 | 522 | return env, fake | 522 | return env, fake |
112 | 523 | 523 | ||
113 | === modified file 'cmd/juju/destroyenvironment_test.go' | |||
114 | --- cmd/juju/destroyenvironment_test.go 2014-02-03 09:09:49 +0000 | |||
115 | +++ cmd/juju/destroyenvironment_test.go 2014-02-18 02:14:09 +0000 | |||
116 | @@ -27,7 +27,7 @@ | |||
117 | 27 | 27 | ||
118 | 28 | func (s *destroyEnvSuite) TestDestroyEnvironmentCommand(c *gc.C) { | 28 | func (s *destroyEnvSuite) TestDestroyEnvironmentCommand(c *gc.C) { |
119 | 29 | // Prepare the environment so we can destroy it. | 29 | // Prepare the environment so we can destroy it. |
121 | 30 | _, err := environs.PrepareFromName("dummyenv", s.ConfigStore) | 30 | _, err := environs.PrepareFromName("dummyenv", nullContext(), s.ConfigStore) |
122 | 31 | c.Assert(err, gc.IsNil) | 31 | c.Assert(err, gc.IsNil) |
123 | 32 | 32 | ||
124 | 33 | // check environment is mandatory | 33 | // check environment is mandatory |
125 | @@ -46,7 +46,7 @@ | |||
126 | 46 | 46 | ||
127 | 47 | func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEFlag(c *gc.C) { | 47 | func (s *destroyEnvSuite) TestDestroyEnvironmentCommandEFlag(c *gc.C) { |
128 | 48 | // Prepare the environment so we can destroy it. | 48 | // Prepare the environment so we can destroy it. |
130 | 49 | _, err := environs.PrepareFromName("dummyenv", s.ConfigStore) | 49 | _, err := environs.PrepareFromName("dummyenv", nullContext(), s.ConfigStore) |
131 | 50 | c.Assert(err, gc.IsNil) | 50 | c.Assert(err, gc.IsNil) |
132 | 51 | 51 | ||
133 | 52 | // check that either environment or the flag is mandatory | 52 | // check that either environment or the flag is mandatory |
134 | @@ -89,7 +89,7 @@ | |||
135 | 89 | c.Assert(err, gc.IsNil) | 89 | c.Assert(err, gc.IsNil) |
136 | 90 | 90 | ||
137 | 91 | // Prepare the environment so we can destroy it. | 91 | // Prepare the environment so we can destroy it. |
139 | 92 | _, err = environs.PrepareFromName("dummyenv", s.ConfigStore) | 92 | _, err = environs.PrepareFromName("dummyenv", nullContext(), s.ConfigStore) |
140 | 93 | c.Assert(err, gc.IsNil) | 93 | c.Assert(err, gc.IsNil) |
141 | 94 | 94 | ||
142 | 95 | // destroy with broken environment | 95 | // destroy with broken environment |
143 | @@ -122,7 +122,7 @@ | |||
144 | 122 | ctx.Stdin = &stdin | 122 | ctx.Stdin = &stdin |
145 | 123 | 123 | ||
146 | 124 | // Prepare the environment so we can destroy it. | 124 | // Prepare the environment so we can destroy it. |
148 | 125 | env, err := environs.PrepareFromName("dummyenv", s.ConfigStore) | 125 | env, err := environs.PrepareFromName("dummyenv", nullContext(), s.ConfigStore) |
149 | 126 | c.Assert(err, gc.IsNil) | 126 | c.Assert(err, gc.IsNil) |
150 | 127 | 127 | ||
151 | 128 | assertEnvironNotDestroyed(c, env, s.ConfigStore) | 128 | assertEnvironNotDestroyed(c, env, s.ConfigStore) |
152 | @@ -156,7 +156,7 @@ | |||
153 | 156 | for _, answer := range []string{"y", "Y", "yes", "YES"} { | 156 | for _, answer := range []string{"y", "Y", "yes", "YES"} { |
154 | 157 | // Prepare the environment so we can destroy it. | 157 | // Prepare the environment so we can destroy it. |
155 | 158 | s.Reset(c) | 158 | s.Reset(c) |
157 | 159 | env, err := environs.PrepareFromName("dummyenv", s.ConfigStore) | 159 | env, err := environs.PrepareFromName("dummyenv", nullContext(), s.ConfigStore) |
158 | 160 | c.Assert(err, gc.IsNil) | 160 | c.Assert(err, gc.IsNil) |
159 | 161 | 161 | ||
160 | 162 | stdin.Reset() | 162 | stdin.Reset() |
161 | 163 | 163 | ||
162 | === modified file 'cmd/juju/synctools.go' | |||
163 | --- cmd/juju/synctools.go 2014-02-17 21:23:26 +0000 | |||
164 | +++ cmd/juju/synctools.go 2014-02-18 02:14:09 +0000 | |||
165 | @@ -92,7 +92,7 @@ | |||
166 | 92 | if _, err := store.ReadInfo(c.EnvName); !errors.IsNotFoundError(err) { | 92 | if _, err := store.ReadInfo(c.EnvName); !errors.IsNotFoundError(err) { |
167 | 93 | existing = true | 93 | existing = true |
168 | 94 | } | 94 | } |
170 | 95 | environ, err := environs.PrepareFromName(c.EnvName, store) | 95 | environ, err := environs.PrepareFromName(c.EnvName, ctx, store) |
171 | 96 | if err != nil { | 96 | if err != nil { |
172 | 97 | return err | 97 | return err |
173 | 98 | } | 98 | } |
174 | 99 | 99 | ||
175 | === modified file 'cmd/juju/synctools_test.go' | |||
176 | --- cmd/juju/synctools_test.go 2014-02-17 21:23:26 +0000 | |||
177 | +++ cmd/juju/synctools_test.go 2014-02-18 02:14:09 +0000 | |||
178 | @@ -125,7 +125,7 @@ | |||
179 | 125 | func (s *syncToolsSuite) TestSyncToolsCommand(c *gc.C) { | 125 | func (s *syncToolsSuite) TestSyncToolsCommand(c *gc.C) { |
180 | 126 | for i, test := range syncToolsCommandTests { | 126 | for i, test := range syncToolsCommandTests { |
181 | 127 | c.Logf("test %d: %s", i, test.description) | 127 | c.Logf("test %d: %s", i, test.description) |
183 | 128 | targetEnv, err := environs.PrepareFromName("test-target", s.configStore) | 128 | targetEnv, err := environs.PrepareFromName("test-target", nullContext(), s.configStore) |
184 | 129 | c.Assert(err, gc.IsNil) | 129 | c.Assert(err, gc.IsNil) |
185 | 130 | called := false | 130 | called := false |
186 | 131 | syncTools = func(sctx *sync.SyncContext) error { | 131 | syncTools = func(sctx *sync.SyncContext) error { |
187 | 132 | 132 | ||
188 | === modified file 'cmd/plugins/juju-metadata/imagemetadata.go' | |||
189 | --- cmd/plugins/juju-metadata/imagemetadata.go 2014-01-31 00:14:11 +0000 | |||
190 | +++ cmd/plugins/juju-metadata/imagemetadata.go 2014-02-18 02:14:09 +0000 | |||
191 | @@ -61,10 +61,16 @@ | |||
192 | 61 | } | 61 | } |
193 | 62 | 62 | ||
194 | 63 | func (c *ImageMetadataCommand) Init(args []string) error { | 63 | func (c *ImageMetadataCommand) Init(args []string) error { |
195 | 64 | return cmd.CheckEmpty(args) | ||
196 | 65 | } | ||
197 | 66 | |||
198 | 67 | // setParams sets parameters based on the environment configuration | ||
199 | 68 | // for those which have not been explicitly specified. | ||
200 | 69 | func (c *ImageMetadataCommand) setParams(context *cmd.Context) error { | ||
201 | 64 | c.privateStorage = "<private storage name>" | 70 | c.privateStorage = "<private storage name>" |
202 | 65 | var environ environs.Environ | 71 | var environ environs.Environ |
203 | 66 | if store, err := configstore.Default(); err == nil { | 72 | if store, err := configstore.Default(); err == nil { |
205 | 67 | if environ, err = environs.PrepareFromName(c.EnvName, store); err == nil { | 73 | if environ, err = environs.PrepareFromName(c.EnvName, context, store); err == nil { |
206 | 68 | logger.Infof("creating image metadata for environment %q", environ.Name()) | 74 | logger.Infof("creating image metadata for environment %q", environ.Name()) |
207 | 69 | // If the user has not specified region and endpoint, try and get it from the environment. | 75 | // If the user has not specified region and endpoint, try and get it from the environment. |
208 | 70 | if c.Region == "" || c.Endpoint == "" { | 76 | if c.Region == "" || c.Endpoint == "" { |
209 | @@ -120,8 +126,7 @@ | |||
210 | 120 | return err | 126 | return err |
211 | 121 | } | 127 | } |
212 | 122 | } | 128 | } |
215 | 123 | 129 | return nil | |
214 | 124 | return cmd.CheckEmpty(args) | ||
216 | 125 | } | 130 | } |
217 | 126 | 131 | ||
218 | 127 | var helpDoc = ` | 132 | var helpDoc = ` |
219 | @@ -143,8 +148,10 @@ | |||
220 | 143 | ` | 148 | ` |
221 | 144 | 149 | ||
222 | 145 | func (c *ImageMetadataCommand) Run(context *cmd.Context) error { | 150 | func (c *ImageMetadataCommand) Run(context *cmd.Context) error { |
223 | 151 | if err := c.setParams(context); err != nil { | ||
224 | 152 | return err | ||
225 | 153 | } | ||
226 | 146 | out := context.Stdout | 154 | out := context.Stdout |
227 | 147 | |||
228 | 148 | im := &imagemetadata.ImageMetadata{ | 155 | im := &imagemetadata.ImageMetadata{ |
229 | 149 | Id: c.ImageId, | 156 | Id: c.ImageId, |
230 | 150 | Arch: c.Arch, | 157 | Arch: c.Arch, |
231 | 151 | 158 | ||
232 | === modified file 'cmd/plugins/juju-metadata/imagemetadata_test.go' | |||
233 | --- cmd/plugins/juju-metadata/imagemetadata_test.go 2013-11-04 00:24:21 +0000 | |||
234 | +++ cmd/plugins/juju-metadata/imagemetadata_test.go 2014-02-18 02:14:09 +0000 | |||
235 | @@ -228,6 +228,6 @@ | |||
236 | 228 | c.Logf("test: %d", i) | 228 | c.Logf("test: %d", i) |
237 | 229 | ctx := testing.Context(c) | 229 | ctx := testing.Context(c) |
238 | 230 | code := cmd.Main(&ImageMetadataCommand{}, ctx, t.args) | 230 | code := cmd.Main(&ImageMetadataCommand{}, ctx, t.args) |
240 | 231 | c.Check(code, gc.Equals, 2) | 231 | c.Check(code, gc.Equals, 1) |
241 | 232 | } | 232 | } |
242 | 233 | } | 233 | } |
243 | 234 | 234 | ||
244 | === modified file 'cmd/plugins/juju-metadata/toolsmetadata_test.go' | |||
245 | --- cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-01-31 04:29:28 +0000 | |||
246 | +++ cmd/plugins/juju-metadata/toolsmetadata_test.go 2014-02-18 02:14:09 +0000 | |||
247 | @@ -43,7 +43,7 @@ | |||
248 | 43 | dummy.Reset() | 43 | dummy.Reset() |
249 | 44 | loggo.ResetLoggers() | 44 | loggo.ResetLoggers() |
250 | 45 | }) | 45 | }) |
252 | 46 | env, err := environs.PrepareFromName("erewhemos", configstore.NewMem()) | 46 | env, err := environs.PrepareFromName("erewhemos", coretesting.Context(c), configstore.NewMem()) |
253 | 47 | c.Assert(err, gc.IsNil) | 47 | c.Assert(err, gc.IsNil) |
254 | 48 | s.env = env | 48 | s.env = env |
255 | 49 | envtesting.RemoveAllTools(c, s.env) | 49 | envtesting.RemoveAllTools(c, s.env) |
256 | 50 | 50 | ||
257 | === modified file 'cmd/plugins/juju-metadata/validateimagemetadata.go' | |||
258 | --- cmd/plugins/juju-metadata/validateimagemetadata.go 2014-01-29 06:45:16 +0000 | |||
259 | +++ cmd/plugins/juju-metadata/validateimagemetadata.go 2014-02-18 02:14:09 +0000 | |||
260 | @@ -134,7 +134,7 @@ | |||
261 | 134 | if err != nil { | 134 | if err != nil { |
262 | 135 | return err | 135 | return err |
263 | 136 | } | 136 | } |
265 | 137 | environ, err := environs.PrepareFromName(c.EnvName, store) | 137 | environ, err := environs.PrepareFromName(c.EnvName, context, store) |
266 | 138 | if err != nil { | 138 | if err != nil { |
267 | 139 | return err | 139 | return err |
268 | 140 | } | 140 | } |
269 | 141 | 141 | ||
270 | === modified file 'cmd/plugins/juju-metadata/validatetoolsmetadata.go' | |||
271 | --- cmd/plugins/juju-metadata/validatetoolsmetadata.go 2013-10-10 11:40:54 +0000 | |||
272 | +++ cmd/plugins/juju-metadata/validatetoolsmetadata.go 2014-02-18 02:14:09 +0000 | |||
273 | @@ -141,7 +141,7 @@ | |||
274 | 141 | if err != nil { | 141 | if err != nil { |
275 | 142 | return err | 142 | return err |
276 | 143 | } | 143 | } |
278 | 144 | environ, err := environs.PrepareFromName(c.EnvName, store) | 144 | environ, err := environs.PrepareFromName(c.EnvName, context, store) |
279 | 145 | if err == nil { | 145 | if err == nil { |
280 | 146 | mdLookup, ok := environ.(simplestreams.MetadataValidator) | 146 | mdLookup, ok := environ.(simplestreams.MetadataValidator) |
281 | 147 | if !ok { | 147 | if !ok { |
282 | 148 | 148 | ||
283 | === modified file 'cmd/plugins/juju-restore/restore.go' | |||
284 | --- cmd/plugins/juju-restore/restore.go 2014-02-06 11:18:27 +0000 | |||
285 | +++ cmd/plugins/juju-restore/restore.go 2014-02-18 02:14:09 +0000 | |||
286 | @@ -12,7 +12,6 @@ | |||
287 | 12 | "io/ioutil" | 12 | "io/ioutil" |
288 | 13 | "os" | 13 | "os" |
289 | 14 | "os/exec" | 14 | "os/exec" |
290 | 15 | "os/signal" | ||
291 | 16 | "path" | 15 | "path" |
292 | 17 | "text/template" | 16 | "text/template" |
293 | 18 | 17 | ||
294 | @@ -154,7 +153,7 @@ | |||
295 | 154 | if err != nil { | 153 | if err != nil { |
296 | 155 | return err | 154 | return err |
297 | 156 | } | 155 | } |
299 | 157 | env, err := rebootstrap(cfg, c.Constraints) | 156 | env, err := rebootstrap(cfg, ctx, c.Constraints) |
300 | 158 | if err != nil { | 157 | if err != nil { |
301 | 159 | return fmt.Errorf("cannot re-bootstrap environment: %v", err) | 158 | return fmt.Errorf("cannot re-bootstrap environment: %v", err) |
302 | 160 | } | 159 | } |
303 | @@ -203,7 +202,7 @@ | |||
304 | 203 | fmt.Printf("%s\n", fmt.Sprintf(f, a...)) | 202 | fmt.Printf("%s\n", fmt.Sprintf(f, a...)) |
305 | 204 | } | 203 | } |
306 | 205 | 204 | ||
308 | 206 | func rebootstrap(cfg *config.Config, cons constraints.Value) (environs.Environ, error) { | 205 | func rebootstrap(cfg *config.Config, ctx *cmd.Context, cons constraints.Value) (environs.Environ, error) { |
309 | 207 | progress("re-bootstrapping environment") | 206 | progress("re-bootstrapping environment") |
310 | 208 | // Turn on safe mode so that the newly bootstrapped instance | 207 | // Turn on safe mode so that the newly bootstrapped instance |
311 | 209 | // will not destroy all the instances it does not know about. | 208 | // will not destroy all the instances it does not know about. |
312 | @@ -245,7 +244,7 @@ | |||
313 | 245 | // error-prone) or we could provide a --no-check flag to make | 244 | // error-prone) or we could provide a --no-check flag to make |
314 | 246 | // it go ahead anyway without the check. | 245 | // it go ahead anyway without the check. |
315 | 247 | 246 | ||
317 | 248 | if err := bootstrap.Bootstrap(bootstrapContext{}, env, cons); err != nil { | 247 | if err := bootstrap.Bootstrap(ctx, env, cons); err != nil { |
318 | 249 | return nil, fmt.Errorf("cannot bootstrap new instance: %v", err) | 248 | return nil, fmt.Errorf("cannot bootstrap new instance: %v", err) |
319 | 250 | } | 249 | } |
320 | 251 | return env, nil | 250 | return env, nil |
321 | @@ -462,25 +461,3 @@ | |||
322 | 462 | } | 461 | } |
323 | 463 | return buf.String() | 462 | return buf.String() |
324 | 464 | } | 463 | } |
325 | 465 | |||
326 | 466 | type bootstrapContext struct{} | ||
327 | 467 | |||
328 | 468 | func (bootstrapContext) Stdin() io.Reader { | ||
329 | 469 | return os.Stdin | ||
330 | 470 | } | ||
331 | 471 | |||
332 | 472 | func (bootstrapContext) Stdout() io.Writer { | ||
333 | 473 | return os.Stdout | ||
334 | 474 | } | ||
335 | 475 | |||
336 | 476 | func (bootstrapContext) Stderr() io.Writer { | ||
337 | 477 | return os.Stderr | ||
338 | 478 | } | ||
339 | 479 | |||
340 | 480 | func (bootstrapContext) InterruptNotify(c chan<- os.Signal) { | ||
341 | 481 | signal.Notify(c, os.Interrupt) | ||
342 | 482 | } | ||
343 | 483 | |||
344 | 484 | func (bootstrapContext) StopInterruptNotify(c chan<- os.Signal) { | ||
345 | 485 | signal.Stop(c) | ||
346 | 486 | } | ||
347 | 487 | 464 | ||
348 | === modified file 'environs/bootstrap/bootstrap_test.go' | |||
349 | --- environs/bootstrap/bootstrap_test.go 2014-01-20 23:32:00 +0000 | |||
350 | +++ environs/bootstrap/bootstrap_test.go 2014-02-18 02:14:09 +0000 | |||
351 | @@ -53,11 +53,6 @@ | |||
352 | 53 | s.LoggingSuite.TearDownTest(c) | 53 | s.LoggingSuite.TearDownTest(c) |
353 | 54 | } | 54 | } |
354 | 55 | 55 | ||
355 | 56 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
356 | 57 | ctx := coretesting.Context(c) | ||
357 | 58 | return envtesting.NewBootstrapContext(ctx) | ||
358 | 59 | } | ||
359 | 60 | |||
360 | 61 | func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) { | 56 | func (s *bootstrapSuite) TestBootstrapNeedsSettings(c *gc.C) { |
361 | 62 | env := newEnviron("bar", noKeysDefined) | 57 | env := newEnviron("bar", noKeysDefined) |
362 | 63 | s.setDummyStorage(c, env) | 58 | s.setDummyStorage(c, env) |
363 | @@ -69,20 +64,20 @@ | |||
364 | 69 | env.cfg = cfg | 64 | env.cfg = cfg |
365 | 70 | } | 65 | } |
366 | 71 | 66 | ||
368 | 72 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 67 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
369 | 73 | c.Assert(err, gc.ErrorMatches, "environment configuration has no admin-secret") | 68 | c.Assert(err, gc.ErrorMatches, "environment configuration has no admin-secret") |
370 | 74 | 69 | ||
371 | 75 | fixEnv("admin-secret", "whatever") | 70 | fixEnv("admin-secret", "whatever") |
373 | 76 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 71 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
374 | 77 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-cert") | 72 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-cert") |
375 | 78 | 73 | ||
376 | 79 | fixEnv("ca-cert", coretesting.CACert) | 74 | fixEnv("ca-cert", coretesting.CACert) |
378 | 80 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 75 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
379 | 81 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-private-key") | 76 | c.Assert(err, gc.ErrorMatches, "environment configuration has no ca-private-key") |
380 | 82 | 77 | ||
381 | 83 | fixEnv("ca-private-key", coretesting.CAKey) | 78 | fixEnv("ca-private-key", coretesting.CAKey) |
382 | 84 | uploadTools(c, env) | 79 | uploadTools(c, env) |
384 | 85 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 80 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
385 | 86 | c.Assert(err, gc.IsNil) | 81 | c.Assert(err, gc.IsNil) |
386 | 87 | } | 82 | } |
387 | 88 | 83 | ||
388 | @@ -95,7 +90,7 @@ | |||
389 | 95 | func (s *bootstrapSuite) TestBootstrapEmptyConstraints(c *gc.C) { | 90 | func (s *bootstrapSuite) TestBootstrapEmptyConstraints(c *gc.C) { |
390 | 96 | env := newEnviron("foo", useDefaultKeys) | 91 | env := newEnviron("foo", useDefaultKeys) |
391 | 97 | s.setDummyStorage(c, env) | 92 | s.setDummyStorage(c, env) |
393 | 98 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 93 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
394 | 99 | c.Assert(err, gc.IsNil) | 94 | c.Assert(err, gc.IsNil) |
395 | 100 | c.Assert(env.bootstrapCount, gc.Equals, 1) | 95 | c.Assert(env.bootstrapCount, gc.Equals, 1) |
396 | 101 | c.Assert(env.constraints, gc.DeepEquals, constraints.Value{}) | 96 | c.Assert(env.constraints, gc.DeepEquals, constraints.Value{}) |
397 | @@ -105,7 +100,7 @@ | |||
398 | 105 | env := newEnviron("foo", useDefaultKeys) | 100 | env := newEnviron("foo", useDefaultKeys) |
399 | 106 | s.setDummyStorage(c, env) | 101 | s.setDummyStorage(c, env) |
400 | 107 | cons := constraints.MustParse("cpu-cores=2 mem=4G") | 102 | cons := constraints.MustParse("cpu-cores=2 mem=4G") |
402 | 108 | err := bootstrap.Bootstrap(bootstrapContext(c), env, cons) | 103 | err := bootstrap.Bootstrap(coretesting.Context(c), env, cons) |
403 | 109 | c.Assert(err, gc.IsNil) | 104 | c.Assert(err, gc.IsNil) |
404 | 110 | c.Assert(env.bootstrapCount, gc.Equals, 1) | 105 | c.Assert(env.bootstrapCount, gc.Equals, 1) |
405 | 111 | c.Assert(env.constraints, gc.DeepEquals, cons) | 106 | c.Assert(env.constraints, gc.DeepEquals, cons) |
406 | @@ -157,7 +152,7 @@ | |||
407 | 157 | } | 152 | } |
408 | 158 | cfg, err := config.New(config.NoDefaults, attrs) | 153 | cfg, err := config.New(config.NoDefaults, attrs) |
409 | 159 | c.Assert(err, gc.IsNil) | 154 | c.Assert(err, gc.IsNil) |
411 | 160 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 155 | env, err := environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem()) |
412 | 161 | c.Assert(err, gc.IsNil) | 156 | c.Assert(err, gc.IsNil) |
413 | 162 | envtesting.RemoveAllTools(c, env) | 157 | envtesting.RemoveAllTools(c, env) |
414 | 163 | 158 | ||
415 | @@ -170,7 +165,7 @@ | |||
416 | 170 | if test.Arch != "" { | 165 | if test.Arch != "" { |
417 | 171 | cons = constraints.MustParse("arch=" + test.Arch) | 166 | cons = constraints.MustParse("arch=" + test.Arch) |
418 | 172 | } | 167 | } |
420 | 173 | err = bootstrap.Bootstrap(bootstrapContext(c), env, cons) | 168 | err = bootstrap.Bootstrap(coretesting.Context(c), env, cons) |
421 | 174 | if test.Err != nil { | 169 | if test.Err != nil { |
422 | 175 | c.Check(err, gc.ErrorMatches, ".*"+test.Err.Error()) | 170 | c.Check(err, gc.ErrorMatches, ".*"+test.Err.Error()) |
423 | 176 | continue | 171 | continue |
424 | @@ -193,7 +188,7 @@ | |||
425 | 193 | env := newEnviron("foo", useDefaultKeys) | 188 | env := newEnviron("foo", useDefaultKeys) |
426 | 194 | s.setDummyStorage(c, env) | 189 | s.setDummyStorage(c, env) |
427 | 195 | envtesting.RemoveFakeTools(c, env.Storage()) | 190 | envtesting.RemoveFakeTools(c, env.Storage()) |
429 | 196 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 191 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
430 | 197 | // bootstrap.Bootstrap leaves it to the provider to | 192 | // bootstrap.Bootstrap leaves it to the provider to |
431 | 198 | // locate bootstrap tools. | 193 | // locate bootstrap tools. |
432 | 199 | c.Assert(err, gc.IsNil) | 194 | c.Assert(err, gc.IsNil) |
433 | 200 | 195 | ||
434 | === modified file 'environs/emptystorage_test.go' | |||
435 | --- environs/emptystorage_test.go 2013-10-03 01:28:51 +0000 | |||
436 | +++ environs/emptystorage_test.go 2014-02-18 02:14:09 +0000 | |||
437 | @@ -63,7 +63,8 @@ | |||
438 | 63 | func (s *verifyStorageSuite) TestVerifyStorage(c *gc.C) { | 63 | func (s *verifyStorageSuite) TestVerifyStorage(c *gc.C) { |
439 | 64 | defer testing.MakeFakeHome(c, existingEnv, "existing").Restore() | 64 | defer testing.MakeFakeHome(c, existingEnv, "existing").Restore() |
440 | 65 | 65 | ||
442 | 66 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 66 | ctx := testing.Context(c) |
443 | 67 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
444 | 67 | c.Assert(err, gc.IsNil) | 68 | c.Assert(err, gc.IsNil) |
445 | 68 | stor := environ.Storage() | 69 | stor := environ.Storage() |
446 | 69 | err = environs.VerifyStorage(stor) | 70 | err = environs.VerifyStorage(stor) |
447 | @@ -80,7 +81,8 @@ | |||
448 | 80 | func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) { | 81 | func (s *verifyStorageSuite) TestVerifyStorageFails(c *gc.C) { |
449 | 81 | defer testing.MakeFakeHome(c, existingEnv, "existing").Restore() | 82 | defer testing.MakeFakeHome(c, existingEnv, "existing").Restore() |
450 | 82 | 83 | ||
452 | 83 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 84 | ctx := testing.Context(c) |
453 | 85 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
454 | 84 | c.Assert(err, gc.IsNil) | 86 | c.Assert(err, gc.IsNil) |
455 | 85 | stor := environ.Storage() | 87 | stor := environ.Storage() |
456 | 86 | someError := errors.Unauthorizedf("you shall not pass") | 88 | someError := errors.Unauthorizedf("you shall not pass") |
457 | 87 | 89 | ||
458 | === modified file 'environs/imagemetadata/urls_test.go' | |||
459 | --- environs/imagemetadata/urls_test.go 2014-01-30 07:37:38 +0000 | |||
460 | +++ environs/imagemetadata/urls_test.go 2014-02-18 02:14:09 +0000 | |||
461 | @@ -46,7 +46,7 @@ | |||
462 | 46 | } | 46 | } |
463 | 47 | cfg, err := config.New(config.NoDefaults, attrs) | 47 | cfg, err := config.New(config.NoDefaults, attrs) |
464 | 48 | c.Assert(err, gc.IsNil) | 48 | c.Assert(err, gc.IsNil) |
466 | 49 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 49 | env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem()) |
467 | 50 | c.Assert(err, gc.IsNil) | 50 | c.Assert(err, gc.IsNil) |
468 | 51 | // Put a file in images since the dummy storage provider requires a | 51 | // Put a file in images since the dummy storage provider requires a |
469 | 52 | // file to exist before the URL can be found. This is to ensure it behaves | 52 | // file to exist before the URL can be found. This is to ensure it behaves |
470 | 53 | 53 | ||
471 | === modified file 'environs/interface.go' | |||
472 | --- environs/interface.go 2013-12-20 02:38:56 +0000 | |||
473 | +++ environs/interface.go 2014-02-18 02:14:09 +0000 | |||
474 | @@ -21,7 +21,7 @@ | |||
475 | 21 | // configuration attributes in the returned environment should | 21 | // configuration attributes in the returned environment should |
476 | 22 | // be saved to be used later. If the environment is already | 22 | // be saved to be used later. If the environment is already |
477 | 23 | // prepared, this call is equivalent to Open. | 23 | // prepared, this call is equivalent to Open. |
479 | 24 | Prepare(cfg *config.Config) (Environ, error) | 24 | Prepare(ctx BootstrapContext, cfg *config.Config) (Environ, error) |
480 | 25 | 25 | ||
481 | 26 | // Open opens the environment and returns it. | 26 | // Open opens the environment and returns it. |
482 | 27 | // The configuration must have come from a previously | 27 | // The configuration must have come from a previously |
483 | @@ -201,9 +201,9 @@ | |||
484 | 201 | // information about and manipulating the context in which | 201 | // information about and manipulating the context in which |
485 | 202 | // it is being invoked. | 202 | // it is being invoked. |
486 | 203 | type BootstrapContext interface { | 203 | type BootstrapContext interface { |
490 | 204 | Stdin() io.Reader | 204 | GetStdin() io.Reader |
491 | 205 | Stdout() io.Writer | 205 | GetStdout() io.Writer |
492 | 206 | Stderr() io.Writer | 206 | GetStderr() io.Writer |
493 | 207 | 207 | ||
494 | 208 | // InterruptNotify starts watching for interrupt signals | 208 | // InterruptNotify starts watching for interrupt signals |
495 | 209 | // on behalf of the caller, sending them to the supplied | 209 | // on behalf of the caller, sending them to the supplied |
496 | 210 | 210 | ||
497 | === modified file 'environs/jujutest/livetests.go' | |||
498 | --- environs/jujutest/livetests.go 2014-01-07 07:35:12 +0000 | |||
499 | +++ environs/jujutest/livetests.go 2014-02-18 02:14:09 +0000 | |||
500 | @@ -118,7 +118,7 @@ | |||
501 | 118 | } | 118 | } |
502 | 119 | cfg, err := config.New(config.NoDefaults, t.TestConfig) | 119 | cfg, err := config.New(config.NoDefaults, t.TestConfig) |
503 | 120 | c.Assert(err, gc.IsNil) | 120 | c.Assert(err, gc.IsNil) |
505 | 121 | e, err := environs.Prepare(cfg, t.ConfigStore) | 121 | e, err := environs.Prepare(cfg, coretesting.Context(c), t.ConfigStore) |
506 | 122 | c.Assert(err, gc.IsNil, gc.Commentf("preparing environ %#v", t.TestConfig)) | 122 | c.Assert(err, gc.IsNil, gc.Commentf("preparing environ %#v", t.TestConfig)) |
507 | 123 | c.Assert(e, gc.NotNil) | 123 | c.Assert(e, gc.NotNil) |
508 | 124 | t.Env = e | 124 | t.Env = e |
509 | @@ -140,7 +140,7 @@ | |||
510 | 140 | envtesting.UploadFakeTools(c, t.Env.Storage()) | 140 | envtesting.UploadFakeTools(c, t.Env.Storage()) |
511 | 141 | err := common.EnsureNotBootstrapped(t.Env) | 141 | err := common.EnsureNotBootstrapped(t.Env) |
512 | 142 | c.Assert(err, gc.IsNil) | 142 | c.Assert(err, gc.IsNil) |
514 | 143 | err = bootstrap.Bootstrap(bootstrapContext(c), t.Env, cons) | 143 | err = bootstrap.Bootstrap(coretesting.Context(c), t.Env, cons) |
515 | 144 | c.Assert(err, gc.IsNil) | 144 | c.Assert(err, gc.IsNil) |
516 | 145 | t.bootstrapped = true | 145 | t.bootstrapped = true |
517 | 146 | } | 146 | } |
518 | @@ -895,7 +895,7 @@ | |||
519 | 895 | "state-server": false, | 895 | "state-server": false, |
520 | 896 | "name": "dummy storage", | 896 | "name": "dummy storage", |
521 | 897 | })) | 897 | })) |
523 | 898 | dummyenv, err := environs.Prepare(dummyCfg, configstore.NewMem()) | 898 | dummyenv, err := environs.Prepare(dummyCfg, coretesting.Context(c), configstore.NewMem()) |
524 | 899 | c.Assert(err, gc.IsNil) | 899 | c.Assert(err, gc.IsNil) |
525 | 900 | defer dummyenv.Destroy() | 900 | defer dummyenv.Destroy() |
526 | 901 | 901 | ||
527 | @@ -904,7 +904,7 @@ | |||
528 | 904 | attrs := t.TestConfig.Merge(coretesting.Attrs{"default-series": other.Series}) | 904 | attrs := t.TestConfig.Merge(coretesting.Attrs{"default-series": other.Series}) |
529 | 905 | cfg, err := config.New(config.NoDefaults, attrs) | 905 | cfg, err := config.New(config.NoDefaults, attrs) |
530 | 906 | c.Assert(err, gc.IsNil) | 906 | c.Assert(err, gc.IsNil) |
532 | 907 | env, err := environs.Prepare(cfg, t.ConfigStore) | 907 | env, err := environs.Prepare(cfg, coretesting.Context(c), t.ConfigStore) |
533 | 908 | c.Assert(err, gc.IsNil) | 908 | c.Assert(err, gc.IsNil) |
534 | 909 | defer environs.Destroy(env, t.ConfigStore) | 909 | defer environs.Destroy(env, t.ConfigStore) |
535 | 910 | 910 | ||
536 | @@ -924,7 +924,7 @@ | |||
537 | 924 | err = storageCopy(dummyStorage, currentName, envStorage, otherName) | 924 | err = storageCopy(dummyStorage, currentName, envStorage, otherName) |
538 | 925 | c.Assert(err, gc.IsNil) | 925 | c.Assert(err, gc.IsNil) |
539 | 926 | 926 | ||
541 | 927 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 927 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
542 | 928 | c.Assert(err, gc.IsNil) | 928 | c.Assert(err, gc.IsNil) |
543 | 929 | 929 | ||
544 | 930 | conn, err := juju.NewConn(env) | 930 | conn, err := juju.NewConn(env) |
545 | 931 | 931 | ||
546 | === modified file 'environs/jujutest/tests.go' | |||
547 | --- environs/jujutest/tests.go 2013-12-20 02:38:56 +0000 | |||
548 | +++ environs/jujutest/tests.go 2014-02-18 02:14:09 +0000 | |||
549 | @@ -61,7 +61,7 @@ | |||
550 | 61 | func (t *Tests) Prepare(c *gc.C) environs.Environ { | 61 | func (t *Tests) Prepare(c *gc.C) environs.Environ { |
551 | 62 | cfg, err := config.New(config.NoDefaults, t.TestConfig) | 62 | cfg, err := config.New(config.NoDefaults, t.TestConfig) |
552 | 63 | c.Assert(err, gc.IsNil) | 63 | c.Assert(err, gc.IsNil) |
554 | 64 | e, err := environs.Prepare(cfg, t.ConfigStore) | 64 | e, err := environs.Prepare(cfg, coretesting.Context(c), t.ConfigStore) |
555 | 65 | c.Assert(err, gc.IsNil, gc.Commentf("preparing environ %#v", t.TestConfig)) | 65 | c.Assert(err, gc.IsNil, gc.Commentf("preparing environ %#v", t.TestConfig)) |
556 | 66 | c.Assert(e, gc.NotNil) | 66 | c.Assert(e, gc.NotNil) |
557 | 67 | return e | 67 | return e |
558 | @@ -78,10 +78,6 @@ | |||
559 | 78 | t.LoggingSuite.TearDownTest(c) | 78 | t.LoggingSuite.TearDownTest(c) |
560 | 79 | } | 79 | } |
561 | 80 | 80 | ||
562 | 81 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
563 | 82 | return envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
564 | 83 | } | ||
565 | 84 | |||
566 | 85 | func (t *Tests) TestStartStop(c *gc.C) { | 81 | func (t *Tests) TestStartStop(c *gc.C) { |
567 | 86 | e := t.Prepare(c) | 82 | e := t.Prepare(c) |
568 | 87 | envtesting.UploadFakeTools(c, e.Storage()) | 83 | envtesting.UploadFakeTools(c, e.Storage()) |
569 | @@ -138,7 +134,7 @@ | |||
570 | 138 | envtesting.UploadFakeTools(c, e.Storage()) | 134 | envtesting.UploadFakeTools(c, e.Storage()) |
571 | 139 | err := common.EnsureNotBootstrapped(e) | 135 | err := common.EnsureNotBootstrapped(e) |
572 | 140 | c.Assert(err, gc.IsNil) | 136 | c.Assert(err, gc.IsNil) |
574 | 141 | err = bootstrap.Bootstrap(bootstrapContext(c), e, constraints.Value{}) | 137 | err = bootstrap.Bootstrap(coretesting.Context(c), e, constraints.Value{}) |
575 | 142 | c.Assert(err, gc.IsNil) | 138 | c.Assert(err, gc.IsNil) |
576 | 143 | 139 | ||
577 | 144 | info, apiInfo, err := e.StateInfo() | 140 | info, apiInfo, err := e.StateInfo() |
578 | @@ -166,7 +162,7 @@ | |||
579 | 166 | 162 | ||
580 | 167 | err = common.EnsureNotBootstrapped(e3) | 163 | err = common.EnsureNotBootstrapped(e3) |
581 | 168 | c.Assert(err, gc.IsNil) | 164 | c.Assert(err, gc.IsNil) |
583 | 169 | err = bootstrap.Bootstrap(bootstrapContext(c), e3, constraints.Value{}) | 165 | err = bootstrap.Bootstrap(coretesting.Context(c), e3, constraints.Value{}) |
584 | 170 | c.Assert(err, gc.IsNil) | 166 | c.Assert(err, gc.IsNil) |
585 | 171 | 167 | ||
586 | 172 | err = common.EnsureNotBootstrapped(e3) | 168 | err = common.EnsureNotBootstrapped(e3) |
587 | 173 | 169 | ||
588 | === modified file 'environs/manual/bootstrap.go' | |||
589 | --- environs/manual/bootstrap.go 2014-01-06 07:38:53 +0000 | |||
590 | +++ environs/manual/bootstrap.go 2014-02-18 02:14:09 +0000 | |||
591 | @@ -136,5 +136,5 @@ | |||
592 | 136 | for k, v := range agentEnv { | 136 | for k, v := range agentEnv { |
593 | 137 | mcfg.AgentEnvironment[k] = v | 137 | mcfg.AgentEnvironment[k] = v |
594 | 138 | } | 138 | } |
596 | 139 | return provisionMachineAgent(args.Host, mcfg, args.Context.Stderr()) | 139 | return provisionMachineAgent(args.Host, mcfg, args.Context.GetStderr()) |
597 | 140 | } | 140 | } |
598 | 141 | 141 | ||
599 | === modified file 'environs/manual/bootstrap_test.go' | |||
600 | --- environs/manual/bootstrap_test.go 2014-01-06 07:17:46 +0000 | |||
601 | +++ environs/manual/bootstrap_test.go 2014-02-18 02:14:09 +0000 | |||
602 | @@ -12,7 +12,6 @@ | |||
603 | 12 | "launchpad.net/juju-core/environs/bootstrap" | 12 | "launchpad.net/juju-core/environs/bootstrap" |
604 | 13 | "launchpad.net/juju-core/environs/filestorage" | 13 | "launchpad.net/juju-core/environs/filestorage" |
605 | 14 | "launchpad.net/juju-core/environs/storage" | 14 | "launchpad.net/juju-core/environs/storage" |
606 | 15 | envtesting "launchpad.net/juju-core/environs/testing" | ||
607 | 16 | "launchpad.net/juju-core/environs/tools" | 15 | "launchpad.net/juju-core/environs/tools" |
608 | 17 | "launchpad.net/juju-core/instance" | 16 | "launchpad.net/juju-core/instance" |
609 | 18 | "launchpad.net/juju-core/juju/testing" | 17 | "launchpad.net/juju-core/juju/testing" |
610 | @@ -81,7 +80,7 @@ | |||
611 | 81 | HardwareCharacteristics: &instance.HardwareCharacteristics{ | 80 | HardwareCharacteristics: &instance.HardwareCharacteristics{ |
612 | 82 | Arch: &arch, | 81 | Arch: &arch, |
613 | 83 | }, | 82 | }, |
615 | 84 | Context: envtesting.NewBootstrapContext(coretesting.Context(c)), | 83 | Context: coretesting.Context(c), |
616 | 85 | } | 84 | } |
617 | 86 | } | 85 | } |
618 | 87 | 86 | ||
619 | 88 | 87 | ||
620 | === modified file 'environs/open.go' | |||
621 | --- environs/open.go 2014-02-13 10:08:31 +0000 | |||
622 | +++ environs/open.go 2014-02-18 02:14:09 +0000 | |||
623 | @@ -118,12 +118,12 @@ | |||
624 | 118 | // and environment information is created using the | 118 | // and environment information is created using the |
625 | 119 | // given store. If the environment is already prepared, | 119 | // given store. If the environment is already prepared, |
626 | 120 | // it behaves like NewFromName. | 120 | // it behaves like NewFromName. |
628 | 121 | func PrepareFromName(name string, store configstore.Storage) (Environ, error) { | 121 | func PrepareFromName(name string, ctx BootstrapContext, store configstore.Storage) (Environ, error) { |
629 | 122 | cfg, _, err := ConfigForName(name, store) | 122 | cfg, _, err := ConfigForName(name, store) |
630 | 123 | if err != nil { | 123 | if err != nil { |
631 | 124 | return nil, err | 124 | return nil, err |
632 | 125 | } | 125 | } |
634 | 126 | return Prepare(cfg, store) | 126 | return Prepare(cfg, ctx, store) |
635 | 127 | } | 127 | } |
636 | 128 | 128 | ||
637 | 129 | // NewFromAttrs returns a new environment based on the provided configuration | 129 | // NewFromAttrs returns a new environment based on the provided configuration |
638 | @@ -148,7 +148,7 @@ | |||
639 | 148 | 148 | ||
640 | 149 | // Prepare prepares a new environment based on the provided configuration. | 149 | // Prepare prepares a new environment based on the provided configuration. |
641 | 150 | // If the environment is already prepared, it behaves like New. | 150 | // If the environment is already prepared, it behaves like New. |
643 | 151 | func Prepare(cfg *config.Config, store configstore.Storage) (Environ, error) { | 151 | func Prepare(cfg *config.Config, ctx BootstrapContext, store configstore.Storage) (Environ, error) { |
644 | 152 | p, err := Provider(cfg.Type()) | 152 | p, err := Provider(cfg.Type()) |
645 | 153 | if err != nil { | 153 | if err != nil { |
646 | 154 | return nil, err | 154 | return nil, err |
647 | @@ -175,7 +175,7 @@ | |||
648 | 175 | if err != nil { | 175 | if err != nil { |
649 | 176 | return nil, fmt.Errorf("cannot create new info for environment %q: %v", cfg.Name(), err) | 176 | return nil, fmt.Errorf("cannot create new info for environment %q: %v", cfg.Name(), err) |
650 | 177 | } | 177 | } |
652 | 178 | env, err := prepare(cfg, info, p) | 178 | env, err := prepare(ctx, cfg, info, p) |
653 | 179 | if err != nil { | 179 | if err != nil { |
654 | 180 | if err := info.Destroy(); err != nil { | 180 | if err := info.Destroy(); err != nil { |
655 | 181 | logger.Warningf("cannot destroy newly created environment info: %v", err) | 181 | logger.Warningf("cannot destroy newly created environment info: %v", err) |
656 | @@ -189,7 +189,7 @@ | |||
657 | 189 | return env, nil | 189 | return env, nil |
658 | 190 | } | 190 | } |
659 | 191 | 191 | ||
661 | 192 | func prepare(cfg *config.Config, info configstore.EnvironInfo, p EnvironProvider) (Environ, error) { | 192 | func prepare(ctx BootstrapContext, cfg *config.Config, info configstore.EnvironInfo, p EnvironProvider) (Environ, error) { |
662 | 193 | cfg, err := ensureAdminSecret(cfg) | 193 | cfg, err := ensureAdminSecret(cfg) |
663 | 194 | if err != nil { | 194 | if err != nil { |
664 | 195 | return nil, fmt.Errorf("cannot generate admin-secret: %v", err) | 195 | return nil, fmt.Errorf("cannot generate admin-secret: %v", err) |
665 | @@ -198,7 +198,7 @@ | |||
666 | 198 | if err != nil { | 198 | if err != nil { |
667 | 199 | return nil, fmt.Errorf("cannot ensure CA certificate: %v", err) | 199 | return nil, fmt.Errorf("cannot ensure CA certificate: %v", err) |
668 | 200 | } | 200 | } |
670 | 201 | return p.Prepare(cfg) | 201 | return p.Prepare(ctx, cfg) |
671 | 202 | } | 202 | } |
672 | 203 | 203 | ||
673 | 204 | // ensureAdminSecret returns a config with a non-empty admin-secret. | 204 | // ensureAdminSecret returns a config with a non-empty admin-secret. |
674 | 205 | 205 | ||
675 | === modified file 'environs/open_test.go' | |||
676 | --- environs/open_test.go 2014-02-11 02:50:17 +0000 | |||
677 | +++ environs/open_test.go 2014-02-18 02:14:09 +0000 | |||
678 | @@ -37,10 +37,10 @@ | |||
679 | 37 | // matches *Settings.Map() | 37 | // matches *Settings.Map() |
680 | 38 | cfg, err := config.New(config.NoDefaults, dummySampleConfig()) | 38 | cfg, err := config.New(config.NoDefaults, dummySampleConfig()) |
681 | 39 | c.Assert(err, gc.IsNil) | 39 | c.Assert(err, gc.IsNil) |
683 | 40 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 40 | ctx := testing.Context(c) |
684 | 41 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
685 | 41 | c.Assert(err, gc.IsNil) | 42 | c.Assert(err, gc.IsNil) |
686 | 42 | envtesting.UploadFakeTools(c, env.Storage()) | 43 | envtesting.UploadFakeTools(c, env.Storage()) |
687 | 43 | ctx := envtesting.NewBootstrapContext(testing.Context(c)) | ||
688 | 44 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) | 44 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
689 | 45 | c.Assert(err, gc.IsNil) | 45 | c.Assert(err, gc.IsNil) |
690 | 46 | } | 46 | } |
691 | @@ -57,7 +57,8 @@ | |||
692 | 57 | func (*OpenSuite) TestNewFromName(c *gc.C) { | 57 | func (*OpenSuite) TestNewFromName(c *gc.C) { |
693 | 58 | defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore() | 58 | defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore() |
694 | 59 | store := configstore.NewMem() | 59 | store := configstore.NewMem() |
696 | 60 | e, err := environs.PrepareFromName("erewhemos", store) | 60 | ctx := testing.Context(c) |
697 | 61 | e, err := environs.PrepareFromName("erewhemos", ctx, store) | ||
698 | 61 | c.Assert(err, gc.IsNil) | 62 | c.Assert(err, gc.IsNil) |
699 | 62 | 63 | ||
700 | 63 | e, err = environs.NewFromName("erewhemos", store) | 64 | e, err = environs.NewFromName("erewhemos", store) |
701 | @@ -96,7 +97,8 @@ | |||
702 | 96 | 97 | ||
703 | 97 | func (*OpenSuite) TestPrepareFromName(c *gc.C) { | 98 | func (*OpenSuite) TestPrepareFromName(c *gc.C) { |
704 | 98 | defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore() | 99 | defer testing.MakeFakeHome(c, testing.MultipleEnvConfigNoDefault, testing.SampleCertName).Restore() |
706 | 99 | e, err := environs.PrepareFromName("erewhemos", configstore.NewMem()) | 100 | ctx := testing.Context(c) |
707 | 101 | e, err := environs.PrepareFromName("erewhemos", ctx, configstore.NewMem()) | ||
708 | 100 | c.Assert(err, gc.IsNil) | 102 | c.Assert(err, gc.IsNil) |
709 | 101 | c.Assert(e.Name(), gc.Equals, "erewhemos") | 103 | c.Assert(e.Name(), gc.Equals, "erewhemos") |
710 | 102 | // Check we can access storage ok, which implies the environment has been prepared. | 104 | // Check we can access storage ok, which implies the environment has been prepared. |
711 | @@ -175,7 +177,8 @@ | |||
712 | 175 | cfg, err := config.New(config.NoDefaults, baselineAttrs) | 177 | cfg, err := config.New(config.NoDefaults, baselineAttrs) |
713 | 176 | c.Assert(err, gc.IsNil) | 178 | c.Assert(err, gc.IsNil) |
714 | 177 | store := configstore.NewMem() | 179 | store := configstore.NewMem() |
716 | 178 | env, err := environs.Prepare(cfg, store) | 180 | ctx := testing.Context(c) |
717 | 181 | env, err := environs.Prepare(cfg, ctx, store) | ||
718 | 179 | c.Assert(err, gc.IsNil) | 182 | c.Assert(err, gc.IsNil) |
719 | 180 | // Check we can access storage ok, which implies the environment has been prepared. | 183 | // Check we can access storage ok, which implies the environment has been prepared. |
720 | 181 | c.Assert(env.Storage(), gc.NotNil) | 184 | c.Assert(env.Storage(), gc.NotNil) |
721 | @@ -204,7 +207,7 @@ | |||
722 | 204 | c.Assert(caCert.Subject.CommonName, gc.Equals, `juju-generated CA for environment "`+testing.SampleEnvName+`"`) | 207 | c.Assert(caCert.Subject.CommonName, gc.Equals, `juju-generated CA for environment "`+testing.SampleEnvName+`"`) |
723 | 205 | 208 | ||
724 | 206 | // Check we can call Prepare again. | 209 | // Check we can call Prepare again. |
726 | 207 | env, err = environs.Prepare(cfg, store) | 210 | env, err = environs.Prepare(cfg, ctx, store) |
727 | 208 | c.Assert(err, gc.IsNil) | 211 | c.Assert(err, gc.IsNil) |
728 | 209 | c.Assert(env.Name(), gc.Equals, "erewhemos") | 212 | c.Assert(env.Name(), gc.Equals, "erewhemos") |
729 | 210 | c.Assert(env.Storage(), gc.NotNil) | 213 | c.Assert(env.Storage(), gc.NotNil) |
730 | @@ -221,13 +224,14 @@ | |||
731 | 221 | cfg, err := config.New(config.NoDefaults, baselineAttrs) | 224 | cfg, err := config.New(config.NoDefaults, baselineAttrs) |
732 | 222 | c.Assert(err, gc.IsNil) | 225 | c.Assert(err, gc.IsNil) |
733 | 223 | 226 | ||
735 | 224 | env0, err := environs.Prepare(cfg, configstore.NewMem()) | 227 | ctx := testing.Context(c) |
736 | 228 | env0, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
737 | 225 | c.Assert(err, gc.IsNil) | 229 | c.Assert(err, gc.IsNil) |
738 | 226 | adminSecret0 := env0.Config().AdminSecret() | 230 | adminSecret0 := env0.Config().AdminSecret() |
739 | 227 | c.Assert(adminSecret0, gc.HasLen, 32) | 231 | c.Assert(adminSecret0, gc.HasLen, 32) |
740 | 228 | c.Assert(adminSecret0, gc.Matches, "^[0-9a-f]*$") | 232 | c.Assert(adminSecret0, gc.Matches, "^[0-9a-f]*$") |
741 | 229 | 233 | ||
743 | 230 | env1, err := environs.Prepare(cfg, configstore.NewMem()) | 234 | env1, err := environs.Prepare(cfg, ctx, configstore.NewMem()) |
744 | 231 | c.Assert(err, gc.IsNil) | 235 | c.Assert(err, gc.IsNil) |
745 | 232 | adminSecret1 := env1.Config().AdminSecret() | 236 | adminSecret1 := env1.Config().AdminSecret() |
746 | 233 | c.Assert(adminSecret1, gc.HasLen, 32) | 237 | c.Assert(adminSecret1, gc.HasLen, 32) |
747 | @@ -246,7 +250,7 @@ | |||
748 | 246 | )) | 250 | )) |
749 | 247 | c.Assert(err, gc.IsNil) | 251 | c.Assert(err, gc.IsNil) |
750 | 248 | store := configstore.NewMem() | 252 | store := configstore.NewMem() |
752 | 249 | env, err := environs.Prepare(cfg, store) | 253 | env, err := environs.Prepare(cfg, testing.Context(c), store) |
753 | 250 | c.Assert(err, gc.ErrorMatches, "cannot ensure CA certificate: environment configuration with a certificate but no CA private key") | 254 | c.Assert(err, gc.ErrorMatches, "cannot ensure CA certificate: environment configuration with a certificate but no CA private key") |
754 | 251 | c.Assert(env, gc.IsNil) | 255 | c.Assert(env, gc.IsNil) |
755 | 252 | // Ensure that the config storage info is cleaned up. | 256 | // Ensure that the config storage info is cleaned up. |
756 | @@ -264,7 +268,8 @@ | |||
757 | 264 | }, | 268 | }, |
758 | 265 | )) | 269 | )) |
759 | 266 | c.Assert(err, gc.IsNil) | 270 | c.Assert(err, gc.IsNil) |
761 | 267 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 271 | ctx := testing.Context(c) |
762 | 272 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
763 | 268 | c.Assert(err, gc.IsNil) | 273 | c.Assert(err, gc.IsNil) |
764 | 269 | cfgCertPEM, cfgCertOK := env.Config().CACert() | 274 | cfgCertPEM, cfgCertOK := env.Config().CACert() |
765 | 270 | cfgKeyPEM, cfgKeyOK := env.Config().CAPrivateKey() | 275 | cfgKeyPEM, cfgKeyOK := env.Config().CAPrivateKey() |
766 | @@ -286,7 +291,8 @@ | |||
767 | 286 | store := configstore.NewMem() | 291 | store := configstore.NewMem() |
768 | 287 | // Prepare the environment and sanity-check that | 292 | // Prepare the environment and sanity-check that |
769 | 288 | // the config storage info has been made. | 293 | // the config storage info has been made. |
771 | 289 | e, err := environs.Prepare(cfg, store) | 294 | ctx := testing.Context(c) |
772 | 295 | e, err := environs.Prepare(cfg, ctx, store) | ||
773 | 290 | c.Assert(err, gc.IsNil) | 296 | c.Assert(err, gc.IsNil) |
774 | 291 | _, err = store.ReadInfo(e.Name()) | 297 | _, err = store.ReadInfo(e.Name()) |
775 | 292 | c.Assert(err, gc.IsNil) | 298 | c.Assert(err, gc.IsNil) |
776 | @@ -332,7 +338,8 @@ | |||
777 | 332 | func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) { | 338 | func (s *checkEnvironmentSuite) TestCheckEnvironment(c *gc.C) { |
778 | 333 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() | 339 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() |
779 | 334 | 340 | ||
781 | 335 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 341 | ctx := testing.Context(c) |
782 | 342 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
783 | 336 | c.Assert(err, gc.IsNil) | 343 | c.Assert(err, gc.IsNil) |
784 | 337 | 344 | ||
785 | 338 | // VerifyStorage is sufficient for our tests and much simpler | 345 | // VerifyStorage is sufficient for our tests and much simpler |
786 | @@ -347,7 +354,8 @@ | |||
787 | 347 | func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *gc.C) { | 354 | func (s *checkEnvironmentSuite) TestCheckEnvironmentFileNotFound(c *gc.C) { |
788 | 348 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() | 355 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() |
789 | 349 | 356 | ||
791 | 350 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 357 | ctx := testing.Context(c) |
792 | 358 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
793 | 351 | c.Assert(err, gc.IsNil) | 359 | c.Assert(err, gc.IsNil) |
794 | 352 | 360 | ||
795 | 353 | // VerifyStorage is sufficient for our tests and much simpler | 361 | // VerifyStorage is sufficient for our tests and much simpler |
796 | @@ -368,7 +376,8 @@ | |||
797 | 368 | func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *gc.C) { | 376 | func (s *checkEnvironmentSuite) TestCheckEnvironmentGetFails(c *gc.C) { |
798 | 369 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() | 377 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() |
799 | 370 | 378 | ||
801 | 371 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 379 | ctx := testing.Context(c) |
802 | 380 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
803 | 372 | c.Assert(err, gc.IsNil) | 381 | c.Assert(err, gc.IsNil) |
804 | 373 | 382 | ||
805 | 374 | // VerifyStorage is sufficient for our tests and much simpler | 383 | // VerifyStorage is sufficient for our tests and much simpler |
806 | @@ -388,7 +397,8 @@ | |||
807 | 388 | func (s *checkEnvironmentSuite) TestCheckEnvironmentBadContent(c *gc.C) { | 397 | func (s *checkEnvironmentSuite) TestCheckEnvironmentBadContent(c *gc.C) { |
808 | 389 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() | 398 | defer testing.MakeFakeHome(c, checkEnv, "existing").Restore() |
809 | 390 | 399 | ||
811 | 391 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 400 | ctx := testing.Context(c) |
812 | 401 | environ, err := environs.PrepareFromName("test", ctx, configstore.NewMem()) | ||
813 | 392 | c.Assert(err, gc.IsNil) | 402 | c.Assert(err, gc.IsNil) |
814 | 393 | 403 | ||
815 | 394 | // We mock a bad (eg. from a Python-juju environment) bootstrap-verify. | 404 | // We mock a bad (eg. from a Python-juju environment) bootstrap-verify. |
816 | 395 | 405 | ||
817 | === modified file 'environs/storage/storage_test.go' | |||
818 | --- environs/storage/storage_test.go 2014-01-31 00:14:11 +0000 | |||
819 | +++ environs/storage/storage_test.go 2014-02-18 02:14:09 +0000 | |||
820 | @@ -42,7 +42,7 @@ | |||
821 | 42 | 42 | ||
822 | 43 | func (s *datasourceSuite) SetUpTest(c *gc.C) { | 43 | func (s *datasourceSuite) SetUpTest(c *gc.C) { |
823 | 44 | s.home = testing.MakeFakeHome(c, existingEnv, "existing") | 44 | s.home = testing.MakeFakeHome(c, existingEnv, "existing") |
825 | 45 | environ, err := environs.PrepareFromName("test", configstore.NewMem()) | 45 | environ, err := environs.PrepareFromName("test", testing.Context(c), configstore.NewMem()) |
826 | 46 | c.Assert(err, gc.IsNil) | 46 | c.Assert(err, gc.IsNil) |
827 | 47 | s.stor = environ.Storage() | 47 | s.stor = environ.Storage() |
828 | 48 | s.baseURL, err = s.stor.URL("") | 48 | s.baseURL, err = s.stor.URL("") |
829 | 49 | 49 | ||
830 | === modified file 'environs/sync/sync_test.go' | |||
831 | --- environs/sync/sync_test.go 2014-01-30 06:21:03 +0000 | |||
832 | +++ environs/sync/sync_test.go 2014-02-18 02:14:09 +0000 | |||
833 | @@ -68,7 +68,7 @@ | |||
834 | 68 | `) | 68 | `) |
835 | 69 | s.AddCleanup(func(*gc.C) { fakeHome.Restore() }) | 69 | s.AddCleanup(func(*gc.C) { fakeHome.Restore() }) |
836 | 70 | var err error | 70 | var err error |
838 | 71 | s.targetEnv, err = environs.PrepareFromName("test-target", configstore.NewMem()) | 71 | s.targetEnv, err = environs.PrepareFromName("test-target", coretesting.Context(c), configstore.NewMem()) |
839 | 72 | c.Assert(err, gc.IsNil) | 72 | c.Assert(err, gc.IsNil) |
840 | 73 | envtesting.RemoveAllTools(c, s.targetEnv) | 73 | envtesting.RemoveAllTools(c, s.targetEnv) |
841 | 74 | 74 | ||
842 | @@ -264,7 +264,7 @@ | |||
843 | 264 | // We only want to use simplestreams to find any synced tools. | 264 | // We only want to use simplestreams to find any synced tools. |
844 | 265 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 265 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
845 | 266 | c.Assert(err, gc.IsNil) | 266 | c.Assert(err, gc.IsNil) |
847 | 267 | s.env, err = environs.Prepare(cfg, configstore.NewMem()) | 267 | s.env, err = environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem()) |
848 | 268 | c.Assert(err, gc.IsNil) | 268 | c.Assert(err, gc.IsNil) |
849 | 269 | } | 269 | } |
850 | 270 | 270 | ||
851 | 271 | 271 | ||
852 | === modified file 'environs/testing/bootstrap.go' | |||
853 | --- environs/testing/bootstrap.go 2014-01-28 04:58:43 +0000 | |||
854 | +++ environs/testing/bootstrap.go 2014-02-18 02:14:09 +0000 | |||
855 | @@ -4,11 +4,8 @@ | |||
856 | 4 | package testing | 4 | package testing |
857 | 5 | 5 | ||
858 | 6 | import ( | 6 | import ( |
859 | 7 | "io" | ||
860 | 8 | |||
861 | 9 | "github.com/loggo/loggo" | 7 | "github.com/loggo/loggo" |
862 | 10 | 8 | ||
863 | 11 | "launchpad.net/juju-core/cmd" | ||
864 | 12 | "launchpad.net/juju-core/environs" | 9 | "launchpad.net/juju-core/environs" |
865 | 13 | "launchpad.net/juju-core/environs/cloudinit" | 10 | "launchpad.net/juju-core/environs/cloudinit" |
866 | 14 | "launchpad.net/juju-core/instance" | 11 | "launchpad.net/juju-core/instance" |
867 | @@ -29,23 +26,3 @@ | |||
868 | 29 | } | 26 | } |
869 | 30 | return testbase.PatchValue(&common.FinishBootstrap, f) | 27 | return testbase.PatchValue(&common.FinishBootstrap, f) |
870 | 31 | } | 28 | } |
871 | 32 | |||
872 | 33 | type bootstrapContext struct { | ||
873 | 34 | *cmd.Context | ||
874 | 35 | } | ||
875 | 36 | |||
876 | 37 | func (c bootstrapContext) Stdin() io.Reader { | ||
877 | 38 | return c.Context.Stdin | ||
878 | 39 | } | ||
879 | 40 | |||
880 | 41 | func (c bootstrapContext) Stdout() io.Writer { | ||
881 | 42 | return c.Context.Stdout | ||
882 | 43 | } | ||
883 | 44 | |||
884 | 45 | func (c bootstrapContext) Stderr() io.Writer { | ||
885 | 46 | return c.Context.Stderr | ||
886 | 47 | } | ||
887 | 48 | |||
888 | 49 | func NewBootstrapContext(ctx *cmd.Context) environs.BootstrapContext { | ||
889 | 50 | return bootstrapContext{ctx} | ||
890 | 51 | } | ||
891 | 52 | 29 | ||
892 | === modified file 'environs/tools/storage_test.go' | |||
893 | --- environs/tools/storage_test.go 2013-09-27 02:31:45 +0000 | |||
894 | +++ environs/tools/storage_test.go 2014-02-18 02:14:09 +0000 | |||
895 | @@ -12,6 +12,7 @@ | |||
896 | 12 | envtesting "launchpad.net/juju-core/environs/testing" | 12 | envtesting "launchpad.net/juju-core/environs/testing" |
897 | 13 | envtools "launchpad.net/juju-core/environs/tools" | 13 | envtools "launchpad.net/juju-core/environs/tools" |
898 | 14 | "launchpad.net/juju-core/provider/dummy" | 14 | "launchpad.net/juju-core/provider/dummy" |
899 | 15 | "launchpad.net/juju-core/testing" | ||
900 | 15 | "launchpad.net/juju-core/testing/testbase" | 16 | "launchpad.net/juju-core/testing/testbase" |
901 | 16 | coretools "launchpad.net/juju-core/tools" | 17 | coretools "launchpad.net/juju-core/tools" |
902 | 17 | "launchpad.net/juju-core/version" | 18 | "launchpad.net/juju-core/version" |
903 | @@ -29,7 +30,7 @@ | |||
904 | 29 | s.LoggingSuite.SetUpTest(c) | 30 | s.LoggingSuite.SetUpTest(c) |
905 | 30 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 31 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
906 | 31 | c.Assert(err, gc.IsNil) | 32 | c.Assert(err, gc.IsNil) |
908 | 32 | s.env, err = environs.Prepare(cfg, configstore.NewMem()) | 33 | s.env, err = environs.Prepare(cfg, testing.Context(c), configstore.NewMem()) |
909 | 33 | c.Assert(err, gc.IsNil) | 34 | c.Assert(err, gc.IsNil) |
910 | 34 | s.dataDir = c.MkDir() | 35 | s.dataDir = c.MkDir() |
911 | 35 | } | 36 | } |
912 | 36 | 37 | ||
913 | === modified file 'environs/tools/tools_test.go' | |||
914 | --- environs/tools/tools_test.go 2014-01-30 07:37:38 +0000 | |||
915 | +++ environs/tools/tools_test.go 2014-02-18 02:14:09 +0000 | |||
916 | @@ -25,6 +25,7 @@ | |||
917 | 25 | envtools "launchpad.net/juju-core/environs/tools" | 25 | envtools "launchpad.net/juju-core/environs/tools" |
918 | 26 | "launchpad.net/juju-core/errors" | 26 | "launchpad.net/juju-core/errors" |
919 | 27 | "launchpad.net/juju-core/provider/dummy" | 27 | "launchpad.net/juju-core/provider/dummy" |
920 | 28 | "launchpad.net/juju-core/testing" | ||
921 | 28 | jc "launchpad.net/juju-core/testing/checkers" | 29 | jc "launchpad.net/juju-core/testing/checkers" |
922 | 29 | "launchpad.net/juju-core/testing/testbase" | 30 | "launchpad.net/juju-core/testing/testbase" |
923 | 30 | coretools "launchpad.net/juju-core/tools" | 31 | coretools "launchpad.net/juju-core/tools" |
924 | @@ -171,7 +172,7 @@ | |||
925 | 171 | dummy.Reset() | 172 | dummy.Reset() |
926 | 172 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(attrs)) | 173 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig().Merge(attrs)) |
927 | 173 | c.Assert(err, gc.IsNil) | 174 | c.Assert(err, gc.IsNil) |
929 | 174 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 175 | env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem()) |
930 | 175 | c.Assert(err, gc.IsNil) | 176 | c.Assert(err, gc.IsNil) |
931 | 176 | s.env = env | 177 | s.env = env |
932 | 177 | s.removeTools(c) | 178 | s.removeTools(c) |
933 | 178 | 179 | ||
934 | === modified file 'environs/tools/urls_test.go' | |||
935 | --- environs/tools/urls_test.go 2014-01-31 00:14:11 +0000 | |||
936 | +++ environs/tools/urls_test.go 2014-02-18 02:14:09 +0000 | |||
937 | @@ -43,7 +43,7 @@ | |||
938 | 43 | } | 43 | } |
939 | 44 | cfg, err := config.New(config.NoDefaults, attrs) | 44 | cfg, err := config.New(config.NoDefaults, attrs) |
940 | 45 | c.Assert(err, gc.IsNil) | 45 | c.Assert(err, gc.IsNil) |
942 | 46 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 46 | env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem()) |
943 | 47 | c.Assert(err, gc.IsNil) | 47 | c.Assert(err, gc.IsNil) |
944 | 48 | return env | 48 | return env |
945 | 49 | } | 49 | } |
946 | 50 | 50 | ||
947 | === modified file 'juju/apiconn_test.go' | |||
948 | --- juju/apiconn_test.go 2014-01-22 22:48:54 +0000 | |||
949 | +++ juju/apiconn_test.go 2014-02-18 02:14:09 +0000 | |||
950 | @@ -46,11 +46,12 @@ | |||
951 | 46 | func (*NewAPIConnSuite) TestNewConn(c *gc.C) { | 46 | func (*NewAPIConnSuite) TestNewConn(c *gc.C) { |
952 | 47 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 47 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
953 | 48 | c.Assert(err, gc.IsNil) | 48 | c.Assert(err, gc.IsNil) |
955 | 49 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 49 | ctx := coretesting.Context(c) |
956 | 50 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
957 | 50 | c.Assert(err, gc.IsNil) | 51 | c.Assert(err, gc.IsNil) |
958 | 51 | 52 | ||
959 | 52 | envtesting.UploadFakeTools(c, env.Storage()) | 53 | envtesting.UploadFakeTools(c, env.Storage()) |
961 | 53 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 54 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
962 | 54 | c.Assert(err, gc.IsNil) | 55 | c.Assert(err, gc.IsNil) |
963 | 55 | 56 | ||
964 | 56 | cfg = env.Config() | 57 | cfg = env.Config() |
965 | 57 | 58 | ||
966 | === modified file 'juju/conn_test.go' | |||
967 | --- juju/conn_test.go 2014-01-30 13:50:27 +0000 | |||
968 | +++ juju/conn_test.go 2014-02-18 02:14:09 +0000 | |||
969 | @@ -62,17 +62,14 @@ | |||
970 | 62 | c.Assert(err, gc.IsNil) | 62 | c.Assert(err, gc.IsNil) |
971 | 63 | } | 63 | } |
972 | 64 | 64 | ||
973 | 65 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
974 | 66 | return envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
975 | 67 | } | ||
976 | 68 | |||
977 | 69 | func (*NewConnSuite) TestNewConnWithoutAdminSecret(c *gc.C) { | 65 | func (*NewConnSuite) TestNewConnWithoutAdminSecret(c *gc.C) { |
978 | 70 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 66 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
979 | 71 | c.Assert(err, gc.IsNil) | 67 | c.Assert(err, gc.IsNil) |
981 | 72 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 68 | ctx := coretesting.Context(c) |
982 | 69 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
983 | 73 | c.Assert(err, gc.IsNil) | 70 | c.Assert(err, gc.IsNil) |
984 | 74 | envtesting.UploadFakeTools(c, env.Storage()) | 71 | envtesting.UploadFakeTools(c, env.Storage()) |
986 | 75 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 72 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
987 | 76 | c.Assert(err, gc.IsNil) | 73 | c.Assert(err, gc.IsNil) |
988 | 77 | 74 | ||
989 | 78 | attrs := env.Config().AllAttrs() | 75 | attrs := env.Config().AllAttrs() |
990 | @@ -88,10 +85,11 @@ | |||
991 | 88 | if store == nil { | 85 | if store == nil { |
992 | 89 | store = configstore.NewMem() | 86 | store = configstore.NewMem() |
993 | 90 | } | 87 | } |
995 | 91 | env, err := environs.PrepareFromName(envName, store) | 88 | ctx := coretesting.Context(c) |
996 | 89 | env, err := environs.PrepareFromName(envName, ctx, store) | ||
997 | 92 | c.Assert(err, gc.IsNil) | 90 | c.Assert(err, gc.IsNil) |
998 | 93 | envtesting.UploadFakeTools(c, env.Storage()) | 91 | envtesting.UploadFakeTools(c, env.Storage()) |
1000 | 94 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 92 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
1001 | 95 | c.Assert(err, gc.IsNil) | 93 | c.Assert(err, gc.IsNil) |
1002 | 96 | } | 94 | } |
1003 | 97 | 95 | ||
1004 | @@ -133,10 +131,11 @@ | |||
1005 | 133 | }) | 131 | }) |
1006 | 134 | cfg, err := config.New(config.NoDefaults, attrs) | 132 | cfg, err := config.New(config.NoDefaults, attrs) |
1007 | 135 | c.Assert(err, gc.IsNil) | 133 | c.Assert(err, gc.IsNil) |
1009 | 136 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 134 | ctx := coretesting.Context(c) |
1010 | 135 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1011 | 137 | c.Assert(err, gc.IsNil) | 136 | c.Assert(err, gc.IsNil) |
1012 | 138 | envtesting.UploadFakeTools(c, env.Storage()) | 137 | envtesting.UploadFakeTools(c, env.Storage()) |
1014 | 139 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 138 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
1015 | 140 | c.Assert(err, gc.IsNil) | 139 | c.Assert(err, gc.IsNil) |
1016 | 141 | info, _, err := env.StateInfo() | 140 | info, _, err := env.StateInfo() |
1017 | 142 | c.Assert(err, gc.IsNil) | 141 | c.Assert(err, gc.IsNil) |
1018 | @@ -182,10 +181,11 @@ | |||
1019 | 182 | }) | 181 | }) |
1020 | 183 | cfg, err := config.New(config.NoDefaults, attrs) | 182 | cfg, err := config.New(config.NoDefaults, attrs) |
1021 | 184 | c.Assert(err, gc.IsNil) | 183 | c.Assert(err, gc.IsNil) |
1023 | 185 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 184 | ctx := coretesting.Context(c) |
1024 | 185 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1025 | 186 | c.Assert(err, gc.IsNil) | 186 | c.Assert(err, gc.IsNil) |
1026 | 187 | envtesting.UploadFakeTools(c, env.Storage()) | 187 | envtesting.UploadFakeTools(c, env.Storage()) |
1028 | 188 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 188 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
1029 | 189 | c.Assert(err, gc.IsNil) | 189 | c.Assert(err, gc.IsNil) |
1030 | 190 | 190 | ||
1031 | 191 | // Make a new Conn, which will push the secrets. | 191 | // Make a new Conn, which will push the secrets. |
1032 | @@ -218,10 +218,11 @@ | |||
1033 | 218 | }) | 218 | }) |
1034 | 219 | cfg, err := config.New(config.NoDefaults, attrs) | 219 | cfg, err := config.New(config.NoDefaults, attrs) |
1035 | 220 | c.Assert(err, gc.IsNil) | 220 | c.Assert(err, gc.IsNil) |
1037 | 221 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 221 | ctx := coretesting.Context(c) |
1038 | 222 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1039 | 222 | c.Assert(err, gc.IsNil) | 223 | c.Assert(err, gc.IsNil) |
1040 | 223 | envtesting.UploadFakeTools(c, env.Storage()) | 224 | envtesting.UploadFakeTools(c, env.Storage()) |
1042 | 224 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 225 | err = bootstrap.Bootstrap(ctx, env, constraints.Value{}) |
1043 | 225 | c.Assert(err, gc.IsNil) | 226 | c.Assert(err, gc.IsNil) |
1044 | 226 | 227 | ||
1045 | 227 | // Check that Bootstrap has correctly used a hash | 228 | // Check that Bootstrap has correctly used a hash |
1046 | @@ -272,10 +273,11 @@ | |||
1047 | 272 | s.ToolsFixture.SetUpTest(c) | 273 | s.ToolsFixture.SetUpTest(c) |
1048 | 273 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 274 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
1049 | 274 | c.Assert(err, gc.IsNil) | 275 | c.Assert(err, gc.IsNil) |
1051 | 275 | environ, err := environs.Prepare(cfg, configstore.NewMem()) | 276 | ctx := coretesting.Context(c) |
1052 | 277 | environ, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1053 | 276 | c.Assert(err, gc.IsNil) | 278 | c.Assert(err, gc.IsNil) |
1054 | 277 | envtesting.UploadFakeTools(c, environ.Storage()) | 279 | envtesting.UploadFakeTools(c, environ.Storage()) |
1056 | 278 | err = bootstrap.Bootstrap(bootstrapContext(c), environ, constraints.Value{}) | 280 | err = bootstrap.Bootstrap(ctx, environ, constraints.Value{}) |
1057 | 279 | c.Assert(err, gc.IsNil) | 281 | c.Assert(err, gc.IsNil) |
1058 | 280 | s.conn, err = juju.NewConn(environ) | 282 | s.conn, err = juju.NewConn(environ) |
1059 | 281 | c.Assert(err, gc.IsNil) | 283 | c.Assert(err, gc.IsNil) |
1060 | 282 | 284 | ||
1061 | === modified file 'juju/testing/conn.go' | |||
1062 | --- juju/testing/conn.go 2014-02-13 00:54:09 +0000 | |||
1063 | +++ juju/testing/conn.go 2014-02-18 02:14:09 +0000 | |||
1064 | @@ -196,13 +196,13 @@ | |||
1065 | 196 | c.Assert(err, gc.IsNil) | 196 | c.Assert(err, gc.IsNil) |
1066 | 197 | s.ConfigStore = store | 197 | s.ConfigStore = store |
1067 | 198 | 198 | ||
1069 | 199 | environ, err := environs.PrepareFromName("dummyenv", s.ConfigStore) | 199 | ctx := testing.Context(c) |
1070 | 200 | environ, err := environs.PrepareFromName("dummyenv", ctx, s.ConfigStore) | ||
1071 | 200 | c.Assert(err, gc.IsNil) | 201 | c.Assert(err, gc.IsNil) |
1072 | 201 | // sanity check we've got the correct environment. | 202 | // sanity check we've got the correct environment. |
1073 | 202 | c.Assert(environ.Name(), gc.Equals, "dummyenv") | 203 | c.Assert(environ.Name(), gc.Equals, "dummyenv") |
1074 | 203 | 204 | ||
1075 | 204 | envtesting.MustUploadFakeTools(environ.Storage()) | 205 | envtesting.MustUploadFakeTools(environ.Storage()) |
1076 | 205 | ctx := envtesting.NewBootstrapContext(testing.Context(c)) | ||
1077 | 206 | c.Assert(bootstrap.Bootstrap(ctx, environ, constraints.Value{}), gc.IsNil) | 206 | c.Assert(bootstrap.Bootstrap(ctx, environ, constraints.Value{}), gc.IsNil) |
1078 | 207 | 207 | ||
1079 | 208 | s.BackingState = environ.(GetStater).GetStateInAPIServer() | 208 | s.BackingState = environ.(GetStater).GetStateInAPIServer() |
1080 | 209 | 209 | ||
1081 | === modified file 'provider/azure/environprovider.go' | |||
1082 | --- provider/azure/environprovider.go 2014-01-28 04:58:43 +0000 | |||
1083 | +++ provider/azure/environprovider.go 2014-02-18 02:14:09 +0000 | |||
1084 | @@ -42,7 +42,7 @@ | |||
1085 | 42 | } | 42 | } |
1086 | 43 | 43 | ||
1087 | 44 | // Prepare is specified in the EnvironProvider interface. | 44 | // Prepare is specified in the EnvironProvider interface. |
1089 | 45 | func (prov azureEnvironProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 45 | func (prov azureEnvironProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1090 | 46 | // TODO prepare environment as necessary | 46 | // TODO prepare environment as necessary |
1091 | 47 | return prov.Open(cfg) | 47 | return prov.Open(cfg) |
1092 | 48 | } | 48 | } |
1093 | 49 | 49 | ||
1094 | === modified file 'provider/common/bootstrap.go' | |||
1095 | --- provider/common/bootstrap.go 2014-01-30 14:13:54 +0000 | |||
1096 | +++ provider/common/bootstrap.go 2014-02-18 02:14:09 +0000 | |||
1097 | @@ -68,12 +68,12 @@ | |||
1098 | 68 | return err | 68 | return err |
1099 | 69 | } | 69 | } |
1100 | 70 | 70 | ||
1102 | 71 | fmt.Fprintln(ctx.Stderr(), "Launching instance") | 71 | fmt.Fprintln(ctx.GetStderr(), "Launching instance") |
1103 | 72 | inst, hw, err := env.StartInstance(cons, selectedTools, machineConfig) | 72 | inst, hw, err := env.StartInstance(cons, selectedTools, machineConfig) |
1104 | 73 | if err != nil { | 73 | if err != nil { |
1105 | 74 | return fmt.Errorf("cannot start bootstrap instance: %v", err) | 74 | return fmt.Errorf("cannot start bootstrap instance: %v", err) |
1106 | 75 | } | 75 | } |
1108 | 76 | fmt.Fprintf(ctx.Stderr(), " - %s\n", inst.Id()) | 76 | fmt.Fprintf(ctx.GetStderr(), " - %s\n", inst.Id()) |
1109 | 77 | 77 | ||
1110 | 78 | var characteristics []instance.HardwareCharacteristics | 78 | var characteristics []instance.HardwareCharacteristics |
1111 | 79 | if hw != nil { | 79 | if hw != nil { |
1112 | @@ -144,12 +144,12 @@ | |||
1113 | 144 | defer close(ch) | 144 | defer close(ch) |
1114 | 145 | go func() { | 145 | go func() { |
1115 | 146 | for _ = range ch { | 146 | for _ = range ch { |
1117 | 147 | fmt.Fprintln(ctx.Stderr(), "Cleaning up failed bootstrap") | 147 | fmt.Fprintln(ctx.GetStderr(), "Cleaning up failed bootstrap") |
1118 | 148 | } | 148 | } |
1119 | 149 | }() | 149 | }() |
1120 | 150 | 150 | ||
1121 | 151 | if inst != nil { | 151 | if inst != nil { |
1123 | 152 | fmt.Fprintln(ctx.Stderr(), "Stopping instance...") | 152 | fmt.Fprintln(ctx.GetStderr(), "Stopping instance...") |
1124 | 153 | if stoperr := env.StopInstances([]instance.Instance{inst}); stoperr != nil { | 153 | if stoperr := env.StopInstances([]instance.Instance{inst}); stoperr != nil { |
1125 | 154 | logger.Errorf("cannot stop failed bootstrap instance %q: %v", inst.Id(), stoperr) | 154 | logger.Errorf("cannot stop failed bootstrap instance %q: %v", inst.Id(), stoperr) |
1126 | 155 | } else { | 155 | } else { |
1127 | @@ -217,7 +217,7 @@ | |||
1128 | 217 | Host: "ubuntu@" + addr, | 217 | Host: "ubuntu@" + addr, |
1129 | 218 | Client: client, | 218 | Client: client, |
1130 | 219 | Config: cloudcfg, | 219 | Config: cloudcfg, |
1132 | 220 | ProgressWriter: ctx.Stderr(), | 220 | ProgressWriter: ctx.GetStderr(), |
1133 | 221 | }) | 221 | }) |
1134 | 222 | } | 222 | } |
1135 | 223 | 223 | ||
1136 | @@ -365,14 +365,14 @@ | |||
1137 | 365 | checker := parallelHostChecker{ | 365 | checker := parallelHostChecker{ |
1138 | 366 | Try: parallel.NewTry(0, nil), | 366 | Try: parallel.NewTry(0, nil), |
1139 | 367 | client: client, | 367 | client: client, |
1141 | 368 | stderr: ctx.Stderr(), | 368 | stderr: ctx.GetStderr(), |
1142 | 369 | active: make(map[instance.Address]chan struct{}), | 369 | active: make(map[instance.Address]chan struct{}), |
1143 | 370 | checkDelay: timeout.RetryDelay, | 370 | checkDelay: timeout.RetryDelay, |
1144 | 371 | checkHostScript: checkHostScript, | 371 | checkHostScript: checkHostScript, |
1145 | 372 | } | 372 | } |
1146 | 373 | defer checker.Kill() | 373 | defer checker.Kill() |
1147 | 374 | 374 | ||
1149 | 375 | fmt.Fprintln(ctx.Stderr(), "Waiting for address") | 375 | fmt.Fprintln(ctx.GetStderr(), "Waiting for address") |
1150 | 376 | for { | 376 | for { |
1151 | 377 | select { | 377 | select { |
1152 | 378 | case <-pollAddresses.C: | 378 | case <-pollAddresses.C: |
1153 | 379 | 379 | ||
1154 | === modified file 'provider/common/bootstrap_test.go' | |||
1155 | --- provider/common/bootstrap_test.go 2014-01-30 17:27:26 +0000 | |||
1156 | +++ provider/common/bootstrap_test.go 2014-02-18 02:14:09 +0000 | |||
1157 | @@ -4,7 +4,6 @@ | |||
1158 | 4 | package common_test | 4 | package common_test |
1159 | 5 | 5 | ||
1160 | 6 | import ( | 6 | import ( |
1161 | 7 | "bytes" | ||
1162 | 8 | "fmt" | 7 | "fmt" |
1163 | 9 | "os" | 8 | "os" |
1164 | 10 | "time" | 9 | "time" |
1165 | @@ -76,22 +75,13 @@ | |||
1166 | 76 | return func() *config.Config { return cfg } | 75 | return func() *config.Config { return cfg } |
1167 | 77 | } | 76 | } |
1168 | 78 | 77 | ||
1169 | 79 | // bootstrapContext creates a BootstrapContext which | ||
1170 | 80 | // writes stderr to the bytes.Buffer returned. | ||
1171 | 81 | func bootstrapContext(c *gc.C) (ctx environs.BootstrapContext, stderr *bytes.Buffer) { | ||
1172 | 82 | cmdContext := coretesting.Context(c) | ||
1173 | 83 | stderr = &bytes.Buffer{} | ||
1174 | 84 | cmdContext.Stderr = stderr | ||
1175 | 85 | return envtesting.NewBootstrapContext(cmdContext), stderr | ||
1176 | 86 | } | ||
1177 | 87 | |||
1178 | 88 | func (s *BootstrapSuite) TestCannotWriteStateFile(c *gc.C) { | 78 | func (s *BootstrapSuite) TestCannotWriteStateFile(c *gc.C) { |
1179 | 89 | brokenStorage := &mockStorage{ | 79 | brokenStorage := &mockStorage{ |
1180 | 90 | Storage: newStorage(s, c), | 80 | Storage: newStorage(s, c), |
1181 | 91 | putErr: fmt.Errorf("noes!"), | 81 | putErr: fmt.Errorf("noes!"), |
1182 | 92 | } | 82 | } |
1183 | 93 | env := &mockEnviron{storage: brokenStorage} | 83 | env := &mockEnviron{storage: brokenStorage} |
1185 | 94 | ctx, _ := bootstrapContext(c) | 84 | ctx := coretesting.Context(c) |
1186 | 95 | err := common.Bootstrap(ctx, env, constraints.Value{}) | 85 | err := common.Bootstrap(ctx, env, constraints.Value{}) |
1187 | 96 | c.Assert(err, gc.ErrorMatches, "cannot create initial state file: noes!") | 86 | c.Assert(err, gc.ErrorMatches, "cannot create initial state file: noes!") |
1188 | 97 | } | 87 | } |
1189 | @@ -118,7 +108,7 @@ | |||
1190 | 118 | config: configGetter(c), | 108 | config: configGetter(c), |
1191 | 119 | } | 109 | } |
1192 | 120 | 110 | ||
1194 | 121 | ctx, _ := bootstrapContext(c) | 111 | ctx := coretesting.Context(c) |
1195 | 122 | err = common.Bootstrap(ctx, env, checkCons) | 112 | err = common.Bootstrap(ctx, env, checkCons) |
1196 | 123 | c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started") | 113 | c.Assert(err, gc.ErrorMatches, "cannot start bootstrap instance: meh, not started") |
1197 | 124 | } | 114 | } |
1198 | @@ -149,7 +139,7 @@ | |||
1199 | 149 | config: configGetter(c), | 139 | config: configGetter(c), |
1200 | 150 | } | 140 | } |
1201 | 151 | 141 | ||
1203 | 152 | ctx, _ := bootstrapContext(c) | 142 | ctx := coretesting.Context(c) |
1204 | 153 | err := common.Bootstrap(ctx, env, constraints.Value{}) | 143 | err := common.Bootstrap(ctx, env, constraints.Value{}) |
1205 | 154 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") | 144 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") |
1206 | 155 | c.Assert(stopped, gc.HasLen, 1) | 145 | c.Assert(stopped, gc.HasLen, 1) |
1207 | @@ -186,7 +176,7 @@ | |||
1208 | 186 | config: configGetter(c), | 176 | config: configGetter(c), |
1209 | 187 | } | 177 | } |
1210 | 188 | 178 | ||
1212 | 189 | ctx, _ := bootstrapContext(c) | 179 | ctx := coretesting.Context(c) |
1213 | 190 | err := common.Bootstrap(ctx, env, constraints.Value{}) | 180 | err := common.Bootstrap(ctx, env, constraints.Value{}) |
1214 | 191 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") | 181 | c.Assert(err, gc.ErrorMatches, "cannot save state: suddenly a wild blah") |
1215 | 192 | c.Assert(stopped, gc.HasLen, 1) | 182 | c.Assert(stopped, gc.HasLen, 1) |
1216 | @@ -231,7 +221,7 @@ | |||
1217 | 231 | setConfig: setConfig, | 221 | setConfig: setConfig, |
1218 | 232 | } | 222 | } |
1219 | 233 | originalAuthKeys := env.Config().AuthorizedKeys() | 223 | originalAuthKeys := env.Config().AuthorizedKeys() |
1221 | 234 | ctx, _ := bootstrapContext(c) | 224 | ctx := coretesting.Context(c) |
1222 | 235 | err := common.Bootstrap(ctx, env, constraints.Value{}) | 225 | err := common.Bootstrap(ctx, env, constraints.Value{}) |
1223 | 236 | c.Assert(err, gc.IsNil) | 226 | c.Assert(err, gc.IsNil) |
1224 | 237 | 227 | ||
1225 | @@ -268,14 +258,14 @@ | |||
1226 | 268 | } | 258 | } |
1227 | 269 | 259 | ||
1228 | 270 | func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForAddresses(c *gc.C) { | 260 | func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForAddresses(c *gc.C) { |
1230 | 271 | ctx, stderr := bootstrapContext(c) | 261 | ctx := coretesting.Context(c) |
1231 | 272 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", neverAddresses{}, testSSHTimeout) | 262 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", neverAddresses{}, testSSHTimeout) |
1232 | 273 | c.Check(err, gc.ErrorMatches, `waited for `+testSSHTimeout.Timeout.String()+` without getting any addresses`) | 263 | c.Check(err, gc.ErrorMatches, `waited for `+testSSHTimeout.Timeout.String()+` without getting any addresses`) |
1234 | 274 | c.Check(stderr.String(), gc.Matches, "Waiting for address\n") | 264 | c.Check(coretesting.Stderr(ctx), gc.Matches, "Waiting for address\n") |
1235 | 275 | } | 265 | } |
1236 | 276 | 266 | ||
1237 | 277 | func (s *BootstrapSuite) TestWaitSSHKilledWaitingForAddresses(c *gc.C) { | 267 | func (s *BootstrapSuite) TestWaitSSHKilledWaitingForAddresses(c *gc.C) { |
1239 | 278 | ctx, stderr := bootstrapContext(c) | 268 | ctx := coretesting.Context(c) |
1240 | 279 | interrupted := make(chan os.Signal, 1) | 269 | interrupted := make(chan os.Signal, 1) |
1241 | 280 | go func() { | 270 | go func() { |
1242 | 281 | <-time.After(2 * time.Millisecond) | 271 | <-time.After(2 * time.Millisecond) |
1243 | @@ -283,7 +273,7 @@ | |||
1244 | 283 | }() | 273 | }() |
1245 | 284 | _, err := common.WaitSSH(ctx, interrupted, ssh.DefaultClient, "/bin/true", neverAddresses{}, testSSHTimeout) | 274 | _, err := common.WaitSSH(ctx, interrupted, ssh.DefaultClient, "/bin/true", neverAddresses{}, testSSHTimeout) |
1246 | 285 | c.Check(err, gc.ErrorMatches, "interrupted") | 275 | c.Check(err, gc.ErrorMatches, "interrupted") |
1248 | 286 | c.Check(stderr.String(), gc.Matches, "Waiting for address\n") | 276 | c.Check(coretesting.Stderr(ctx), gc.Matches, "Waiting for address\n") |
1249 | 287 | } | 277 | } |
1250 | 288 | 278 | ||
1251 | 289 | type brokenAddresses struct { | 279 | type brokenAddresses struct { |
1252 | @@ -295,10 +285,10 @@ | |||
1253 | 295 | } | 285 | } |
1254 | 296 | 286 | ||
1255 | 297 | func (s *BootstrapSuite) TestWaitSSHStopsOnBadError(c *gc.C) { | 287 | func (s *BootstrapSuite) TestWaitSSHStopsOnBadError(c *gc.C) { |
1257 | 298 | ctx, stderr := bootstrapContext(c) | 288 | ctx := coretesting.Context(c) |
1258 | 299 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", brokenAddresses{}, testSSHTimeout) | 289 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", brokenAddresses{}, testSSHTimeout) |
1259 | 300 | c.Check(err, gc.ErrorMatches, "getting addresses: Addresses will never work") | 290 | c.Check(err, gc.ErrorMatches, "getting addresses: Addresses will never work") |
1261 | 301 | c.Check(stderr.String(), gc.Equals, "Waiting for address\n") | 291 | c.Check(coretesting.Stderr(ctx), gc.Equals, "Waiting for address\n") |
1262 | 302 | } | 292 | } |
1263 | 303 | 293 | ||
1264 | 304 | type neverOpensPort struct { | 294 | type neverOpensPort struct { |
1265 | @@ -311,12 +301,12 @@ | |||
1266 | 311 | } | 301 | } |
1267 | 312 | 302 | ||
1268 | 313 | func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForDial(c *gc.C) { | 303 | func (s *BootstrapSuite) TestWaitSSHTimesOutWaitingForDial(c *gc.C) { |
1270 | 314 | ctx, stderr := bootstrapContext(c) | 304 | ctx := coretesting.Context(c) |
1271 | 315 | // 0.x.y.z addresses are always invalid | 305 | // 0.x.y.z addresses are always invalid |
1272 | 316 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", &neverOpensPort{addr: "0.1.2.3"}, testSSHTimeout) | 306 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "/bin/true", &neverOpensPort{addr: "0.1.2.3"}, testSSHTimeout) |
1273 | 317 | c.Check(err, gc.ErrorMatches, | 307 | c.Check(err, gc.ErrorMatches, |
1274 | 318 | `waited for `+testSSHTimeout.Timeout.String()+` without being able to connect: mock connection failure to 0.1.2.3`) | 308 | `waited for `+testSSHTimeout.Timeout.String()+` without being able to connect: mock connection failure to 0.1.2.3`) |
1276 | 319 | c.Check(stderr.String(), gc.Matches, | 309 | c.Check(coretesting.Stderr(ctx), gc.Matches, |
1277 | 320 | "Waiting for address\n"+ | 310 | "Waiting for address\n"+ |
1278 | 321 | "(Attempting to connect to 0.1.2.3:22\n)+") | 311 | "(Attempting to connect to 0.1.2.3:22\n)+") |
1279 | 322 | } | 312 | } |
1280 | @@ -339,14 +329,14 @@ | |||
1281 | 339 | } | 329 | } |
1282 | 340 | 330 | ||
1283 | 341 | func (s *BootstrapSuite) TestWaitSSHKilledWaitingForDial(c *gc.C) { | 331 | func (s *BootstrapSuite) TestWaitSSHKilledWaitingForDial(c *gc.C) { |
1285 | 342 | ctx, stderr := bootstrapContext(c) | 332 | ctx := coretesting.Context(c) |
1286 | 343 | timeout := testSSHTimeout | 333 | timeout := testSSHTimeout |
1287 | 344 | timeout.Timeout = 1 * time.Minute | 334 | timeout.Timeout = 1 * time.Minute |
1288 | 345 | interrupted := make(chan os.Signal, 1) | 335 | interrupted := make(chan os.Signal, 1) |
1289 | 346 | _, err := common.WaitSSH(ctx, interrupted, ssh.DefaultClient, "", &interruptOnDial{name: "0.1.2.3", interrupted: interrupted}, timeout) | 336 | _, err := common.WaitSSH(ctx, interrupted, ssh.DefaultClient, "", &interruptOnDial{name: "0.1.2.3", interrupted: interrupted}, timeout) |
1290 | 347 | c.Check(err, gc.ErrorMatches, "interrupted") | 337 | c.Check(err, gc.ErrorMatches, "interrupted") |
1291 | 348 | // Exact timing is imprecise but it should have tried a few times before being killed | 338 | // Exact timing is imprecise but it should have tried a few times before being killed |
1293 | 349 | c.Check(stderr.String(), gc.Matches, | 339 | c.Check(coretesting.Stderr(ctx), gc.Matches, |
1294 | 350 | "Waiting for address\n"+ | 340 | "Waiting for address\n"+ |
1295 | 351 | "(Attempting to connect to 0.1.2.3:22\n)+") | 341 | "(Attempting to connect to 0.1.2.3:22\n)+") |
1296 | 352 | } | 342 | } |
1297 | @@ -371,7 +361,7 @@ | |||
1298 | 371 | } | 361 | } |
1299 | 372 | 362 | ||
1300 | 373 | func (s *BootstrapSuite) TestWaitSSHRefreshAddresses(c *gc.C) { | 363 | func (s *BootstrapSuite) TestWaitSSHRefreshAddresses(c *gc.C) { |
1302 | 374 | ctx, stderr := bootstrapContext(c) | 364 | ctx := coretesting.Context(c) |
1303 | 375 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "", &addressesChange{addrs: [][]string{ | 365 | _, err := common.WaitSSH(ctx, nil, ssh.DefaultClient, "", &addressesChange{addrs: [][]string{ |
1304 | 376 | nil, | 366 | nil, |
1305 | 377 | nil, | 367 | nil, |
1306 | @@ -383,10 +373,11 @@ | |||
1307 | 383 | // Not necessarily the last one in the list, due to scheduling. | 373 | // Not necessarily the last one in the list, due to scheduling. |
1308 | 384 | c.Check(err, gc.ErrorMatches, | 374 | c.Check(err, gc.ErrorMatches, |
1309 | 385 | `waited for `+testSSHTimeout.Timeout.String()+` without being able to connect: mock connection failure to 0.1.2.[34]`) | 375 | `waited for `+testSSHTimeout.Timeout.String()+` without being able to connect: mock connection failure to 0.1.2.[34]`) |
1311 | 386 | c.Check(stderr.String(), gc.Matches, | 376 | stderr := coretesting.Stderr(ctx) |
1312 | 377 | c.Check(stderr, gc.Matches, | ||
1313 | 387 | "Waiting for address\n"+ | 378 | "Waiting for address\n"+ |
1314 | 388 | "(.|\n)*(Attempting to connect to 0.1.2.3:22\n)+(.|\n)*") | 379 | "(.|\n)*(Attempting to connect to 0.1.2.3:22\n)+(.|\n)*") |
1316 | 389 | c.Check(stderr.String(), gc.Matches, | 380 | c.Check(stderr, gc.Matches, |
1317 | 390 | "Waiting for address\n"+ | 381 | "Waiting for address\n"+ |
1318 | 391 | "(.|\n)*(Attempting to connect to 0.1.2.4:22\n)+(.|\n)*") | 382 | "(.|\n)*(Attempting to connect to 0.1.2.4:22\n)+(.|\n)*") |
1319 | 392 | } | 383 | } |
1320 | 393 | 384 | ||
1321 | === modified file 'provider/dummy/config_test.go' | |||
1322 | --- provider/dummy/config_test.go 2013-10-01 16:46:31 +0000 | |||
1323 | +++ provider/dummy/config_test.go 2014-02-18 02:14:09 +0000 | |||
1324 | @@ -29,7 +29,8 @@ | |||
1325 | 29 | attrs := dummy.SampleConfig().Delete("secret") | 29 | attrs := dummy.SampleConfig().Delete("secret") |
1326 | 30 | cfg, err := config.New(config.NoDefaults, attrs) | 30 | cfg, err := config.New(config.NoDefaults, attrs) |
1327 | 31 | c.Assert(err, gc.IsNil) | 31 | c.Assert(err, gc.IsNil) |
1329 | 32 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 32 | ctx := testing.Context(c) |
1330 | 33 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1331 | 33 | c.Assert(err, gc.IsNil) | 34 | c.Assert(err, gc.IsNil) |
1332 | 34 | defer env.Destroy() | 35 | defer env.Destroy() |
1333 | 35 | expected := map[string]string{ | 36 | expected := map[string]string{ |
1334 | @@ -81,7 +82,8 @@ | |||
1335 | 81 | c.Assert(err, gc.ErrorMatches, test.errorMsg) | 82 | c.Assert(err, gc.ErrorMatches, test.errorMsg) |
1336 | 82 | continue | 83 | continue |
1337 | 83 | } | 84 | } |
1339 | 84 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 85 | ctx := testing.Context(c) |
1340 | 86 | env, err := environs.Prepare(cfg, ctx, configstore.NewMem()) | ||
1341 | 85 | if test.errorMsg != "" { | 87 | if test.errorMsg != "" { |
1342 | 86 | c.Assert(err, gc.ErrorMatches, test.errorMsg) | 88 | c.Assert(err, gc.ErrorMatches, test.errorMsg) |
1343 | 87 | continue | 89 | continue |
1344 | 88 | 90 | ||
1345 | === modified file 'provider/dummy/environs.go' | |||
1346 | --- provider/dummy/environs.go 2014-02-03 06:58:26 +0000 | |||
1347 | +++ provider/dummy/environs.go 2014-02-18 02:14:09 +0000 | |||
1348 | @@ -422,7 +422,7 @@ | |||
1349 | 422 | return env, nil | 422 | return env, nil |
1350 | 423 | } | 423 | } |
1351 | 424 | 424 | ||
1353 | 425 | func (p *environProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 425 | func (p *environProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1354 | 426 | cfg, err := p.prepare(cfg) | 426 | cfg, err := p.prepare(cfg) |
1355 | 427 | if err != nil { | 427 | if err != nil { |
1356 | 428 | return nil, err | 428 | return nil, err |
1357 | 429 | 429 | ||
1358 | === modified file 'provider/ec2/config_test.go' | |||
1359 | --- provider/ec2/config_test.go 2013-10-24 00:20:59 +0000 | |||
1360 | +++ provider/ec2/config_test.go 2014-02-18 02:14:09 +0000 | |||
1361 | @@ -294,12 +294,13 @@ | |||
1362 | 294 | cfg, err := config.New(config.NoDefaults, attrs) | 294 | cfg, err := config.New(config.NoDefaults, attrs) |
1363 | 295 | c.Assert(err, gc.IsNil) | 295 | c.Assert(err, gc.IsNil) |
1364 | 296 | 296 | ||
1366 | 297 | env0, err := providerInstance.Prepare(cfg) | 297 | ctx := testing.Context(c) |
1367 | 298 | env0, err := providerInstance.Prepare(ctx, cfg) | ||
1368 | 298 | c.Assert(err, gc.IsNil) | 299 | c.Assert(err, gc.IsNil) |
1369 | 299 | bucket0 := env0.(*environ).ecfg().controlBucket() | 300 | bucket0 := env0.(*environ).ecfg().controlBucket() |
1370 | 300 | c.Assert(bucket0, gc.Matches, "[a-f0-9]{32}") | 301 | c.Assert(bucket0, gc.Matches, "[a-f0-9]{32}") |
1371 | 301 | 302 | ||
1373 | 302 | env1, err := providerInstance.Prepare(cfg) | 303 | env1, err := providerInstance.Prepare(ctx, cfg) |
1374 | 303 | c.Assert(err, gc.IsNil) | 304 | c.Assert(err, gc.IsNil) |
1375 | 304 | bucket1 := env1.(*environ).ecfg().controlBucket() | 305 | bucket1 := env1.(*environ).ecfg().controlBucket() |
1376 | 305 | c.Assert(bucket1, gc.Matches, "[a-f0-9]{32}") | 306 | c.Assert(bucket1, gc.Matches, "[a-f0-9]{32}") |
1377 | @@ -315,7 +316,7 @@ | |||
1378 | 315 | cfg, err := config.New(config.NoDefaults, attrs) | 316 | cfg, err := config.New(config.NoDefaults, attrs) |
1379 | 316 | c.Assert(err, gc.IsNil) | 317 | c.Assert(err, gc.IsNil) |
1380 | 317 | 318 | ||
1382 | 318 | env, err := providerInstance.Prepare(cfg) | 319 | env, err := providerInstance.Prepare(testing.Context(c), cfg) |
1383 | 319 | c.Assert(err, gc.IsNil) | 320 | c.Assert(err, gc.IsNil) |
1384 | 320 | bucket := env.(*environ).ecfg().controlBucket() | 321 | bucket := env.(*environ).ecfg().controlBucket() |
1385 | 321 | c.Assert(bucket, gc.Equals, "burblefoo") | 322 | c.Assert(bucket, gc.Equals, "burblefoo") |
1386 | 322 | 323 | ||
1387 | === modified file 'provider/ec2/ec2.go' | |||
1388 | --- provider/ec2/ec2.go 2014-01-29 09:58:08 +0000 | |||
1389 | +++ provider/ec2/ec2.go 2014-02-18 02:14:09 +0000 | |||
1390 | @@ -207,7 +207,7 @@ | |||
1391 | 207 | return e, nil | 207 | return e, nil |
1392 | 208 | } | 208 | } |
1393 | 209 | 209 | ||
1395 | 210 | func (p environProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 210 | func (p environProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1396 | 211 | attrs := cfg.UnknownAttrs() | 211 | attrs := cfg.UnknownAttrs() |
1397 | 212 | if _, ok := attrs["control-bucket"]; !ok { | 212 | if _, ok := attrs["control-bucket"]; !ok { |
1398 | 213 | uuid, err := utils.NewUUID() | 213 | uuid, err := utils.NewUUID() |
1399 | 214 | 214 | ||
1400 | === modified file 'provider/ec2/local_test.go' | |||
1401 | --- provider/ec2/local_test.go 2014-01-29 06:45:16 +0000 | |||
1402 | +++ provider/ec2/local_test.go 2014-02-18 02:14:09 +0000 | |||
1403 | @@ -74,7 +74,7 @@ | |||
1404 | 74 | } | 74 | } |
1405 | 75 | cfg, err := config.New(config.NoDefaults, envAttrs) | 75 | cfg, err := config.New(config.NoDefaults, envAttrs) |
1406 | 76 | c.Assert(err, gc.IsNil) | 76 | c.Assert(err, gc.IsNil) |
1408 | 77 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 77 | env, err := environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem()) |
1409 | 78 | c.Assert(err, gc.IsNil) | 78 | c.Assert(err, gc.IsNil) |
1410 | 79 | c.Assert(env, gc.NotNil) | 79 | c.Assert(env, gc.NotNil) |
1411 | 80 | 80 | ||
1412 | @@ -229,10 +229,6 @@ | |||
1413 | 229 | t.srv.stopServer(c) | 229 | t.srv.stopServer(c) |
1414 | 230 | } | 230 | } |
1415 | 231 | 231 | ||
1416 | 232 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
1417 | 233 | return envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
1418 | 234 | } | ||
1419 | 235 | |||
1420 | 236 | func (t *localServerSuite) TestPrecheck(c *gc.C) { | 232 | func (t *localServerSuite) TestPrecheck(c *gc.C) { |
1421 | 237 | env := t.Prepare(c) | 233 | env := t.Prepare(c) |
1422 | 238 | prechecker, ok := env.(environs.Prechecker) | 234 | prechecker, ok := env.(environs.Prechecker) |
1423 | @@ -247,7 +243,7 @@ | |||
1424 | 247 | func (t *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { | 243 | func (t *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { |
1425 | 248 | env := t.Prepare(c) | 244 | env := t.Prepare(c) |
1426 | 249 | envtesting.UploadFakeTools(c, env.Storage()) | 245 | envtesting.UploadFakeTools(c, env.Storage()) |
1428 | 250 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 246 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1429 | 251 | c.Assert(err, gc.IsNil) | 247 | c.Assert(err, gc.IsNil) |
1430 | 252 | 248 | ||
1431 | 253 | // check that the state holds the id of the bootstrap machine. | 249 | // check that the state holds the id of the bootstrap machine. |
1432 | @@ -334,7 +330,7 @@ | |||
1433 | 334 | func (t *localServerSuite) TestInstanceStatus(c *gc.C) { | 330 | func (t *localServerSuite) TestInstanceStatus(c *gc.C) { |
1434 | 335 | env := t.Prepare(c) | 331 | env := t.Prepare(c) |
1435 | 336 | envtesting.UploadFakeTools(c, env.Storage()) | 332 | envtesting.UploadFakeTools(c, env.Storage()) |
1437 | 337 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 333 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1438 | 338 | c.Assert(err, gc.IsNil) | 334 | c.Assert(err, gc.IsNil) |
1439 | 339 | t.srv.ec2srv.SetInitialInstanceState(ec2test.Terminated) | 335 | t.srv.ec2srv.SetInitialInstanceState(ec2test.Terminated) |
1440 | 340 | inst, _ := testing.AssertStartInstance(c, env, "1") | 336 | inst, _ := testing.AssertStartInstance(c, env, "1") |
1441 | @@ -345,7 +341,7 @@ | |||
1442 | 345 | func (t *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { | 341 | func (t *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { |
1443 | 346 | env := t.Prepare(c) | 342 | env := t.Prepare(c) |
1444 | 347 | envtesting.UploadFakeTools(c, env.Storage()) | 343 | envtesting.UploadFakeTools(c, env.Storage()) |
1446 | 348 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 344 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1447 | 349 | c.Assert(err, gc.IsNil) | 345 | c.Assert(err, gc.IsNil) |
1448 | 350 | _, hc := testing.AssertStartInstance(c, env, "1") | 346 | _, hc := testing.AssertStartInstance(c, env, "1") |
1449 | 351 | c.Check(*hc.Arch, gc.Equals, "amd64") | 347 | c.Check(*hc.Arch, gc.Equals, "amd64") |
1450 | @@ -357,7 +353,7 @@ | |||
1451 | 357 | func (t *localServerSuite) TestAddresses(c *gc.C) { | 353 | func (t *localServerSuite) TestAddresses(c *gc.C) { |
1452 | 358 | env := t.Prepare(c) | 354 | env := t.Prepare(c) |
1453 | 359 | envtesting.UploadFakeTools(c, env.Storage()) | 355 | envtesting.UploadFakeTools(c, env.Storage()) |
1455 | 360 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 356 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1456 | 361 | c.Assert(err, gc.IsNil) | 357 | c.Assert(err, gc.IsNil) |
1457 | 362 | inst, _ := testing.AssertStartInstance(c, env, "1") | 358 | inst, _ := testing.AssertStartInstance(c, env, "1") |
1458 | 363 | c.Assert(err, gc.IsNil) | 359 | c.Assert(err, gc.IsNil) |
1459 | @@ -442,7 +438,7 @@ | |||
1460 | 442 | 438 | ||
1461 | 443 | cfg, err := config.New(config.NoDefaults, localConfigAttrs) | 439 | cfg, err := config.New(config.NoDefaults, localConfigAttrs) |
1462 | 444 | c.Assert(err, gc.IsNil) | 440 | c.Assert(err, gc.IsNil) |
1464 | 445 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 441 | env, err := environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem()) |
1465 | 446 | c.Assert(err, gc.IsNil) | 442 | c.Assert(err, gc.IsNil) |
1466 | 447 | t.env = env | 443 | t.env = env |
1467 | 448 | } | 444 | } |
1468 | 449 | 445 | ||
1469 | === modified file 'provider/joyent/config_test.go' | |||
1470 | --- provider/joyent/config_test.go 2013-11-21 17:53:05 +0000 | |||
1471 | +++ provider/joyent/config_test.go 2014-02-18 02:14:09 +0000 | |||
1472 | @@ -286,7 +286,7 @@ | |||
1473 | 286 | c.Logf("test %d: %s", i, test.info) | 286 | c.Logf("test %d: %s", i, test.info) |
1474 | 287 | attrs := validAttrs().Merge(test.insert).Delete(test.remove...) | 287 | attrs := validAttrs().Merge(test.insert).Delete(test.remove...) |
1475 | 288 | testConfig := newConfig(c, attrs) | 288 | testConfig := newConfig(c, attrs) |
1477 | 289 | preparedConfig, err := joyent.Provider.Prepare(testConfig) | 289 | preparedConfig, err := joyent.Provider.Prepare(testing.Context(c), testConfig) |
1478 | 290 | if test.err == "" { | 290 | if test.err == "" { |
1479 | 291 | c.Assert(err, gc.IsNil) | 291 | c.Assert(err, gc.IsNil) |
1480 | 292 | attrs := preparedConfig.Config().AllAttrs() | 292 | attrs := preparedConfig.Config().AllAttrs() |
1481 | 293 | 293 | ||
1482 | === modified file 'provider/joyent/provider.go' | |||
1483 | --- provider/joyent/provider.go 2014-01-28 04:58:43 +0000 | |||
1484 | +++ provider/joyent/provider.go 2014-02-18 02:14:09 +0000 | |||
1485 | @@ -30,7 +30,7 @@ | |||
1486 | 30 | 30 | ||
1487 | 31 | var errNotImplemented = errors.New("not implemented in Joyent provider") | 31 | var errNotImplemented = errors.New("not implemented in Joyent provider") |
1488 | 32 | 32 | ||
1490 | 33 | func (environProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 33 | func (environProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1491 | 34 | // This method may be called with an incomplete cfg. It should make every | 34 | // This method may be called with an incomplete cfg. It should make every |
1492 | 35 | // reasonable effort to create a valid configuration based on the supplied, | 35 | // reasonable effort to create a valid configuration based on the supplied, |
1493 | 36 | // and open the resulting environment. | 36 | // and open the resulting environment. |
1494 | 37 | 37 | ||
1495 | === modified file 'provider/local/config_test.go' | |||
1496 | --- provider/local/config_test.go 2014-01-31 08:44:08 +0000 | |||
1497 | +++ provider/local/config_test.go 2014-02-18 02:14:09 +0000 | |||
1498 | @@ -10,7 +10,6 @@ | |||
1499 | 10 | 10 | ||
1500 | 11 | "launchpad.net/juju-core/constraints" | 11 | "launchpad.net/juju-core/constraints" |
1501 | 12 | "launchpad.net/juju-core/environs/config" | 12 | "launchpad.net/juju-core/environs/config" |
1502 | 13 | envtesting "launchpad.net/juju-core/environs/testing" | ||
1503 | 14 | "launchpad.net/juju-core/juju/osenv" | 13 | "launchpad.net/juju-core/juju/osenv" |
1504 | 15 | "launchpad.net/juju-core/provider" | 14 | "launchpad.net/juju-core/provider" |
1505 | 16 | "launchpad.net/juju-core/provider/local" | 15 | "launchpad.net/juju-core/provider/local" |
1506 | @@ -109,8 +108,8 @@ | |||
1507 | 109 | func (s *configSuite) TestBootstrapAsRoot(c *gc.C) { | 108 | func (s *configSuite) TestBootstrapAsRoot(c *gc.C) { |
1508 | 110 | restore := local.SetRootCheckFunction(func() bool { return true }) | 109 | restore := local.SetRootCheckFunction(func() bool { return true }) |
1509 | 111 | defer restore() | 110 | defer restore() |
1511 | 112 | env, err := local.Provider.Prepare(minimalConfig(c)) | 111 | env, err := local.Provider.Prepare(testing.Context(c), minimalConfig(c)) |
1512 | 113 | c.Assert(err, gc.IsNil) | 112 | c.Assert(err, gc.IsNil) |
1514 | 114 | err = env.Bootstrap(envtesting.NewBootstrapContext(testing.Context(c)), constraints.Value{}) | 113 | err = env.Bootstrap(testing.Context(c), constraints.Value{}) |
1515 | 115 | c.Assert(err, gc.ErrorMatches, "bootstrapping a local environment must not be done as root") | 114 | c.Assert(err, gc.ErrorMatches, "bootstrapping a local environment must not be done as root") |
1516 | 116 | } | 115 | } |
1517 | 117 | 116 | ||
1518 | === modified file 'provider/local/environ.go' | |||
1519 | --- provider/local/environ.go 2014-02-14 03:11:25 +0000 | |||
1520 | +++ provider/local/environ.go 2014-02-18 02:14:09 +0000 | |||
1521 | @@ -195,8 +195,8 @@ | |||
1522 | 195 | } | 195 | } |
1523 | 196 | cmd := exec.Command("sudo", "/bin/bash", "-s") | 196 | cmd := exec.Command("sudo", "/bin/bash", "-s") |
1524 | 197 | cmd.Stdin = strings.NewReader(script) | 197 | cmd.Stdin = strings.NewReader(script) |
1527 | 198 | cmd.Stdout = ctx.Stdout() | 198 | cmd.Stdout = ctx.GetStdout() |
1528 | 199 | cmd.Stderr = ctx.Stderr() | 199 | cmd.Stderr = ctx.GetStderr() |
1529 | 200 | return cmd.Run() | 200 | return cmd.Run() |
1530 | 201 | } | 201 | } |
1531 | 202 | 202 | ||
1532 | 203 | 203 | ||
1533 | === modified file 'provider/local/environ_test.go' | |||
1534 | --- provider/local/environ_test.go 2014-02-12 02:56:13 +0000 | |||
1535 | +++ provider/local/environ_test.go 2014-02-18 02:14:09 +0000 | |||
1536 | @@ -161,11 +161,11 @@ | |||
1537 | 161 | return nil | 161 | return nil |
1538 | 162 | }) | 162 | }) |
1539 | 163 | testConfig := minimalConfig(c) | 163 | testConfig := minimalConfig(c) |
1541 | 164 | environ, err := local.Provider.Prepare(testConfig) | 164 | ctx := coretesting.Context(c) |
1542 | 165 | environ, err := local.Provider.Prepare(ctx, testConfig) | ||
1543 | 165 | c.Assert(err, gc.IsNil) | 166 | c.Assert(err, gc.IsNil) |
1544 | 166 | envtesting.UploadFakeTools(c, environ.Storage()) | 167 | envtesting.UploadFakeTools(c, environ.Storage()) |
1545 | 167 | defer environ.Storage().RemoveAll() | 168 | defer environ.Storage().RemoveAll() |
1546 | 168 | ctx := envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
1547 | 169 | err = environ.Bootstrap(ctx, constraints.Value{}) | 169 | err = environ.Bootstrap(ctx, constraints.Value{}) |
1548 | 170 | c.Assert(err, gc.IsNil) | 170 | c.Assert(err, gc.IsNil) |
1549 | 171 | } | 171 | } |
1550 | 172 | 172 | ||
1551 | === modified file 'provider/local/environprovider.go' | |||
1552 | --- provider/local/environprovider.go 2014-02-14 04:26:21 +0000 | |||
1553 | +++ provider/local/environprovider.go 2014-02-18 02:14:09 +0000 | |||
1554 | @@ -86,7 +86,7 @@ | |||
1555 | 86 | var detectAptProxies = utils.DetectAptProxies | 86 | var detectAptProxies = utils.DetectAptProxies |
1556 | 87 | 87 | ||
1557 | 88 | // Prepare implements environs.EnvironProvider.Prepare. | 88 | // Prepare implements environs.EnvironProvider.Prepare. |
1559 | 89 | func (p environProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 89 | func (p environProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1560 | 90 | // The user must not set bootstrap-ip; this is determined by the provider, | 90 | // The user must not set bootstrap-ip; this is determined by the provider, |
1561 | 91 | // and its presence used to determine whether the environment has yet been | 91 | // and its presence used to determine whether the environment has yet been |
1562 | 92 | // bootstrapped. | 92 | // bootstrapped. |
1563 | 93 | 93 | ||
1564 | === modified file 'provider/local/environprovider_test.go' | |||
1565 | --- provider/local/environprovider_test.go 2014-02-14 03:41:57 +0000 | |||
1566 | +++ provider/local/environprovider_test.go 2014-02-18 02:14:09 +0000 | |||
1567 | @@ -215,7 +215,7 @@ | |||
1568 | 215 | testConfig, err = baseConfig.Apply(test.extraConfig) | 215 | testConfig, err = baseConfig.Apply(test.extraConfig) |
1569 | 216 | c.Assert(err, gc.IsNil) | 216 | c.Assert(err, gc.IsNil) |
1570 | 217 | } | 217 | } |
1572 | 218 | env, err := provider.Prepare(testConfig) | 218 | env, err := provider.Prepare(testing.Context(c), testConfig) |
1573 | 219 | c.Assert(err, gc.IsNil) | 219 | c.Assert(err, gc.IsNil) |
1574 | 220 | 220 | ||
1575 | 221 | envConfig := env.Config() | 221 | envConfig := env.Config() |
1576 | @@ -269,7 +269,7 @@ | |||
1577 | 269 | s.PatchValue(local.UserCurrent, func() (*user.User, error) { | 269 | s.PatchValue(local.UserCurrent, func() (*user.User, error) { |
1578 | 270 | return &user.User{Username: test.userOS}, test.userOSErr | 270 | return &user.User{Username: test.userOS}, test.userOSErr |
1579 | 271 | }) | 271 | }) |
1581 | 272 | env, err := provider.Prepare(basecfg) | 272 | env, err := provider.Prepare(testing.Context(c), basecfg) |
1582 | 273 | if test.err == "" { | 273 | if test.err == "" { |
1583 | 274 | c.Assert(err, gc.IsNil) | 274 | c.Assert(err, gc.IsNil) |
1584 | 275 | cfg := env.Config() | 275 | cfg := env.Config() |
1585 | 276 | 276 | ||
1586 | === modified file 'provider/maas/environ_whitebox_test.go' | |||
1587 | --- provider/maas/environ_whitebox_test.go 2014-01-29 06:45:16 +0000 | |||
1588 | +++ provider/maas/environ_whitebox_test.go 2014-02-18 02:14:09 +0000 | |||
1589 | @@ -149,16 +149,12 @@ | |||
1590 | 149 | return utils.Gunzip(data) | 149 | return utils.Gunzip(data) |
1591 | 150 | } | 150 | } |
1592 | 151 | 151 | ||
1593 | 152 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
1594 | 153 | return envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
1595 | 154 | } | ||
1596 | 155 | |||
1597 | 156 | func (suite *environSuite) TestStartInstanceStartsInstance(c *gc.C) { | 152 | func (suite *environSuite) TestStartInstanceStartsInstance(c *gc.C) { |
1598 | 157 | suite.setupFakeTools(c) | 153 | suite.setupFakeTools(c) |
1599 | 158 | env := suite.makeEnviron() | 154 | env := suite.makeEnviron() |
1600 | 159 | // Create node 0: it will be used as the bootstrap node. | 155 | // Create node 0: it will be used as the bootstrap node. |
1601 | 160 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "node0", "hostname": "host0"}`) | 156 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "node0", "hostname": "host0"}`) |
1603 | 161 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 157 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1604 | 162 | c.Assert(err, gc.IsNil) | 158 | c.Assert(err, gc.IsNil) |
1605 | 163 | // The bootstrap node has been acquired and started. | 159 | // The bootstrap node has been acquired and started. |
1606 | 164 | operations := suite.testMAASObject.TestServer.NodeOperations() | 160 | operations := suite.testMAASObject.TestServer.NodeOperations() |
1607 | @@ -372,7 +368,7 @@ | |||
1608 | 372 | suite.setupFakeTools(c) | 368 | suite.setupFakeTools(c) |
1609 | 373 | env := suite.makeEnviron() | 369 | env := suite.makeEnviron() |
1610 | 374 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "thenode", "hostname": "host"}`) | 370 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "thenode", "hostname": "host"}`) |
1612 | 375 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 371 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1613 | 376 | c.Assert(err, gc.IsNil) | 372 | c.Assert(err, gc.IsNil) |
1614 | 377 | } | 373 | } |
1615 | 378 | 374 | ||
1616 | @@ -388,14 +384,14 @@ | |||
1617 | 388 | c.Assert(err, gc.IsNil) | 384 | c.Assert(err, gc.IsNil) |
1618 | 389 | err = env.SetConfig(cfg) | 385 | err = env.SetConfig(cfg) |
1619 | 390 | c.Assert(err, gc.IsNil) | 386 | c.Assert(err, gc.IsNil) |
1621 | 391 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 387 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1622 | 392 | c.Check(err, gc.ErrorMatches, "cannot find bootstrap tools.*") | 388 | c.Check(err, gc.ErrorMatches, "cannot find bootstrap tools.*") |
1623 | 393 | } | 389 | } |
1624 | 394 | 390 | ||
1625 | 395 | func (suite *environSuite) TestBootstrapFailsIfNoNodes(c *gc.C) { | 391 | func (suite *environSuite) TestBootstrapFailsIfNoNodes(c *gc.C) { |
1626 | 396 | suite.setupFakeTools(c) | 392 | suite.setupFakeTools(c) |
1627 | 397 | env := suite.makeEnviron() | 393 | env := suite.makeEnviron() |
1629 | 398 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 394 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1630 | 399 | // Since there are no nodes, the attempt to allocate one returns a | 395 | // Since there are no nodes, the attempt to allocate one returns a |
1631 | 400 | // 409: Conflict. | 396 | // 409: Conflict. |
1632 | 401 | c.Check(err, gc.ErrorMatches, ".*409.*") | 397 | c.Check(err, gc.ErrorMatches, ".*409.*") |
1633 | @@ -407,7 +403,7 @@ | |||
1634 | 407 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "bootstrapnode", "hostname": "host"}`) | 403 | suite.testMAASObject.TestServer.NewNode(`{"system_id": "bootstrapnode", "hostname": "host"}`) |
1635 | 408 | 404 | ||
1636 | 409 | // bootstrap.Bootstrap calls Environ.Bootstrap. This works. | 405 | // bootstrap.Bootstrap calls Environ.Bootstrap. This works. |
1638 | 410 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 406 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1639 | 411 | c.Assert(err, gc.IsNil) | 407 | c.Assert(err, gc.IsNil) |
1640 | 412 | } | 408 | } |
1641 | 413 | 409 | ||
1642 | 414 | 410 | ||
1643 | === modified file 'provider/maas/environprovider.go' | |||
1644 | --- provider/maas/environprovider.go 2014-01-28 04:58:43 +0000 | |||
1645 | +++ provider/maas/environprovider.go 2014-02-18 02:14:09 +0000 | |||
1646 | @@ -41,7 +41,7 @@ | |||
1647 | 41 | var errAgentNameAlreadySet = errors.New( | 41 | var errAgentNameAlreadySet = errors.New( |
1648 | 42 | "maas-agent-name is already set; this should not be set by hand") | 42 | "maas-agent-name is already set; this should not be set by hand") |
1649 | 43 | 43 | ||
1651 | 44 | func (p maasEnvironProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 44 | func (p maasEnvironProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1652 | 45 | attrs := cfg.UnknownAttrs() | 45 | attrs := cfg.UnknownAttrs() |
1653 | 46 | oldName, found := attrs["maas-agent-name"] | 46 | oldName, found := attrs["maas-agent-name"] |
1654 | 47 | if found && oldName != "" { | 47 | if found && oldName != "" { |
1655 | 48 | 48 | ||
1656 | === modified file 'provider/maas/environprovider_test.go' | |||
1657 | --- provider/maas/environprovider_test.go 2014-01-22 22:48:54 +0000 | |||
1658 | +++ provider/maas/environprovider_test.go 2014-02-18 02:14:09 +0000 | |||
1659 | @@ -52,7 +52,8 @@ | |||
1660 | 52 | config, err := config.New(config.NoDefaults, attrs) | 52 | config, err := config.New(config.NoDefaults, attrs) |
1661 | 53 | c.Assert(err, gc.IsNil) | 53 | c.Assert(err, gc.IsNil) |
1662 | 54 | 54 | ||
1664 | 55 | environ, err := suite.makeEnviron().Provider().Prepare(config) | 55 | ctx := testing.Context(c) |
1665 | 56 | environ, err := suite.makeEnviron().Provider().Prepare(ctx, config) | ||
1666 | 56 | c.Assert(err, gc.IsNil) | 57 | c.Assert(err, gc.IsNil) |
1667 | 57 | 58 | ||
1668 | 58 | preparedConfig := environ.Config() | 59 | preparedConfig := environ.Config() |
1669 | @@ -76,7 +77,8 @@ | |||
1670 | 76 | config, err := config.New(config.NoDefaults, attrs) | 77 | config, err := config.New(config.NoDefaults, attrs) |
1671 | 77 | c.Assert(err, gc.IsNil) | 78 | c.Assert(err, gc.IsNil) |
1672 | 78 | 79 | ||
1674 | 79 | _, err = suite.makeEnviron().Provider().Prepare(config) | 80 | ctx := testing.Context(c) |
1675 | 81 | _, err = suite.makeEnviron().Provider().Prepare(ctx, config) | ||
1676 | 80 | c.Assert(err, gc.Equals, errAgentNameAlreadySet) | 82 | c.Assert(err, gc.Equals, errAgentNameAlreadySet) |
1677 | 81 | } | 83 | } |
1678 | 82 | 84 | ||
1679 | 83 | 85 | ||
1680 | === modified file 'provider/manual/environ.go' | |||
1681 | --- provider/manual/environ.go 2014-02-10 11:35:13 +0000 | |||
1682 | +++ provider/manual/environ.go 2014-02-18 02:14:09 +0000 | |||
1683 | @@ -100,7 +100,7 @@ | |||
1684 | 100 | return nil | 100 | return nil |
1685 | 101 | } | 101 | } |
1686 | 102 | cfg := e.envConfig() | 102 | cfg := e.envConfig() |
1688 | 103 | err := initUbuntuUser(cfg.bootstrapHost(), cfg.bootstrapUser(), cfg.AuthorizedKeys(), ctx.Stdin(), ctx.Stdout()) | 103 | err := initUbuntuUser(cfg.bootstrapHost(), cfg.bootstrapUser(), cfg.AuthorizedKeys(), ctx.GetStdin(), ctx.GetStdout()) |
1689 | 104 | if err != nil { | 104 | if err != nil { |
1690 | 105 | logger.Errorf("initializing ubuntu user: %v", err) | 105 | logger.Errorf("initializing ubuntu user: %v", err) |
1691 | 106 | return err | 106 | return err |
1692 | 107 | 107 | ||
1693 | === modified file 'provider/manual/environ_test.go' | |||
1694 | --- provider/manual/environ_test.go 2014-02-10 07:27:49 +0000 | |||
1695 | +++ provider/manual/environ_test.go 2014-02-18 02:14:09 +0000 | |||
1696 | @@ -13,7 +13,6 @@ | |||
1697 | 13 | "launchpad.net/juju-core/environs" | 13 | "launchpad.net/juju-core/environs" |
1698 | 14 | "launchpad.net/juju-core/environs/manual" | 14 | "launchpad.net/juju-core/environs/manual" |
1699 | 15 | "launchpad.net/juju-core/environs/storage" | 15 | "launchpad.net/juju-core/environs/storage" |
1700 | 16 | envtesting "launchpad.net/juju-core/environs/testing" | ||
1701 | 17 | "launchpad.net/juju-core/environs/tools" | 16 | "launchpad.net/juju-core/environs/tools" |
1702 | 18 | "launchpad.net/juju-core/instance" | 17 | "launchpad.net/juju-core/instance" |
1703 | 19 | coretesting "launchpad.net/juju-core/testing" | 18 | coretesting "launchpad.net/juju-core/testing" |
1704 | @@ -139,7 +138,7 @@ | |||
1705 | 139 | return initUbuntuResult | 138 | return initUbuntuResult |
1706 | 140 | }) | 139 | }) |
1707 | 141 | 140 | ||
1709 | 142 | ctx := envtesting.NewBootstrapContext(coretesting.Context(c)) | 141 | ctx := coretesting.Context(c) |
1710 | 143 | initUbuntuResult = errors.New("failed to initialise ubuntu user") | 142 | initUbuntuResult = errors.New("failed to initialise ubuntu user") |
1711 | 144 | c.Assert(s.env.EnableBootstrapStorage(ctx), gc.Equals, initUbuntuResult) | 143 | c.Assert(s.env.EnableBootstrapStorage(ctx), gc.Equals, initUbuntuResult) |
1712 | 145 | initUbuntuResult = nil | 144 | initUbuntuResult = nil |
1713 | 146 | 145 | ||
1714 | === modified file 'provider/manual/provider.go' | |||
1715 | --- provider/manual/provider.go 2014-02-10 12:32:35 +0000 | |||
1716 | +++ provider/manual/provider.go 2014-02-18 02:14:09 +0000 | |||
1717 | @@ -21,7 +21,7 @@ | |||
1718 | 21 | 21 | ||
1719 | 22 | var errNoBootstrapHost = errors.New("bootstrap-host must be specified") | 22 | var errNoBootstrapHost = errors.New("bootstrap-host must be specified") |
1720 | 23 | 23 | ||
1722 | 24 | func (p manualProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 24 | func (p manualProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1723 | 25 | if _, ok := cfg.UnknownAttrs()["storage-auth-key"]; !ok { | 25 | if _, ok := cfg.UnknownAttrs()["storage-auth-key"]; !ok { |
1724 | 26 | uuid, err := utils.NewUUID() | 26 | uuid, err := utils.NewUUID() |
1725 | 27 | if err != nil { | 27 | if err != nil { |
1726 | 28 | 28 | ||
1727 | === modified file 'provider/manual/provider_test.go' | |||
1728 | --- provider/manual/provider_test.go 2014-02-10 12:32:35 +0000 | |||
1729 | +++ provider/manual/provider_test.go 2014-02-18 02:14:09 +0000 | |||
1730 | @@ -12,6 +12,7 @@ | |||
1731 | 12 | "launchpad.net/juju-core/environs/config" | 12 | "launchpad.net/juju-core/environs/config" |
1732 | 13 | "launchpad.net/juju-core/environs/storage" | 13 | "launchpad.net/juju-core/environs/storage" |
1733 | 14 | "launchpad.net/juju-core/provider/manual" | 14 | "launchpad.net/juju-core/provider/manual" |
1734 | 15 | coretesting "launchpad.net/juju-core/testing" | ||
1735 | 15 | jc "launchpad.net/juju-core/testing/checkers" | 16 | jc "launchpad.net/juju-core/testing/checkers" |
1736 | 16 | "launchpad.net/juju-core/testing/testbase" | 17 | "launchpad.net/juju-core/testing/testbase" |
1737 | 17 | "launchpad.net/juju-core/utils" | 18 | "launchpad.net/juju-core/utils" |
1738 | @@ -29,7 +30,7 @@ | |||
1739 | 29 | delete(minimal, "storage-auth-key") | 30 | delete(minimal, "storage-auth-key") |
1740 | 30 | testConfig, err := config.New(config.UseDefaults, minimal) | 31 | testConfig, err := config.New(config.UseDefaults, minimal) |
1741 | 31 | c.Assert(err, gc.IsNil) | 32 | c.Assert(err, gc.IsNil) |
1743 | 32 | env, err := manual.ProviderInstance.Prepare(testConfig) | 33 | env, err := manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig) |
1744 | 33 | c.Assert(err, gc.IsNil) | 34 | c.Assert(err, gc.IsNil) |
1745 | 34 | cfg := env.Config() | 35 | cfg := env.Config() |
1746 | 35 | key, _ := cfg.UnknownAttrs()["storage-auth-key"].(string) | 36 | key, _ := cfg.UnknownAttrs()["storage-auth-key"].(string) |
1747 | @@ -41,7 +42,7 @@ | |||
1748 | 41 | minimal["use-sshstorage"] = false | 42 | minimal["use-sshstorage"] = false |
1749 | 42 | testConfig, err := config.New(config.UseDefaults, minimal) | 43 | testConfig, err := config.New(config.UseDefaults, minimal) |
1750 | 43 | c.Assert(err, gc.IsNil) | 44 | c.Assert(err, gc.IsNil) |
1752 | 44 | _, err = manual.ProviderInstance.Prepare(testConfig) | 45 | _, err = manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig) |
1753 | 45 | c.Assert(err, gc.ErrorMatches, "use-sshstorage must not be specified") | 46 | c.Assert(err, gc.ErrorMatches, "use-sshstorage must not be specified") |
1754 | 46 | 47 | ||
1755 | 47 | s.PatchValue(manual.NewSSHStorage, func(sshHost, storageDir, storageTmpdir string) (storage.Storage, error) { | 48 | s.PatchValue(manual.NewSSHStorage, func(sshHost, storageDir, storageTmpdir string) (storage.Storage, error) { |
1756 | @@ -50,7 +51,7 @@ | |||
1757 | 50 | minimal["use-sshstorage"] = true | 51 | minimal["use-sshstorage"] = true |
1758 | 51 | testConfig, err = config.New(config.UseDefaults, minimal) | 52 | testConfig, err = config.New(config.UseDefaults, minimal) |
1759 | 52 | c.Assert(err, gc.IsNil) | 53 | c.Assert(err, gc.IsNil) |
1761 | 53 | _, err = manual.ProviderInstance.Prepare(testConfig) | 54 | _, err = manual.ProviderInstance.Prepare(coretesting.Context(c), testConfig) |
1762 | 54 | c.Assert(err, gc.ErrorMatches, "initialising SSH storage failed: newSSHStorage failed") | 55 | c.Assert(err, gc.ErrorMatches, "initialising SSH storage failed: newSSHStorage failed") |
1763 | 55 | } | 56 | } |
1764 | 56 | 57 | ||
1765 | 57 | 58 | ||
1766 | === modified file 'provider/openstack/config_test.go' | |||
1767 | --- provider/openstack/config_test.go 2014-01-28 04:58:43 +0000 | |||
1768 | +++ provider/openstack/config_test.go 2014-02-18 02:14:09 +0000 | |||
1769 | @@ -460,12 +460,13 @@ | |||
1770 | 460 | cfg, err := config.New(config.NoDefaults, attrs) | 460 | cfg, err := config.New(config.NoDefaults, attrs) |
1771 | 461 | c.Assert(err, gc.IsNil) | 461 | c.Assert(err, gc.IsNil) |
1772 | 462 | 462 | ||
1774 | 463 | env0, err := providerInstance.Prepare(cfg) | 463 | ctx := testing.Context(c) |
1775 | 464 | env0, err := providerInstance.Prepare(ctx, cfg) | ||
1776 | 464 | c.Assert(err, gc.IsNil) | 465 | c.Assert(err, gc.IsNil) |
1777 | 465 | bucket0 := env0.(*environ).ecfg().controlBucket() | 466 | bucket0 := env0.(*environ).ecfg().controlBucket() |
1778 | 466 | c.Assert(bucket0, gc.Matches, "[a-f0-9]{32}") | 467 | c.Assert(bucket0, gc.Matches, "[a-f0-9]{32}") |
1779 | 467 | 468 | ||
1781 | 468 | env1, err := providerInstance.Prepare(cfg) | 469 | env1, err := providerInstance.Prepare(ctx, cfg) |
1782 | 469 | c.Assert(err, gc.IsNil) | 470 | c.Assert(err, gc.IsNil) |
1783 | 470 | bucket1 := env1.(*environ).ecfg().controlBucket() | 471 | bucket1 := env1.(*environ).ecfg().controlBucket() |
1784 | 471 | c.Assert(bucket1, gc.Matches, "[a-f0-9]{32}") | 472 | c.Assert(bucket1, gc.Matches, "[a-f0-9]{32}") |
1785 | @@ -482,7 +483,7 @@ | |||
1786 | 482 | cfg, err := config.New(config.NoDefaults, attrs) | 483 | cfg, err := config.New(config.NoDefaults, attrs) |
1787 | 483 | c.Assert(err, gc.IsNil) | 484 | c.Assert(err, gc.IsNil) |
1788 | 484 | 485 | ||
1790 | 485 | env, err := providerInstance.Prepare(cfg) | 486 | env, err := providerInstance.Prepare(testing.Context(c), cfg) |
1791 | 486 | c.Assert(err, gc.IsNil) | 487 | c.Assert(err, gc.IsNil) |
1792 | 487 | bucket := env.(*environ).ecfg().controlBucket() | 488 | bucket := env.(*environ).ecfg().controlBucket() |
1793 | 488 | c.Assert(bucket, gc.Equals, "burblefoo") | 489 | c.Assert(bucket, gc.Equals, "burblefoo") |
1794 | 489 | 490 | ||
1795 | === modified file 'provider/openstack/live_test.go' | |||
1796 | --- provider/openstack/live_test.go 2014-02-17 12:57:06 +0000 | |||
1797 | +++ provider/openstack/live_test.go 2014-02-18 02:14:09 +0000 | |||
1798 | @@ -230,7 +230,7 @@ | |||
1799 | 230 | c.Assert(env, gc.NotNil) | 230 | c.Assert(env, gc.NotNil) |
1800 | 231 | defer env.Destroy() | 231 | defer env.Destroy() |
1801 | 232 | // Bootstrap and start an instance. | 232 | // Bootstrap and start an instance. |
1803 | 233 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 233 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1804 | 234 | c.Assert(err, gc.IsNil) | 234 | c.Assert(err, gc.IsNil) |
1805 | 235 | inst, _ := jujutesting.AssertStartInstance(c, env, "100") | 235 | inst, _ := jujutesting.AssertStartInstance(c, env, "100") |
1806 | 236 | // Check whether the instance has the default security group assigned. | 236 | // Check whether the instance has the default security group assigned. |
1807 | 237 | 237 | ||
1808 | === modified file 'provider/openstack/local_test.go' | |||
1809 | --- provider/openstack/local_test.go 2014-02-14 01:03:03 +0000 | |||
1810 | +++ provider/openstack/local_test.go 2014-02-18 02:14:09 +0000 | |||
1811 | @@ -252,10 +252,6 @@ | |||
1812 | 252 | s.LoggingSuite.TearDownTest(c) | 252 | s.LoggingSuite.TearDownTest(c) |
1813 | 253 | } | 253 | } |
1814 | 254 | 254 | ||
1815 | 255 | func bootstrapContext(c *gc.C) environs.BootstrapContext { | ||
1816 | 256 | return envtesting.NewBootstrapContext(coretesting.Context(c)) | ||
1817 | 257 | } | ||
1818 | 258 | |||
1819 | 259 | func (s *localServerSuite) TestPrecheck(c *gc.C) { | 255 | func (s *localServerSuite) TestPrecheck(c *gc.C) { |
1820 | 260 | var cons constraints.Value | 256 | var cons constraints.Value |
1821 | 261 | env := s.Prepare(c) | 257 | env := s.Prepare(c) |
1822 | @@ -285,7 +281,7 @@ | |||
1823 | 285 | c.Assert(err, gc.IsNil) | 281 | c.Assert(err, gc.IsNil) |
1824 | 286 | env, err := environs.New(cfg) | 282 | env, err := environs.New(cfg) |
1825 | 287 | c.Assert(err, gc.IsNil) | 283 | c.Assert(err, gc.IsNil) |
1827 | 288 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 284 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1828 | 289 | c.Assert(err, gc.ErrorMatches, "(.|\n)*cannot allocate a public IP as needed(.|\n)*") | 285 | c.Assert(err, gc.ErrorMatches, "(.|\n)*cannot allocate a public IP as needed(.|\n)*") |
1829 | 290 | } | 286 | } |
1830 | 291 | 287 | ||
1831 | @@ -312,9 +308,9 @@ | |||
1832 | 312 | "use-floating-ip": false, | 308 | "use-floating-ip": false, |
1833 | 313 | })) | 309 | })) |
1834 | 314 | c.Assert(err, gc.IsNil) | 310 | c.Assert(err, gc.IsNil) |
1836 | 315 | env, err := environs.Prepare(cfg, s.ConfigStore) | 311 | env, err := environs.Prepare(cfg, coretesting.Context(c), s.ConfigStore) |
1837 | 316 | c.Assert(err, gc.IsNil) | 312 | c.Assert(err, gc.IsNil) |
1839 | 317 | err = bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 313 | err = bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1840 | 318 | c.Assert(err, gc.IsNil) | 314 | c.Assert(err, gc.IsNil) |
1841 | 319 | inst, _ := testing.AssertStartInstance(c, env, "100") | 315 | inst, _ := testing.AssertStartInstance(c, env, "100") |
1842 | 320 | err = env.StopInstances([]instance.Instance{inst}) | 316 | err = env.StopInstances([]instance.Instance{inst}) |
1843 | @@ -323,7 +319,7 @@ | |||
1844 | 323 | 319 | ||
1845 | 324 | func (s *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { | 320 | func (s *localServerSuite) TestStartInstanceHardwareCharacteristics(c *gc.C) { |
1846 | 325 | env := s.Prepare(c) | 321 | env := s.Prepare(c) |
1848 | 326 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 322 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1849 | 327 | c.Assert(err, gc.IsNil) | 323 | c.Assert(err, gc.IsNil) |
1850 | 328 | _, hc := testing.AssertStartInstanceWithConstraints(c, env, "100", constraints.MustParse("mem=1024")) | 324 | _, hc := testing.AssertStartInstanceWithConstraints(c, env, "100", constraints.MustParse("mem=1024")) |
1851 | 329 | c.Check(*hc.Arch, gc.Equals, "amd64") | 325 | c.Check(*hc.Arch, gc.Equals, "amd64") |
1852 | @@ -522,7 +518,7 @@ | |||
1853 | 522 | // It should be moved to environs.jujutests.Tests. | 518 | // It should be moved to environs.jujutests.Tests. |
1854 | 523 | func (s *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { | 519 | func (s *localServerSuite) TestBootstrapInstanceUserDataAndState(c *gc.C) { |
1855 | 524 | env := s.Prepare(c) | 520 | env := s.Prepare(c) |
1857 | 525 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 521 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1858 | 526 | c.Assert(err, gc.IsNil) | 522 | c.Assert(err, gc.IsNil) |
1859 | 527 | 523 | ||
1860 | 528 | // check that the state holds the id of the bootstrap machine. | 524 | // check that the state holds the id of the bootstrap machine. |
1861 | @@ -760,7 +756,7 @@ | |||
1862 | 760 | c.Assert(attrs["auth-url"].(string)[:8], gc.Equals, "https://") | 756 | c.Assert(attrs["auth-url"].(string)[:8], gc.Equals, "https://") |
1863 | 761 | cfg, err := config.New(config.NoDefaults, attrs) | 757 | cfg, err := config.New(config.NoDefaults, attrs) |
1864 | 762 | c.Assert(err, gc.IsNil) | 758 | c.Assert(err, gc.IsNil) |
1866 | 763 | s.env, err = environs.Prepare(cfg, configstore.NewMem()) | 759 | s.env, err = environs.Prepare(cfg, coretesting.Context(c), configstore.NewMem()) |
1867 | 764 | c.Assert(err, gc.IsNil) | 760 | c.Assert(err, gc.IsNil) |
1868 | 765 | s.attrs = s.env.Config().AllAttrs() | 761 | s.attrs = s.env.Config().AllAttrs() |
1869 | 766 | } | 762 | } |
1870 | @@ -817,7 +813,7 @@ | |||
1871 | 817 | openstack.UseTestImageData(metadataStorage, s.cred) | 813 | openstack.UseTestImageData(metadataStorage, s.cred) |
1872 | 818 | defer openstack.RemoveTestImageData(metadataStorage) | 814 | defer openstack.RemoveTestImageData(metadataStorage) |
1873 | 819 | 815 | ||
1875 | 820 | err = bootstrap.Bootstrap(bootstrapContext(c), s.env, constraints.Value{}) | 816 | err = bootstrap.Bootstrap(coretesting.Context(c), s.env, constraints.Value{}) |
1876 | 821 | c.Assert(err, gc.IsNil) | 817 | c.Assert(err, gc.IsNil) |
1877 | 822 | } | 818 | } |
1878 | 823 | 819 | ||
1879 | @@ -960,7 +956,7 @@ | |||
1880 | 960 | 956 | ||
1881 | 961 | func (s *localServerSuite) TestAllInstancesIgnoresOtherMachines(c *gc.C) { | 957 | func (s *localServerSuite) TestAllInstancesIgnoresOtherMachines(c *gc.C) { |
1882 | 962 | env := s.Prepare(c) | 958 | env := s.Prepare(c) |
1884 | 963 | err := bootstrap.Bootstrap(bootstrapContext(c), env, constraints.Value{}) | 959 | err := bootstrap.Bootstrap(coretesting.Context(c), env, constraints.Value{}) |
1885 | 964 | c.Assert(err, gc.IsNil) | 960 | c.Assert(err, gc.IsNil) |
1886 | 965 | 961 | ||
1887 | 966 | // Check that we see 1 instance in the environment | 962 | // Check that we see 1 instance in the environment |
1888 | 967 | 963 | ||
1889 | === modified file 'provider/openstack/provider.go' | |||
1890 | --- provider/openstack/provider.go 2014-01-29 09:58:08 +0000 | |||
1891 | +++ provider/openstack/provider.go 2014-02-18 02:14:09 +0000 | |||
1892 | @@ -180,7 +180,7 @@ | |||
1893 | 180 | return e, nil | 180 | return e, nil |
1894 | 181 | } | 181 | } |
1895 | 182 | 182 | ||
1897 | 183 | func (p environProvider) Prepare(cfg *config.Config) (environs.Environ, error) { | 183 | func (p environProvider) Prepare(ctx environs.BootstrapContext, cfg *config.Config) (environs.Environ, error) { |
1898 | 184 | attrs := cfg.UnknownAttrs() | 184 | attrs := cfg.UnknownAttrs() |
1899 | 185 | if _, ok := attrs["control-bucket"]; !ok { | 185 | if _, ok := attrs["control-bucket"]; !ok { |
1900 | 186 | uuid, err := utils.NewUUID() | 186 | uuid, err := utils.NewUUID() |
1901 | 187 | 187 | ||
1902 | === modified file 'state/apiserver/common/environwatcher_test.go' | |||
1903 | --- state/apiserver/common/environwatcher_test.go 2014-01-21 13:56:50 +0000 | |||
1904 | +++ state/apiserver/common/environwatcher_test.go 2014-02-18 02:14:09 +0000 | |||
1905 | @@ -16,6 +16,7 @@ | |||
1906 | 16 | "launchpad.net/juju-core/state/api/params" | 16 | "launchpad.net/juju-core/state/api/params" |
1907 | 17 | "launchpad.net/juju-core/state/apiserver/common" | 17 | "launchpad.net/juju-core/state/apiserver/common" |
1908 | 18 | apiservertesting "launchpad.net/juju-core/state/apiserver/testing" | 18 | apiservertesting "launchpad.net/juju-core/state/apiserver/testing" |
1909 | 19 | "launchpad.net/juju-core/testing" | ||
1910 | 19 | jc "launchpad.net/juju-core/testing/checkers" | 20 | jc "launchpad.net/juju-core/testing/checkers" |
1911 | 20 | "launchpad.net/juju-core/testing/testbase" | 21 | "launchpad.net/juju-core/testing/testbase" |
1912 | 21 | ) | 22 | ) |
1913 | @@ -187,7 +188,7 @@ | |||
1914 | 187 | func testingEnvConfig(c *gc.C) *config.Config { | 188 | func testingEnvConfig(c *gc.C) *config.Config { |
1915 | 188 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) | 189 | cfg, err := config.New(config.NoDefaults, dummy.SampleConfig()) |
1916 | 189 | c.Assert(err, gc.IsNil) | 190 | c.Assert(err, gc.IsNil) |
1918 | 190 | env, err := environs.Prepare(cfg, configstore.NewMem()) | 191 | env, err := environs.Prepare(cfg, testing.Context(c), configstore.NewMem()) |
1919 | 191 | c.Assert(err, gc.IsNil) | 192 | c.Assert(err, gc.IsNil) |
1920 | 192 | return env.Config() | 193 | return env.Config() |
1921 | 193 | } | 194 | } |
Reviewers: mp+206082_ code.launchpad. net,
Message:
Please take a look.
Description: BootstrapContex t to Prepare
Pass environs.
This is part one of fixing lp:1279259.
In this CL, we pass context to Prepare,
giving providers an opportunity to prompt
the user to initialise an environment.
Passing context was previously restricted to Storage; this is
Bootstrap and EnableBootstrap
insufficient, as there are many ways to prepare
an environment. It is currently possible to
successfully "Prepare" and environment, but
for the result to be unusable in the manual
provider (e.g. if the bootstrap-host address is
invalid). We should that a successfully Prepared
environment should be able to be Destroyed
(with force).
The next CL will remove BootstrapStorager and fix
lp:1279259 by initialising the ubuntu user during
Prepare.
https:/ /code.launchpad .net/~axwalk/ juju-core/ lp1279259- part1-prepare- context/ +merge/ 206082
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/62780044/
Affected files (+223, -270 lines): juju/bootstrap. go juju/bootstrap_ test.go juju/destroyenv ironment_ test.go juju/synctools. go juju/synctools_ test.go plugins/ juju-metadata/ imagemetadata. go plugins/ juju-metadata/ imagemetadata_ test.go plugins/ juju-metadata/ toolsmetadata_ test.go plugins/ juju-metadata/ validateimageme tadata. go plugins/ juju-metadata/ validatetoolsme tadata. go plugins/ juju-restore/ restore. go bootstrap/ bootstrap_ test.go emptystorage_ test.go imagemetadata/ urls_test. go interface. go jujutest/ livetests. go jujutest/ tests.go manual/ bootstrap. go manual/ bootstrap_ test.go open_test. go storage/ storage_ test.go sync/sync_ test.go testing/ bootstrap. go tools/storage_ test.go tools/tools_ test.go tools/urls_ test.go apiconn_ test.go conn_test. go testing/ conn.go azure/environpr ovider. go common/ bootstrap. go common/ bootstrap_ test.go dummy/config_ test.go dummy/environs. go ec2/config_ test.go ec2/ec2. go ec2/local_ test.go joyent/ config_ test.go joyent/ provider. go local/config_ test.go local/environ. go local/environ_ test.go local/environpr ovider. go local/environpr ovider_ test.go maas/environ_ whitebox_ test.go maas/environpro vider.go maas/environpro vider_test. go manual/ environ. go manual/ environ_ test.go manual/ provider. go manual/ provider_ test.go openstack/ config_ test.go openstack/ live_test. go openstack/ local_test. go openstack/ provider. go apiserver/ common/ environwatcher_ test.go
[revision details]
cmd/cmd.go
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
cmd/
environs/
environs/
environs/
environs/
environs/
environs/
environs/
environs/
environs/open.go
environs/
environs/
environs/
environs/
environs/
environs/
environs/
juju/
juju/
juju/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
provider/
state/