Skip to content

Commit 91c837e

Browse files
authored
Merge pull request #14 from tianhao64/master
Remove the output file before creating the parallel port
2 parents 0bafaf3 + ca53102 commit 91c837e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

samples/vsphere/vcenter/vm/hardware/parallel.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,9 @@ def run():
103103
print('vm.hardware.Parallel.get({}, {}) -> {}'.format(vm, parallel, pp(
104104
parallel_info)))
105105

106+
# Make sure output file doesn't exist already
107+
cleanup_backends()
108+
106109
print('\n# Example: Create Parallel port with defaults')
107110
parallel_create_spec = Parallel.CreateSpec()
108111
parallel = parallel_svc.create(vm, parallel_create_spec)
@@ -180,6 +183,9 @@ def run():
180183
print('vm.hardware.Parallel.list({}) -> {}'.
181184
format(vm, parallel_summaries))
182185

186+
# Always cleanup output file so the VM can be powered on next time
187+
cleanup_backends()
188+
183189

184190
def cleanup():
185191
print('\n# Cleanup: Delete VM Parallel ports that were added')
@@ -193,8 +199,6 @@ def cleanup():
193199
print('vm.hardware.Parallel WARNING: '
194200
'Final Parallel ports info does not match original')
195201

196-
cleanup_backends()
197-
198202

199203
def cleanup_backends():
200204
"""

samples/vsphere/vcenter/vm/hardware/serial.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@ def run():
214214
serial_summaries = serial_svc.list(vm=vm)
215215
print('vm.hardware.Serial.list({}) -> {}'.format(vm, serial_summaries))
216216

217+
# Always cleanup output file so the VM can be powered on next time
218+
cleanup_backends()
219+
217220

218221
def cleanup():
219222
print('\n# Delete VM Serial ports that were added')
@@ -227,8 +230,6 @@ def cleanup():
227230
print('vm.hardware.Serial WARNING: '
228231
'Final Serial ports info does not match original')
229232

230-
cleanup_backends()
231-
232233

233234
def cleanup_backends():
234235
"""

0 commit comments

Comments
 (0)