fix(cgi-bin): handle VMs without VNC port in get_vnc_info

main
Tsu-ba-me 4 years ago
parent 454ab7bc84
commit 6c4f817a58
  1. 15
      cgi-bin/manage_vnc_ports

@ -72,18 +72,21 @@ sub get_vnc_info
my $shell_call = "ssh root@".$host_name." \"virsh vncdisplay ".$server_name."\""; my $shell_call = "ssh root@".$host_name." \"virsh vncdisplay ".$server_name."\"";
my ($shell_output, $shell_return_code) = $anvil->System->call({ shell_call => $shell_call }); my ($shell_output, $shell_return_code) = $anvil->System->call({ shell_call => $shell_call });
my ($port_offset) = $shell_output =~ /:(\d+)$/;
my $port_sum = $port_base + int($port_offset);
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => {
shell_output => $shell_output, shell_output => $shell_output,
shell_return_code => $shell_return_code, shell_return_code => $shell_return_code
port_offset => $port_offset,
port_sum => $port_sum
} }); } });
if ($shell_return_code == 0) if ($shell_return_code == 0)
{ {
$vnc_info->{port} = $port_sum; my ($port_offset) = $shell_output =~ /:(\d+)$/;
$vnc_info->{port} = $port_base + int($port_offset);
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => {
port_offset => $port_offset,
vnc_port => $vnc_info->{port}
} });
} }
return $vnc_info; return $vnc_info;

Loading…
Cancel
Save