1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-21 17:29:59 -05:00

Remove the output file before creating the parallel port

Need to make the same fix as the one in #13 for parallel port.
Also move the cleanup_backends to the main sample run to make
sure the output file is always deleted.

Signed-off-by: Tianhao He <tianhao64@users.noreply.github.com>
This commit is contained in:
Tianhao He 2017-03-24 20:02:40 -07:00
parent 0bafaf380c
commit ca53102df4
2 changed files with 9 additions and 4 deletions

View File

@ -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():
"""

View File

@ -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():
"""