Handle ssh attempt to VM that is down

This commit is contained in:
Josh Holtrop 2026-05-01 07:18:11 -04:00
parent 16f88d4401
commit a21bf2c215

View File

@ -147,9 +147,11 @@ def read_vm_dominfo(name)
end
def read_vm_info(name)
ssh_out = `ssh -Ti /root/.ssh/malp-vm-key malp@#{name}`
ssh_out = `ssh -o ConnectTimeout=1 -Ti /root/.ssh/malp-vm-key malp@#{name} 2>/dev/null`
if ssh_out != ""
JSON.parse(ssh_out)
end
end
def read_virtual_machines
list_out = `virsh --connect qemu:///system list --all --name 2>/dev/null`
@ -159,7 +161,7 @@ def read_virtual_machines
names.map do |name|
dom_info = read_vm_dominfo(name)
vm_info = read_vm_info(name)
vm_info = read_vm_info(name) || {}
{
"type" => "vm",
"name" => name,