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
This commit is contained in:
Rick Harris
2013-05-01 21:47:35 +00:00
parent 261c43a561
commit 78f61855e1

View File

@@ -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)