From 9a4e62b90af2348974d1f068ec518520baa900d2 Mon Sep 17 00:00:00 2001 From: pgbidkar Date: Mon, 20 Feb 2017 00:28:13 -0800 Subject: [PATCH] Modified according to review comments. --- samples/vsphere/vcenter/vm/list_vms.py | 32 +++++++++++--------------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/samples/vsphere/vcenter/vm/list_vms.py b/samples/vsphere/vcenter/vm/list_vms.py index 7b691b58..b4ab96b4 100644 --- a/samples/vsphere/vcenter/vm/list_vms.py +++ b/samples/vsphere/vcenter/vm/list_vms.py @@ -13,6 +13,7 @@ """ import atexit +import json from samples.vsphere.common import vapiconnect from samples.vsphere.common.sample_util import parse_cli_args from samples.vsphere.common.sample_util import pp @@ -39,27 +40,22 @@ def setup(context=None): def run(): - """ - List VMs present in server - """ - vm_svc = VM(stub_config) - list_of_vms = vm_svc.list() - print "----------------------------" - print "List Of VMs" - print "----------------------------" - for vm in list_of_vms: - print ('{}'.format(vm)) - print "----------------------------" + """ + List VMs present in server + """ + vm_svc = VM(stub_config) + list_of_vms = vm_svc.list() + print ("----------------------------") + print ("List Of VMs") + print ("----------------------------") + for vm in list_of_vms: + print ('{}'.format(vm)) + print ("----------------------------") def main(): - try: - setup() - run() - finally: - if stub_config: - pass - + setup() + run() if __name__ == '__main__': main() \ No newline at end of file