diff -Nru landscape-client-16.03/debian/changelog landscape-client-16.03/debian/changelog --- landscape-client-16.03/debian/changelog 2016-03-21 19:51:18.000000000 +0000 +++ landscape-client-16.03/debian/changelog 2016-04-05 12:15:55.000000000 +0000 @@ -1,3 +1,10 @@ +landscape-client (16.03-0ubuntu2) xenial; urgency=medium + + * Cope with an api change in python-swift that broke swift storage + reporting in Autopilot. (LP: #1563565) + + -- Andreas Hasenack Tue, 05 Apr 2016 09:15:40 -0300 + landscape-client (16.03-0ubuntu1) xenial; urgency=medium * New upstream release 16.03: diff -Nru landscape-client-16.03/debian/patches/series landscape-client-16.03/debian/patches/series --- landscape-client-16.03/debian/patches/series 2016-03-21 19:29:19.000000000 +0000 +++ landscape-client-16.03/debian/patches/series 2016-04-05 12:16:10.000000000 +0000 @@ -0,0 +1 @@ +swift-changed-api-1563565.diff diff -Nru landscape-client-16.03/debian/patches/swift-changed-api-1563565.diff landscape-client-16.03/debian/patches/swift-changed-api-1563565.diff --- landscape-client-16.03/debian/patches/swift-changed-api-1563565.diff 1970-01-01 00:00:00.000000000 +0000 +++ landscape-client-16.03/debian/patches/swift-changed-api-1563565.diff 2016-04-05 12:17:29.000000000 +0000 @@ -0,0 +1,103 @@ +--- a/landscape/monitor/swiftusage.py ++++ b/landscape/monitor/swiftusage.py +@@ -118,8 +118,10 @@ + + scout = Scout("diskusage") + # Perform the actual call +- _, disk_usage, code = scout.scout(host) +- if code == 200: ++ scout_result = scout.scout(host) ++ disk_usage = scout_result[1] ++ status_code = scout_result[2] ++ if status_code == 200: + return disk_usage + + def _handle_usage(self, disk_usage): +@@ -130,7 +132,7 @@ + if not usage["mounted"]: + continue + +- device = usage["device"] ++ device = usage["device"].encode("utf-8") + devices.add(device) + + step_values = [] +--- a/landscape/monitor/tests/test_swiftusage.py ++++ b/landscape/monitor/tests/test_swiftusage.py +@@ -1,9 +1,16 @@ + from twisted.internet.defer import succeed ++from unittest import skipUnless + + from landscape.monitor.swiftusage import SwiftUsage + from landscape.tests.helpers import LandscapeTest, MonitorHelper + from landscape.tests.mocker import ANY + ++try: ++ from swift.cli.recon import Scout ++ has_swift = True ++except ImportError: ++ has_swift = False ++ + + class FakeRing(object): + def __init__(self, ip_port_tuples=[]): +@@ -261,3 +268,59 @@ + self.plugin._handle_usage(recon_response) + self.assertNotIn("vdc", self.plugin._persist.get("usage")) + self.assertEqual(["vdb"], self.plugin._persist.get("devices")) ++ ++ @skipUnless(has_swift, "Test relies on python-swift being installed") ++ def test_perform_recon_call(self): ++ """ ++ Checks that disk usage is correctly returned after the change ++ in scout() results ++ """ ++ plugin = SwiftUsage(create_time=self.reactor.time) ++ expected_disk_usage = [ ++ {u"device": u"vdb", ++ u"mounted": True, ++ u"size": 100000, ++ u"avail": 70000, ++ u"used": 30000}] ++ Scout.scout = lambda _, host: ("recon_url", expected_disk_usage, 200, ++ 1459286522.711885, 1459286522.716989) ++ host = ("192.168.1.10", 6000) ++ response = plugin._perform_recon_call(host) ++ self.assertEqual(response, expected_disk_usage) ++ ++ @skipUnless(has_swift, "Test relies on python-swift being installed") ++ def test_perform_old_recon_call(self): ++ """ ++ Checks that disk usage is correctly returned with the old scout() ++ result format as well ++ """ ++ plugin = SwiftUsage(create_time=self.reactor.time) ++ expected_disk_usage = [ ++ {u"device": u"vdb", ++ u"mounted": True, ++ u"size": 100000, ++ u"avail": 70000, ++ u"used": 30000}] ++ Scout.scout = lambda _, host: ("recon_url", expected_disk_usage, 200) ++ host = ("192.168.1.10", 6000) ++ response = plugin._perform_recon_call(host) ++ self.assertEqual(response, expected_disk_usage) ++ ++ def test_device_enconding(self): ++ """ ++ Checks that unicode responses can be processed without errors ++ """ ++ recon_response = [ ++ {u"device": u"vdb", ++ u"mounted": True, ++ u"size": 100000, ++ u"avail": 70000, ++ u"used": 30000}] ++ self.plugin._perform_recon_call = lambda host: succeed(recon_response) ++ self.plugin._get_recon_host = lambda: ("192.168.1.10", 6000) ++ ++ self.monitor.add(self.plugin) ++ self.reactor.advance(self.monitor.step_size) ++ self.plugin._handle_usage(recon_response) ++ self.assertEqual( ++ [u"vdb"], sorted(self.plugin._persist.get("devices")))