Merge lp:~thumper/juju-core/instance-id into lp:~go-bot/juju-core/trunk

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 1289
Proposed branch: lp:~thumper/juju-core/instance-id
Merge into: lp:~go-bot/juju-core/trunk
Prerequisite: lp:~thumper/juju-core/lxc-cloud-init
Diff against target: 1455 lines (+188/-185)
38 files modified
cmd/juju/ssh.go (+2/-1)
cmd/juju/ssh_test.go (+2/-1)
cmd/juju/status.go (+4/-4)
cmd/jujud/bootstrap_test.go (+2/-1)
environs/azure/environ.go (+1/-1)
environs/azure/environprovider.go (+2/-2)
environs/azure/instance.go (+1/-2)
environs/dummy/environs.go (+10/-10)
environs/ec2/ec2.go (+13/-13)
environs/ec2/export_test.go (+1/-2)
environs/ec2/live_test.go (+3/-4)
environs/ec2/local_test.go (+2/-2)
environs/ec2/state.go (+2/-2)
environs/interface.go (+2/-2)
environs/jujutest/livetests.go (+7/-7)
environs/jujutest/tests.go (+2/-3)
environs/maas/environ.go (+5/-5)
environs/maas/environ_test.go (+7/-8)
environs/maas/environprovider.go (+3/-3)
environs/maas/environprovider_test.go (+2/-2)
environs/maas/instance.go (+5/-6)
environs/maas/state.go (+2/-2)
environs/maas/util.go (+3/-3)
environs/maas/util_test.go (+5/-4)
environs/openstack/export_test.go (+2/-2)
environs/openstack/local_test.go (+43/-44)
environs/openstack/provider.go (+15/-15)
environs/openstack/state.go (+2/-2)
instance/instance.go (+5/-2)
state/apiserver/api_test.go (+3/-2)
state/machine.go (+4/-7)
state/machine_test.go (+3/-2)
state/megawatcher_internal_test.go (+3/-2)
state/state.go (+3/-2)
state/state_test.go (+10/-9)
worker/firewaller/firewaller.go (+3/-2)
worker/provisioner/provisioner_task.go (+3/-3)
worker/provisioner/provisioner_test.go (+1/-1)
To merge this branch: bzr merge lp:~thumper/juju-core/instance-id
Reviewer Review Type Date Requested Status
Juju Engineering Pending
Review via email: mp+169709@code.launchpad.net

Commit message

Move state.InstanceId to instance.Id

Very mechanical change, just imports, and occasional variable renames.

https://codereview.appspot.com/10325043/

Description of the change

Move state.InstanceId to instance.Id

Very mechanical change, just imports, and occasional variable renames.

https://codereview.appspot.com/10325043/

To post a comment you must log in.
Revision history for this message
Tim Penhey (thumper) wrote :

Reviewers: mp+169709_code.launchpad.net,

Message:
Please take a look.

Description:
Move state.InstanceId to instance.Id

Very mechanical change, just imports, and occasional variable renames.

https://code.launchpad.net/~thumper/juju-core/instance-id/+merge/169709

Requires:
https://code.launchpad.net/~thumper/juju-core/lxc-cloud-init/+merge/169328

(do not edit description out of merge proposal)

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

Affected files:
   A [revision details]
   M cmd/juju/ssh.go
   M cmd/juju/ssh_test.go
   M cmd/juju/status.go
   M cmd/jujud/bootstrap_test.go
   M environs/azure/environ.go
   M environs/azure/environprovider.go
   M environs/azure/instance.go
   M environs/dummy/environs.go
   M environs/ec2/ec2.go
   M environs/ec2/export_test.go
   M environs/ec2/live_test.go
   M environs/ec2/local_test.go
   M environs/ec2/state.go
   M environs/interface.go
   M environs/jujutest/livetests.go
   M environs/jujutest/tests.go
   M environs/maas/environ.go
   M environs/maas/environ_test.go
   M environs/maas/environprovider.go
   M environs/maas/environprovider_test.go
   M environs/maas/instance.go
   M environs/maas/state.go
   M environs/maas/util.go
   M environs/maas/util_test.go
   M environs/openstack/export_test.go
   M environs/openstack/local_test.go
   M environs/openstack/provider.go
   M environs/openstack/state.go
   M instance/instance.go
   M state/apiserver/api_test.go
   M state/machine.go
   M state/machine_test.go
   M state/megawatcher_internal_test.go
   M state/state.go
   M state/state_test.go
   M worker/firewaller/firewaller.go
   M worker/provisioner/provisioner_task.go
   M worker/provisioner/provisioner_test.go

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

LGTM with the rename suggestion.

https://codereview.appspot.com/10325043/diff/1/environs/maas/instance.go
File environs/maas/instance.go (right):

