From 7495657587b2ff852ee90121e7c848632045af6c Mon Sep 17 00:00:00 2001 From: Tianhao He Date: Fri, 24 Feb 2017 16:09:10 -0800 Subject: [PATCH] fix format --- .../vsphere/vcenter/vm/create/create_default_vm.py | 1 + .../vcenter/vm/create/create_exhaustive_vm.py | 1 + .../vsphere/vcenter/vm/hardware/adapter/scsi.py | 2 +- samples/vsphere/vcenter/vm/hardware/memory.py | 1 - samples/vsphere/vcenter/vm/hardware/serial.py | 2 ++ samples/vsphere/vcenter/vm/list_vms.py | 14 ++++++++------ 6 files changed, 13 insertions(+), 8 deletions(-) diff --git a/samples/vsphere/vcenter/vm/create/create_default_vm.py b/samples/vsphere/vcenter/vm/create/create_default_vm.py index bed975e7..3a9278e0 100644 --- a/samples/vsphere/vcenter/vm/create/create_default_vm.py +++ b/samples/vsphere/vcenter/vm/create/create_default_vm.py @@ -122,5 +122,6 @@ def main(): if cleardata: cleanup() + if __name__ == '__main__': main() diff --git a/samples/vsphere/vcenter/vm/create/create_exhaustive_vm.py b/samples/vsphere/vcenter/vm/create/create_exhaustive_vm.py index f0301aad..2bc8acad 100644 --- a/samples/vsphere/vcenter/vm/create/create_exhaustive_vm.py +++ b/samples/vsphere/vcenter/vm/create/create_exhaustive_vm.py @@ -251,5 +251,6 @@ def main(): if cleardata: cleanup() + if __name__ == '__main__': main() diff --git a/samples/vsphere/vcenter/vm/hardware/adapter/scsi.py b/samples/vsphere/vcenter/vm/hardware/adapter/scsi.py index 6f3cc877..f4868c5b 100644 --- a/samples/vsphere/vcenter/vm/hardware/adapter/scsi.py +++ b/samples/vsphere/vcenter/vm/hardware/adapter/scsi.py @@ -59,7 +59,6 @@ def setup(context=None): atexit.register(vapiconnect.logout, stub_config) - def run(): global vm vm = get_vm(stub_config, vm_name) @@ -145,5 +144,6 @@ def main(): if cleardata: cleanup() + if __name__ == '__main__': main() diff --git a/samples/vsphere/vcenter/vm/hardware/memory.py b/samples/vsphere/vcenter/vm/hardware/memory.py index 88e62b2b..232c823b 100644 --- a/samples/vsphere/vcenter/vm/hardware/memory.py +++ b/samples/vsphere/vcenter/vm/hardware/memory.py @@ -58,7 +58,6 @@ def setup(context=None): atexit.register(vapiconnect.logout, stub_config) - def run(): global vm vm = get_vm(stub_config, vm_name) diff --git a/samples/vsphere/vcenter/vm/hardware/serial.py b/samples/vsphere/vcenter/vm/hardware/serial.py index 9811769f..4fc5359b 100644 --- a/samples/vsphere/vcenter/vm/hardware/serial.py +++ b/samples/vsphere/vcenter/vm/hardware/serial.py @@ -235,6 +235,7 @@ def cleanup_backends(): datacenter_name, datastore_path) + def main(): setup() cleanup_backends() @@ -242,5 +243,6 @@ def main(): if cleardata: cleanup() + if __name__ == '__main__': main() diff --git a/samples/vsphere/vcenter/vm/list_vms.py b/samples/vsphere/vcenter/vm/list_vms.py index 4d79de26..c5c88d58 100644 --- a/samples/vsphere/vcenter/vm/list_vms.py +++ b/samples/vsphere/vcenter/vm/list_vms.py @@ -31,7 +31,8 @@ cleardata = False def setup(context=None): global stub_config, cleardata server, username, password, cleardata, skip_verification = parse_cli_args() - stub_config = vapiconnect.connect(server, username, password, skip_verification) + stub_config = vapiconnect.connect(server, username, password, + skip_verification) atexit.register(vapiconnect.logout, stub_config) @@ -41,17 +42,18 @@ def run(): """ vm_svc = VM(stub_config) list_of_vms = vm_svc.list() - print ("----------------------------") - print ("List Of VMs") - print ("----------------------------") + print("----------------------------") + print("List Of VMs") + print("----------------------------") for vm in list_of_vms: - print ('{}'.format(vm)) - print ("----------------------------") + print('{}'.format(vm)) + print("----------------------------") def main(): setup() run() + if __name__ == '__main__': main()