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
=== modified file 'landscape/broker/registration.py'
--- landscape/broker/registration.py 2012-01-20 15:13:23 +0000
+++ landscape/broker/registration.py 2012-01-24 09:11:37 +0000
@@ -148,7 +148,6 @@
148 "/meta-data/local-hostname",148 "/meta-data/local-hostname",
149 "/meta-data/public-hostname",149 "/meta-data/public-hostname",
150 "/meta-data/ami-launch-index",150 "/meta-data/ami-launch-index",
151 "/meta-data/kernel-id",
152 "/meta-data/ami-id",151 "/meta-data/ami-id",
153 "/meta-data/local-ipv4",152 "/meta-data/local-ipv4",
154 "/meta-data/public-ipv4"]153 "/meta-data/public-ipv4"]
@@ -162,13 +161,18 @@
162 lambda ignore: self._fetch_async(161 lambda ignore: self._fetch_async(
163 EC2_API + "/meta-data/ramdisk-id").addErrback(log_failure))162 EC2_API + "/meta-data/ramdisk-id").addErrback(log_failure))
164 deferred.addCallback(ec2_data.append)163 deferred.addCallback(ec2_data.append)
164 # And same for kernel
165 deferred.addCallback(
166 lambda ignore: self._fetch_async(
167 EC2_API + "/meta-data/kernel-id").addErrback(log_failure))
168 deferred.addCallback(ec2_data.append)
165169
166 def record_data(ignore):170 def record_data(ignore):
167 """Record the instance data returned by the EC2 API."""171 """Record the instance data returned by the EC2 API."""
168 (raw_user_data, instance_key, reservation_key,172 (raw_user_data, instance_key, reservation_key,
169 local_hostname, public_hostname, launch_index,173 local_hostname, public_hostname, launch_index,
170 kernel_key, ami_key, local_ip,174 ami_key, local_ip, public_ip, ramdisk_key,
171 public_ip, ramdisk_key) = ec2_data175 kernel_key) = ec2_data
172 self._ec2_data = {176 self._ec2_data = {
173 "instance_key": instance_key,177 "instance_key": instance_key,
174 "reservation_key": reservation_key,178 "reservation_key": reservation_key,
@@ -181,7 +185,7 @@
181 "public_ipv4": public_ip,185 "public_ipv4": public_ip,
182 "local_ipv4": local_ip}186 "local_ipv4": local_ip}
183 for k, v in self._ec2_data.items():187 for k, v in self._ec2_data.items():
184 if v is None and k == "ramdisk_key":188 if v is None and k in ("ramdisk_key", "kernel_key"):
185 continue189 continue
186 self._ec2_data[k] = v.decode("utf-8")190 self._ec2_data[k] = v.decode("utf-8")
187 self._ec2_data["launch_index"] = int(191 self._ec2_data["launch_index"] = int(
188192
=== modified file 'landscape/broker/tests/test_registration.py'
--- landscape/broker/tests/test_registration.py 2012-01-20 15:13:23 +0000
+++ landscape/broker/tests/test_registration.py 2012-01-24 09:11:37 +0000
@@ -855,6 +855,24 @@
855 [self.get_expected_cloud_message(855 [self.get_expected_cloud_message(
856 ramdisk_key=None)])856 ramdisk_key=None)])
857857
858 def test_cloud_registration_continues_without_kernel(self):
859 """
860 If the instance doesn't have a kernel (ie, the query for kernel
861 returns a 404), then register-cloud-vm still occurs.
862 """
863 self.log_helper.ignore_errors(HTTPCodeError)
864 self.prepare_query_results(kernel_key=HTTPCodeError(404, "ohno"))
865 self.prepare_cloud_registration()
866
867 self.reactor.fire("run")
868 self.exchanger.exchange()
869 self.assertIn("HTTPCodeError: Server returned HTTP code 404",
870 self.logfile.getvalue())
871 self.assertEqual(len(self.transport.payloads), 1)
872 self.assertMessages(self.transport.payloads[0]["messages"],
873 [self.get_expected_cloud_message(
874 kernel_key=None)])
875
858 def test_fall_back_to_normal_registration_when_metadata_fetch_fails(self):876 def test_fall_back_to_normal_registration_when_metadata_fetch_fails(self):
859 """877 """
860 If fetching metadata fails, but we do have an account name, then we878 If fetching metadata fails, but we do have an account name, then we
861879
=== modified file 'landscape/message_schemas.py'
--- landscape/message_schemas.py 2012-01-23 12:10:15 +0000
+++ landscape/message_schemas.py 2012-01-24 09:11:37 +0000
@@ -163,7 +163,7 @@
163 "reservation_key": Unicode(),163 "reservation_key": Unicode(),
164 "public_hostname": Unicode(),164 "public_hostname": Unicode(),
165 "local_hostname": Unicode(),165 "local_hostname": Unicode(),
166 "kernel_key": Unicode(),166 "kernel_key": Any(Unicode(), Constant(None)),
167 "ramdisk_key": Any(Unicode(), Constant(None)),167 "ramdisk_key": Any(Unicode(), Constant(None)),
168 "launch_index": Int(),168 "launch_index": Int(),
169 "image_key": Unicode(),169 "image_key": Unicode(),

Subscribers

People subscribed via source and target branches

to all changes: