VMware: get_all_cluster_refs_by_name default to {}
Currently get_all_cluster_refs_by_name returns None when no cluster is found. driver.py is using the keys() method without checking whether the object returned is None. This can potentially end up throwing an AttributeError. This patch fixes the issue by returning an empty dictionary when no cluster is found. Change-Id: I3293c916d79aaa4de8913e8ab9c609c9c0bb023e Closes-Bug: #1372672
This commit is contained in:
@@ -466,7 +466,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
|
||||
fake_objects = fake.FakeRetrieveResult()
|
||||
refs = vm_util.get_all_cluster_refs_by_name(
|
||||
fake.FakeObjectRetrievalSession(fake_objects), ['fake_cluster'])
|
||||
self.assertTrue(not refs)
|
||||
self.assertEqual({}, refs)
|
||||
|
||||
def test_get_all_cluster_refs_by_name_exists(self):
|
||||
fake_objects = fake.FakeRetrieveResult()
|
||||
@@ -480,7 +480,7 @@ class VMwareVMUtilTestCase(test.NoDBTestCase):
|
||||
fake_objects.add_object(partialObject(path='cluster'))
|
||||
refs = vm_util.get_all_cluster_refs_by_name(
|
||||
fake.FakeObjectRetrievalSession(fake_objects), ['cluster'])
|
||||
self.assertTrue(not refs)
|
||||
self.assertEqual({}, refs)
|
||||
|
||||
def test_propset_dict_simple(self):
|
||||
ObjectContent = collections.namedtuple('ObjectContent', ['propSet'])
|
||||
|
||||
@@ -1176,10 +1176,10 @@ def get_all_cluster_refs_by_name(session, path_list):
|
||||
"""
|
||||
cls = get_all_cluster_mors(session)
|
||||
if not cls:
|
||||
return
|
||||
return {}
|
||||
res = get_all_res_pool_mors(session)
|
||||
if not res:
|
||||
return
|
||||
return {}
|
||||
path_list = [path.strip() for path in path_list]
|
||||
list_obj = []
|
||||
for entity_path in path_list:
|
||||
|
||||
Reference in New Issue
Block a user