Merge "VMware: prevent image snapshot if no root disk defined"
This commit is contained in:
commit
b52a63e3b6
|
@ -1078,6 +1078,12 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||
self._create_vm()
|
||||
self._test_snapshot()
|
||||
|
||||
def test_snapshot_no_root_disk(self):
|
||||
self._iso_disk_type_created(instance_type='m1.micro')
|
||||
self.assertRaises(error_util.NoRootDiskDefined, self.conn.snapshot,
|
||||
self.context, self.instance, "Test-Snapshot",
|
||||
lambda *args, **kwargs: None)
|
||||
|
||||
def test_snapshot_non_existent(self):
|
||||
self._create_instance()
|
||||
self.assertRaises(exception.InstanceNotFound, self.conn.snapshot,
|
||||
|
|
|
@ -150,6 +150,10 @@ class MissingParameter(VMwareDriverException):
|
|||
msg_fmt = _("Missing parameter : %(param)s")
|
||||
|
||||
|
||||
class NoRootDiskDefined(VMwareDriverException):
|
||||
msg_fmt = _("No root disk defined.")
|
||||
|
||||
|
||||
class AlreadyExistsException(VMwareDriverException):
|
||||
msg_fmt = _("Resource already exists.")
|
||||
code = 409
|
||||
|
|
|
@ -731,6 +731,10 @@ class VMwareVMOps(object):
|
|||
(vmdk_file_path_before_snapshot, adapter_type,
|
||||
disk_type) = vm_util.get_vmdk_path_and_adapter_type(
|
||||
hw_devices, uuid=instance['uuid'])
|
||||
if not vmdk_file_path_before_snapshot:
|
||||
LOG.debug("No root disk defined. Unable to snapshot.")
|
||||
raise error_util.NoRootDiskDefined()
|
||||
|
||||
datastore_name = ds_util.split_datastore_path(
|
||||
vmdk_file_path_before_snapshot)[0]
|
||||
os_type = self._session._call_method(vim_util,
|
||||
|
|
Loading…
Reference in New Issue