Skip to content

Instantly share code, notes, and snippets.

@einarnn
Last active September 12, 2021 21:00
Show Gist options
  • Save einarnn/793ad6f0cb2da3365911f0ba18c3ae45 to your computer and use it in GitHub Desktop.
Save einarnn/793ad6f0cb2da3365911f0ba18c3ae45 to your computer and use it in GitHub Desktop.
Add Serial Port To VM
#!/bin/bash
#
#
# simple function to check for existence of a binary on the current
# path
#
checkExists() {
bin=`command -v $1`
if [ -z "$bin" ]
then
echo this script requires $1 to be on your path
exit 1
fi
}
# we need govc to do this
checkExists govc
# parameters for govc
GOVC_URL=vcenter.fq.dn
GOVC_USERNAME=some_user
GOVC_PASSWORD='password'
GOVC_INSECURE=true
GOVC_NETWORK="VM Network"
GOVC_DATACENTER=some_datacenter
# take first parameter
VM=$1
PORT=$2
# simplistically add serial port for debugging
govc device.serial.add \
-vm=${VM}
govc device.serial.connect \
-vm=${VM} \
-client=false \
telnet://:${PORT}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment