Merge lp:~free.ekanayaka/landscape-client/drop-provisioning-registration-2 into lp:~landscape/landscape-client/trunk

Proposed by Free Ekanayaka
Status: Merged
Approved by: Free Ekanayaka
Approved revision: 788
Merged at revision: 781
Proposed branch: lp:~free.ekanayaka/landscape-client/drop-provisioning-registration-2
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 357 lines (+43/-134)
6 files modified
landscape/broker/config.py (+0/-3)
landscape/broker/registration.py (+26/-54)
landscape/broker/tests/test_registration.py (+7/-51)
landscape/configuration.py (+2/-3)
landscape/message_schemas.py (+6/-3)
landscape/tests/test_configuration.py (+2/-20)
To merge this branch: bzr merge lp:~free.ekanayaka/landscape-client/drop-provisioning-registration-2
Reviewer Review Type Date Requested Status
Chris Glass (community) Approve
Alberto Donato (community) Approve
Review via email: mp+227339@code.launchpad.net

Commit message

Drop unused provisioning registration code.

Description of the change

Drop unused provisioning registration code.

To post a comment you must log in.
Revision history for this message
Alberto Donato (ack) wrote :

Nice cleanup, +1

review: Approve
Revision history for this message
Chris Glass (tribaal) wrote :

