Friday, February 15, 2019

SSH to all of the serial ports

This is just a quick-and-dirty script for logging into every serial port on an Opengear box, one in each tab of a MacOS terminal.

Used it just recently because I couldn't remember where a device console was connected.

Don't change mouse focus while it's running: It'll wind up dumping keystrokes into the wrong window.

for i in $(seq 48)
  port=$(expr 3000 + $i)
  sshcmd="ssh -p $port terminalserver"
  osascript \
    -e 'tell application "Terminal" to activate' \
    -e 'tell application "System Events" to tell process "Terminal" to keystroke "t" using command down' \
    -e "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"$sshcmd\"" \
    -e "tell application \"System Events\" to tell process \"Terminal\" to key code 36"

Leaving it here in case somebody (probably me) finds it useful in the future.

Monday, January 21, 2019

Cannot connect the virtual device ... because no corresponding device is available on the host

Recently I've been building some VM templates on my MacBook and launching instances of them in VMware. Each time it produced following error:

Cannot connect the virtual device sata0:1 because no corresponding device is available on the host.

Either button caused the guest to boot up. The "No" button ensured that it booted without error on subsequent reboots, while choosing "Yes" allowed me to enjoy the error with each power-on of the guest.

Sata0 is, of course a (virtual) disk controller, and device 1 is an optical drive. I knew that much, but the exact meaning of the error wasn't clear to me, and googling didn't lead to a great explanation.

I wasn't expecting there to be a "corresponding device ... available on the host" because the host has neither a SATA controller nor an optical drive, and no such hardware should be required for my use case, so, what did the error mean?

It turns out that I was producing the template (a .ova file) with the optical drive "connected" (VMware term) to ... something. The issue isn't related to the lack of a device on the host, but that there's no ISO file "inserted" into the virtual drive.

Here's the relevant stanza from the template's .ovf file:

        <rasd:Description>CD-ROM Drive</rasd:Description>


The problem here is the AutomaticaAllocation element. AutomaticAllocation is VMware's "connect at boot" feature, which really boils down to "insert a disk into this virtual drive". Without specifying a backend device and/or file, it can't be connected.

Deleting the element, or setting it to "false" fixes the problem.

AddressOnParent: 1 <- This makes it sata0:1 instead of sata0:0
InstanceID: 7 <- This device is the 8th hardware device defined for the guest
Parent: 5 <- This device is a child of the hardware device at instance id #5 (the sata0)
ResourceType: 15 <- This is an optical drive