Merge "vmware: Handle empty list attributes on vSphere objects"

This commit is contained in:
Zuul 2021-04-16 16:41:52 +00:00 committed by Gerrit Code Review
commit 3e04d9f9bf
2 changed files with 3 additions and 3 deletions

View File

@ -395,7 +395,7 @@ def file_size(session, ds_browser, ds_path, file_name):
datastorePath=str(ds_path),
searchSpec=search_spec)
task_info = session._wait_for_task(search_task)
if hasattr(task_info.result, 'file'):
if hasattr(task_info.result, 'file') and task_info.result.file:
return task_info.result.file[0].fileSize

View File

@ -1069,7 +1069,7 @@ def _get_allocated_vnc_ports(session):
"VirtualMachine", [VNC_CONFIG_KEY])
while result:
for obj in result.objects:
if not hasattr(obj, 'propSet'):
if not hasattr(obj, 'propSet') or not obj.propSet:
continue
dynamic_prop = obj.propSet[0]
option_value = dynamic_prop.val
@ -1328,7 +1328,7 @@ def get_cluster_ref_by_name(session, cluster_name):
"""Get reference to the vCenter cluster with the specified name."""
all_clusters = get_all_cluster_mors(session)
for cluster in all_clusters:
if (hasattr(cluster, 'propSet') and
if (hasattr(cluster, 'propSet') and cluster.propSet and
cluster.propSet[0].val == cluster_name):
return cluster.obj