glennmatthews / cot

Common OVF Tool
MIT License
90 stars 23 forks source link

"cot deploy esxi" needs to create serial ports after deployment #24

Closed glennmatthews closed 9 years ago

glennmatthews commented 9 years ago

Currently ovftool ignores serial ports defined in an OVF, so cot deploy esxi (which uses ovftool) will create VMs with no serial ports even if the OVF defines them.

Until/unless VMware fixes this ovftool limitation, it would be really helpful for COT to implement some workaround (possibly using PowerCLI?) to force creation of the requested serial ports.

glennmatthews commented 9 years ago

Probably relevant:

http://access-console-port-virtual-machine.blogspot.com/2013/07/add-serial-port-to-vm-through-gui-or.html

PowerCLI script to do create serial port. Although Firewall settings on esxi server has to be done manually.

# Adds the base cmdlets
Add-PSSnapin VMware.VimAutomation.Core
# This script adds some helper functions and sets the appearance. You can pick and choose parts of this file for a fully custom appearance.
. "C:\Program Files (x86)\VMware\Infrastructure\vSphere PowerCLI\Scripts\Initialize-PowerCLIEnvironment.ps1"

Function New-SerialPort
{
 Param(
   [string]$vmName,
   [string]$prt
) #end
$dev = New-Object VMware.Vim.VirtualDeviceConfigSpec
$dev.operation = "add"
$dev.device = New-Object VMware.Vim.VirtualSerialPort
$dev.device.key = -1
$dev.device.backing = New-Object VMware.Vim.VirtualSerialPortURIBackingInfo
$dev.device.backing.direction = "server"
$dev.device.backing.serviceURI = "telnet://:$prt"
$dev.device.connectable = New-Object VMware.Vim.VirtualDeviceConnectInfo
$dev.device.connectable.connected = $true
$dev.device.connectable.StartConnected = $true
$dev.device.yieldOnPoll = $true

$spec = New-Object VMware.Vim.VirtualMachineConfigSpec
$spec.DeviceChange += $dev

$vm = Get-VM -Name $vmName
$vm.ExtensionData.ReconfigVM($spec)

}
  1. Power OFF your VM
  2. open PowerCLI
  3. New-SerialPort
  4. Power ON your vm
  5. telnet
glennmatthews commented 9 years ago

14da863 is related

glennmatthews commented 9 years ago

I found an example of adding serial ports via pysphere: https://groups.google.com/forum/#!topic/pysphere/u1PI4tnpiXA

I installed pysphere on my server and was able to run the serial port script from the web page above. deploy vm with cot add serial port: python add_serial_port.py -s 10.122.197.27 -u root -p rtpfe123 -v skorka_test3 -P 33334 telnet to the serial port telnet 10.122.197.27 33334

glennmatthews commented 9 years ago

55e78d32f31b8b8db24323014ed6b87e6a66214d