Merge lp:~free.ekanayaka/landscape-client/juju-machine-info into lp:~landscape/landscape-client/trunk
- juju-machine-info
- Merge into trunk
Status: | Merged | ||||
---|---|---|---|---|---|
Approved by: | Free Ekanayaka | ||||
Approved revision: | 786 | ||||
Merged at revision: | 783 | ||||
Proposed branch: | lp:~free.ekanayaka/landscape-client/juju-machine-info | ||||
Merge into: | lp:~landscape/landscape-client/trunk | ||||
Diff against target: |
332 lines (+68/-37) 9 files modified
landscape/broker/registration.py (+1/-1) landscape/broker/service.py (+2/-2) landscape/broker/tests/helpers.py (+1/-11) landscape/broker/tests/test_exchange.py (+1/-2) landscape/broker/tests/test_registration.py (+0/-1) landscape/lib/juju.py (+29/-9) landscape/lib/tests/test_juju.py (+23/-10) landscape/monitor/jujuinfo.py (+9/-1) landscape/monitor/tests/test_jujuinfo.py (+2/-0) |
||||
To merge this branch: | bzr merge lp:~free.ekanayaka/landscape-client/juju-machine-info | ||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Adam Collard (community) | Approve | ||
Alberto Donato (community) | Approve | ||
Review via email: mp+231895@code.launchpad.net |
Commit message
This branch changes the get_juju_info utility to return information
about the Juju machine ID the client runs in. Since we're in the
middle of the transition, both the old info with unit names and the
new info with the machine ID are returned. When the transition completes
in the server too the old info can be dropped.
Description of the change
This branch changes the get_juju_info utility to return information
about the Juju machine ID the client runs in. Since we're in the
middle of the transition, both the old info with unit names and the
new info with the machine ID are returned. When the transition completes
in the server too the old info can be dropped.
- 784. By Free Ekanayaka
-
Fix failing tests
Alberto Donato (ack) wrote : | # |
Code looks good, just a question:
what's the plan for the charm? Will we just add the "machine-id" and keep "unit-name" for backwards compatibility?
Free Ekanayaka (free.ekanayaka) wrote : | # |
Alberto: for the charm we don't need backward compatibility since never released and LDS with support for Juju integration. So the current code in the charm is basically dead code from the user perspective, and we can change it to send just machine-id. Said that, for sake of our internal migration we'll keep both for a bit, till we complete the process.
Free Ekanayaka (free.ekanayaka) wrote : | # |
Thanks Adam, replied/fixed all three issues.
- 785. By Free Ekanayaka
-
Address review comments
Adam Collard (adam-collard) wrote : | # |
Thanks Free.
Lint issue:
landscape/
Otherwise looks good. +1
- 786. By Free Ekanayaka
-
Fix lint
Preview Diff
1 | === modified file 'landscape/broker/registration.py' | |||
2 | --- landscape/broker/registration.py 2014-07-16 18:04:22 +0000 | |||
3 | +++ landscape/broker/registration.py 2014-08-28 07:37:26 +0000 | |||
4 | @@ -126,7 +126,7 @@ | |||
5 | 126 | 126 | ||
6 | 127 | def _get_juju_data(self): | 127 | def _get_juju_data(self): |
7 | 128 | """Load Juju information.""" | 128 | """Load Juju information.""" |
9 | 129 | juju_info = get_juju_info(self._config) | 129 | juju_info = get_juju_info(self._config)[0] |
10 | 130 | if juju_info is None: | 130 | if juju_info is None: |
11 | 131 | return None | 131 | return None |
12 | 132 | self._juju_data = juju_info # A list of dicts | 132 | self._juju_data = juju_info # A list of dicts |
13 | 133 | 133 | ||
14 | === modified file 'landscape/broker/service.py' | |||
15 | --- landscape/broker/service.py 2013-05-07 22:47:06 +0000 | |||
16 | +++ landscape/broker/service.py 2014-08-28 07:37:26 +0000 | |||
17 | @@ -1,7 +1,7 @@ | |||
18 | 1 | """Deployment code for the monitor.""" | 1 | """Deployment code for the monitor.""" |
19 | 2 | 2 | ||
20 | 3 | import os | 3 | import os |
22 | 4 | from landscape.lib.fetch import fetch_async | 4 | |
23 | 5 | from landscape.service import LandscapeService, run_landscape_service | 5 | from landscape.service import LandscapeService, run_landscape_service |
24 | 6 | from landscape.amp import ComponentPublisher | 6 | from landscape.amp import ComponentPublisher |
25 | 7 | from landscape.broker.registration import RegistrationHandler, Identity | 7 | from landscape.broker.registration import RegistrationHandler, Identity |
26 | @@ -61,7 +61,7 @@ | |||
27 | 61 | self.reactor, self.identity, self.exchanger, config) | 61 | self.reactor, self.identity, self.exchanger, config) |
28 | 62 | self.registration = RegistrationHandler( | 62 | self.registration = RegistrationHandler( |
29 | 63 | config, self.identity, self.reactor, self.exchanger, self.pinger, | 63 | config, self.identity, self.reactor, self.exchanger, self.pinger, |
31 | 64 | self.message_store, fetch_async) | 64 | self.message_store) |
32 | 65 | self.broker = BrokerServer(self.config, self.reactor, self.exchanger, | 65 | self.broker = BrokerServer(self.config, self.reactor, self.exchanger, |
33 | 66 | self.registration, self.message_store, | 66 | self.registration, self.message_store, |
34 | 67 | self.pinger) | 67 | self.pinger) |
35 | 68 | 68 | ||
36 | === modified file 'landscape/broker/tests/helpers.py' | |||
37 | --- landscape/broker/tests/helpers.py 2014-06-09 08:18:05 +0000 | |||
38 | +++ landscape/broker/tests/helpers.py 2014-08-28 07:37:26 +0000 | |||
39 | @@ -7,7 +7,6 @@ | |||
40 | 7 | """ | 7 | """ |
41 | 8 | import os | 8 | import os |
42 | 9 | 9 | ||
43 | 10 | from landscape.lib.fetch import fetch_async | ||
44 | 11 | from landscape.lib.persist import Persist | 10 | from landscape.lib.persist import Persist |
45 | 12 | from landscape.watchdog import bootstrap_list | 11 | from landscape.watchdog import bootstrap_list |
46 | 13 | from landscape.reactor import FakeReactor | 12 | from landscape.reactor import FakeReactor |
47 | @@ -112,20 +111,12 @@ | |||
48 | 112 | The following attributes will be set in your test case: | 111 | The following attributes will be set in your test case: |
49 | 113 | 112 | ||
50 | 114 | - C{handler}: A L{RegistrationHandler}. | 113 | - C{handler}: A L{RegistrationHandler}. |
51 | 115 | |||
52 | 116 | - C{fetch_func}: The C{fetch_async} function used by the C{handler}, it | ||
53 | 117 | can be customised by test cases. | ||
54 | 118 | """ | 114 | """ |
55 | 119 | 115 | ||
56 | 120 | def set_up(self, test_case): | 116 | def set_up(self, test_case): |
57 | 121 | super(RegistrationHelper, self).set_up(test_case) | 117 | super(RegistrationHelper, self).set_up(test_case) |
58 | 122 | test_case.pinger = Pinger(test_case.reactor, test_case.identity, | 118 | test_case.pinger = Pinger(test_case.reactor, test_case.identity, |
59 | 123 | test_case.exchanger, test_case.config) | 119 | test_case.exchanger, test_case.config) |
60 | 124 | |||
61 | 125 | def fetch_func(*args, **kwargs): | ||
62 | 126 | return test_case.fetch_func(*args, **kwargs) | ||
63 | 127 | |||
64 | 128 | test_case.fetch_func = fetch_async | ||
65 | 129 | test_case.config.cloud = getattr(test_case, "cloud", False) | 120 | test_case.config.cloud = getattr(test_case, "cloud", False) |
66 | 130 | if hasattr(test_case, "juju_contents"): | 121 | if hasattr(test_case, "juju_contents"): |
67 | 131 | if not os.path.exists(test_case.config.juju_directory): | 122 | if not os.path.exists(test_case.config.juju_directory): |
68 | @@ -135,8 +126,7 @@ | |||
69 | 135 | dirname=test_case.config.juju_directory, suffix=".json") | 126 | dirname=test_case.config.juju_directory, suffix=".json") |
70 | 136 | test_case.handler = RegistrationHandler( | 127 | test_case.handler = RegistrationHandler( |
71 | 137 | test_case.config, test_case.identity, test_case.reactor, | 128 | test_case.config, test_case.identity, test_case.reactor, |
74 | 138 | test_case.exchanger, test_case.pinger, test_case.mstore, | 129 | test_case.exchanger, test_case.pinger, test_case.mstore) |
73 | 139 | fetch_async=fetch_func) | ||
75 | 140 | 130 | ||
76 | 141 | 131 | ||
77 | 142 | class BrokerServerHelper(RegistrationHelper): | 132 | class BrokerServerHelper(RegistrationHelper): |
78 | 143 | 133 | ||
79 | === modified file 'landscape/broker/tests/test_exchange.py' | |||
80 | --- landscape/broker/tests/test_exchange.py 2014-07-16 11:41:29 +0000 | |||
81 | +++ landscape/broker/tests/test_exchange.py 2014-08-28 07:37:26 +0000 | |||
82 | @@ -1,7 +1,6 @@ | |||
83 | 1 | from landscape import SERVER_API, CLIENT_API | 1 | from landscape import SERVER_API, CLIENT_API |
84 | 2 | from landscape.lib.persist import Persist | 2 | from landscape.lib.persist import Persist |
85 | 3 | from landscape.lib.hashlib import md5 | 3 | from landscape.lib.hashlib import md5 |
86 | 4 | from landscape.lib.fetch import fetch_async | ||
87 | 5 | from landscape.schema import Message, Int | 4 | from landscape.schema import Message, Int |
88 | 6 | from landscape.broker.config import BrokerConfiguration | 5 | from landscape.broker.config import BrokerConfiguration |
89 | 7 | from landscape.broker.exchange import get_accepted_types_diff, MessageExchange | 6 | from landscape.broker.exchange import get_accepted_types_diff, MessageExchange |
90 | @@ -1061,7 +1060,7 @@ | |||
91 | 1061 | # message types that we want to catch as well | 1060 | # message types that we want to catch as well |
92 | 1062 | self.handler = RegistrationHandler( | 1061 | self.handler = RegistrationHandler( |
93 | 1063 | self.config, self.identity, self.reactor, self.exchanger, | 1062 | self.config, self.identity, self.reactor, self.exchanger, |
95 | 1064 | self.pinger, self.mstore, fetch_async) | 1063 | self.pinger, self.mstore) |
96 | 1065 | 1064 | ||
97 | 1066 | def test_register_accepted_message_type(self): | 1065 | def test_register_accepted_message_type(self): |
98 | 1067 | self.exchanger.register_client_accepted_message_type("type-B") | 1066 | self.exchanger.register_client_accepted_message_type("type-B") |
99 | 1068 | 1067 | ||
100 | === modified file 'landscape/broker/tests/test_registration.py' | |||
101 | --- landscape/broker/tests/test_registration.py 2014-07-24 12:21:06 +0000 | |||
102 | +++ landscape/broker/tests/test_registration.py 2014-08-28 07:37:26 +0000 | |||
103 | @@ -2,7 +2,6 @@ | |||
104 | 2 | import logging | 2 | import logging |
105 | 3 | import socket | 3 | import socket |
106 | 4 | 4 | ||
107 | 5 | from landscape import SERVER_API | ||
108 | 6 | from landscape.broker.registration import ( | 5 | from landscape.broker.registration import ( |
109 | 7 | InvalidCredentialsError, Identity) | 6 | InvalidCredentialsError, Identity) |
110 | 8 | from landscape.tests.helpers import LandscapeTest | 7 | from landscape.tests.helpers import LandscapeTest |
111 | 9 | 8 | ||
112 | === modified file 'landscape/lib/juju.py' | |||
113 | --- landscape/lib/juju.py 2014-06-11 08:47:29 +0000 | |||
114 | +++ landscape/lib/juju.py 2014-08-28 07:37:26 +0000 | |||
115 | @@ -9,22 +9,28 @@ | |||
116 | 9 | 9 | ||
117 | 10 | def get_juju_info(config): | 10 | def get_juju_info(config): |
118 | 11 | """ | 11 | """ |
120 | 12 | Returns the list of Juju info or C{None} if the path referenced from | 12 | Returns available Juju info or C{None} if the path referenced from |
121 | 13 | L{config} is not a valid directory. | 13 | L{config} is not a valid directory. |
122 | 14 | 14 | ||
124 | 15 | The list of juju info is constructed by appending all the contents of | 15 | XXX At the moment this function returns a 2-tuple because we're |
125 | 16 | transitioning from unit-computer associations to machine-computer | ||
126 | 17 | associations. Once the transition is completed in the server, the | ||
127 | 18 | old format can be dropped. | ||
128 | 19 | |||
129 | 20 | The list of old juju info is constructed by appending all the contents of | ||
130 | 16 | *.json files found in the path referenced from the L{config}. | 21 | *.json files found in the path referenced from the L{config}. |
131 | 17 | """ | 22 | """ |
132 | 18 | juju_directory = config.juju_directory | 23 | juju_directory = config.juju_directory |
133 | 19 | legacy_juju_file = config.juju_filename | 24 | legacy_juju_file = config.juju_filename |
134 | 20 | 25 | ||
135 | 26 | new_juju_info = {} | ||
136 | 21 | juju_info_list = [] | 27 | juju_info_list = [] |
137 | 22 | juju_file_list = glob("%s/*.json" % juju_directory) | 28 | juju_file_list = glob("%s/*.json" % juju_directory) |
138 | 23 | 29 | ||
139 | 24 | if os.path.exists(legacy_juju_file): | 30 | if os.path.exists(legacy_juju_file): |
140 | 25 | juju_file_list.append(legacy_juju_file) | 31 | juju_file_list.append(legacy_juju_file) |
141 | 26 | 32 | ||
143 | 27 | for juju_file in juju_file_list: | 33 | for index, juju_file in enumerate(juju_file_list): |
144 | 28 | 34 | ||
145 | 29 | json_contents = read_file(juju_file) | 35 | json_contents = read_file(juju_file) |
146 | 30 | try: | 36 | try: |
147 | @@ -36,11 +42,25 @@ | |||
148 | 36 | logging.exception( | 42 | logging.exception( |
149 | 37 | "Error attempting to read JSON from %s" % juju_file) | 43 | "Error attempting to read JSON from %s" % juju_file) |
150 | 38 | return None | 44 | return None |
156 | 39 | else: | 45 | |
157 | 40 | if "api-addresses" in juju_info: | 46 | if "api-addresses" in juju_info: |
158 | 41 | split = juju_info["api-addresses"].split() | 47 | split = juju_info["api-addresses"].split() |
159 | 42 | juju_info["api-addresses"] = split | 48 | juju_info["api-addresses"] = split |
160 | 43 | juju_info_list.append(juju_info) | 49 | |
161 | 50 | # Strip away machine-id, which is not understood by the old format | ||
162 | 51 | machine_id = juju_info.pop("machine-id", None) | ||
163 | 52 | |||
164 | 53 | if index == 0 and machine_id is not None: | ||
165 | 54 | # We care only about the first file, as the machine ID is the same | ||
166 | 55 | # for all | ||
167 | 56 | new_juju_info["environment-uuid"] = juju_info["environment-uuid"] | ||
168 | 57 | new_juju_info["api-addresses"] = juju_info["api-addresses"] | ||
169 | 58 | new_juju_info["machine-id"] = machine_id | ||
170 | 59 | |||
171 | 60 | juju_info_list.append(juju_info) | ||
172 | 44 | 61 | ||
173 | 45 | juju_info_list.sort(key=lambda x: x["unit-name"]) | 62 | juju_info_list.sort(key=lambda x: x["unit-name"]) |
175 | 46 | return juju_info_list or None | 63 | |
176 | 64 | if juju_info_list: | ||
177 | 65 | return juju_info_list, new_juju_info | ||
178 | 66 | return None | ||
179 | 47 | 67 | ||
180 | === modified file 'landscape/lib/tests/test_juju.py' | |||
181 | --- landscape/lib/tests/test_juju.py 2014-06-11 08:47:29 +0000 | |||
182 | +++ landscape/lib/tests/test_juju.py 2014-08-28 07:37:26 +0000 | |||
183 | @@ -6,11 +6,13 @@ | |||
184 | 6 | 6 | ||
185 | 7 | 7 | ||
186 | 8 | SAMPLE_JUJU_INFO = json.dumps({"environment-uuid": "DEAD-BEEF", | 8 | SAMPLE_JUJU_INFO = json.dumps({"environment-uuid": "DEAD-BEEF", |
187 | 9 | "machine-id": "1", | ||
188 | 9 | "unit-name": "service/0", | 10 | "unit-name": "service/0", |
189 | 10 | "api-addresses": "10.0.3.1:17070", | 11 | "api-addresses": "10.0.3.1:17070", |
190 | 11 | "private-address": "127.0.0.1"}) | 12 | "private-address": "127.0.0.1"}) |
191 | 12 | 13 | ||
192 | 13 | SAMPLE_JUJU_INFO_2 = json.dumps({"environment-uuid": "DEAD-BEEF", | 14 | SAMPLE_JUJU_INFO_2 = json.dumps({"environment-uuid": "DEAD-BEEF", |
193 | 15 | "machine-id": "1", | ||
194 | 14 | "unit-name": "service-2/0", | 16 | "unit-name": "service-2/0", |
195 | 15 | "api-addresses": "10.0.3.2:17070", | 17 | "api-addresses": "10.0.3.2:17070", |
196 | 16 | "private-address": "127.0.0.1"}) | 18 | "private-address": "127.0.0.1"}) |
197 | @@ -28,11 +30,23 @@ | |||
198 | 28 | return self.makeFile( | 30 | return self.makeFile( |
199 | 29 | contents, dirname=self.stub_config.juju_directory, suffix=".json") | 31 | contents, dirname=self.stub_config.juju_directory, suffix=".json") |
200 | 30 | 32 | ||
201 | 33 | def test_get_juju_info(self): | ||
202 | 34 | """ | ||
203 | 35 | L{get_juju_info} parses JSON data from the '*.json' files in the | ||
204 | 36 | juju_directory. A single file is present. | ||
205 | 37 | """ | ||
206 | 38 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) | ||
207 | 39 | _, juju_info = get_juju_info(self.stub_config) | ||
208 | 40 | self.assertEqual( | ||
209 | 41 | {u"environment-uuid": "DEAD-BEEF", | ||
210 | 42 | u"machine-id": "1", | ||
211 | 43 | u"api-addresses": ["10.0.3.1:17070"]}, juju_info) | ||
212 | 44 | |||
213 | 31 | def test_get_juju_info_sample_data(self): | 45 | def test_get_juju_info_sample_data(self): |
214 | 32 | """L{get_juju_info} parses JSON data from the '*.json' files in the | 46 | """L{get_juju_info} parses JSON data from the '*.json' files in the |
215 | 33 | juju_directory. A single file is present.""" | 47 | juju_directory. A single file is present.""" |
216 | 34 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) | 48 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) |
218 | 35 | juju_info = get_juju_info(self.stub_config) | 49 | juju_info, _ = get_juju_info(self.stub_config) |
219 | 36 | self.assertEqual([ | 50 | self.assertEqual([ |
220 | 37 | {u"environment-uuid": "DEAD-BEEF", | 51 | {u"environment-uuid": "DEAD-BEEF", |
221 | 38 | u"unit-name": "service/0", | 52 | u"unit-name": "service/0", |
222 | @@ -45,7 +59,7 @@ | |||
223 | 45 | landscape-client charm.""" | 59 | landscape-client charm.""" |
224 | 46 | self.stub_config = self.Config(self.makeDir(), self.makeFile( | 60 | self.stub_config = self.Config(self.makeDir(), self.makeFile( |
225 | 47 | content=SAMPLE_JUJU_INFO, basename="juju-info", suffix=".json")) | 61 | content=SAMPLE_JUJU_INFO, basename="juju-info", suffix=".json")) |
227 | 48 | juju_info = get_juju_info(self.stub_config) | 62 | juju_info, _ = get_juju_info(self.stub_config) |
228 | 49 | self.assertEqual([ | 63 | self.assertEqual([ |
229 | 50 | {u"environment-uuid": "DEAD-BEEF", | 64 | {u"environment-uuid": "DEAD-BEEF", |
230 | 51 | u"unit-name": "service/0", | 65 | u"unit-name": "service/0", |
231 | @@ -59,7 +73,7 @@ | |||
232 | 59 | """ | 73 | """ |
233 | 60 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) | 74 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) |
234 | 61 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO_2) | 75 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO_2) |
236 | 62 | juju_info = get_juju_info(self.stub_config) | 76 | juju_info, _ = get_juju_info(self.stub_config) |
237 | 63 | self.assertEqual([ | 77 | self.assertEqual([ |
238 | 64 | {u"environment-uuid": "DEAD-BEEF", | 78 | {u"environment-uuid": "DEAD-BEEF", |
239 | 65 | u"unit-name": "service-2/0", | 79 | u"unit-name": "service-2/0", |
240 | @@ -77,7 +91,7 @@ | |||
241 | 77 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) | 91 | self._create_tmp_juju_file(SAMPLE_JUJU_INFO) |
242 | 78 | self.makeFile(SAMPLE_JUJU_INFO_2, suffix=".txt", | 92 | self.makeFile(SAMPLE_JUJU_INFO_2, suffix=".txt", |
243 | 79 | dirname=self.stub_config.juju_directory) | 93 | dirname=self.stub_config.juju_directory) |
245 | 80 | juju_info = get_juju_info(self.stub_config) | 94 | juju_info, _ = get_juju_info(self.stub_config) |
246 | 81 | self.assertEqual([ | 95 | self.assertEqual([ |
247 | 82 | {u"environment-uuid": "DEAD-BEEF", | 96 | {u"environment-uuid": "DEAD-BEEF", |
248 | 83 | u"unit-name": "service/0", | 97 | u"unit-name": "service/0", |
249 | @@ -89,10 +103,9 @@ | |||
250 | 89 | If L{get_juju_info} is called with a configuration pointing to | 103 | If L{get_juju_info} is called with a configuration pointing to |
251 | 90 | an empty file, it returns C{None}. | 104 | an empty file, it returns C{None}. |
252 | 91 | """ | 105 | """ |
253 | 106 | self.log_helper.ignore_errors(ValueError) | ||
254 | 92 | self._create_tmp_juju_file("") | 107 | self._create_tmp_juju_file("") |
258 | 93 | juju_info = get_juju_info(self.stub_config) | 108 | self.assertIs(None, get_juju_info(self.stub_config)) |
256 | 94 | self.log_helper.ignore_errors(ValueError) | ||
257 | 95 | self.assertEqual(juju_info, None) | ||
259 | 96 | self.assertIn("Error attempting to read JSON", self.logfile.getvalue()) | 109 | self.assertIn("Error attempting to read JSON", self.logfile.getvalue()) |
260 | 97 | 110 | ||
261 | 98 | def test_get_juju_info_no_json_file(self): | 111 | def test_get_juju_info_no_json_file(self): |
262 | @@ -100,19 +113,19 @@ | |||
263 | 100 | If L{get_juju_info} is called with a configuration pointing to | 113 | If L{get_juju_info} is called with a configuration pointing to |
264 | 101 | a directory containing no json files, it returns None. | 114 | a directory containing no json files, it returns None. |
265 | 102 | """ | 115 | """ |
268 | 103 | juju_info = get_juju_info(self.stub_config) | 116 | self.assertIs(None, get_juju_info(self.stub_config)) |
267 | 104 | self.assertIs(juju_info, None) | ||
269 | 105 | 117 | ||
270 | 106 | def test_get_juju_info_multiple_endpoints(self): | 118 | def test_get_juju_info_multiple_endpoints(self): |
271 | 107 | """L{get_juju_info} turns space separated API addresses into a list.""" | 119 | """L{get_juju_info} turns space separated API addresses into a list.""" |
272 | 108 | juju_multiple_endpoints = json.dumps({ | 120 | juju_multiple_endpoints = json.dumps({ |
273 | 109 | "environment-uuid": "DEAD-BEEF", | 121 | "environment-uuid": "DEAD-BEEF", |
274 | 122 | "machine-id": "0", | ||
275 | 110 | "unit-name": "service/0", | 123 | "unit-name": "service/0", |
276 | 111 | "api-addresses": "10.0.3.1:17070 10.0.3.2:18080", | 124 | "api-addresses": "10.0.3.1:17070 10.0.3.2:18080", |
277 | 112 | "private-address": "127.0.0.1"}) | 125 | "private-address": "127.0.0.1"}) |
278 | 113 | 126 | ||
279 | 114 | self._create_tmp_juju_file(juju_multiple_endpoints) | 127 | self._create_tmp_juju_file(juju_multiple_endpoints) |
281 | 115 | juju_info = get_juju_info(self.stub_config) | 128 | juju_info, _ = get_juju_info(self.stub_config) |
282 | 116 | self.assertEqual([ | 129 | self.assertEqual([ |
283 | 117 | {"environment-uuid": "DEAD-BEEF", | 130 | {"environment-uuid": "DEAD-BEEF", |
284 | 118 | "unit-name": "service/0", | 131 | "unit-name": "service/0", |
285 | 119 | 132 | ||
286 | === modified file 'landscape/monitor/jujuinfo.py' | |||
287 | --- landscape/monitor/jujuinfo.py 2014-06-30 18:40:29 +0000 | |||
288 | +++ landscape/monitor/jujuinfo.py 2014-08-28 07:37:26 +0000 | |||
289 | @@ -5,7 +5,12 @@ | |||
290 | 5 | 5 | ||
291 | 6 | 6 | ||
292 | 7 | class JujuInfo(MonitorPlugin): | 7 | class JujuInfo(MonitorPlugin): |
294 | 8 | """Plugin for reporting Juju information.""" | 8 | """Plugin for reporting Juju information. |
295 | 9 | |||
296 | 10 | XXX this plugin is going to be dropped when the transition from | ||
297 | 11 | unit-computer association to machine-computer association is | ||
298 | 12 | completed on the server. | ||
299 | 13 | """ | ||
300 | 9 | 14 | ||
301 | 10 | persist_name = "juju-info" | 15 | persist_name = "juju-info" |
302 | 11 | scope = "juju" | 16 | scope = "juju" |
303 | @@ -35,6 +40,9 @@ | |||
304 | 35 | """ | 40 | """ |
305 | 36 | juju_info = get_juju_info(self.registry.config) | 41 | juju_info = get_juju_info(self.registry.config) |
306 | 37 | 42 | ||
307 | 43 | if juju_info: | ||
308 | 44 | juju_info = juju_info[0] | ||
309 | 45 | |||
310 | 38 | if juju_info != self._persist.get("juju-info"): | 46 | if juju_info != self._persist.get("juju-info"): |
311 | 39 | self._persist.set("juju-info", juju_info) | 47 | self._persist.set("juju-info", juju_info) |
312 | 40 | message = {"type": "juju-units-info", | 48 | message = {"type": "juju-units-info", |
313 | 41 | 49 | ||
314 | === modified file 'landscape/monitor/tests/test_jujuinfo.py' | |||
315 | --- landscape/monitor/tests/test_jujuinfo.py 2014-06-27 11:02:24 +0000 | |||
316 | +++ landscape/monitor/tests/test_jujuinfo.py 2014-08-28 07:37:26 +0000 | |||
317 | @@ -6,6 +6,7 @@ | |||
318 | 6 | 6 | ||
319 | 7 | 7 | ||
320 | 8 | SAMPLE_JUJU_INFO = json.dumps({"environment-uuid": "DEAD-BEEF", | 8 | SAMPLE_JUJU_INFO = json.dumps({"environment-uuid": "DEAD-BEEF", |
321 | 9 | "machine-id": "1", | ||
322 | 9 | "unit-name": "juju-unit-name", | 10 | "unit-name": "juju-unit-name", |
323 | 10 | "api-addresses": "10.0.3.1:17070", | 11 | "api-addresses": "10.0.3.1:17070", |
324 | 11 | "private-address": "127.0.0.1"}) | 12 | "private-address": "127.0.0.1"}) |
325 | @@ -72,6 +73,7 @@ | |||
326 | 72 | 73 | ||
327 | 73 | self.makeFile( | 74 | self.makeFile( |
328 | 74 | json.dumps({"environment-uuid": "FEED-BEEF", | 75 | json.dumps({"environment-uuid": "FEED-BEEF", |
329 | 76 | "machine-id": "1", | ||
330 | 75 | "unit-name": "changed-unit-name", | 77 | "unit-name": "changed-unit-name", |
331 | 76 | "api-addresses": "10.0.3.2:17070", | 78 | "api-addresses": "10.0.3.2:17070", |
332 | 77 | "private-address": "127.0.1.1"}), | 79 | "private-address": "127.0.1.1"}), |
3 inline comments