From 1dcf1572567b2851ee7873dd3cf559a572eac8a3 Mon Sep 17 00:00:00 2001 From: Nitin Madhok Date: Fri, 21 Aug 2015 07:10:18 -0400 Subject: [PATCH] Do not raise KeyError when calling avail_images if VM/template is in disconnected state --- salt/cloud/clouds/vmware.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/salt/cloud/clouds/vmware.py b/salt/cloud/clouds/vmware.py index c3b6e1d19f..2a70faefb6 100644 --- a/salt/cloud/clouds/vmware.py +++ b/salt/cloud/clouds/vmware.py @@ -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