From 2ecbca4718e964b4a5f6b16d6a2bcf05e8892601 Mon Sep 17 00:00:00 2001 From: pgbidkar Date: Mon, 6 Feb 2017 03:36:00 -0800 Subject: [PATCH] Modified to incorporate review comments --- samples/vsphere/vcenter/vm/list_vms.py | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/samples/vsphere/vcenter/vm/list_vms.py b/samples/vsphere/vcenter/vm/list_vms.py index 481e13a6..7b691b58 100644 --- a/samples/vsphere/vcenter/vm/list_vms.py +++ b/samples/vsphere/vcenter/vm/list_vms.py @@ -12,6 +12,7 @@ * NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. """ +import atexit from samples.vsphere.common import vapiconnect from samples.vsphere.common.sample_util import parse_cli_args from samples.vsphere.common.sample_util import pp @@ -34,37 +35,30 @@ def setup(context=None): username, password, skip_verification) - #atexit.register(vapiconnect.logout, stub_config) + atexit.register(vapiconnect.logout, stub_config) def run(): - list_vms(stub_config) - - -def list_vms(stub_config): """ 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)) - - -def cleanup(): - pass - + print "----------------------------" + def main(): try: setup() - cleanup() run() - if cleardata: - cleanup() finally: if stub_config: - vapiconnect.logout(stub_config) + pass if __name__ == '__main__':