Nice, thanks fro dropping that.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'landscape/broker/config.py'
2--- landscape/broker/config.py 2014-07-10 18:51:49 +0000
3+++ landscape/broker/config.py 2014-07-18 14:32:52 +0000
4@@ -32,7 +32,6 @@
5 - C{urgent_exchange_interval} (C{1*60})
6 - C{http_proxy}
7 - C{https_proxy}
8- - C{provisioning_otp}
9 """
10 parser = super(BrokerConfiguration, self).make_parser()
11
12@@ -63,8 +62,6 @@
13 parser.add_option("--tags",
14 help="Comma separated list of tag names to be sent "
15 "to the server.")
16- parser.add_option("--provisioning-otp", default="",
17- help="The OTP to use for a provisioned machine.")
18
19 return parser
20
21
22=== modified file 'landscape/broker/registration.py'
23--- landscape/broker/registration.py 2014-07-16 09:59:28 +0000
24+++ landscape/broker/registration.py 2014-07-18 14:32:52 +0000
25@@ -107,9 +107,6 @@
26 if id.secure_id:
27 return False
28
29- if self._config.provisioning_otp:
30- return self._message_store.accepts("register-provisioned-machine")
31-
32 return bool(id.computer_title and id.account_name
33 and self._message_store.accepts("register"))
34
35@@ -134,13 +131,6 @@
36 return None
37 self._juju_data = juju_info # A list of dicts
38
39- def _get_data(self, path, accumulate):
40- """
41- Get data at C{path} on the EC2 API endpoint, and add the result to the
42- C{accumulate} list.
43- """
44- return self._fetch_async(EC2_API + path).addCallback(accumulate.append)
45-
46 def _handle_exchange_done(self):
47 """Registered handler for the C{"exchange-done"} event.
48
49@@ -158,13 +148,7 @@
50 An exchange is about to happen. If we don't have a secure id already
51 set, and we have the needed information available, queue a registration
52 message with the server.
53-
54- A computer can fall into several categories:
55- - a "normal" computer
56- - a "provisionned machine".
57 """
58- registration_failed = False
59-
60 # The point of storing this flag is that if we should *not* register
61 # now, and then after the exchange we *should*, we schedule an urgent
62 # exchange again. Without this flag we would just spin trying to
63@@ -177,6 +161,11 @@
64 # These are just to shorten the code.
65 identity = self._identity
66 account_name = identity.account_name
67+
68+ if not account_name:
69+ self._reactor.fire("registration-failed")
70+ return
71+
72 tags = identity.tags
73 group = identity.access_group
74 registration_key = identity.registration_key
75@@ -187,51 +176,34 @@
76 tags = None
77 logging.error("Invalid tags provided for registration.")
78
79- message = {"type": None, # either "register" or "register-cloud-vm"
80+ message = {"type": "register",
81 "hostname": get_fqdn(),
82- "account_name": identity.account_name,
83- "registration_password": None,
84+ "account_name": account_name,
85+ "computer_title": identity.computer_title,
86+ "registration_password": identity.registration_key,
87 "tags": tags,
88+ "container-info": get_container_info(),
89 "vm-info": get_vm_info()}
90
91 if group:
92 message["access_group"] = group
93
94- if account_name:
95- # The computer is a normal computer, possibly a container.
96- with_word = "with" if bool(registration_key) else "without"
97- with_tags = "and tags %s " % tags if tags else ""
98- with_group = "in access group '%s' " % group if group else ""
99-
100- logging.info(u"Queueing message to register with account %r %s%s"
101- "%s a password." % (account_name, with_group,
102- with_tags, with_word))
103- message["type"] = "register"
104- message["computer_title"] = identity.computer_title
105- message["registration_password"] = identity.registration_key
106- message["container-info"] = get_container_info()
107-
108- if self._juju_data is not None:
109- # For backwards compatibility, set the juju-info to be one of
110- # the juju infos (it used not to be a list).
111- message["juju-info"] = self._juju_data[0]
112- message["juju-info-list"] = self._juju_data
113-
114- elif self._config.provisioning_otp:
115- # This is a newly provisionned machine.
116- # In this case message is overwritten because it's much simpler
117- logging.info(u"Queueing message to register with OTP as a"
118- u" newly provisioned machine.")
119- message = {"type": "register-provisioned-machine",
120- "otp": self._config.provisioning_otp}
121- else:
122- registration_failed = True
123-
124- if registration_failed:
125- self._reactor.fire("registration-failed")
126- else:
127- logging.info("Sending registration message to exchange.")
128- self._exchange.send(message)
129+ if self._juju_data is not None:
130+ # For backwards compatibility, set the juju-info to be one of
131+ # the juju infos (it used not to be a list).
132+ message["juju-info"] = self._juju_data[0]
133+ message["juju-info-list"] = self._juju_data
134+
135+ # The computer is a normal computer, possibly a container.
136+ with_word = "with" if bool(registration_key) else "without"
137+ with_tags = "and tags %s " % tags if tags else ""
138+ with_group = "in access group '%s' " % group if group else ""
139+
140+ logging.info(
141+ u"Queueing message to register with account %r %s%s"
142+ "%s a password." % (
143+ account_name, with_group, with_tags, with_word))
144+ self._exchange.send(message)
145
146 def _handle_set_id(self, message):
147 """Registered handler for the C{"set-id"} event.
148
149=== modified file 'landscape/broker/tests/test_registration.py'
150--- landscape/broker/tests/test_registration.py 2014-07-16 09:59:28 +0000
151+++ landscape/broker/tests/test_registration.py 2014-07-18 14:32:52 +0000
152@@ -161,8 +161,7 @@
153 self.assertEqual("register", messages[0]["type"])
154 self.assertEqual(self.logfile.getvalue().strip(),
155 "INFO: Queueing message to register with account "
156- "'account_name' without a password.\n "
157- "INFO: Sending registration message to exchange.")
158+ "'account_name' without a password.")
159
160 def test_queue_message_on_exchange_with_vm_info(self):
161 """
162@@ -182,8 +181,7 @@
163 self.assertEqual("vmware", messages[0]["vm-info"])
164 self.assertEqual(self.logfile.getvalue().strip(),
165 "INFO: Queueing message to register with account "
166- "'account_name' without a password.\n "
167- "INFO: Sending registration message to exchange.")
168+ "'account_name' without a password.")
169
170 def test_queue_message_on_exchange_with_lxc_container(self):
171 """
172@@ -214,8 +212,7 @@
173 self.assertEqual("SEKRET", password)
174 self.assertEqual(self.logfile.getvalue().strip(),
175 "INFO: Queueing message to register with account "
176- "'account_name' with a password.\n "
177- "INFO: Sending registration message to exchange.")
178+ "'account_name' with a password.")
179
180 def test_queue_message_on_exchange_with_tags(self):
181 """
182@@ -233,8 +230,7 @@
183 self.assertEqual(self.logfile.getvalue().strip(),
184 "INFO: Queueing message to register with account "
185 "'account_name' and tags computer,tag with a "
186- "password.\n "
187- "INFO: Sending registration message to exchange.")
188+ "password.")
189
190 def test_queue_message_on_exchange_with_invalid_tags(self):
191 """
192@@ -253,8 +249,7 @@
193 self.assertEqual(self.logfile.getvalue().strip(),
194 "ERROR: Invalid tags provided for registration.\n "
195 "INFO: Queueing message to register with account "
196- "'account_name' with a password.\n "
197- "INFO: Sending registration message to exchange.")
198+ "'account_name' with a password.")
199
200 def test_queue_message_on_exchange_with_unicode_tags(self):
201 """
202@@ -274,8 +269,7 @@
203 self.assertEqual(self.logfile.getvalue().strip(),
204 "INFO: Queueing message to register with account "
205 "'account_name' and tags prova\xc4\xb5o "
206- "with a password.\n "
207- "INFO: Sending registration message to exchange.")
208+ "with a password.")
209
210 def test_queue_message_on_exchange_with_access_group(self):
211 """
212@@ -292,8 +286,7 @@
213 self.assertEqual(self.logfile.getvalue().strip(),
214 "INFO: Queueing message to register with account "
215 "'account_name' in access group 'dinosaurs' and "
216- "tags server,london without a password.\n "
217- "INFO: Sending registration message to exchange.")
218+ "tags server,london without a password.")
219
220 def test_queue_message_on_exchange_with_empty_access_group(self):
221 """
222@@ -575,40 +568,3 @@
223 "unit-name": "service-2/0",
224 "private-address": "127.0.0.1"}
225 self.assertIn(expected2, juju_info)
226-
227-
228-class ProvisioningRegistrationTest(RegistrationHandlerTestBase):
229-
230- def test_provisioned_machine_registration_with_otp(self):
231- """
232- Register provisioned machines using an OTP.
233- """
234- self.mstore.set_accepted_types(["register-provisioned-machine"])
235- self.config.account_name = ""
236- self.config.provisioning_otp = "ohteepee"
237- self.reactor.fire("pre-exchange")
238-
239- self.assertMessages([{"otp": "ohteepee", "timestamp": 0, "api": "3.2",
240- "type": "register-provisioned-machine"}],
241- self.mstore.get_pending_messages())
242- self.assertEqual(u"INFO: Queueing message to register with OTP as a"
243- u" newly provisioned machine.\n "
244- "INFO: Sending registration message to exchange.",
245- self.logfile.getvalue().strip())
246-
247- self.exchanger.exchange()
248- self.assertMessages([{"otp": "ohteepee", "timestamp": 0, "api": "3.2",
249- "type": "register-provisioned-machine"}],
250- self.transport.payloads[0]["messages"])
251-
252- def test_provisioned_machine_registration_with_empty_otp(self):
253- """
254- No message should be sent when an empty OTP is passed.
255- """
256- self.mstore.set_accepted_types(["register-provisioned-machine"])
257- self.config.account_name = ""
258- self.config.provisioning_otp = ""
259- self.reactor.fire("pre-exchange")
260-
261- self.assertMessages([], self.mstore.get_pending_messages())
262- self.assertEqual(u"", self.logfile.getvalue().strip())
263
264=== modified file 'landscape/configuration.py'
265--- landscape/configuration.py 2014-07-10 19:16:56 +0000
266+++ landscape/configuration.py 2014-07-18 14:32:52 +0000
267@@ -472,11 +472,10 @@
268 def check_account_name_and_password(config):
269 """
270 Ensure that silent configurations which plan to start landscape-client are
271- either configured for OTP or have both an account_name and computer title.
272+ have both an account_name and computer title.
273 """
274 if config.silent and not config.no_start:
275- if not (config.get("otp") or config.provisioning_otp or
276- (config.get("account_name") and config.get("computer_title"))):
277+ if not (config.get("account_name") and config.get("computer_title")):
278 raise ConfigurationError("An account name and computer title are "
279 "required.")
280
281
282=== modified file 'landscape/message_schemas.py'
283--- landscape/message_schemas.py 2014-07-17 06:51:40 +0000
284+++ landscape/message_schemas.py 2014-07-18 14:32:52 +0000
285@@ -206,6 +206,9 @@
286 "access_group"])
287
288
289+# XXX The register-provisioned-machine message is obsolete, it's kept around
290+# just to not break older LDS releases that import it the last LDS release
291+# to have it is 14.07). Eventually it shall be dropped.
292 REGISTER_PROVISIONED_MACHINE = Message(
293 "register-provisioned-machine",
294 {"otp": Bytes()})
295@@ -479,12 +482,12 @@
296 OPERATION_RESULT, COMPUTER_INFO, DISTRIBUTION_INFO,
297 HARDWARE_INVENTORY, HARDWARE_INFO, LOAD_AVERAGE, MEMORY_INFO,
298 RESYNCHRONIZE, MOUNT_ACTIVITY, MOUNT_INFO, FREE_SPACE,
299- REGISTER, REGISTER_CLOUD_VM, REGISTER_PROVISIONED_MACHINE,
300+ REGISTER,
301 TEMPERATURE, PROCESSOR_INFO, USERS, PACKAGES, PACKAGE_LOCKS,
302 CHANGE_PACKAGES_RESULT, UNKNOWN_PACKAGE_HASHES,
303 ADD_PACKAGES, PACKAGE_REPORTER_RESULT, TEXT_MESSAGE, TEST,
304- CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES, EUCALYPTUS_INFO,
305- EUCALYPTUS_INFO_ERROR, NETWORK_DEVICE, NETWORK_ACTIVITY,
306+ CUSTOM_GRAPH, REBOOT_REQUIRED, APT_PREFERENCES,
307+ NETWORK_DEVICE, NETWORK_ACTIVITY,
308 REBOOT_REQUIRED_INFO, UPDATE_MANAGER_INFO, CPU_USAGE,
309 CEPH_USAGE, SWIFT_USAGE, SWIFT_DEVICE_INFO, KEYSTONE_TOKEN,
310 CHANGE_HA_SERVICE, JUJU_INFO, JUJU_UNITS_INFO, CLOUD_METADATA]:
311
312=== modified file 'landscape/tests/test_configuration.py'
313--- landscape/tests/test_configuration.py 2014-07-10 19:16:56 +0000
314+++ landscape/tests/test_configuration.py 2014-07-18 14:32:52 +0000
315@@ -820,8 +820,7 @@
316 "--ping-interval", "30",
317 "--http-proxy", "",
318 "--https-proxy", "",
319- "--tags", "",
320- "--provisioning-otp", ""]
321+ "--tags", ""]
322 config = self.get_config(args)
323 setup(config)
324 self.assertConfigEqual(
325@@ -838,9 +837,7 @@
326 "exchange_interval = 900\n"
327 "ping_interval = 30\n"
328 "ping_url = http://landscape.canonical.com/ping\n"
329- "provisioning_otp = \n"
330- "urgent_exchange_interval = 60\n"
331- % config.data_path)
332+ "urgent_exchange_interval = 60\n" % config.data_path)
333
334 def test_silent_setup_without_computer_title(self):
335 """A computer title is required."""
336@@ -860,21 +857,6 @@
337 config = self.get_config(["--silent", "-t", "rex"])
338 self.assertRaises(ConfigurationError, setup, config)
339
340- def test_silent_setup_with_provisioning_otp(self):
341- """
342- If the provisioning OTP is specified, there is no need to pass the
343- account name and the computer title.
344- """
345- sysvconfig_mock = self.mocker.patch(SysVConfig)
346- sysvconfig_mock.set_start_on_boot(True)
347- sysvconfig_mock.restart_landscape()
348- self.mocker.replay()
349-
350- config = self.get_config(["--silent", "--provisioning-otp", "otp1"])
351- setup(config)
352-
353- self.assertEqual("otp1", config.provisioning_otp)
354-
355 def test_silent_script_users_imply_script_execution_plugin(self):
356 """
357 If C{--script-users} is specified, without C{ScriptExecution} in the

Subscribers

People subscribed via source and target branches

to all changes: