Merge "VMware: Fix deletion of an instance with no files"

This commit is contained in:
Jenkins
2014-10-03 16:36:14 +00:00
committed by Gerrit Code Review
3 changed files with 11 additions and 5 deletions

View File

@@ -242,6 +242,10 @@ class ManagedObject(object):
"""
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):
# TODO(hartsocks): this is adds unnecessary complexity to the class
for prop in self.propSet:

View File

@@ -1444,9 +1444,9 @@ class VMwareAPIVMTestCase(test.NoDBTestCase):
self._check_vm_info(info, power_state.RUNNING)
instances = self.conn.list_instances()
self.assertEqual(len(instances), 1)
# Overwrite the vmPathName
# Delete the vmPathName
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)
instances = self.conn.list_instances()
self.assertEqual(len(instances), 0)