https://codereview.appspot.com/10325043/diff/1/environs/maas/instance.go#newcode20
environs/maas/instance.go:20: func (this *maasInstance) Id() instance.Id
{
The usual convention would be something like:
func (mi *maasInstance) Id() instance.Id {

https://codereview.appspot.com/10325043/

Revision history for this message
Go Bot (go-bot) wrote :

There are additional revisions which have not been approved in review. Please seek review and approval of these new revisions.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'cmd/juju/ssh.go'
2--- cmd/juju/ssh.go 2013-05-02 15:55:42 +0000
3+++ cmd/juju/ssh.go 2013-06-17 21:39:25 +0000
4@@ -7,6 +7,7 @@
5 "errors"
6 "fmt"
7 "launchpad.net/juju-core/cmd"
8+ "launchpad.net/juju-core/instance"
9 "launchpad.net/juju-core/juju"
10 "launchpad.net/juju-core/log"
11 "launchpad.net/juju-core/state"
12@@ -105,7 +106,7 @@
13 for _ = range w.Changes() {
14 if instid, ok := machine.InstanceId(); ok {
15 w.Stop()
16- inst, err := c.Environ.Instances([]state.InstanceId{instid})
17+ inst, err := c.Environ.Instances([]instance.Id{instid})
18 if err != nil {
19 return "", err
20 }
21
22=== modified file 'cmd/juju/ssh_test.go'
23--- cmd/juju/ssh_test.go 2013-05-27 03:17:41 +0000
24+++ cmd/juju/ssh_test.go 2013-06-17 21:39:25 +0000
25@@ -9,6 +9,7 @@
26 . "launchpad.net/gocheck"
27 "launchpad.net/juju-core/charm"
28 "launchpad.net/juju-core/cmd"
29+ "launchpad.net/juju-core/instance"
30 "launchpad.net/juju-core/juju/testing"
31 "launchpad.net/juju-core/state"
32 coretesting "launchpad.net/juju-core/testing"
33@@ -139,7 +140,7 @@
34 // fudge unit.SetPublicAddress
35 id, ok := m.InstanceId()
36 c.Assert(ok, Equals, true)
37- insts, err := s.Conn.Environ.Instances([]state.InstanceId{id})
38+ insts, err := s.Conn.Environ.Instances([]instance.Id{id})
39 c.Assert(err, IsNil)
40 addr, err := insts[0].WaitDNSName()
41 c.Assert(err, IsNil)
42
43=== modified file 'cmd/juju/status.go'
44--- cmd/juju/status.go 2013-06-16 22:10:37 +0000
45+++ cmd/juju/status.go 2013-06-17 21:39:25 +0000
46@@ -43,7 +43,7 @@
47 }
48
49 type statusContext struct {
50- instances map[state.InstanceId]instance.Instance
51+ instances map[instance.Id]instance.Instance
52 machines map[string][]*state.Machine
53 services map[string]*state.Service
54 units map[string]map[string]*state.Unit
55@@ -80,8 +80,8 @@
56 }
57
58 // fetchAllInstances returns a map from instance id to instance.
59-func fetchAllInstances(env environs.Environ) (map[state.InstanceId]instance.Instance, error) {
60- m := make(map[state.InstanceId]instance.Instance)
61+func fetchAllInstances(env environs.Environ) (map[instance.Id]instance.Instance, error) {
62+ m := make(map[instance.Id]instance.Instance)
63 insts, err := env.AllInstances()
64 if err != nil {
65 return nil, err
66@@ -357,7 +357,7 @@
67 AgentStateInfo string `json:"agent-state-info,omitempty" yaml:"agent-state-info,omitempty"`
68 AgentVersion string `json:"agent-version,omitempty" yaml:"agent-version,omitempty"`
69 DNSName string `json:"dns-name,omitempty" yaml:"dns-name,omitempty"`
70- InstanceId state.InstanceId `json:"instance-id,omitempty" yaml:"instance-id,omitempty"`
71+ InstanceId instance.Id `json:"instance-id,omitempty" yaml:"instance-id,omitempty"`
72 InstanceState string `json:"instance-state,omitempty" yaml:"instance-state,omitempty"`
73 Life string `json:"life,omitempty" yaml:"life,omitempty"`
74 Series string `json:"series,omitempty" yaml:"series,omitempty"`
75
76=== modified file 'cmd/jujud/bootstrap_test.go'
77--- cmd/jujud/bootstrap_test.go 2013-06-11 13:52:19 +0000
78+++ cmd/jujud/bootstrap_test.go 2013-06-17 21:39:25 +0000
79@@ -10,6 +10,7 @@
80 "launchpad.net/juju-core/constraints"
81 "launchpad.net/juju-core/environs/agent"
82 "launchpad.net/juju-core/errors"
83+ "launchpad.net/juju-core/instance"
84 "launchpad.net/juju-core/state"
85 "launchpad.net/juju-core/testing"
86 )
87@@ -79,7 +80,7 @@
88
89 instid, ok := machines[0].InstanceId()
90 c.Assert(ok, Equals, true)
91- c.Assert(instid, Equals, state.InstanceId("dummy.instance.id"))
92+ c.Assert(instid, Equals, instance.Id("dummy.instance.id"))
93
94 cons, err := st.EnvironConstraints()
95 c.Assert(err, IsNil)
96
97=== modified file 'environs/azure/environ.go'
98--- environs/azure/environ.go 2013-06-14 01:02:53 +0000
99+++ environs/azure/environ.go 2013-06-17 21:39:25 +0000
100@@ -54,7 +54,7 @@
101 }
102
103 // Instances is specified in the Environ interface.
104-func (env *azureEnviron) Instances(ids []state.InstanceId) ([]instance.Instance, error) {
105+func (env *azureEnviron) Instances(ids []instance.Id) ([]instance.Instance, error) {
106 panic("unimplemented")
107 }
108
109
110=== modified file 'environs/azure/environprovider.go'
111--- environs/azure/environprovider.go 2013-06-11 12:41:10 +0000
112+++ environs/azure/environprovider.go 2013-06-17 21:39:25 +0000
113@@ -6,7 +6,7 @@
114 import (
115 "launchpad.net/juju-core/environs"
116 "launchpad.net/juju-core/environs/config"
117- "launchpad.net/juju-core/state"
118+ "launchpad.net/juju-core/instance"
119 )
120
121 type azureEnvironProvider struct{}
122@@ -45,6 +45,6 @@
123 }
124
125 // InstanceId is specified in the EnvironProvider interface.
126-func (prov azureEnvironProvider) InstanceId() (state.InstanceId, error) {
127+func (prov azureEnvironProvider) InstanceId() (instance.Id, error) {
128 panic("unimplemented")
129 }
130
131=== modified file 'environs/azure/instance.go'
132--- environs/azure/instance.go 2013-06-14 01:02:53 +0000
133+++ environs/azure/instance.go 2013-06-17 21:39:25 +0000
134@@ -5,7 +5,6 @@
135
136 import (
137 "launchpad.net/juju-core/instance"
138- "launchpad.net/juju-core/state"
139 "launchpad.net/juju-core/state/api/params"
140 )
141
142@@ -15,7 +14,7 @@
143 var _ instance.Instance = (*azureInstance)(nil)
144
145 // Id is specified in the Instance interface.
146-func (instance *azureInstance) Id() state.InstanceId {
147+func (instance *azureInstance) Id() instance.Id {
148 panic("unimplemented")
149 }
150
151
152=== modified file 'environs/dummy/environs.go'
153--- environs/dummy/environs.go 2013-06-17 15:12:53 +0000
154+++ environs/dummy/environs.go 2013-06-17 21:39:25 +0000
155@@ -91,14 +91,14 @@
156 type OpOpenPorts struct {
157 Env string
158 MachineId string
159- InstanceId state.InstanceId
160+ InstanceId instance.Id
161 Ports []params.Port
162 }
163
164 type OpClosePorts struct {
165 Env string
166 MachineId string
167- InstanceId state.InstanceId
168+ InstanceId instance.Id
169 Ports []params.Port
170 }
171
172@@ -126,7 +126,7 @@
173 ops chan<- Operation
174 mu sync.Mutex
175 maxId int // maximum instance id allocated so far.
176- insts map[state.InstanceId]*dummyInstance
177+ insts map[instance.Id]*dummyInstance
178 globalPorts map[params.Port]bool
179 firewallMode config.FirewallMode
180 bootstrapped bool
181@@ -228,7 +228,7 @@
182 s := &environState{
183 name: name,
184 ops: ops,
185- insts: make(map[state.InstanceId]*dummyInstance),
186+ insts: make(map[instance.Id]*dummyInstance),
187 globalPorts: make(map[params.Port]bool),
188 firewallMode: fwmode,
189 }
190@@ -389,8 +389,8 @@
191 return "private.dummy.address.example.com", nil
192 }
193
194-func (*environProvider) InstanceId() (state.InstanceId, error) {
195- return state.InstanceId("dummy.instance.id"), nil
196+func (*environProvider) InstanceId() (instance.Id, error) {
197+ return instance.Id("dummy.instance.id"), nil
198 }
199
200 func (*environProvider) BoilerplateConfig() string {
201@@ -561,7 +561,7 @@
202 }
203 i := &dummyInstance{
204 state: e.state,
205- id: state.InstanceId(fmt.Sprintf("%s-%d", e.state.name, e.state.maxId)),
206+ id: instance.Id(fmt.Sprintf("%s-%d", e.state.name, e.state.maxId)),
207 ports: make(map[params.Port]bool),
208 machineId: machineId,
209 series: series,
210@@ -598,7 +598,7 @@
211 return nil
212 }
213
214-func (e *environ) Instances(ids []state.InstanceId) (insts []instance.Instance, err error) {
215+func (e *environ) Instances(ids []instance.Id) (insts []instance.Instance, err error) {
216 defer delay()
217 if err := e.checkBroken("Instances"); err != nil {
218 return nil, err
219@@ -684,12 +684,12 @@
220 type dummyInstance struct {
221 state *environState
222 ports map[params.Port]bool
223- id state.InstanceId
224+ id instance.Id
225 machineId string
226 series string
227 }
228
229-func (inst *dummyInstance) Id() state.InstanceId {
230+func (inst *dummyInstance) Id() instance.Id {
231 return inst.id
232 }
233
234
235=== modified file 'environs/ec2/ec2.go'
236--- environs/ec2/ec2.go 2013-06-17 15:12:53 +0000
237+++ environs/ec2/ec2.go 2013-06-17 21:39:25 +0000
238@@ -77,8 +77,8 @@
239
240 var _ instance.Instance = (*ec2Instance)(nil)
241
242-func (inst *ec2Instance) Id() state.InstanceId {
243- return state.InstanceId(inst.InstanceId)
244+func (inst *ec2Instance) Id() instance.Id {
245+ return instance.Id(inst.InstanceId)
246 }
247
248 func (inst *ec2Instance) DNSName() (string, error) {
249@@ -87,7 +87,7 @@
250 }
251 // Fetch the instance information again, in case
252 // the DNS information has become available.
253- insts, err := inst.e.Instances([]state.InstanceId{inst.Id()})
254+ insts, err := inst.e.Instances([]instance.Id{inst.Id()})
255 if err != nil {
256 return "", err
257 }
258@@ -158,9 +158,9 @@
259 return fetchMetadata("local-hostname")
260 }
261
262-func (environProvider) InstanceId() (state.InstanceId, error) {
263+func (environProvider) InstanceId() (instance.Id, error) {
264 str, err := fetchMetadata("instance-id")
265- return state.InstanceId(str), err
266+ return instance.Id(str), err
267 }
268
269 func (e *environ) Config() *config.Config {
270@@ -279,7 +279,7 @@
271 return fmt.Errorf("cannot start bootstrap instance: %v", err)
272 }
273 err = e.saveState(&bootstrapState{
274- StateInstances: []state.InstanceId{inst.Id()},
275+ StateInstances: []instance.Id{inst.Id()},
276 })
277 if err != nil {
278 // ignore error on StopInstance because the previous error is
279@@ -467,7 +467,7 @@
280 }
281
282 func (e *environ) StopInstances(insts []instance.Instance) error {
283- ids := make([]state.InstanceId, len(insts))
284+ ids := make([]instance.Id, len(insts))
285 for i, inst := range insts {
286 ids[i] = inst.(*ec2Instance).Id()
287 }
288@@ -478,7 +478,7 @@
289 // id whose corresponding insts slot is nil.
290 // It returns environs.ErrPartialInstances if the insts
291 // slice has not been completely filled.
292-func (e *environ) gatherInstances(ids []state.InstanceId, insts []instance.Instance) error {
293+func (e *environ) gatherInstances(ids []instance.Id, insts []instance.Instance) error {
294 var need []string
295 for i, inst := range insts {
296 if inst == nil {
297@@ -520,7 +520,7 @@
298 return nil
299 }
300
301-func (e *environ) Instances(ids []state.InstanceId) ([]instance.Instance, error) {
302+func (e *environ) Instances(ids []instance.Id) ([]instance.Instance, error) {
303 if len(ids) == 0 {
304 return nil, nil
305 }
306@@ -573,8 +573,8 @@
307 if err != nil {
308 return fmt.Errorf("cannot get instances: %v", err)
309 }
310- found := make(map[state.InstanceId]bool)
311- var ids []state.InstanceId
312+ found := make(map[instance.Id]bool)
313+ var ids []instance.Id
314 for _, inst := range insts {
315 ids = append(ids, inst.Id())
316 found[inst.Id()] = true
317@@ -583,7 +583,7 @@
318 // Add any instances we've been told about but haven't yet shown
319 // up in the instance list.
320 for _, inst := range ensureInsts {
321- id := state.InstanceId(inst.(*ec2Instance).InstanceId)
322+ id := instance.Id(inst.(*ec2Instance).InstanceId)
323 if !found[id] {
324 ids = append(ids, id)
325 found[id] = true
326@@ -720,7 +720,7 @@
327 return &providerInstance
328 }
329
330-func (e *environ) terminateInstances(ids []state.InstanceId) error {
331+func (e *environ) terminateInstances(ids []instance.Id) error {
332 if len(ids) == 0 {
333 return nil
334 }
335
336=== modified file 'environs/ec2/export_test.go'
337--- environs/ec2/export_test.go 2013-06-14 01:23:48 +0000
338+++ environs/ec2/export_test.go 2013-06-17 21:39:25 +0000
339@@ -12,13 +12,12 @@
340 "launchpad.net/juju-core/environs/imagemetadata"
341 "launchpad.net/juju-core/environs/jujutest"
342 "launchpad.net/juju-core/instance"
343- "launchpad.net/juju-core/state"
344 "launchpad.net/juju-core/utils"
345 "net/http"
346 )
347
348 type BootstrapState struct {
349- StateInstances []state.InstanceId
350+ StateInstances []instance.Id
351 }
352
353 func LoadState(e environs.Environ) (*BootstrapState, error) {
354
355=== modified file 'environs/ec2/live_test.go'
356--- environs/ec2/live_test.go 2013-06-14 01:02:53 +0000
357+++ environs/ec2/live_test.go 2013-06-17 21:39:25 +0000
358@@ -19,7 +19,6 @@
359 "launchpad.net/juju-core/errors"
360 "launchpad.net/juju-core/instance"
361 "launchpad.net/juju-core/juju/testing"
362- "launchpad.net/juju-core/state"
363 coretesting "launchpad.net/juju-core/testing"
364 "strings"
365 )
366@@ -120,7 +119,7 @@
367 c.Assert(err, IsNil)
368 c.Assert(dns, Not(Equals), "")
369
370- insts, err := t.Env.Instances([]state.InstanceId{inst.Id()})
371+ insts, err := t.Env.Instances([]instance.Id{inst.Id()})
372 c.Assert(err, IsNil)
373 c.Assert(len(insts), Equals, 1)
374
375@@ -230,7 +229,7 @@
376 msg := Commentf("reservation %#v", r)
377 c.Assert(hasSecurityGroup(r, groups[0]), Equals, true, msg)
378 inst := r.Instances[0]
379- switch state.InstanceId(inst.InstanceId) {
380+ switch instance.Id(inst.InstanceId) {
381 case inst0.Id():
382 c.Assert(hasSecurityGroup(r, groups[1]), Equals, true, msg)
383 c.Assert(hasSecurityGroup(r, groups[2]), Equals, false, msg)
384@@ -325,7 +324,7 @@
385 // if it succeeds.
386 gone := false
387 for a := ec2.ShortAttempt.Start(); a.Next(); {
388- insts, err = t.Env.Instances([]state.InstanceId{inst0.Id(), inst2.Id()})
389+ insts, err = t.Env.Instances([]instance.Id{inst0.Id(), inst2.Id()})
390 if err == environs.ErrPartialInstances {
391 // instances not gone yet.
392 continue
393
394=== modified file 'environs/ec2/local_test.go'
395--- environs/ec2/local_test.go 2013-05-28 08:05:49 +0000
396+++ environs/ec2/local_test.go 2013-06-17 21:39:25 +0000
397@@ -18,7 +18,7 @@
398 "launchpad.net/juju-core/environs/imagemetadata"
399 "launchpad.net/juju-core/environs/jujutest"
400 envtesting "launchpad.net/juju-core/environs/testing"
401- "launchpad.net/juju-core/state"
402+ "launchpad.net/juju-core/instance"
403 "launchpad.net/juju-core/testing"
404 "launchpad.net/juju-core/utils"
405 "regexp"
406@@ -50,7 +50,7 @@
407
408 id, err := p.InstanceId()
409 c.Assert(err, IsNil)
410- c.Assert(id, Equals, state.InstanceId("dummy.instance.id"))
411+ c.Assert(id, Equals, instance.Id("dummy.instance.id"))
412 }
413
414 func registerLocalTests() {
415
416=== modified file 'environs/ec2/state.go'
417--- environs/ec2/state.go 2013-05-02 15:55:42 +0000
418+++ environs/ec2/state.go 2013-06-17 21:39:25 +0000
419@@ -8,13 +8,13 @@
420 "fmt"
421 "io/ioutil"
422 "launchpad.net/goyaml"
423- "launchpad.net/juju-core/state"
424+ "launchpad.net/juju-core/instance"
425 )
426
427 const stateFile = "provider-state"
428
429 type bootstrapState struct {
430- StateInstances []state.InstanceId `yaml:"state-instances"`
431+ StateInstances []instance.Id `yaml:"state-instances"`
432 }
433
434 func (e *environ) saveState(state *bootstrapState) error {
435
436=== modified file 'environs/interface.go'
437--- environs/interface.go 2013-06-14 01:02:53 +0000
438+++ environs/interface.go 2013-06-17 21:39:25 +0000
439@@ -47,7 +47,7 @@
440 PrivateAddress() (string, error)
441
442 // InstanceId returns this machine's instance id.
443- InstanceId() (state.InstanceId, error)
444+ InstanceId() (instance.Id, error)
445 }
446
447 var ErrNoInstances = errors.New("no instances found")
448@@ -146,7 +146,7 @@
449 // some but not all the instances were found, the returned slice
450 // will have some nil slots, and an ErrPartialInstances error
451 // will be returned.
452- Instances(ids []state.InstanceId) ([]instance.Instance, error)
453+ Instances(ids []instance.Id) ([]instance.Instance, error)
454
455 // AllInstances returns all instances currently known to the
456 // environment.
457
458=== modified file 'environs/jujutest/livetests.go'
459--- environs/jujutest/livetests.go 2013-06-17 15:12:53 +0000
460+++ environs/jujutest/livetests.go 2013-06-17 21:39:25 +0000
461@@ -113,7 +113,7 @@
462 c.Assert(inst, NotNil)
463 id0 := inst.Id()
464
465- insts, err := t.Env.Instances([]state.InstanceId{id0, id0})
466+ insts, err := t.Env.Instances([]instance.Id{id0, id0})
467 c.Assert(err, IsNil)
468 c.Assert(insts, HasLen, 2)
469 c.Assert(insts[0].Id(), Equals, id0)
470@@ -138,7 +138,7 @@
471 c.Assert(err, IsNil)
472 c.Assert(dns, Not(Equals), "")
473
474- insts, err = t.Env.Instances([]state.InstanceId{id0, ""})
475+ insts, err = t.Env.Instances([]instance.Id{id0, ""})
476 c.Assert(err, Equals, environs.ErrPartialInstances)
477 c.Assert(insts, HasLen, 2)
478 c.Check(insts[0].Id(), Equals, id0)
479@@ -150,7 +150,7 @@
480 // The machine may not be marked as shutting down
481 // immediately. Repeat a few times to ensure we get the error.
482 for a := t.Attempt.Start(); a.Next(); {
483- insts, err = t.Env.Instances([]state.InstanceId{id0})
484+ insts, err = t.Env.Instances([]instance.Id{id0})
485 if err != nil {
486 break
487 }
488@@ -621,17 +621,17 @@
489 if !ok {
490 continue
491 }
492- _, err = t.Env.Instances([]state.InstanceId{instId})
493+ _, err = t.Env.Instances([]instance.Id{instId})
494 c.Assert(err, IsNil)
495 return
496 }
497 c.Fatalf("provisioner failed to start machine after %v", waitAgent.Total)
498 }
499
500-func (t *LiveTests) assertStopInstance(c *C, env environs.Environ, instId state.InstanceId) {
501+func (t *LiveTests) assertStopInstance(c *C, env environs.Environ, instId instance.Id) {
502 var err error
503 for a := waitAgent.Start(); a.Next(); {
504- _, err = t.Env.Instances([]state.InstanceId{instId})
505+ _, err = t.Env.Instances([]instance.Id{instId})
506 if err == nil {
507 continue
508 }
509@@ -647,7 +647,7 @@
510 // that matches that of the given instance. If the instance is nil,
511 // It asserts that the instance id is unset.
512 func assertInstanceId(c *C, m *state.Machine, inst instance.Instance) {
513- var wantId, gotId state.InstanceId
514+ var wantId, gotId instance.Id
515 var err error
516 if inst != nil {
517 wantId = inst.Id()
518
519=== modified file 'environs/jujutest/tests.go'
520--- environs/jujutest/tests.go 2013-06-14 01:02:53 +0000
521+++ environs/jujutest/tests.go 2013-06-17 21:39:25 +0000
522@@ -14,7 +14,6 @@
523 "launchpad.net/juju-core/errors"
524 "launchpad.net/juju-core/instance"
525 "launchpad.net/juju-core/juju/testing"
526- "launchpad.net/juju-core/state"
527 coretesting "launchpad.net/juju-core/testing"
528 "launchpad.net/juju-core/utils"
529 "launchpad.net/juju-core/version"
530@@ -96,7 +95,7 @@
531 c.Assert(inst1, NotNil)
532 id1 := inst1.Id()
533
534- insts, err = e.Instances([]state.InstanceId{id0, id1})
535+ insts, err = e.Instances([]instance.Id{id0, id1})
536 c.Assert(err, IsNil)
537 c.Assert(insts, HasLen, 2)
538 c.Assert(insts[0].Id(), Equals, id0)
539@@ -111,7 +110,7 @@
540 err = e.StopInstances([]instance.Instance{inst0})
541 c.Assert(err, IsNil)
542
543- insts, err = e.Instances([]state.InstanceId{id0, id1})
544+ insts, err = e.Instances([]instance.Id{id0, id1})
545 c.Assert(err, Equals, environs.ErrPartialInstances)
546 c.Assert(insts[0], IsNil)
547 c.Assert(insts[1].Id(), Equals, id1)
548
549=== modified file 'environs/maas/environ.go'
550--- environs/maas/environ.go 2013-06-17 15:12:53 +0000
551+++ environs/maas/environ.go 2013-06-17 21:39:25 +0000
552@@ -116,7 +116,7 @@
553 if err != nil {
554 return err
555 }
556- err = env.saveState(&bootstrapState{StateInstances: []state.InstanceId{inst.Id()}})
557+ err = env.saveState(&bootstrapState{StateInstances: []instance.Id{inst.Id()}})
558 if err != nil {
559 if err := env.releaseInstance(inst); err != nil {
560 log.Errorf("environs/maas: cannot release failed bootstrap instance: %v", err)
561@@ -397,9 +397,9 @@
562 }
563
564 // Instances returns the instance.Instance objects corresponding to the given
565-// slice of state.InstanceId. Similar to what the ec2 provider does,
566+// slice of instance.Id. Similar to what the ec2 provider does,
567 // Instances returns nil if the given slice is empty or nil.
568-func (environ *maasEnviron) Instances(ids []state.InstanceId) ([]instance.Instance, error) {
569+func (environ *maasEnviron) Instances(ids []instance.Id) ([]instance.Instance, error) {
570 if len(ids) == 0 {
571 return nil, nil
572 }
573@@ -411,7 +411,7 @@
574 // If the some of the intances could not be found, it returns the instance
575 // that could be found plus the error environs.ErrPartialInstances in the error
576 // return.
577-func (environ *maasEnviron) instances(ids []state.InstanceId) ([]instance.Instance, error) {
578+func (environ *maasEnviron) instances(ids []instance.Id) ([]instance.Instance, error) {
579 nodeListing := environ.getMAASClient().GetSubObject("nodes")
580 filter := getSystemIdValues(ids)
581 listNodeObjects, err := nodeListing.CallGet("list", filter)
582@@ -463,7 +463,7 @@
583 if err != nil {
584 return fmt.Errorf("cannot get instances: %v", err)
585 }
586- found := make(map[state.InstanceId]bool)
587+ found := make(map[instance.Id]bool)
588 for _, inst := range insts {
589 found[inst.Id()] = true
590 }
591
592=== modified file 'environs/maas/environ_test.go'
593--- environs/maas/environ_test.go 2013-06-14 01:23:48 +0000
594+++ environs/maas/environ_test.go 2013-06-17 21:39:25 +0000
595@@ -16,7 +16,6 @@
596 "launchpad.net/juju-core/environs/tools"
597 "launchpad.net/juju-core/errors"
598 "launchpad.net/juju-core/instance"
599- "launchpad.net/juju-core/state"
600 "launchpad.net/juju-core/testing"
601 "launchpad.net/juju-core/utils"
602 "launchpad.net/juju-core/version"
603@@ -134,7 +133,7 @@
604 input := `{"system_id": "test"}`
605 node := suite.testMAASObject.TestServer.NewNode(input)
606 resourceURI, _ := node.GetField("resource_uri")
607- instanceIds := []state.InstanceId{state.InstanceId(resourceURI)}
608+ instanceIds := []instance.Id{instance.Id(resourceURI)}
609
610 instances, err := suite.environ.Instances(instanceIds)
611
612@@ -147,7 +146,7 @@
613 // Instances returns nil if the given parameter is empty.
614 input := `{"system_id": "test"}`
615 suite.testMAASObject.TestServer.NewNode(input)
616- instances, err := suite.environ.Instances([]state.InstanceId{})
617+ instances, err := suite.environ.Instances([]instance.Id{})
618
619 c.Check(err, IsNil)
620 c.Check(instances, IsNil)
621@@ -188,9 +187,9 @@
622 resourceURI1, _ := node1.GetField("resource_uri")
623 input2 := `{"system_id": "test2"}`
624 suite.testMAASObject.TestServer.NewNode(input2)
625- instanceId1 := state.InstanceId(resourceURI1)
626- instanceId2 := state.InstanceId("unknown systemID")
627- instanceIds := []state.InstanceId{instanceId1, instanceId2}
628+ instanceId1 := instance.Id(resourceURI1)
629+ instanceId2 := instance.Id("unknown systemID")
630+ instanceIds := []instance.Id{instanceId1, instanceId2}
631
632 instances, err := suite.environ.Instances(instanceIds)
633
634@@ -370,8 +369,8 @@
635 hostname := "test"
636 input := `{"system_id": "system_id", "hostname": "` + hostname + `"}`
637 node := suite.testMAASObject.TestServer.NewNode(input)
638- instance := &maasInstance{&node, suite.environ}
639- err := env.saveState(&bootstrapState{StateInstances: []state.InstanceId{instance.Id()}})
640+ testInstance := &maasInstance{&node, suite.environ}
641+ err := env.saveState(&bootstrapState{StateInstances: []instance.Id{testInstance.Id()}})
642 c.Assert(err, IsNil)
643
644 stateInfo, apiInfo, err := env.StateInfo()
645
646=== modified file 'environs/maas/environprovider.go'
647--- environs/maas/environprovider.go 2013-05-02 15:55:42 +0000
648+++ environs/maas/environprovider.go 2013-06-17 21:39:25 +0000
649@@ -6,8 +6,8 @@
650 import (
651 "launchpad.net/juju-core/environs"
652 "launchpad.net/juju-core/environs/config"
653+ "launchpad.net/juju-core/instance"
654 "launchpad.net/juju-core/log"
655- "launchpad.net/juju-core/state"
656 )
657
658 type maasEnvironProvider struct{}
659@@ -78,11 +78,11 @@
660 }
661
662 // InstanceId is specified in the EnvironProvider interface.
663-func (maasEnvironProvider) InstanceId() (state.InstanceId, error) {
664+func (maasEnvironProvider) InstanceId() (instance.Id, error) {
665 info := machineInfo{}
666 err := info.load()
667 if err != nil {
668 return "", err
669 }
670- return state.InstanceId(info.InstanceId), nil
671+ return instance.Id(info.InstanceId), nil
672 }
673
674=== modified file 'environs/maas/environprovider_test.go'
675--- environs/maas/environprovider_test.go 2013-05-02 15:55:42 +0000
676+++ environs/maas/environprovider_test.go 2013-06-17 21:39:25 +0000
677@@ -8,7 +8,7 @@
678 . "launchpad.net/gocheck"
679 "launchpad.net/goyaml"
680 "launchpad.net/juju-core/environs/config"
681- "launchpad.net/juju-core/state"
682+ "launchpad.net/juju-core/instance"
683 )
684
685 type EnvironProviderSuite struct {
686@@ -68,7 +68,7 @@
687 provider := suite.environ.Provider()
688 returnedInstanceId, err := provider.InstanceId()
689 c.Assert(err, IsNil)
690- c.Check(returnedInstanceId, Equals, state.InstanceId(instanceId))
691+ c.Check(returnedInstanceId, Equals, instance.Id(instanceId))
692 }
693
694 // PublicAddress and PrivateAddress return the hostname of the machine read
695
696=== modified file 'environs/maas/instance.go'
697--- environs/maas/instance.go 2013-06-14 01:02:53 +0000
698+++ environs/maas/instance.go 2013-06-17 21:39:25 +0000
699@@ -7,7 +7,6 @@
700 "launchpad.net/gomaasapi"
701 "launchpad.net/juju-core/instance"
702 "launchpad.net/juju-core/log"
703- "launchpad.net/juju-core/state"
704 "launchpad.net/juju-core/state/api/params"
705 )
706
707@@ -18,20 +17,20 @@
708
709 var _ instance.Instance = (*maasInstance)(nil)
710
711-func (instance *maasInstance) Id() state.InstanceId {
712+func (mi *maasInstance) Id() instance.Id {
713 // Use the node's 'resource_uri' value.
714- return state.InstanceId((*instance.maasObject).URI().String())
715+ return instance.Id((*mi.maasObject).URI().String())
716 }
717
718 // refreshInstance refreshes the instance with the most up-to-date information
719 // from the MAAS server.
720-func (instance *maasInstance) refreshInstance() error {
721- insts, err := instance.environ.Instances([]state.InstanceId{instance.Id()})
722+func (mi *maasInstance) refreshInstance() error {
723+ insts, err := mi.environ.Instances([]instance.Id{mi.Id()})
724 if err != nil {
725 return err
726 }
727 newMaasObject := insts[0].(*maasInstance).maasObject
728- instance.maasObject = newMaasObject
729+ mi.maasObject = newMaasObject
730 return nil
731 }
732
733
734=== modified file 'environs/maas/state.go'
735--- environs/maas/state.go 2013-05-02 15:55:42 +0000
736+++ environs/maas/state.go 2013-06-17 21:39:25 +0000
737@@ -8,7 +8,7 @@
738 "fmt"
739 "io/ioutil"
740 "launchpad.net/goyaml"
741- "launchpad.net/juju-core/state"
742+ "launchpad.net/juju-core/instance"
743 )
744
745 const stateFile = "provider-state"
746@@ -16,7 +16,7 @@
747 // Persistent environment state. An environment needs to know what instances
748 // it manages.
749 type bootstrapState struct {
750- StateInstances []state.InstanceId `yaml:"state-instances"`
751+ StateInstances []instance.Id `yaml:"state-instances"`
752 }
753
754 // saveState writes the environment's state to the provider-state file stored
755
756=== modified file 'environs/maas/util.go'
757--- environs/maas/util.go 2013-05-02 15:55:42 +0000
758+++ environs/maas/util.go 2013-06-17 21:39:25 +0000
759@@ -8,8 +8,8 @@
760 "launchpad.net/goyaml"
761 cloudinit_core "launchpad.net/juju-core/cloudinit"
762 "launchpad.net/juju-core/environs/cloudinit"
763+ "launchpad.net/juju-core/instance"
764 "launchpad.net/juju-core/log"
765- "launchpad.net/juju-core/state"
766 "launchpad.net/juju-core/utils"
767 "net/url"
768 "strings"
769@@ -17,7 +17,7 @@
770
771 // extractSystemId extracts the 'system_id' part from an InstanceId.
772 // "/MAAS/api/1.0/nodes/system_id/" => "system_id"
773-func extractSystemId(instanceId state.InstanceId) string {
774+func extractSystemId(instanceId instance.Id) string {
775 trimmed := strings.TrimRight(string(instanceId), "/")
776 split := strings.Split(trimmed, "/")
777 return split[len(split)-1]
778@@ -26,7 +26,7 @@
779 // getSystemIdValues returns a url.Values object with all the 'system_ids'
780 // from the given instanceIds stored under the key 'id'. This is used
781 // to filter out instances when listing the nodes objects.
782-func getSystemIdValues(instanceIds []state.InstanceId) url.Values {
783+func getSystemIdValues(instanceIds []instance.Id) url.Values {
784 values := url.Values{}
785 for _, instanceId := range instanceIds {
786 values.Add("id", extractSystemId(instanceId))
787
788=== modified file 'environs/maas/util_test.go'
789--- environs/maas/util_test.go 2013-05-31 07:39:15 +0000
790+++ environs/maas/util_test.go 2013-06-17 21:39:25 +0000
791@@ -9,6 +9,7 @@
792 "launchpad.net/goyaml"
793 "launchpad.net/juju-core/environs/cloudinit"
794 "launchpad.net/juju-core/environs/config"
795+ "launchpad.net/juju-core/instance"
796 "launchpad.net/juju-core/state"
797 "launchpad.net/juju-core/state/api"
798 "launchpad.net/juju-core/testing"
799@@ -21,7 +22,7 @@
800 var _ = Suite(&UtilSuite{})
801
802 func (s *UtilSuite) TestExtractSystemId(c *C) {
803- instanceId := state.InstanceId("/MAAS/api/1.0/nodes/system_id/")
804+ instanceId := instance.Id("/MAAS/api/1.0/nodes/system_id/")
805
806 systemId := extractSystemId(instanceId)
807
808@@ -29,9 +30,9 @@
809 }
810
811 func (s *UtilSuite) TestGetSystemIdValues(c *C) {
812- instanceId1 := state.InstanceId("/MAAS/api/1.0/nodes/system_id1/")
813- instanceId2 := state.InstanceId("/MAAS/api/1.0/nodes/system_id2/")
814- instanceIds := []state.InstanceId{instanceId1, instanceId2}
815+ instanceId1 := instance.Id("/MAAS/api/1.0/nodes/system_id1/")
816+ instanceId2 := instance.Id("/MAAS/api/1.0/nodes/system_id2/")
817+ instanceIds := []instance.Id{instanceId1, instanceId2}
818
819 values := getSystemIdValues(instanceIds)
820
821
822=== modified file 'environs/openstack/export_test.go'
823--- environs/openstack/export_test.go 2013-05-30 05:39:33 +0000
824+++ environs/openstack/export_test.go 2013-06-17 21:39:25 +0000
825@@ -15,7 +15,7 @@
826 "launchpad.net/juju-core/environs/instances"
827 "launchpad.net/juju-core/environs/jujutest"
828 "launchpad.net/juju-core/environs/tools"
829- "launchpad.net/juju-core/state"
830+ "launchpad.net/juju-core/instance"
831 "launchpad.net/juju-core/utils"
832 "net/http"
833 "strings"
834@@ -286,7 +286,7 @@
835 }
836
837 type BootstrapState struct {
838- StateInstances []state.InstanceId
839+ StateInstances []instance.Id
840 }
841
842 func LoadState(e environs.Environ) (*BootstrapState, error) {
843
844=== modified file 'environs/openstack/local_test.go'
845--- environs/openstack/local_test.go 2013-06-14 01:02:53 +0000
846+++ environs/openstack/local_test.go 2013-06-17 21:39:25 +0000
847@@ -19,7 +19,6 @@
848 envtesting "launchpad.net/juju-core/environs/testing"
849 "launchpad.net/juju-core/instance"
850 "launchpad.net/juju-core/juju/testing"
851- "launchpad.net/juju-core/state"
852 coretesting "launchpad.net/juju-core/testing"
853 "launchpad.net/juju-core/version"
854 "net/http"
855@@ -56,7 +55,7 @@
856
857 id, err := p.InstanceId()
858 c.Assert(err, IsNil)
859- c.Assert(id, Equals, state.InstanceId("d8e02d56-2648-49a3-bf97-6be8f1204f38"))
860+ c.Assert(id, Equals, instance.Id("d8e02d56-2648-49a3-bf97-6be8f1204f38"))
861 }
862
863 func (s *ProviderSuite) TestPublicFallbackToPrivate(c *C) {
864@@ -90,7 +89,7 @@
865
866 id, err := p.InstanceId()
867 c.Assert(err, IsNil)
868- c.Assert(id, Equals, state.InstanceId("2748"))
869+ c.Assert(id, Equals, instance.Id("2748"))
870 }
871
872 // Register tests to run against a test Openstack instance (service doubles).
873@@ -287,48 +286,48 @@
874 }
875
876 var instanceGathering = []struct {
877- ids []state.InstanceId
878+ ids []instance.Id
879 err error
880 }{
881- {ids: []state.InstanceId{"id0"}},
882- {ids: []state.InstanceId{"id0", "id0"}},
883- {ids: []state.InstanceId{"id0", "id1"}},
884- {ids: []state.InstanceId{"id1", "id0"}},
885- {ids: []state.InstanceId{"id1", "id0", "id1"}},
886- {
887- ids: []state.InstanceId{""},
888- err: environs.ErrNoInstances,
889- },
890- {
891- ids: []state.InstanceId{"", ""},
892- err: environs.ErrNoInstances,
893- },
894- {
895- ids: []state.InstanceId{"", "", ""},
896- err: environs.ErrNoInstances,
897- },
898- {
899- ids: []state.InstanceId{"id0", ""},
900- err: environs.ErrPartialInstances,
901- },
902- {
903- ids: []state.InstanceId{"", "id1"},
904- err: environs.ErrPartialInstances,
905- },
906- {
907- ids: []state.InstanceId{"id0", "id1", ""},
908- err: environs.ErrPartialInstances,
909- },
910- {
911- ids: []state.InstanceId{"id0", "", "id0"},
912- err: environs.ErrPartialInstances,
913- },
914- {
915- ids: []state.InstanceId{"id0", "id0", ""},
916- err: environs.ErrPartialInstances,
917- },
918- {
919- ids: []state.InstanceId{"", "id0", "id1"},
920+ {ids: []instance.Id{"id0"}},
921+ {ids: []instance.Id{"id0", "id0"}},
922+ {ids: []instance.Id{"id0", "id1"}},
923+ {ids: []instance.Id{"id1", "id0"}},
924+ {ids: []instance.Id{"id1", "id0", "id1"}},
925+ {
926+ ids: []instance.Id{""},
927+ err: environs.ErrNoInstances,
928+ },
929+ {
930+ ids: []instance.Id{"", ""},
931+ err: environs.ErrNoInstances,
932+ },
933+ {
934+ ids: []instance.Id{"", "", ""},
935+ err: environs.ErrNoInstances,
936+ },
937+ {
938+ ids: []instance.Id{"id0", ""},
939+ err: environs.ErrPartialInstances,
940+ },
941+ {
942+ ids: []instance.Id{"", "id1"},
943+ err: environs.ErrPartialInstances,
944+ },
945+ {
946+ ids: []instance.Id{"id0", "id1", ""},
947+ err: environs.ErrPartialInstances,
948+ },
949+ {
950+ ids: []instance.Id{"id0", "", "id0"},
951+ err: environs.ErrPartialInstances,
952+ },
953+ {
954+ ids: []instance.Id{"id0", "id0", ""},
955+ err: environs.ErrPartialInstances,
956+ },
957+ {
958+ ids: []instance.Id{"", "id0", "id1"},
959 err: environs.ErrPartialInstances,
960 },
961 }
962@@ -345,7 +344,7 @@
963
964 for i, test := range instanceGathering {
965 c.Logf("test %d: find %v -> expect len %d, err: %v", i, test.ids, len(test.ids), test.err)
966- ids := make([]state.InstanceId, len(test.ids))
967+ ids := make([]instance.Id, len(test.ids))
968 for j, id := range test.ids {
969 switch id {
970 case "id0":
971
972=== modified file 'environs/openstack/provider.go'
973--- environs/openstack/provider.go 2013-06-17 15:12:53 +0000
974+++ environs/openstack/provider.go 2013-06-17 21:39:25 +0000
975@@ -159,12 +159,12 @@
976 return fetchMetadata("local-ipv4")
977 }
978
979-func (p environProvider) InstanceId() (state.InstanceId, error) {
980+func (p environProvider) InstanceId() (instance.Id, error) {
981 str, err := fetchInstanceUUID()
982 if err != nil {
983 str, err = fetchLegacyId()
984 }
985- return state.InstanceId(str), err
986+ return instance.Id(str), err
987 }
988
989 // metadataHost holds the address of the instance metadata service.
990@@ -283,8 +283,8 @@
991
992 var _ instance.Instance = (*openstackInstance)(nil)
993
994-func (inst *openstackInstance) Id() state.InstanceId {
995- return state.InstanceId(inst.ServerDetail.Id)
996+func (inst *openstackInstance) Id() instance.Id {
997+ return instance.Id(inst.ServerDetail.Id)
998 }
999
1000 // instanceAddress processes a map of networks to lists of IP
1001@@ -507,7 +507,7 @@
1002 return fmt.Errorf("cannot start bootstrap instance: %v", err)
1003 }
1004 err = e.saveState(&bootstrapState{
1005- StateInstances: []state.InstanceId{inst.Id()},
1006+ StateInstances: []instance.Id{inst.Id()},
1007 })
1008 if err != nil {
1009 // ignore error on StopInstance because the previous error is
1010@@ -841,7 +841,7 @@
1011 log.Infof("environs/openstack: started instance %q", inst.Id())
1012 if scfg.withPublicIP {
1013 if err := e.assignPublicIP(publicIP, string(inst.Id())); err != nil {
1014- if err := e.terminateInstances([]state.InstanceId{inst.Id()}); err != nil {
1015+ if err := e.terminateInstances([]instance.Id{inst.Id()}); err != nil {
1016 // ignore the failure at this stage, just log it
1017 log.Debugf("environs/openstack: failed to terminate instance %q: %v", inst.Id(), err)
1018 }
1019@@ -853,7 +853,7 @@
1020 }
1021
1022 func (e *environ) StopInstances(insts []instance.Instance) error {
1023- ids := make([]state.InstanceId, len(insts))
1024+ ids := make([]instance.Id, len(insts))
1025 for i, inst := range insts {
1026 instanceValue, ok := inst.(*openstackInstance)
1027 if !ok {
1028@@ -868,7 +868,7 @@
1029 // collectInstances tries to get information on each instance id in ids.
1030 // It fills the slots in the given map for known servers with status
1031 // either ACTIVE or BUILD. Returns a list of missing ids.
1032-func (e *environ) collectInstances(ids []state.InstanceId, out map[state.InstanceId]instance.Instance) []state.InstanceId {
1033+func (e *environ) collectInstances(ids []instance.Id, out map[instance.Id]instance.Instance) []instance.Id {
1034 var err error
1035 serversById := make(map[string]nova.ServerDetail)
1036 if len(ids) == 1 {
1037@@ -888,7 +888,7 @@
1038 if err != nil {
1039 return ids
1040 }
1041- var missing []state.InstanceId
1042+ var missing []instance.Id
1043 for _, id := range ids {
1044 if server, found := serversById[string(id)]; found {
1045 if server.Status == nova.StatusActive || server.Status == nova.StatusBuild {
1046@@ -901,12 +901,12 @@
1047 return missing
1048 }
1049
1050-func (e *environ) Instances(ids []state.InstanceId) ([]instance.Instance, error) {
1051+func (e *environ) Instances(ids []instance.Id) ([]instance.Instance, error) {
1052 if len(ids) == 0 {
1053 return nil, nil
1054 }
1055 missing := ids
1056- found := make(map[state.InstanceId]instance.Instance)
1057+ found := make(map[instance.Id]instance.Instance)
1058 // Make a series of requests to cope with eventual consistency.
1059 // Each request will attempt to add more instances to the requested
1060 // set.
1061@@ -950,8 +950,8 @@
1062 if err != nil {
1063 return fmt.Errorf("cannot get instances: %v", err)
1064 }
1065- found := make(map[state.InstanceId]bool)
1066- var ids []state.InstanceId
1067+ found := make(map[instance.Id]bool)
1068+ var ids []instance.Id
1069 for _, inst := range insts {
1070 ids = append(ids, inst.Id())
1071 found[inst.Id()] = true
1072@@ -960,7 +960,7 @@
1073 // Add any instances we've been told about but haven't yet shown
1074 // up in the instance list.
1075 for _, inst := range ensureInsts {
1076- id := state.InstanceId(inst.(*openstackInstance).Id())
1077+ id := instance.Id(inst.(*openstackInstance).Id())
1078 if !found[id] {
1079 ids = append(ids, id)
1080 found[id] = true
1081@@ -1190,7 +1190,7 @@
1082 return *group, nil
1083 }
1084
1085-func (e *environ) terminateInstances(ids []state.InstanceId) error {
1086+func (e *environ) terminateInstances(ids []instance.Id) error {
1087 if len(ids) == 0 {
1088 return nil
1089 }
1090
1091=== modified file 'environs/openstack/state.go'
1092--- environs/openstack/state.go 2013-05-02 15:55:42 +0000
1093+++ environs/openstack/state.go 2013-06-17 21:39:25 +0000
1094@@ -8,13 +8,13 @@
1095 "fmt"
1096 "io/ioutil"
1097 "launchpad.net/goyaml"
1098- "launchpad.net/juju-core/state"
1099+ "launchpad.net/juju-core/instance"
1100 )
1101
1102 const stateFile = "provider-state"
1103
1104 type bootstrapState struct {
1105- StateInstances []state.InstanceId `yaml:"state-instances"`
1106+ StateInstances []instance.Id `yaml:"state-instances"`
1107 }
1108
1109 func (e *environ) saveState(state *bootstrapState) error {
1110
1111=== modified file 'instance/instance.go'
1112--- instance/instance.go 2013-06-14 00:43:05 +0000
1113+++ instance/instance.go 2013-06-17 21:39:25 +0000
1114@@ -6,16 +6,19 @@
1115 import (
1116 "errors"
1117
1118- "launchpad.net/juju-core/state"
1119 "launchpad.net/juju-core/state/api/params"
1120 )
1121
1122 var ErrNoDNSName = errors.New("DNS name not allocated")
1123
1124+// An instance Id is a provider-specific identifier associated with an
1125+// instance (physical or virtual machine allocated in the provider).
1126+type Id string
1127+
1128 // Instance represents the the realization of a machine in state.
1129 type Instance interface {
1130 // Id returns a provider-generated identifier for the Instance.
1131- Id() state.InstanceId
1132+ Id() Id
1133
1134 // DNSName returns the DNS name for the instance.
1135 // If the name is not yet allocated, it will return
1136
1137=== modified file 'state/apiserver/api_test.go'
1138--- state/apiserver/api_test.go 2013-06-05 12:03:14 +0000
1139+++ state/apiserver/api_test.go 2013-06-17 21:39:25 +0000
1140@@ -9,6 +9,7 @@
1141 "launchpad.net/juju-core/constraints"
1142 "launchpad.net/juju-core/environs/config"
1143 "launchpad.net/juju-core/errors"
1144+ "launchpad.net/juju-core/instance"
1145 "launchpad.net/juju-core/juju/testing"
1146 "launchpad.net/juju-core/state"
1147 "launchpad.net/juju-core/state/api"
1148@@ -203,7 +204,7 @@
1149 m, err := s.State.AddMachine("series", state.JobManageEnviron)
1150 c.Assert(err, IsNil)
1151 c.Assert(m.Tag(), Equals, "machine-0")
1152- err = m.SetProvisioned(state.InstanceId("i-"+m.Tag()), "fake_nonce")
1153+ err = m.SetProvisioned(instance.Id("i-"+m.Tag()), "fake_nonce")
1154 c.Assert(err, IsNil)
1155 setDefaultPassword(c, m)
1156 setDefaultStatus(c, m)
1157@@ -237,7 +238,7 @@
1158 err = m.SetConstraints(constraints.MustParse("mem=1G"))
1159 c.Assert(err, IsNil)
1160 }
1161- err = m.SetProvisioned(state.InstanceId("i-"+m.Tag()), "fake_nonce")
1162+ err = m.SetProvisioned(instance.Id("i-"+m.Tag()), "fake_nonce")
1163 c.Assert(err, IsNil)
1164 setDefaultPassword(c, m)
1165 setDefaultStatus(c, m)
1166
1167=== modified file 'state/machine.go'
1168--- state/machine.go 2013-06-16 22:12:59 +0000
1169+++ state/machine.go 2013-06-17 21:39:25 +0000
1170@@ -9,6 +9,7 @@
1171 "labix.org/v2/mgo/txn"
1172 "launchpad.net/juju-core/constraints"
1173 "launchpad.net/juju-core/errors"
1174+ "launchpad.net/juju-core/instance"
1175 "launchpad.net/juju-core/state/api/params"
1176 "launchpad.net/juju-core/state/presence"
1177 "launchpad.net/juju-core/utils"
1178@@ -16,10 +17,6 @@
1179 "time"
1180 )
1181
1182-// An InstanceId is a provider-specific identifier associated with an
1183-// instance (physical or virtual machine allocated in the provider).
1184-type InstanceId string
1185-
1186 // Machine represents the state of a machine.
1187 type Machine struct {
1188 st *State
1189@@ -59,7 +56,7 @@
1190 Nonce string
1191 Series string
1192 ContainerType string
1193- InstanceId InstanceId
1194+ InstanceId instance.Id
1195 Principals []string
1196 Life Life
1197 Tools *Tools `bson:",omitempty"`
1198@@ -452,7 +449,7 @@
1199
1200 // InstanceId returns the provider specific instance id for this machine
1201 // and whether it has been set.
1202-func (m *Machine) InstanceId() (InstanceId, bool) {
1203+func (m *Machine) InstanceId() (instance.Id, bool) {
1204 return m.doc.InstanceId, m.doc.InstanceId != ""
1205 }
1206
1207@@ -480,7 +477,7 @@
1208
1209 // SetProvisioned sets the provider specific machine id and nonce for
1210 // this machine. Once set, the instance id cannot be changed.
1211-func (m *Machine) SetProvisioned(id InstanceId, nonce string) (err error) {
1212+func (m *Machine) SetProvisioned(id instance.Id, nonce string) (err error) {
1213 defer utils.ErrorContextf(&err, "cannot set instance id of machine %q", m)
1214
1215 if id == "" || nonce == "" {
1216
1217=== modified file 'state/machine_test.go'
1218--- state/machine_test.go 2013-06-14 02:27:04 +0000
1219+++ state/machine_test.go 2013-06-17 21:39:25 +0000
1220@@ -7,6 +7,7 @@
1221 . "launchpad.net/gocheck"
1222 "launchpad.net/juju-core/constraints"
1223 "launchpad.net/juju-core/errors"
1224+ "launchpad.net/juju-core/instance"
1225 "launchpad.net/juju-core/state"
1226 "launchpad.net/juju-core/state/api/params"
1227 "launchpad.net/juju-core/version"
1228@@ -255,7 +256,7 @@
1229 err = machine.Refresh()
1230 c.Assert(err, IsNil)
1231 iid, _ := machine.InstanceId()
1232- c.Assert(iid, Equals, state.InstanceId("spaceship/0"))
1233+ c.Assert(iid, Equals, instance.Id("spaceship/0"))
1234 }
1235
1236 func (s *MachineSuite) TestMachineInstanceIdCorrupt(c *C) {
1237@@ -271,7 +272,7 @@
1238 c.Assert(err, IsNil)
1239 iid, ok := machine.InstanceId()
1240 c.Assert(ok, Equals, false)
1241- c.Assert(iid, Equals, state.InstanceId(""))
1242+ c.Assert(iid, Equals, instance.Id(""))
1243 }
1244
1245 func (s *MachineSuite) TestMachineInstanceIdMissing(c *C) {
1246
1247=== modified file 'state/megawatcher_internal_test.go'
1248--- state/megawatcher_internal_test.go 2013-06-11 00:58:34 +0000
1249+++ state/megawatcher_internal_test.go 2013-06-17 21:39:25 +0000
1250@@ -10,6 +10,7 @@
1251 . "launchpad.net/gocheck"
1252 "launchpad.net/juju-core/charm"
1253 "launchpad.net/juju-core/constraints"
1254+ "launchpad.net/juju-core/instance"
1255 "launchpad.net/juju-core/state/api/params"
1256 "launchpad.net/juju-core/state/multiwatcher"
1257 "launchpad.net/juju-core/state/watcher"
1258@@ -64,7 +65,7 @@
1259 m, err := s.State.AddMachine("series", JobManageEnviron)
1260 c.Assert(err, IsNil)
1261 c.Assert(m.Tag(), Equals, "machine-0")
1262- err = m.SetProvisioned(InstanceId("i-"+m.Tag()), "fake_nonce")
1263+ err = m.SetProvisioned(instance.Id("i-"+m.Tag()), "fake_nonce")
1264 c.Assert(err, IsNil)
1265 add(&params.MachineInfo{
1266 Id: "0",
1267@@ -140,7 +141,7 @@
1268 Annotations: pairs,
1269 })
1270
1271- err = m.SetProvisioned(InstanceId("i-"+m.Tag()), "fake_nonce")
1272+ err = m.SetProvisioned(instance.Id("i-"+m.Tag()), "fake_nonce")
1273 c.Assert(err, IsNil)
1274 err = m.SetStatus(params.StatusError, m.Tag())
1275 c.Assert(err, IsNil)
1276
1277=== modified file 'state/state.go'
1278--- state/state.go 2013-06-16 11:39:46 +0000
1279+++ state/state.go 2013-06-17 21:39:25 +0000
1280@@ -15,6 +15,7 @@
1281 "launchpad.net/juju-core/constraints"
1282 "launchpad.net/juju-core/environs/config"
1283 "launchpad.net/juju-core/errors"
1284+ "launchpad.net/juju-core/instance"
1285 "launchpad.net/juju-core/log"
1286 "launchpad.net/juju-core/state/api/params"
1287 "launchpad.net/juju-core/state/multiwatcher"
1288@@ -200,7 +201,7 @@
1289 // InjectMachine adds a new machine, corresponding to an existing provider
1290 // instance, configured to run the supplied jobs on the supplied series, using
1291 // the specified constraints.
1292-func (st *State) InjectMachine(series string, cons constraints.Value, instanceId InstanceId, jobs ...MachineJob) (m *Machine, err error) {
1293+func (st *State) InjectMachine(series string, cons constraints.Value, instanceId instance.Id, jobs ...MachineJob) (m *Machine, err error) {
1294 if instanceId == "" {
1295 return nil, fmt.Errorf("cannot inject a machine without an instance id")
1296 }
1297@@ -275,7 +276,7 @@
1298 Constraints constraints.Value
1299 ParentId string
1300 ContainerType ContainerType
1301- instanceId InstanceId
1302+ instanceId instance.Id
1303 nonce string
1304 Jobs []MachineJob
1305 }
1306
1307=== modified file 'state/state_test.go'
1308--- state/state_test.go 2013-06-16 11:39:46 +0000
1309+++ state/state_test.go 2013-06-17 21:39:25 +0000
1310@@ -11,6 +11,7 @@
1311 "launchpad.net/juju-core/constraints"
1312 "launchpad.net/juju-core/environs/config"
1313 "launchpad.net/juju-core/errors"
1314+ "launchpad.net/juju-core/instance"
1315 "launchpad.net/juju-core/state"
1316 "launchpad.net/juju-core/state/api/params"
1317 "launchpad.net/juju-core/testing"
1318@@ -307,22 +308,22 @@
1319 }
1320
1321 func (s *StateSuite) TestInjectMachineErrors(c *C) {
1322- _, err := s.State.InjectMachine("", emptyCons, state.InstanceId("i-minvalid"), state.JobHostUnits)
1323+ _, err := s.State.InjectMachine("", emptyCons, instance.Id("i-minvalid"), state.JobHostUnits)
1324 c.Assert(err, ErrorMatches, "cannot add a new machine: no series specified")
1325- _, err = s.State.InjectMachine("series", emptyCons, state.InstanceId(""), state.JobHostUnits)
1326+ _, err = s.State.InjectMachine("series", emptyCons, instance.Id(""), state.JobHostUnits)
1327 c.Assert(err, ErrorMatches, "cannot inject a machine without an instance id")
1328- _, err = s.State.InjectMachine("series", emptyCons, state.InstanceId("i-mlazy"))
1329+ _, err = s.State.InjectMachine("series", emptyCons, instance.Id("i-mlazy"))
1330 c.Assert(err, ErrorMatches, "cannot add a new machine: no jobs specified")
1331 }
1332
1333 func (s *StateSuite) TestInjectMachine(c *C) {
1334 cons := constraints.MustParse("mem=4G")
1335- m, err := s.State.InjectMachine("series", cons, state.InstanceId("i-mindustrious"), state.JobHostUnits, state.JobManageEnviron)
1336+ m, err := s.State.InjectMachine("series", cons, instance.Id("i-mindustrious"), state.JobHostUnits, state.JobManageEnviron)
1337 c.Assert(err, IsNil)
1338 c.Assert(m.Jobs(), DeepEquals, []state.MachineJob{state.JobHostUnits, state.JobManageEnviron})
1339 instanceId, ok := m.InstanceId()
1340 c.Assert(ok, Equals, true)
1341- c.Assert(instanceId, Equals, state.InstanceId("i-mindustrious"))
1342+ c.Assert(instanceId, Equals, instance.Id("i-mindustrious"))
1343 mcons, err := m.Constraints()
1344 c.Assert(err, IsNil)
1345 c.Assert(cons, DeepEquals, mcons)
1346@@ -333,7 +334,7 @@
1347
1348 func (s *StateSuite) TestAddContainerToInjectedMachine(c *C) {
1349 oneJob := []state.MachineJob{state.JobHostUnits}
1350- m0, err := s.State.InjectMachine("series", emptyCons, state.InstanceId("i-mindustrious"), state.JobHostUnits, state.JobManageEnviron)
1351+ m0, err := s.State.InjectMachine("series", emptyCons, instance.Id("i-mindustrious"), state.JobHostUnits, state.JobManageEnviron)
1352 c.Assert(err, IsNil)
1353
1354 // Add first container.
1355@@ -397,7 +398,7 @@
1356 for i := 0; i < numInserts; i++ {
1357 m, err := s.State.AddMachine("series", state.JobHostUnits)
1358 c.Assert(err, IsNil)
1359- err = m.SetProvisioned(state.InstanceId(fmt.Sprintf("foo-%d", i)), "fake_nonce")
1360+ err = m.SetProvisioned(instance.Id(fmt.Sprintf("foo-%d", i)), "fake_nonce")
1361 c.Assert(err, IsNil)
1362 err = m.SetAgentTools(newTools("7.8.9-foo-bar", "http://arble.tgz"))
1363 c.Assert(err, IsNil)
1364@@ -772,7 +773,7 @@
1365 // Dying machine...
1366 dying, err := s.State.AddMachine("series", state.JobHostUnits)
1367 c.Assert(err, IsNil)
1368- err = dying.SetProvisioned(state.InstanceId("i-blah"), "fake-nonce")
1369+ err = dying.SetProvisioned(instance.Id("i-blah"), "fake-nonce")
1370 c.Assert(err, IsNil)
1371 err = dying.Destroy()
1372 c.Assert(err, IsNil)
1373@@ -820,7 +821,7 @@
1374 s.assertChange(c, w, "0")
1375
1376 // Change the machine: not reported.
1377- err = machine.SetProvisioned(state.InstanceId("i-blah"), "fake-nonce")
1378+ err = machine.SetProvisioned(instance.Id("i-blah"), "fake-nonce")
1379 c.Assert(err, IsNil)
1380 s.assertNoChange(c, w)
1381
1382
1383=== modified file 'worker/firewaller/firewaller.go'
1384--- worker/firewaller/firewaller.go 2013-06-11 02:15:31 +0000
1385+++ worker/firewaller/firewaller.go 2013-06-17 21:39:25 +0000
1386@@ -8,6 +8,7 @@
1387 "launchpad.net/juju-core/environs"
1388 "launchpad.net/juju-core/environs/config"
1389 "launchpad.net/juju-core/errors"
1390+ "launchpad.net/juju-core/instance"
1391 "launchpad.net/juju-core/log"
1392 "launchpad.net/juju-core/state"
1393 "launchpad.net/juju-core/state/api/params"
1394@@ -273,7 +274,7 @@
1395 if !ok {
1396 return errors.NotFoundf("instance id for %v", m)
1397 }
1398- instances, err := fw.environ.Instances([]state.InstanceId{instanceId})
1399+ instances, err := fw.environ.Instances([]instance.Id{instanceId})
1400 if err == environs.ErrNoInstances {
1401 return nil
1402 } else if err != nil {
1403@@ -444,7 +445,7 @@
1404 if !ok {
1405 return errors.NotFoundf("instance id for %v", m)
1406 }
1407- instances, err := fw.environ.Instances([]state.InstanceId{instanceId})
1408+ instances, err := fw.environ.Instances([]instance.Id{instanceId})
1409 if err != nil {
1410 return err
1411 }
1412
1413=== modified file 'worker/provisioner/provisioner_task.go'
1414--- worker/provisioner/provisioner_task.go 2013-06-14 01:02:53 +0000
1415+++ worker/provisioner/provisioner_task.go 2013-06-17 21:39:25 +0000
1416@@ -68,7 +68,7 @@
1417 apiInfo *api.Info
1418
1419 // instance id -> instance
1420- instances map[state.InstanceId]instance.Instance
1421+ instances map[instance.Id]instance.Instance
1422 // machine id -> machine
1423 machines map[string]*state.Machine
1424 }
1425@@ -159,7 +159,7 @@
1426 }
1427
1428 func (task *provisionerTask) populateMachineMaps(ids []string) error {
1429- task.instances = make(map[state.InstanceId]instance.Instance)
1430+ task.instances = make(map[instance.Id]instance.Instance)
1431
1432 instances, err := task.broker.AllInstances()
1433 if err != nil {
1434@@ -240,7 +240,7 @@
1435 // findUnknownInstances finds instances which are not associated with a machine.
1436 func (task *provisionerTask) findUnknownInstances() ([]instance.Instance, error) {
1437 // Make a copy of the instances we know about.
1438- instances := make(map[state.InstanceId]instance.Instance)
1439+ instances := make(map[instance.Id]instance.Instance)
1440 for k, v := range task.instances {
1441 instances[k] = v
1442 }
1443
1444=== modified file 'worker/provisioner/provisioner_test.go'
1445--- worker/provisioner/provisioner_test.go 2013-06-14 01:23:48 +0000
1446+++ worker/provisioner/provisioner_test.go 2013-06-17 21:39:25 +0000
1447@@ -222,7 +222,7 @@
1448
1449 // waitInstanceId waits until the supplied machine has an instance id, then
1450 // asserts it is as expected.
1451-func (s *ProvisionerSuite) waitInstanceId(c *C, m *state.Machine, expect state.InstanceId) {
1452+func (s *ProvisionerSuite) waitInstanceId(c *C, m *state.Machine, expect instance.Id) {
1453 s.waitMachine(c, m, func() bool {
1454 err := m.Refresh()
1455 c.Assert(err, IsNil)

Subscribers

People subscribed via source and target branches

to status/vote changes: