Merge "VMware: Fix deletion of an instance with no files"
This commit is contained in:
@@ -242,6 +242,10 @@ class ManagedObject(object):
|
|||||||
"""
|
"""
|
||||||
return self.__getattr__(attr)
|
return self.__getattr__(attr)
|
||||||
|
|
||||||
|
def delete(self, attr):
|
||||||
|
"""Deletes an attribute."""
|
||||||
|
self.propSet = filter(lambda elem: elem.name != attr, self.propSet)
|
||||||
|
|
||||||
def __setattr__(self, attr, val):
|
def __setattr__(self, attr, val):
|
||||||
# TODO(hartsocks): this is adds unnecessary complexity to the class
|
# TODO(hartsocks): this is adds unnecessary complexity to the class
|
||||||
for prop in self.propSet:
|
for prop in self.propSet:
|
||||||
|
|||||||
@@ -1444,9 +1444,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
|
|||||||
self._check_vm_info(info, power_state.RUNNING)
|
self._check_vm_info(info, power_state.RUNNING)
|
||||||
instances = self.conn.list_instances()
|
instances = self.conn.list_instances()
|
||||||
self.assertEqual(len(instances), 1)
|
self.assertEqual(len(instances), 1)
|
||||||
# Overwrite the vmPathName
|
# Delete the vmPathName
|
||||||
vm = self._get_vm_record()
|
vm = self._get_vm_record()
|
||||||
vm.set("config.files.vmPathName", None)
|
vm.delete('config.files.vmPathName')
|
||||||
self.conn.destroy(self.context, self.instance, self.network_info)
|
self.conn.destroy(self.context, self.instance, self.network_info)
|
||||||
instances = self.conn.list_instances()
|
instances = self.conn.list_instances()
|
||||||
self.assertEqual(len(instances), 0)
|
self.assertEqual(len(instances), 0)
|
||||||
|
|||||||
@@ -771,10 +771,12 @@ class VMwareVMOps(object):
|
|||||||
query = vm_util.get_values_from_object_properties(
|
query = vm_util.get_values_from_object_properties(
|
||||||
self._session, props)
|
self._session, props)
|
||||||
pwr_state = query['runtime.powerState']
|
pwr_state = query['runtime.powerState']
|
||||||
vm_config_pathname = query['config.files.vmPathName']
|
|
||||||
|
vm_config_pathname = query.get('config.files.vmPathName')
|
||||||
vm_ds_path = None
|
vm_ds_path = None
|
||||||
if vm_config_pathname:
|
if vm_config_pathname is not None:
|
||||||
vm_ds_path = ds_util.DatastorePath.parse(vm_config_pathname)
|
vm_ds_path = ds_util.DatastorePath.parse(
|
||||||
|
vm_config_pathname)
|
||||||
|
|
||||||
# Power off the VM if it is in PoweredOn state.
|
# Power off the VM if it is in PoweredOn state.
|
||||||
if pwr_state == "poweredOn":
|
if pwr_state == "poweredOn":
|
||||||
|
|||||||
Reference in New Issue
Block a user