I need access to my deployed virtual machine's serial console, not through a GUI window, but through ssh or telnet. I finally found how to define a serial console so that I can telnet in, which is perfect, but now I'd like to automate the defining of that serial device without using the vSphere Client GUI.
I can define my serial port from the vSphere Client GUI after deploying my VM by powering off the VM, Edit Settings -> Add a Serial Port, check "Connect via Network" -> Network Backing -> Server (VM listens for connections), Port URI = telnet://10.36.0.85:7001, where 10.36.0.85 is my ESXi 4.1 server's IP address and 7001 is a random port. When I power on my VM, I can telnet 10.36.0.85 7001 from a remote system and viola, I have serial console/terminal access.
In the vmx file, I can see
serial0.present = "TRUE"
serial0.yieldOnMsrRead = "TRUE"
serial0.fileType = "network"
serial0.fileName = "telnet://10.36.0.85:7001"
The question is, how can I define the above either in the ovf file before I deploy, as I deploy (I'm using ovftool from a remote system), or via a remote command afterwards, e.g. a vSphere CLI command? When I try exporting the ovf template from the vSphere client, I get "Device 'Serial port 1' cannot be exported."