From 78f61855e119306e5328efcf396c01d2be14a12e Mon Sep 17 00:00:00 2001 From: Rick Harris Date: Wed, 1 May 2013 21:47:35 +0000 Subject: [PATCH] xenapi: Don't swallow missing SR exception The existing code would catch a missing SR exception and bail out of the `update_status` method before finishing, causing required keys to be missing. The end-result was code breaking later on when it tried to access these keys. Since an SR is required to generate these required stats keys, we shouldn't swallow the StorageRepositoryNotFound exception and instead should fail-fast. Fixes bug 1175357 Change-Id: I3d65ae807fb2d86277bc0061c1967a87792b6662 --- nova/tests/test_xenapi.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index 9919fc13..3490a5db 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1639,6 +1639,15 @@ class XenAPIHostTestCase(stubs.XenAPITestBase): self.assertEquals(stats['host_memory_overhead'], 20) self.assertEquals(stats['host_memory_free'], 30) self.assertEquals(stats['host_memory_free_computed'], 40) + self.assertEquals(stats['hypervisor_hostname'], 'fake-xenhost') + + def test_host_state_missing_sr(self): + def fake_safe_find_sr(session): + raise exception.StorageRepositoryNotFound('not there') + + self.stubs.Set(vm_utils, 'safe_find_sr', fake_safe_find_sr) + self.assertRaises(exception.StorageRepositoryNotFound, + self.conn.get_host_stats) def _test_host_action(self, method, action, expected=None): result = method('host', action)