Merge lp:~axwalk/juju-core/status-addresses-publicaddress into lp:~go-bot/juju-core/trunk
- status-addresses-publicaddress
- Merge into trunk
Status: | Merged |
---|---|
Approved by: | Andrew Wilkins |
Approved revision: | no longer in the source branch. |
Merged at revision: | 2228 |
Proposed branch: | lp:~axwalk/juju-core/status-addresses-publicaddress |
Merge into: | lp:~go-bot/juju-core/trunk |
Diff against target: |
591 lines (+135/-25) 3 files modified
cmd/juju/status_test.go (+122/-22) state/machine.go (+12/-2) state/statecmd/status.go (+1/-1) |
To merge this branch: | bzr merge lp:~axwalk/juju-core/status-addresses-publicaddress |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Juju Engineering | Pending | ||
Review via email: mp+202397@code.launchpad.net |
Commit message
use machine.Addresses() for status dns-name
juju status now uses state.Machine.
of instance.
of machines. This returns the same value as before for
all providers (except dummy).
state.Machine.
machine addresses and provider addresses. The provider
addresses replace any of the machine addresses with the
same address string/value.
This change means that local provider instances now
have dns-name associated; this enables "juju ssh <id>"
and co. for the local provider.
Description of the change
use machine.Addresses() for status dns-name
juju status now uses state.Machine.
of instance.
of machines. This returns the same value as before for
all providers (except dummy).
state.Machine.
machine addresses and provider addresses. The provider
addresses replace any of the machine addresses with the
same address string/value.
This change means that local provider instances now
have dns-name associated; this enables "juju ssh <id>"
and co. for the local provider.
Andrew Wilkins (axwalk) wrote : | # |
Ian Booth (wallyworld) wrote : | # |
LGTM. Please double check there's a status test for when no addresses
are known.
Andrew Wilkins (axwalk) wrote : | # |
Please take a look.
Go Bot (go-bot) wrote : | # |
The attempt to merge lp:~axwalk/juju-core/status-addresses-publicaddress into lp:juju-core failed. Below is the output from the failed tests.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
? launchpad.
? launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
? launchpad.
ok launchpad.
ok launchpad.
ok launchpad.
? launchpad.ne...
Preview Diff
1 | === modified file 'cmd/juju/status_test.go' |
2 | --- cmd/juju/status_test.go 2014-01-16 05:28:03 +0000 |
3 | +++ cmd/juju/status_test.go 2014-01-21 04:39:14 +0000 |
4 | @@ -247,6 +247,10 @@ |
5 | }, |
6 | |
7 | startAliveMachine{"0"}, |
8 | + setAddresses{"0", []instance.Address{ |
9 | + instance.NewAddress("10.0.0.1"), |
10 | + instance.NewAddress("dummyenv-0.dns"), |
11 | + }}, |
12 | expect{ |
13 | "simulate the PA starting an instance in response to the state change", |
14 | M{ |
15 | @@ -297,6 +301,10 @@ |
16 | ), test( |
17 | "instance with different hardware characteristics", |
18 | addMachine{"0", machineCons, state.JobManageEnviron}, |
19 | + setAddresses{"0", []instance.Address{ |
20 | + instance.NewAddress("10.0.0.1"), |
21 | + instance.NewAddress("dummyenv-0.dns"), |
22 | + }}, |
23 | startAliveMachine{"0"}, |
24 | setMachineStatus{"0", params.StatusStarted, ""}, |
25 | expect{ |
26 | @@ -316,6 +324,26 @@ |
27 | }, |
28 | }, |
29 | ), test( |
30 | + "instance without addresses", |
31 | + addMachine{"0", machineCons, state.JobManageEnviron}, |
32 | + startAliveMachine{"0"}, |
33 | + setMachineStatus{"0", params.StatusStarted, ""}, |
34 | + expect{ |
35 | + "machine 0 has no dns-name", |
36 | + M{ |
37 | + "environment": "dummyenv", |
38 | + "machines": M{ |
39 | + "0": M{ |
40 | + "agent-state": "started", |
41 | + "instance-id": "dummyenv-0", |
42 | + "series": "quantal", |
43 | + "hardware": "arch=amd64 cpu-cores=2 mem=8192M root-disk=8192M", |
44 | + }, |
45 | + }, |
46 | + "services": M{}, |
47 | + }, |
48 | + }, |
49 | + ), test( |
50 | "test pending and missing machines", |
51 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
52 | expect{ |
53 | @@ -352,6 +380,7 @@ |
54 | ), test( |
55 | "add two services and expose one, then add 2 more machines and some units", |
56 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
57 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
58 | startAliveMachine{"0"}, |
59 | setMachineStatus{"0", params.StatusStarted, ""}, |
60 | addCharm{"dummy"}, |
61 | @@ -387,9 +416,11 @@ |
62 | }, |
63 | |
64 | addMachine{machineId: "1", job: state.JobHostUnits}, |
65 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
66 | startAliveMachine{"1"}, |
67 | setMachineStatus{"1", params.StatusStarted, ""}, |
68 | addMachine{machineId: "2", job: state.JobHostUnits}, |
69 | + setAddresses{"2", []instance.Address{instance.NewAddress("dummyenv-2.dns")}}, |
70 | startAliveMachine{"2"}, |
71 | setMachineStatus{"2", params.StatusStarted, ""}, |
72 | expect{ |
73 | @@ -440,6 +471,7 @@ |
74 | "open-ports": L{ |
75 | "2/tcp", "3/tcp", "2/udp", "10/udp", |
76 | }, |
77 | + "public-address": "dummyenv-2.dns", |
78 | }, |
79 | }, |
80 | }, |
81 | @@ -451,6 +483,7 @@ |
82 | "machine": "1", |
83 | "agent-state": "down", |
84 | "agent-state-info": "(started)", |
85 | + "public-address": "dummyenv-1.dns", |
86 | }, |
87 | }, |
88 | }, |
89 | @@ -461,8 +494,10 @@ |
90 | addMachine{machineId: "3", job: state.JobHostUnits}, |
91 | startMachine{"3"}, |
92 | // Simulate some status with info, while the agent is down. |
93 | + setAddresses{"3", []instance.Address{instance.NewAddress("dummyenv-3.dns")}}, |
94 | setMachineStatus{"3", params.StatusStopped, "Really?"}, |
95 | addMachine{machineId: "4", job: state.JobHostUnits}, |
96 | + setAddresses{"4", []instance.Address{instance.NewAddress("dummyenv-4.dns")}}, |
97 | startAliveMachine{"4"}, |
98 | setMachineStatus{"4", params.StatusError, "Beware the red toys"}, |
99 | ensureDyingUnit{"dummy-service/0"}, |
100 | @@ -510,6 +545,7 @@ |
101 | "open-ports": L{ |
102 | "2/tcp", "3/tcp", "2/udp", "10/udp", |
103 | }, |
104 | + "public-address": "dummyenv-2.dns", |
105 | }, |
106 | }, |
107 | }, |
108 | @@ -522,6 +558,7 @@ |
109 | "life": "dying", |
110 | "agent-state": "down", |
111 | "agent-state-info": "(started)", |
112 | + "public-address": "dummyenv-1.dns", |
113 | }, |
114 | }, |
115 | }, |
116 | @@ -547,6 +584,7 @@ |
117 | "life": "dying", |
118 | "agent-state": "down", |
119 | "agent-state-info": "(started)", |
120 | + "public-address": "dummyenv-1.dns", |
121 | }, |
122 | }, |
123 | }, |
124 | @@ -573,6 +611,7 @@ |
125 | "open-ports": L{ |
126 | "2/tcp", "3/tcp", "2/udp", "10/udp", |
127 | }, |
128 | + "public-address": "dummyenv-2.dns", |
129 | }, |
130 | }, |
131 | }, |
132 | @@ -597,6 +636,7 @@ |
133 | "life": "dying", |
134 | "agent-state": "down", |
135 | "agent-state-info": "(started)", |
136 | + "public-address": "dummyenv-1.dns", |
137 | }, |
138 | }, |
139 | }, |
140 | @@ -623,6 +663,7 @@ |
141 | "open-ports": L{ |
142 | "2/tcp", "3/tcp", "2/udp", "10/udp", |
143 | }, |
144 | + "public-address": "dummyenv-2.dns", |
145 | }, |
146 | }, |
147 | }, |
148 | @@ -648,6 +689,7 @@ |
149 | "life": "dying", |
150 | "agent-state": "down", |
151 | "agent-state-info": "(started)", |
152 | + "public-address": "dummyenv-1.dns", |
153 | }, |
154 | }, |
155 | }, |
156 | @@ -662,6 +704,7 @@ |
157 | "open-ports": L{ |
158 | "2/tcp", "3/tcp", "2/udp", "10/udp", |
159 | }, |
160 | + "public-address": "dummyenv-2.dns", |
161 | }, |
162 | }, |
163 | }, |
164 | @@ -707,6 +750,7 @@ |
165 | test( |
166 | "complex scenario with multiple related services", |
167 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
168 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
169 | startAliveMachine{"0"}, |
170 | setMachineStatus{"0", params.StatusStarted, ""}, |
171 | addCharm{"wordpress"}, |
172 | @@ -716,6 +760,7 @@ |
173 | addService{"project", "wordpress"}, |
174 | setServiceExposed{"project", true}, |
175 | addMachine{machineId: "1", job: state.JobHostUnits}, |
176 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
177 | startAliveMachine{"1"}, |
178 | setMachineStatus{"1", params.StatusStarted, ""}, |
179 | addAliveUnit{"project", "1"}, |
180 | @@ -724,6 +769,7 @@ |
181 | addService{"mysql", "mysql"}, |
182 | setServiceExposed{"mysql", true}, |
183 | addMachine{machineId: "2", job: state.JobHostUnits}, |
184 | + setAddresses{"2", []instance.Address{instance.NewAddress("dummyenv-2.dns")}}, |
185 | startAliveMachine{"2"}, |
186 | setMachineStatus{"2", params.StatusStarted, ""}, |
187 | addAliveUnit{"mysql", "2"}, |
188 | @@ -732,6 +778,7 @@ |
189 | addService{"varnish", "varnish"}, |
190 | setServiceExposed{"varnish", true}, |
191 | addMachine{machineId: "3", job: state.JobHostUnits}, |
192 | + setAddresses{"3", []instance.Address{instance.NewAddress("dummyenv-3.dns")}}, |
193 | startAliveMachine{"3"}, |
194 | setMachineStatus{"3", params.StatusStarted, ""}, |
195 | addUnit{"varnish", "3"}, |
196 | @@ -739,6 +786,7 @@ |
197 | addService{"private", "wordpress"}, |
198 | setServiceExposed{"private", true}, |
199 | addMachine{machineId: "4", job: state.JobHostUnits}, |
200 | + setAddresses{"4", []instance.Address{instance.NewAddress("dummyenv-4.dns")}}, |
201 | startAliveMachine{"4"}, |
202 | setMachineStatus{"4", params.StatusStarted, ""}, |
203 | addUnit{"private", "4"}, |
204 | @@ -764,8 +812,9 @@ |
205 | "exposed": true, |
206 | "units": M{ |
207 | "project/0": M{ |
208 | - "machine": "1", |
209 | - "agent-state": "started", |
210 | + "machine": "1", |
211 | + "agent-state": "started", |
212 | + "public-address": "dummyenv-1.dns", |
213 | }, |
214 | }, |
215 | "relations": M{ |
216 | @@ -778,8 +827,9 @@ |
217 | "exposed": true, |
218 | "units": M{ |
219 | "mysql/0": M{ |
220 | - "machine": "2", |
221 | - "agent-state": "started", |
222 | + "machine": "2", |
223 | + "agent-state": "started", |
224 | + "public-address": "dummyenv-2.dns", |
225 | }, |
226 | }, |
227 | "relations": M{ |
228 | @@ -791,8 +841,9 @@ |
229 | "exposed": true, |
230 | "units": M{ |
231 | "varnish/0": M{ |
232 | - "machine": "3", |
233 | - "agent-state": "pending", |
234 | + "machine": "3", |
235 | + "agent-state": "pending", |
236 | + "public-address": "dummyenv-3.dns", |
237 | }, |
238 | }, |
239 | "relations": M{ |
240 | @@ -804,8 +855,9 @@ |
241 | "exposed": true, |
242 | "units": M{ |
243 | "private/0": M{ |
244 | - "machine": "4", |
245 | - "agent-state": "pending", |
246 | + "machine": "4", |
247 | + "agent-state": "pending", |
248 | + "public-address": "dummyenv-4.dns", |
249 | }, |
250 | }, |
251 | "relations": M{ |
252 | @@ -818,6 +870,7 @@ |
253 | ), test( |
254 | "simple peer scenario", |
255 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
256 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
257 | startAliveMachine{"0"}, |
258 | setMachineStatus{"0", params.StatusStarted, ""}, |
259 | addCharm{"riak"}, |
260 | @@ -826,16 +879,19 @@ |
261 | addService{"riak", "riak"}, |
262 | setServiceExposed{"riak", true}, |
263 | addMachine{machineId: "1", job: state.JobHostUnits}, |
264 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
265 | startAliveMachine{"1"}, |
266 | setMachineStatus{"1", params.StatusStarted, ""}, |
267 | addAliveUnit{"riak", "1"}, |
268 | setUnitStatus{"riak/0", params.StatusStarted, ""}, |
269 | addMachine{machineId: "2", job: state.JobHostUnits}, |
270 | + setAddresses{"2", []instance.Address{instance.NewAddress("dummyenv-2.dns")}}, |
271 | startAliveMachine{"2"}, |
272 | setMachineStatus{"2", params.StatusStarted, ""}, |
273 | addAliveUnit{"riak", "2"}, |
274 | setUnitStatus{"riak/1", params.StatusStarted, ""}, |
275 | addMachine{machineId: "3", job: state.JobHostUnits}, |
276 | + setAddresses{"3", []instance.Address{instance.NewAddress("dummyenv-3.dns")}}, |
277 | startAliveMachine{"3"}, |
278 | setMachineStatus{"3", params.StatusStarted, ""}, |
279 | addAliveUnit{"riak", "3"}, |
280 | @@ -857,16 +913,19 @@ |
281 | "exposed": true, |
282 | "units": M{ |
283 | "riak/0": M{ |
284 | - "machine": "1", |
285 | - "agent-state": "started", |
286 | + "machine": "1", |
287 | + "agent-state": "started", |
288 | + "public-address": "dummyenv-1.dns", |
289 | }, |
290 | "riak/1": M{ |
291 | - "machine": "2", |
292 | - "agent-state": "started", |
293 | + "machine": "2", |
294 | + "agent-state": "started", |
295 | + "public-address": "dummyenv-2.dns", |
296 | }, |
297 | "riak/2": M{ |
298 | - "machine": "3", |
299 | - "agent-state": "started", |
300 | + "machine": "3", |
301 | + "agent-state": "started", |
302 | + "public-address": "dummyenv-3.dns", |
303 | }, |
304 | }, |
305 | "relations": M{ |
306 | @@ -882,6 +941,7 @@ |
307 | test( |
308 | "one service with one subordinate service", |
309 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
310 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
311 | startAliveMachine{"0"}, |
312 | setMachineStatus{"0", params.StatusStarted, ""}, |
313 | addCharm{"wordpress"}, |
314 | @@ -891,6 +951,7 @@ |
315 | addService{"wordpress", "wordpress"}, |
316 | setServiceExposed{"wordpress", true}, |
317 | addMachine{machineId: "1", job: state.JobHostUnits}, |
318 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
319 | startAliveMachine{"1"}, |
320 | setMachineStatus{"1", params.StatusStarted, ""}, |
321 | addAliveUnit{"wordpress", "1"}, |
322 | @@ -899,6 +960,7 @@ |
323 | addService{"mysql", "mysql"}, |
324 | setServiceExposed{"mysql", true}, |
325 | addMachine{machineId: "2", job: state.JobHostUnits}, |
326 | + setAddresses{"2", []instance.Address{instance.NewAddress("dummyenv-2.dns")}}, |
327 | startAliveMachine{"2"}, |
328 | setMachineStatus{"2", params.StatusStarted, ""}, |
329 | addAliveUnit{"mysql", "2"}, |
330 | @@ -940,6 +1002,7 @@ |
331 | "agent-state": "started", |
332 | }, |
333 | }, |
334 | + "public-address": "dummyenv-1.dns", |
335 | }, |
336 | }, |
337 | "relations": M{ |
338 | @@ -960,6 +1023,7 @@ |
339 | "agent-state-info": "somehow lost in all those logs", |
340 | }, |
341 | }, |
342 | + "public-address": "dummyenv-2.dns", |
343 | }, |
344 | }, |
345 | "relations": M{ |
346 | @@ -1003,6 +1067,7 @@ |
347 | "agent-state": "started", |
348 | }, |
349 | }, |
350 | + "public-address": "dummyenv-1.dns", |
351 | }, |
352 | }, |
353 | "relations": M{ |
354 | @@ -1023,6 +1088,7 @@ |
355 | "agent-state-info": "somehow lost in all those logs", |
356 | }, |
357 | }, |
358 | + "public-address": "dummyenv-2.dns", |
359 | }, |
360 | }, |
361 | "relations": M{ |
362 | @@ -1065,6 +1131,7 @@ |
363 | "agent-state": "started", |
364 | }, |
365 | }, |
366 | + "public-address": "dummyenv-1.dns", |
367 | }, |
368 | }, |
369 | "relations": M{ |
370 | @@ -1096,6 +1163,7 @@ |
371 | addService{"wordpress", "wordpress"}, |
372 | setServiceExposed{"wordpress", true}, |
373 | addMachine{machineId: "1", job: state.JobHostUnits}, |
374 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
375 | startAliveMachine{"1"}, |
376 | setMachineStatus{"1", params.StatusStarted, ""}, |
377 | addAliveUnit{"wordpress", "1"}, |
378 | @@ -1140,6 +1208,7 @@ |
379 | "agent-state": "started", |
380 | }, |
381 | }, |
382 | + "public-address": "dummyenv-1.dns", |
383 | }, |
384 | }, |
385 | "relations": M{ |
386 | @@ -1161,6 +1230,7 @@ |
387 | ), test( |
388 | "machines with containers", |
389 | addMachine{machineId: "0", job: state.JobManageEnviron}, |
390 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
391 | startAliveMachine{"0"}, |
392 | setMachineStatus{"0", params.StatusStarted, ""}, |
393 | addCharm{"mysql"}, |
394 | @@ -1168,6 +1238,7 @@ |
395 | setServiceExposed{"mysql", true}, |
396 | |
397 | addMachine{machineId: "1", job: state.JobHostUnits}, |
398 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
399 | startAliveMachine{"1"}, |
400 | setMachineStatus{"1", params.StatusStarted, ""}, |
401 | addAliveUnit{"mysql", "1"}, |
402 | @@ -1175,6 +1246,7 @@ |
403 | |
404 | // A container on machine 1. |
405 | addContainer{"1", "1/lxc/0", state.JobHostUnits}, |
406 | + setAddresses{"1/lxc/0", []instance.Address{instance.NewAddress("dummyenv-2.dns")}}, |
407 | startAliveMachine{"1/lxc/0"}, |
408 | setMachineStatus{"1/lxc/0", params.StatusStarted, ""}, |
409 | addAliveUnit{"mysql", "1/lxc/0"}, |
410 | @@ -1183,6 +1255,7 @@ |
411 | |
412 | // A nested container. |
413 | addContainer{"1/lxc/0", "1/lxc/0/lxc/0", state.JobHostUnits}, |
414 | + setAddresses{"1/lxc/0/lxc/0", []instance.Address{instance.NewAddress("dummyenv-3.dns")}}, |
415 | startAliveMachine{"1/lxc/0/lxc/0"}, |
416 | setMachineStatus{"1/lxc/0/lxc/0", params.StatusStarted, ""}, |
417 | |
418 | @@ -1200,12 +1273,14 @@ |
419 | "exposed": true, |
420 | "units": M{ |
421 | "mysql/0": M{ |
422 | - "machine": "1", |
423 | - "agent-state": "started", |
424 | + "machine": "1", |
425 | + "agent-state": "started", |
426 | + "public-address": "dummyenv-1.dns", |
427 | }, |
428 | "mysql/1": M{ |
429 | - "machine": "1/lxc/0", |
430 | - "agent-state": "started", |
431 | + "machine": "1/lxc/0", |
432 | + "agent-state": "started", |
433 | + "public-address": "dummyenv-2.dns", |
434 | }, |
435 | }, |
436 | }, |
437 | @@ -1228,8 +1303,9 @@ |
438 | "exposed": true, |
439 | "units": M{ |
440 | "mysql/1": M{ |
441 | - "machine": "1/lxc/0", |
442 | - "agent-state": "started", |
443 | + "machine": "1/lxc/0", |
444 | + "agent-state": "started", |
445 | + "public-address": "dummyenv-2.dns", |
446 | }, |
447 | }, |
448 | }, |
449 | @@ -1239,9 +1315,11 @@ |
450 | ), test( |
451 | "service with out of date charm", |
452 | addMachine{machineId: "0", job: state.JobManageState}, |
453 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
454 | startAliveMachine{"0"}, |
455 | setMachineStatus{"0", params.StatusStarted, ""}, |
456 | addMachine{machineId: "1", job: state.JobHostUnits}, |
457 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
458 | startAliveMachine{"1"}, |
459 | setMachineStatus{"1", params.StatusStarted, ""}, |
460 | addCharm{"mysql"}, |
461 | @@ -1265,8 +1343,9 @@ |
462 | "exposed": true, |
463 | "units": M{ |
464 | "mysql/0": M{ |
465 | - "machine": "1", |
466 | - "agent-state": "pending", |
467 | + "machine": "1", |
468 | + "agent-state": "pending", |
469 | + "public-address": "dummyenv-1.dns", |
470 | }, |
471 | }, |
472 | }, |
473 | @@ -1276,9 +1355,11 @@ |
474 | ), test( |
475 | "unit with out of date charm", |
476 | addMachine{machineId: "0", job: state.JobManageState}, |
477 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
478 | startAliveMachine{"0"}, |
479 | setMachineStatus{"0", params.StatusStarted, ""}, |
480 | addMachine{machineId: "1", job: state.JobHostUnits}, |
481 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
482 | startAliveMachine{"1"}, |
483 | setMachineStatus{"1", params.StatusStarted, ""}, |
484 | addCharm{"mysql"}, |
485 | @@ -1306,6 +1387,7 @@ |
486 | "machine": "1", |
487 | "agent-state": "started", |
488 | "upgrading-from": "cs:quantal/mysql-1", |
489 | + "public-address": "dummyenv-1.dns", |
490 | }, |
491 | }, |
492 | }, |
493 | @@ -1315,9 +1397,11 @@ |
494 | ), test( |
495 | "service and unit with out of date charms", |
496 | addMachine{machineId: "0", job: state.JobManageState}, |
497 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
498 | startAliveMachine{"0"}, |
499 | setMachineStatus{"0", params.StatusStarted, ""}, |
500 | addMachine{machineId: "1", job: state.JobHostUnits}, |
501 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
502 | startAliveMachine{"1"}, |
503 | setMachineStatus{"1", params.StatusStarted, ""}, |
504 | addCharm{"mysql"}, |
505 | @@ -1347,6 +1431,7 @@ |
506 | "machine": "1", |
507 | "agent-state": "started", |
508 | "upgrading-from": "cs:quantal/mysql-1", |
509 | + "public-address": "dummyenv-1.dns", |
510 | }, |
511 | }, |
512 | }, |
513 | @@ -1356,9 +1441,11 @@ |
514 | ), test( |
515 | "service with local charm not shown as out of date", |
516 | addMachine{machineId: "0", job: state.JobManageState}, |
517 | + setAddresses{"0", []instance.Address{instance.NewAddress("dummyenv-0.dns")}}, |
518 | startAliveMachine{"0"}, |
519 | setMachineStatus{"0", params.StatusStarted, ""}, |
520 | addMachine{machineId: "1", job: state.JobHostUnits}, |
521 | + setAddresses{"1", []instance.Address{instance.NewAddress("dummyenv-1.dns")}}, |
522 | startAliveMachine{"1"}, |
523 | setMachineStatus{"1", params.StatusStarted, ""}, |
524 | addCharm{"mysql"}, |
525 | @@ -1387,6 +1474,7 @@ |
526 | "machine": "1", |
527 | "agent-state": "started", |
528 | "upgrading-from": "cs:quantal/mysql-1", |
529 | + "public-address": "dummyenv-1.dns", |
530 | }, |
531 | }, |
532 | }, |
533 | @@ -1474,6 +1562,18 @@ |
534 | ctx.pingers[m.Id()] = pinger |
535 | } |
536 | |
537 | +type setAddresses struct { |
538 | + machineId string |
539 | + addresses []instance.Address |
540 | +} |
541 | + |
542 | +func (sa setAddresses) step(c *gc.C, ctx *context) { |
543 | + m, err := ctx.st.Machine(sa.machineId) |
544 | + c.Assert(err, gc.IsNil) |
545 | + err = m.SetAddresses(sa.addresses) |
546 | + c.Assert(err, gc.IsNil) |
547 | +} |
548 | + |
549 | type setTools struct { |
550 | machineId string |
551 | version version.Binary |
552 | |
553 | === modified file 'state/machine.go' |
554 | --- state/machine.go 2014-01-20 21:00:43 +0000 |
555 | +++ state/machine.go 2014-01-21 04:39:14 +0000 |
556 | @@ -720,10 +720,20 @@ |
557 | } |
558 | |
559 | // Addresses returns any hostnames and ips associated with a machine, |
560 | -// determined by asking the provider. |
561 | +// determined both by the machine itself, and by asking the provider. |
562 | +// |
563 | +// The addresses returned by the provider shadow any of the addresses |
564 | +// that the machine reported with the same address value. |
565 | func (m *Machine) Addresses() (addresses []instance.Address) { |
566 | + merged := make(map[string]instance.Address) |
567 | + for _, address := range m.doc.MachineAddresses { |
568 | + merged[address.Value] = address.InstanceAddress() |
569 | + } |
570 | for _, address := range m.doc.Addresses { |
571 | - addresses = append(addresses, address.InstanceAddress()) |
572 | + merged[address.Value] = address.InstanceAddress() |
573 | + } |
574 | + for _, address := range merged { |
575 | + addresses = append(addresses, address) |
576 | } |
577 | return |
578 | } |
579 | |
580 | === modified file 'state/statecmd/status.go' |
581 | --- state/statecmd/status.go 2014-01-16 05:28:03 +0000 |
582 | +++ state/statecmd/status.go 2014-01-21 04:39:14 +0000 |
583 | @@ -315,7 +315,7 @@ |
584 | status.InstanceId = instid |
585 | inst, ok := context.instances[instid] |
586 | if ok { |
587 | - status.DNSName, _ = inst.DNSName() |
588 | + status.DNSName = instance.SelectPublicAddress(machine.Addresses()) |
589 | status.InstanceState = inst.Status() |
590 | } else { |
591 | // Double plus ungood. There is an instance id recorded |
Reviewers: mp+202397_ code.launchpad. net,
Message:
Please take a look.
Description:
use machine.Addresses() for status dns-name
juju status now uses state.Machine. Addresses( ) instead Instance. DNSName( ) for the dns-name field
of instance.
of machines. This returns the same value as before for
all providers (except dummy).
state.Machine. Addresses has been updated to merge the
machine addresses and provider addresses. The provider
addresses replace any of the machine addresses with the
same address string/value.
This change means that local provider instances now
have dns-name associated; this enables "juju ssh <id>"
and co. for the local provider.
https:/ /code.launchpad .net/~axwalk/ juju-core/ status- addresses- publicaddress/ +merge/ 202397
(do not edit description out of merge proposal)
Please review this at https:/ /codereview. appspot. com/54800043/
Affected files (+113, -24 lines): status_ test.go status. go
A [revision details]
M cmd/juju/
M state/machine.go
M state/statecmd/