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