summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Harris <rconradharris@gmail.com>2012-07-30 20:05:35 +0000
committerRick Harris <rconradharris@gmail.com>2012-07-30 21:25:01 +0000
commitc46394ac7b953950a3eda3975308031b67cb7312 (patch)
tree567bd8b1f455d4f2baaf36d1ec016ef90fbd9112
parenta84c35d0830f68553cf9c814f7ae2eccf04b84e8 (diff)
downloadnova-c46394ac7b953950a3eda3975308031b67cb7312.tar.gz
nova-c46394ac7b953950a3eda3975308031b67cb7312.tar.xz
nova-c46394ac7b953950a3eda3975308031b67cb7312.zip
Compute: VM-Mode should use instance dict.
Instance dicts no longer support attribute-style access. Change-Id: Ia5191aa14ad7cc62630bd6b0df8aaccb87e51e03
-rw-r--r--nova/compute/vm_mode.py2
-rw-r--r--nova/tests/test_vmmode.py15
2 files changed, 6 insertions, 11 deletions
diff --git a/nova/compute/vm_mode.py b/nova/compute/vm_mode.py
index a380511a9..26e5ad8a0 100644
--- a/nova/compute/vm_mode.py
+++ b/nova/compute/vm_mode.py
@@ -38,7 +38,7 @@ ALL = [HVM, XEN, UML, EXE]
def get_from_instance(instance):
- mode = instance.vm_mode
+ mode = instance['vm_mode']
if mode is None:
return None
diff --git a/nova/tests/test_vmmode.py b/nova/tests/test_vmmode.py
index cd639478c..374f040ed 100644
--- a/nova/tests/test_vmmode.py
+++ b/nova/tests/test_vmmode.py
@@ -22,33 +22,28 @@ from nova.compute import vm_mode
class ComputeVMModeTest(test.TestCase):
- class testinstance(object):
- def __init__(self, mode):
- self.vm_mode = mode
-
def test_case(self):
- inst = ComputeVMModeTest.testinstance("HVM")
+ inst = dict(vm_mode="HVM")
mode = vm_mode.get_from_instance(inst)
self.assertEqual(mode, "hvm")
def test_legacy_pv(self):
- inst = ComputeVMModeTest.testinstance("pv")
+ inst = dict(vm_mode="pv")
mode = vm_mode.get_from_instance(inst)
self.assertEqual(mode, "xen")
def test_legacy_hv(self):
- inst = ComputeVMModeTest.testinstance("hv")
+ inst = dict(vm_mode="hv")
mode = vm_mode.get_from_instance(inst)
self.assertEqual(mode, "hvm")
def test_bogus(self):
- inst = ComputeVMModeTest.testinstance("wibble")
-
+ inst = dict(vm_mode="wibble")
self.assertRaises(exception.Invalid,
vm_mode.get_from_instance,
inst)
def test_good(self):
- inst = ComputeVMModeTest.testinstance("hvm")
+ inst = dict(vm_mode="hvm")
mode = vm_mode.get_from_instance(inst)
self.assertEqual(mode, "hvm")