Update restrictions of vm_state when attaching/detaching volumes
Permit all states except PAUSED. Change-Id: Iaba22591f448de4af44f4c0874c88aca62fc7257
This commit is contained in:
parent
39246de043
commit
d07134b0d9
|
@ -930,14 +930,6 @@ class ZVMDriverTestCases(ZVMTestCase):
|
|||
|
||||
def test_attach_volume_invalid_vm_states(self):
|
||||
self.instance.vm_state = vm_states.PAUSED
|
||||
self.assertRaises(exception.ZVMDriverError,
|
||||
self.driver.attach_volume,
|
||||
{}, None, self.instance, None)
|
||||
self.instance.vm_state = vm_states.RESIZED
|
||||
self.assertRaises(exception.ZVMDriverError,
|
||||
self.driver.attach_volume,
|
||||
{}, None, self.instance, None)
|
||||
self.instance.vm_state = vm_states.SOFT_DELETED
|
||||
self.assertRaises(exception.ZVMDriverError,
|
||||
self.driver.attach_volume,
|
||||
{}, None, self.instance, None)
|
||||
|
|
|
@ -745,10 +745,8 @@ class ZVMDriver(driver.ComputeDriver):
|
|||
def attach_volume(self, context, connection_info, instance, mountpoint,
|
||||
disk_bus=None, device_type=None, encryption=None):
|
||||
"""Attach the disk to the instance at mountpoint using info."""
|
||||
if instance.vm_state not in [vm_states.ACTIVE, vm_states.STOPPED,
|
||||
vm_states.BUILDING]:
|
||||
msg = _("Instance must be ACTIVE, BUILDING or SHUTDOWN "
|
||||
"when attaching volumes.")
|
||||
if instance.vm_state == vm_states.PAUSED:
|
||||
msg = _("Attaching to a paused instance is not supported.")
|
||||
raise exception.ZVMDriverError(msg=msg)
|
||||
if mountpoint:
|
||||
mountpoint = self._format_mountpoint(mountpoint)
|
||||
|
|
Loading…
Reference in New Issue