Merge pull request #26546 from nmadhok/vmware-key-error-patch-2015.5

Do not raise KeyError when calling avail_images if VM/template is in disconnected state
This commit is contained in:
Justin Findlay 2015-08-21 08:17:49 -06:00
commit d721b7b2be

View File

@ -1669,12 +1669,12 @@ def avail_images(call=None):
vm_list = _get_mors_with_properties(vim.VirtualMachine, vm_properties)
for vm in vm_list:
if vm["config.template"]:
if "config.template" in vm and vm["config.template"]:
templates[vm["name"]] = {
'name': vm["name"],
'guest_fullname': vm["config.guestFullName"],
'cpus': vm["config.hardware.numCPU"],
'ram': vm["config.hardware.memoryMB"]
'guest_fullname': vm["config.guestFullName"] if "config.guestFullName" in vm else "N/A",
'cpus': vm["config.hardware.numCPU"] if "config.hardware.numCPU" in vm else "N/A",
'ram': vm["config.hardware.memoryMB"] if "config.hardware.memoryMB" in vm else "N/A"
}
return templates