Merge lp:~free.ekanayaka/landscape-client/drop-juju-info-list into lp:~landscape/landscape-client/trunk

Proposed by Free Ekanayaka
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 785
Merged at revision: 785
Proposed branch: lp:~free.ekanayaka/landscape-client/drop-juju-info-list
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 278 lines (+2/-220)
6 files modified
landscape/broker/registration.py (+0/-3)
landscape/broker/tests/test_registration.py (+0/-53)
landscape/message_schemas.py (+1/-4)
landscape/monitor/config.py (+1/-1)
landscape/monitor/jujuinfo.py (+0/-52)
landscape/monitor/tests/test_jujuinfo.py (+0/-107)
To merge this branch: bzr merge lp:~free.ekanayaka/landscape-client/drop-juju-info-list
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Geoff Teale (community) Approve
Review via email: mp+235002@code.launchpad.net

Commit message

Drop the code that sends the legacy juju-info-list message/field,
which we don't use anymore in the server.

Description of the change

Drop the code that sends the legacy juju-info-list message/field,
which we don't use anymore in the server.

To post a comment you must log in.
Revision history for this message
Geoff Teale (tealeg) wrote :

+1 Approve.

review: Approve
Revision history for this message
Alberto Donato (ack) wrote :

LGTM, +1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/broker/registration.py'
2--- landscape/broker/registration.py 2014-09-01 13:16:02 +0000
3+++ landscape/broker/registration.py 2014-09-17 15:29:16 +0000
4@@ -199,9 +199,6 @@
5 if self._juju_data and is_version_higher(server_api, "3.3"):
6 juju_info_list, juju_info = self._juju_data
7 message["juju-info"] = juju_info
8- # XXX the juju-info-list field will be dropped once the migration
9- # to computer-machine association is complete
10- message["juju-info-list"] = juju_info_list
11
12 # The computer is a normal computer, possibly a container.
13 with_word = "with" if bool(registration_key) else "without"
14
15=== modified file 'landscape/broker/tests/test_registration.py'
16--- landscape/broker/tests/test_registration.py 2014-09-01 13:16:02 +0000
17+++ landscape/broker/tests/test_registration.py 2014-09-17 15:29:16 +0000
18@@ -521,59 +521,6 @@
19 "api-addresses": ["10.0.3.1:17070"]},
20 messages[0]["juju-info"])
21
22- def test_juju_info_list_added_when_present(self):
23- """
24- When Juju information is found in $data_dir/juju-info.d/*.json,
25- key parts of it are sent in the registration message.
26- """
27- self.mstore.set_accepted_types(["register"])
28- self.mstore.set_server_api("3.3")
29- self.config.account_name = "account_name"
30- self.reactor.fire("run")
31- self.reactor.fire("pre-exchange")
32-
33- messages = self.mstore.get_pending_messages()
34- expected = {"environment-uuid": "DEAD-BEEF",
35- "api-addresses": ["10.0.3.1:17070"],
36- "unit-name": "service/0"}
37- self.assertEqual(expected, messages[0]["juju-info-list"][0])
38-
39- def test_multiple_juju_information_added_when_present(self):
40- """
41- When Juju information is found in $data_dir/juju-info.json,
42- key parts of it are sent in the registration message.
43- """
44- # Write a second file in the config directory
45- contents = json.dumps({"environment-uuid": "DEAD-BEEF",
46- "machine-id": "1",
47- "unit-name": "service-2/0",
48- "api-addresses": "10.0.3.2:17070",
49- "private-address": "127.0.0.1"})
50- self.makeFile(
51- contents,
52- dirname=self.config.juju_directory, suffix=".json")
53-
54- self.mstore.set_accepted_types(["register"])
55- self.mstore.set_server_api("3.3")
56- self.config.account_name = "account_name"
57- self.reactor.fire("run")
58- self.reactor.fire("pre-exchange")
59-
60- messages = self.mstore.get_pending_messages()
61- juju_info = messages[0]["juju-info-list"]
62- self.assertEqual(2, len(juju_info))
63-
64- expected1 = {"environment-uuid": "DEAD-BEEF",
65- "api-addresses": ["10.0.3.1:17070"],
66- "unit-name": "service/0"}
67- self.assertIn(expected1, juju_info)
68-
69- expected2 = {"environment-uuid": "DEAD-BEEF",
70- "api-addresses": ["10.0.3.2:17070"],
71- "unit-name": "service-2/0",
72- "private-address": "127.0.0.1"}
73- self.assertIn(expected2, juju_info)
74-
75 def test_juju_info_skipped_with_old_server(self):
76 """
77 If a server doesn't speak at least 3.3, the juju-info field is
78
79=== modified file 'landscape/message_schemas.py'
80--- landscape/message_schemas.py 2014-09-01 13:16:02 +0000
81+++ landscape/message_schemas.py 2014-09-17 15:29:16 +0000
82@@ -204,13 +204,10 @@
83 "juju-info": KeyDict({"environment-uuid": Unicode(),
84 "api-addresses": List(Unicode()),
85 "machine-id": Unicode()}),
86- # XXX temporary field with unit info, will be dropped when we complete
87- # the migration to machine info.
88- "juju-info-list": List(KeyDict(juju_data, optional=["private-address"])),
89 "access_group": Unicode()},
90 api="3.3",
91 optional=["registration_password", "hostname", "tags", "vm-info",
92- "container-info", "access_group", "juju-info", "juju-info-list"])
93+ "container-info", "access_group", "juju-info"])
94
95
96 # XXX The register-provisioned-machine message is obsolete, it's kept around
97
98=== modified file 'landscape/monitor/config.py'
99--- landscape/monitor/config.py 2014-05-16 13:28:44 +0000
100+++ landscape/monitor/config.py 2014-09-17 15:29:16 +0000
101@@ -6,7 +6,7 @@
102 "Temperature", "PackageMonitor", "UserMonitor",
103 "RebootRequired", "AptPreferences", "NetworkActivity",
104 "NetworkDevice", "UpdateManager", "CPUUsage", "SwiftUsage",
105- "CephUsage", "JujuInfo"]
106+ "CephUsage"]
107
108
109 class MonitorConfiguration(Configuration):
110
111=== removed file 'landscape/monitor/jujuinfo.py'
112--- landscape/monitor/jujuinfo.py 2014-08-28 09:47:21 +0000
113+++ landscape/monitor/jujuinfo.py 1970-01-01 00:00:00 +0000
114@@ -1,52 +0,0 @@
115-import logging
116-
117-from landscape.lib.juju import get_juju_info
118-from landscape.monitor.plugin import MonitorPlugin
119-
120-
121-class JujuInfo(MonitorPlugin):
122- """Plugin for reporting Juju information.
123-
124- XXX this plugin is going to be dropped when the transition from
125- unit-computer association to machine-computer association is
126- completed on the server.
127- """
128-
129- persist_name = "juju-info"
130- scope = "juju"
131- run_interval = 30
132-
133- # Need persist to be setup so have to wait C{run_interval} seconds
134- run_immediately = False
135-
136- def run(self):
137- broker = self.registry.broker
138- broker.call_if_accepted("juju-units-info", self.send_juju_message)
139-
140- def send_juju_message(self):
141- message = self._create_juju_info_message()
142- if message:
143- logging.info("Queuing message with updated juju info.")
144- self.registry.broker.send_message(message, self._session_id,
145- urgent=True)
146-
147- def _create_juju_info_message(self):
148- """Return a "juju-units-info" message if the juju info gathered from
149- the JSON files living in juju-info.d/ has changed.
150-
151- The message is of the form:
152- {"type": "juju-units-info",
153- "juju-info-list": [{<juju-info dict>}, {<juju-info dict>}]}
154- """
155- juju_info = get_juju_info(self.registry.config)
156-
157- if juju_info:
158- juju_info = juju_info[0]
159-
160- if juju_info != self._persist.get("juju-info"):
161- self._persist.set("juju-info", juju_info)
162- message = {"type": "juju-units-info",
163- "juju-info-list": juju_info}
164- return message
165-
166- return None
167
168=== removed file 'landscape/monitor/tests/test_jujuinfo.py'
169--- landscape/monitor/tests/test_jujuinfo.py 2014-08-28 09:47:21 +0000
170+++ landscape/monitor/tests/test_jujuinfo.py 1970-01-01 00:00:00 +0000
171@@ -1,107 +0,0 @@
172-import json
173-import os
174-
175-from landscape.monitor.jujuinfo import JujuInfo
176-from landscape.tests.helpers import LandscapeTest, MonitorHelper
177-
178-
179-SAMPLE_JUJU_INFO = json.dumps({"environment-uuid": "DEAD-BEEF",
180- "machine-id": "1",
181- "unit-name": "juju-unit-name",
182- "api-addresses": "10.0.3.1:17070",
183- "private-address": "127.0.0.1"})
184-
185-SAMPLE_JUJU_FILE = "juju-unit-name.json"
186-
187-
188-class JujuInfoTest(LandscapeTest):
189-
190- helpers = [MonitorHelper]
191-
192- def setUp(self):
193- super(JujuInfoTest, self).setUp()
194- self.mstore.set_accepted_types(["juju-units-info"])
195- self.plugin = JujuInfo()
196- self.monitor.add(self.plugin)
197-
198- if not os.path.exists(self.config.juju_directory):
199- os.mkdir(self.config.juju_directory)
200-
201- self.filepath = os.path.join(self.config.juju_directory,
202- SAMPLE_JUJU_FILE)
203- self.makeFile(SAMPLE_JUJU_INFO, path=self.filepath)
204-
205- def test_get_sample_juju_info(self):
206- """
207- Sample data is used to ensure that expected values end up in
208- the Juju data reported by the plugin.
209- """
210- self.plugin.run()
211- message = self.mstore.get_pending_messages()[0]
212- self.assertEqual(message["type"], "juju-units-info")
213- juju_info = message["juju-info-list"][0]
214- self.assertEqual(juju_info["environment-uuid"], "DEAD-BEEF")
215- self.assertEqual(juju_info["unit-name"], "juju-unit-name")
216- self.assertEqual(juju_info["api-addresses"], ["10.0.3.1:17070"])
217-
218- def test_juju_info_reported_only_once(self):
219- """
220- Juju data shouldn't be reported unless it's changed since the
221- last time it was reported.
222- """
223- self.plugin.run()
224- messages = self.mstore.get_pending_messages()
225- self.assertEqual(len(messages), 1)
226- self.assertEqual(messages[0]["type"], "juju-units-info")
227-
228- self.plugin.run()
229- messages = self.mstore.get_pending_messages()
230- self.assertEqual(len(messages), 1)
231-
232- def test_report_changed_juju_info(self):
233- """
234- When juju data changes, the new data should be sent to the
235- server.
236- """
237- self.plugin.run()
238- message = self.mstore.get_pending_messages()[0]
239- self.assertEqual(message["type"], "juju-units-info")
240- juju_info = message["juju-info-list"][0]
241- self.assertEqual(juju_info["environment-uuid"], "DEAD-BEEF")
242- self.assertEqual(juju_info["unit-name"], "juju-unit-name")
243- self.assertEqual(juju_info["api-addresses"], ["10.0.3.1:17070"])
244-
245- self.makeFile(
246- json.dumps({"environment-uuid": "FEED-BEEF",
247- "machine-id": "1",
248- "unit-name": "changed-unit-name",
249- "api-addresses": "10.0.3.2:17070",
250- "private-address": "127.0.1.1"}),
251- path=self.filepath)
252- self.plugin.run()
253-
254- message = self.mstore.get_pending_messages()[1]
255- self.assertEqual(message["type"], "juju-units-info")
256- juju_info = message["juju-info-list"][0]
257- self.assertEqual(juju_info["environment-uuid"], "FEED-BEEF")
258- self.assertEqual(juju_info["unit-name"], "changed-unit-name")
259- self.assertEqual(juju_info["api-addresses"], ["10.0.3.2:17070"])
260-
261- def test_no_message_with_invalid_json(self):
262- """No Juju message is sent if the JSON file is invalid."""
263- self.makeFile("barf", path=self.filepath)
264-
265- self.plugin.run()
266- messages = self.mstore.get_pending_messages()
267- self.assertEqual(messages, [])
268- self.log_helper.ignore_errors(ValueError)
269- self.assertTrue(
270- "Error attempting to read JSON from" in self.logfile.getvalue())
271-
272- def test_no_message_with_missing_file(self):
273- """No Juju message is sent if the JSON file is missing."""
274- os.remove(self.filepath)
275-
276- self.plugin.run()
277- messages = self.mstore.get_pending_messages()
278- self.assertEqual(messages, [])

Subscribers

People subscribed via source and target branches

to all changes: