1
0
mirror of https://github.com/vmware/vsphere-automation-sdk-python.git synced 2024-11-22 01:39:58 -05:00

Merge pull request #13 from tianhao64/master

Remove the output file before creating new serial port
This commit is contained in:
Tianhao He 2017-03-24 15:37:46 -07:00 committed by GitHub
commit 0bafaf380c

View File

@ -35,6 +35,15 @@ Demonstrates how to configure Serial ports for a VM.
Sample Prerequisites: Sample Prerequisites:
The sample needs an existing VM. The sample needs an existing VM.
Note:
The sample adds new serial ports to the existing VM. If you re-run the sample
without cleaning up the previous created serial ports, the VM may be stuck at
power on stage as there will be multiple serial ports using the same output
file. In such case, you will see a question in vCenter UI asking if the file
should be Replaced or Appended.
To avoid this, make sure to pass -c to clean up the serial ports or manually
delete them after running the sample.
""" """
vm = None vm = None
@ -122,6 +131,9 @@ def run():
print('vm.hardware.Serial.get({}, {}) -> {}'. print('vm.hardware.Serial.get({}, {}) -> {}'.
format(vm, serial, pp(serial_info))) format(vm, serial, pp(serial_info)))
# Make sure output file doesn't exist already
cleanup_backends()
print('\n# Example: Create Serial port with FILE backing') print('\n# Example: Create Serial port with FILE backing')
serial_port_datastore_path = testbed.config['SERIAL_PORT_DATASTORE_PATH'] serial_port_datastore_path = testbed.config['SERIAL_PORT_DATASTORE_PATH']
serial_create_spec = Serial.CreateSpec( serial_create_spec = Serial.CreateSpec(