fix(tools): pass server vnc port as flag in manage-vnc-pipes

main
Tsu-ba-me 2 years ago
parent 17bef8b415
commit a7b2f7c9e1
  1. 31
      tools/striker-manage-vnc-pipes

@ -94,13 +94,18 @@ sub get_vnc_info
{ {
my $parameters = shift; my $parameters = shift;
my $host_name = $parameters->{host_name}; my $host_name = $parameters->{host_name};
my $port = $parameters->{port};
my $port_base = $parameters->{port_base} // 5900; my $port_base = $parameters->{port_base} // 5900;
my $server_name = $parameters->{server_name}; my $server_name = $parameters->{server_name};
my $server_uuid = $parameters->{server_uuid}; my $server_uuid = $parameters->{server_uuid};
my $port_offset;
my $vnc_info;
if ( (not defined $port) or (not $port =~ /^\d+$/) )
{
# Requires root to access VM information. # Requires root to access VM information.
my $shell_call = "virsh vncdisplay ".$server_name; my $shell_call = "virsh vncdisplay ".$server_name;
my $vnc_info;
my ($shell_output, $shell_error, $shell_return_code) = call({ my ($shell_output, $shell_error, $shell_return_code) = call({
host_name => $host_name, host_name => $host_name,
@ -110,10 +115,15 @@ sub get_vnc_info
return if ($shell_return_code != 0); return if ($shell_return_code != 0);
my ($port_offset) = $shell_output =~ /:(\d+)$/; ($port_offset) = $shell_output =~ /:(\d+)$/;
$port = $port_base + int($port_offset);
}
else
{
$port = int($port);
}
$vnc_info = { host_name => $host_name }; $vnc_info = { host_name => $host_name, port => $port };
$vnc_info->{port} = $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 => {
port_offset => $port_offset, port_offset => $port_offset,
@ -713,6 +723,7 @@ sub open_ws
{ {
my $parameters = shift; my $parameters = shift;
my $server_uuid = $parameters->{server_uuid}; my $server_uuid = $parameters->{server_uuid};
my $server_vnc_port = $parameters->{server_vnc_port};
my $server_info = $parameters->{server_info} // get_server_info($parameters); my $server_info = $parameters->{server_info} // get_server_info($parameters);
@ -722,6 +733,7 @@ sub open_ws
my $vnc_info = get_vnc_info({ my $vnc_info = get_vnc_info({
host_name => $server_info->{host_name}, host_name => $server_info->{host_name},
port => $server_vnc_port,
server_name => $server_info->{server_name}, server_name => $server_info->{server_name},
server_uuid => $server_uuid server_uuid => $server_uuid
}); });
@ -866,6 +878,7 @@ sub open_vnc_pipe
my $host_uuid = $parameters->{host_uuid}; my $host_uuid = $parameters->{host_uuid};
my $is_print = $parameters->{print} // (not $anvil->data->{switches}{'job-uuid'}); my $is_print = $parameters->{print} // (not $anvil->data->{switches}{'job-uuid'});
my $server_uuid = $parameters->{server_uuid}; my $server_uuid = $parameters->{server_uuid};
my $server_vnc_port = $parameters->{server_vnc_port};
my $is_error; my $is_error;
my $open_output; my $open_output;
@ -873,7 +886,8 @@ sub open_vnc_pipe
my $open_params = { my $open_params = {
host_uuid => $host_uuid, host_uuid => $host_uuid,
server_info => get_server_info($parameters), server_info => get_server_info($parameters),
server_uuid => $server_uuid server_uuid => $server_uuid,
server_vnc_port => $server_vnc_port
}; };
($is_error, $open_output) = open_ws($open_params); ($is_error, $open_output) = open_ws($open_params);
@ -993,13 +1007,15 @@ my $is_drop_table = $anvil->data->{switches}{'drop-table'};
my $is_open = $anvil->data->{switches}{'open'}; my $is_open = $anvil->data->{switches}{'open'};
my $server = $anvil->data->{switches}{'server'}; my $server = $anvil->data->{switches}{'server'};
my $server_uuid = $anvil->data->{switches}{'server-uuid'} // $anvil->Get->server_uuid_from_name({ server_name => $server }); my $server_uuid = $anvil->data->{switches}{'server-uuid'} // $anvil->Get->server_uuid_from_name({ server_name => $server });
my $server_vnc_port = $anvil->data->{switches}{'server-vnc-port'};
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => {
component => $component, component => $component,
is_open => $is_open, is_open => $is_open,
is_drop_table => $is_drop_table, is_drop_table => $is_drop_table,
server => $server, server => $server,
server_uuid => $server_uuid server_uuid => $server_uuid,
server_vnc_port => $server_vnc_port
} }); } });
my $map_to_operation = { my $map_to_operation = {
@ -1023,8 +1039,9 @@ if ($server_uuid)
$anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => { operation => $op } }); $anvil->Log->variables({ source => $THIS_FILE, line => __LINE__, level => 2, list => { operation => $op } });
my ($is_error) = $ops->{$op}({ my ($is_error) = $ops->{$op}({
host_uuid => $anvil->data->{sys}{host_uuid},
server_uuid => $server_uuid, server_uuid => $server_uuid,
host_uuid => $anvil->data->{sys}{host_uuid} server_vnc_port => $server_vnc_port
}); });
$anvil->nice_exit({ exit_code => 2 }) if ($is_error); $anvil->nice_exit({ exit_code => 2 }) if ($is_error);

Loading…
Cancel
Save