Merge lp:~therve/landscape-client/cloud-missing-kernel into lp:~landscape/landscape-client/trunk

Proposed by Thomas Herve
Status: Merged
Approved by: Alberto Donato
Approved revision: 437
Merged at revision: 438
Proposed branch: lp:~therve/landscape-client/cloud-missing-kernel
Merge into: lp:~landscape/landscape-client/trunk
Diff against target: 83 lines (+27/-5)
3 files modified
landscape/broker/registration.py (+8/-4)
landscape/broker/tests/test_registration.py (+18/-0)
landscape/message_schemas.py (+1/-1)
To merge this branch: bzr merge lp:~therve/landscape-client/cloud-missing-kernel
Reviewer Review Type Date Requested Status
Alberto Donato (community) Approve
Free Ekanayaka (community) Approve
Review via email: mp+89844@code.launchpad.net

Description of the change

A fairly simple change, as I simply mirror what have been done with ramdisk. Unfortunately, that change won't work with old server code, but there is no way around it, and the client wouldn't work anyway without the fix.

To post a comment you must log in.
Revision history for this message
Free Ekanayaka (free.ekanayaka) wrote :

+1!

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

good, +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 2012-01-20 15:13:23 +0000
3+++ landscape/broker/registration.py 2012-01-24 09:11:37 +0000
4@@ -148,7 +148,6 @@
5 "/meta-data/local-hostname",
6 "/meta-data/public-hostname",
7 "/meta-data/ami-launch-index",
8- "/meta-data/kernel-id",
9 "/meta-data/ami-id",
10 "/meta-data/local-ipv4",
11 "/meta-data/public-ipv4"]
12@@ -162,13 +161,18 @@
13 lambda ignore: self._fetch_async(
14 EC2_API + "/meta-data/ramdisk-id").addErrback(log_failure))
15 deferred.addCallback(ec2_data.append)
16+ # And same for kernel
17+ deferred.addCallback(
18+ lambda ignore: self._fetch_async(
19+ EC2_API + "/meta-data/kernel-id").addErrback(log_failure))
20+ deferred.addCallback(ec2_data.append)
21
22 def record_data(ignore):
23 """Record the instance data returned by the EC2 API."""
24 (raw_user_data, instance_key, reservation_key,
25 local_hostname, public_hostname, launch_index,
26- kernel_key, ami_key, local_ip,
27- public_ip, ramdisk_key) = ec2_data
28+ ami_key, local_ip, public_ip, ramdisk_key,
29+ kernel_key) = ec2_data
30 self._ec2_data = {
31 "instance_key": instance_key,
32 "reservation_key": reservation_key,
33@@ -181,7 +185,7 @@
34 "public_ipv4": public_ip,
35 "local_ipv4": local_ip}
36 for k, v in self._ec2_data.items():
37- if v is None and k == "ramdisk_key":
38+ if v is None and k in ("ramdisk_key", "kernel_key"):
39 continue
40 self._ec2_data[k] = v.decode("utf-8")
41 self._ec2_data["launch_index"] = int(
42
43=== modified file 'landscape/broker/tests/test_registration.py'
44--- landscape/broker/tests/test_registration.py 2012-01-20 15:13:23 +0000
45+++ landscape/broker/tests/test_registration.py 2012-01-24 09:11:37 +0000
46@@ -855,6 +855,24 @@
47 [self.get_expected_cloud_message(
48 ramdisk_key=None)])
49
50+ def test_cloud_registration_continues_without_kernel(self):
51+ """
52+ If the instance doesn't have a kernel (ie, the query for kernel
53+ returns a 404), then register-cloud-vm still occurs.
54+ """
55+ self.log_helper.ignore_errors(HTTPCodeError)
56+ self.prepare_query_results(kernel_key=HTTPCodeError(404, "ohno"))
57+ self.prepare_cloud_registration()
58+
59+ self.reactor.fire("run")
60+ self.exchanger.exchange()
61+ self.assertIn("HTTPCodeError: Server returned HTTP code 404",
62+ self.logfile.getvalue())
63+ self.assertEqual(len(self.transport.payloads), 1)
64+ self.assertMessages(self.transport.payloads[0]["messages"],
65+ [self.get_expected_cloud_message(
66+ kernel_key=None)])
67+
68 def test_fall_back_to_normal_registration_when_metadata_fetch_fails(self):
69 """
70 If fetching metadata fails, but we do have an account name, then we
71
72=== modified file 'landscape/message_schemas.py'
73--- landscape/message_schemas.py 2012-01-23 12:10:15 +0000
74+++ landscape/message_schemas.py 2012-01-24 09:11:37 +0000
75@@ -163,7 +163,7 @@
76 "reservation_key": Unicode(),
77 "public_hostname": Unicode(),
78 "local_hostname": Unicode(),
79- "kernel_key": Unicode(),
80+ "kernel_key": Any(Unicode(), Constant(None)),
81 "ramdisk_key": Any(Unicode(), Constant(None)),
82 "launch_index": Int(),
83 "image_key": Unicode(),

Subscribers

People subscribed via source and target branches

to all changes: