Skip to content

Commit 0bafaf3

Browse files
authored
Merge pull request #13 from tianhao64/master
Remove the output file before creating new serial port
2 parents 6847135 + 43c25d0 commit 0bafaf3

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,15 @@
3535
3636
Sample Prerequisites:
3737
The sample needs an existing VM.
38+
39+
Note:
40+
The sample adds new serial ports to the existing VM. If you re-run the sample
41+
without cleaning up the previous created serial ports, the VM may be stuck at
42+
power on stage as there will be multiple serial ports using the same output
43+
file. In such case, you will see a question in vCenter UI asking if the file
44+
should be Replaced or Appended.
45+
To avoid this, make sure to pass -c to clean up the serial ports or manually
46+
delete them after running the sample.
3847
"""
3948

4049
vm = None
@@ -122,6 +131,9 @@ def run():
122131
print('vm.hardware.Serial.get({}, {}) -> {}'.
123132
format(vm, serial, pp(serial_info)))
124133

134+
# Make sure output file doesn't exist already
135+
cleanup_backends()
136+
125137
print('\n# Example: Create Serial port with FILE backing')
126138
serial_port_datastore_path = testbed.config['SERIAL_PORT_DATASTORE_PATH']
127139
serial_create_spec = Serial.CreateSpec(

0 commit comments

Comments
 (0)