diff options
-rw-r--r-- | nova/tests/test_xenapi.py | 20 | ||||
-rw-r--r-- | nova/virt/xenapi/driver.py | 2 |
2 files changed, 6 insertions, 16 deletions
diff --git a/nova/tests/test_xenapi.py b/nova/tests/test_xenapi.py index b3437db62..0b1c5d0e7 100644 --- a/nova/tests/test_xenapi.py +++ b/nova/tests/test_xenapi.py @@ -1780,19 +1780,12 @@ class XenAPIBWCountersTestCase(stubs.XenAPITestBase): } def test_get_all_bw_counters(self): - class testinstance(object): - def __init__(self, name, uuid): - self.name = name - self.uuid = uuid + instances = [dict(name='test1', uuid='1-2-3'), + dict(name='test2', uuid='4-5-6')] self.stubs.Set(vm_utils, 'fetch_bandwidth', XenAPIBWCountersTestCase._fake_fetch_bandwidth) - result = self.conn.get_all_bw_counters([testinstance( - name='test1', - uuid='1-2-3'), - testinstance( - name='test2', - uuid='4-5-6')]) + result = self.conn.get_all_bw_counters(instances) self.assertEqual(len(result), 4) self.assertIn(dict(uuid='1-2-3', mac_address="a:b:c:d...", @@ -1816,14 +1809,11 @@ class XenAPIBWCountersTestCase(stubs.XenAPITestBase): """Test that get_all_bw_conters returns an empty list when no data returned from Xenserver. c.f. bug #910045. """ - class testinstance(object): - def __init__(self): - self.name = "instance-0001" - self.uuid = "1-2-3-4-5" + instances = [dict(name='instance-0001', uuid='1-2-3-4-5')] self.stubs.Set(vm_utils, 'fetch_bandwidth', XenAPIBWCountersTestCase._fake_fetch_bandwidth_mt) - result = self.conn.get_all_bw_counters([testinstance()]) + result = self.conn.get_all_bw_counters(instances) self.assertEqual(result, []) diff --git a/nova/virt/xenapi/driver.py b/nova/virt/xenapi/driver.py index bdb73b28f..0acc360e8 100644 --- a/nova/virt/xenapi/driver.py +++ b/nova/virt/xenapi/driver.py @@ -311,7 +311,7 @@ class XenAPIDriver(driver.ComputeDriver): # we only care about VMs that correspond to a nova-managed # instance: - imap = dict([(inst.name, inst.uuid) for inst in instances]) + imap = dict([(inst['name'], inst['uuid']) for inst in instances]) bwcounters = [] # get a dictionary of instance names. values are dictionaries |