summaryrefslogtreecommitdiffstats
path: root/nova/tests
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2012-10-25 02:24:22 +0000
committerGerrit Code Review <review@openstack.org>2012-10-25 02:24:22 +0000
commita09e00cfa03ede3eea6d33e692b29907cb8f7b91 (patch)
tree3b7fa28b813d7d592c16848d60546c8d50b1ed1b /nova/tests
parent1ae3f8a41ea1a930577d1c35c8d4893dca934196 (diff)
parent814e7f8c827aa21a87a62594d5b6413bb49e31e1 (diff)
Merge "libvirt: persist volume attachments into config"
Diffstat (limited to 'nova/tests')
-rw-r--r--nova/tests/fakelibvirt.py7
-rw-r--r--nova/tests/test_virt_drivers.py12
2 files changed, 18 insertions, 1 deletions
diff --git a/nova/tests/fakelibvirt.py b/nova/tests/fakelibvirt.py
index b933b004a..7c9d5b238 100644
--- a/nova/tests/fakelibvirt.py
+++ b/nova/tests/fakelibvirt.py
@@ -73,6 +73,8 @@ VIR_DOMAIN_XML_SECURE = 1
VIR_DOMAIN_UNDEFINE_MANAGED_SAVE = 1
VIR_DOMAIN_AFFECT_CURRENT = 0
+VIR_DOMAIN_AFFECT_LIVE = 1
+VIR_DOMAIN_AFFECT_CONFIG = 2
VIR_CPU_COMPARE_ERROR = -1
VIR_CPU_COMPARE_INCOMPATIBLE = 0
@@ -337,7 +339,10 @@ class Domain(object):
self._def['devices']['disks'] += [disk_info]
return True
- def attachDeviceFlags(self, xml, _flags):
+ def attachDeviceFlags(self, xml, flags):
+ if (flags & VIR_DOMAIN_AFFECT_LIVE and
+ self._state != VIR_DOMAIN_RUNNING):
+ raise libvirtError("AFFECT_LIVE only allowed for running domains!")
self.attachDevice(xml)
def detachDevice(self, xml):
diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py
index d5a2203f3..5508ab9bb 100644
--- a/nova/tests/test_virt_drivers.py
+++ b/nova/tests/test_virt_drivers.py
@@ -361,6 +361,18 @@ class _VirtDriverTestCase(_FakeDriverBackendTestCase):
'/mnt/nova/something')
@catch_notimplementederror
+ def test_attach_detach_different_power_states(self):
+ instance_ref, network_info = self._get_running_instance()
+ self.connection.power_off(instance_ref)
+ self.connection.attach_volume({'driver_volume_type': 'fake'},
+ instance_ref['name'],
+ '/mnt/nova/something')
+ self.connection.power_on(instance_ref)
+ self.connection.detach_volume({'driver_volume_type': 'fake'},
+ instance_ref['name'],
+ '/mnt/nova/something')
+
+ @catch_notimplementederror
def test_get_info(self):
instance_ref, network_info = self._get_running_instance()
info = self.connection.get_info(instance_ref)