From 43c25d0b616a1244ed79db682b4b2b918c9f3fec Mon Sep 17 00:00:00 2001 From: Tianhao He Date: Fri, 24 Mar 2017 14:14:18 -0700 Subject: [PATCH] Remove the output file before creating new serial port When re-run the sample without cleanup previous port the power on peration may time out due to the output file exist already. Remove the file before creating new port and add notes to help avoiding this. Signed-off-by: Tianhao He --- samples/vsphere/vcenter/vm/hardware/serial.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/samples/vsphere/vcenter/vm/hardware/serial.py b/samples/vsphere/vcenter/vm/hardware/serial.py index e1cb1ef5..1f282b8e 100644 --- a/samples/vsphere/vcenter/vm/hardware/serial.py +++ b/samples/vsphere/vcenter/vm/hardware/serial.py @@ -35,6 +35,15 @@ Demonstrates how to configure Serial ports for a VM. Sample Prerequisites: 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 @@ -122,6 +131,9 @@ def run(): print('vm.hardware.Serial.get({}, {}) -> {}'. 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') serial_port_datastore_path = testbed.config['SERIAL_PORT_DATASTORE_PATH'] serial_create_spec = Serial.CreateSpec(