summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-01-11 03:02:15 +0000
committerGerrit Code Review <review@openstack.org>2013-01-11 03:02:15 +0000
commitfabc6ec5d8eb09e6891637bd884e09da05288b6c (patch)
treeab6679b6d711383d4f15a6c1abc28411b0a5dadc
parenta4e290a0f17b1f773a9d53255857d19b02164bcd (diff)
parent97f0ec7039611e4c9a7c543ea4631d7182a5ec99 (diff)
downloadnova-fabc6ec5d8eb09e6891637bd884e09da05288b6c.tar.gz
nova-fabc6ec5d8eb09e6891637bd884e09da05288b6c.tar.xz
nova-fabc6ec5d8eb09e6891637bd884e09da05288b6c.zip
Merge "Access instance as dict, not object in xenapi"
-rw-r--r--nova/tests/test_xenapi.py20
-rw-r--r--nova/virt/xenapi/driver.py2
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