diff --git a/samples/vsphere/vcenter/vm/hardware/parallel.py b/samples/vsphere/vcenter/vm/hardware/parallel.py index de528920..b7764e7a 100644 --- a/samples/vsphere/vcenter/vm/hardware/parallel.py +++ b/samples/vsphere/vcenter/vm/hardware/parallel.py @@ -103,6 +103,9 @@ def run(): print('vm.hardware.Parallel.get({}, {}) -> {}'.format(vm, parallel, pp( parallel_info))) + # Make sure output file doesn't exist already + cleanup_backends() + print('\n# Example: Create Parallel port with defaults') parallel_create_spec = Parallel.CreateSpec() parallel = parallel_svc.create(vm, parallel_create_spec) @@ -180,6 +183,9 @@ def run(): print('vm.hardware.Parallel.list({}) -> {}'. format(vm, parallel_summaries)) + # Always cleanup output file so the VM can be powered on next time + cleanup_backends() + def cleanup(): print('\n# Cleanup: Delete VM Parallel ports that were added') @@ -193,8 +199,6 @@ def cleanup(): print('vm.hardware.Parallel WARNING: ' 'Final Parallel ports info does not match original') - cleanup_backends() - def cleanup_backends(): """ diff --git a/samples/vsphere/vcenter/vm/hardware/serial.py b/samples/vsphere/vcenter/vm/hardware/serial.py index 1f282b8e..3e9d9286 100644 --- a/samples/vsphere/vcenter/vm/hardware/serial.py +++ b/samples/vsphere/vcenter/vm/hardware/serial.py @@ -214,6 +214,9 @@ def run(): serial_summaries = serial_svc.list(vm=vm) print('vm.hardware.Serial.list({}) -> {}'.format(vm, serial_summaries)) + # Always cleanup output file so the VM can be powered on next time + cleanup_backends() + def cleanup(): print('\n# Delete VM Serial ports that were added') @@ -227,8 +230,6 @@ def cleanup(): print('vm.hardware.Serial WARNING: ' 'Final Serial ports info does not match original') - cleanup_backends() - def cleanup_backends(): """