fix(tools): check server state before getting screenshot

main
Tsu-ba-me 2 years ago
parent a9cc123300
commit 3802c72912
  1. 14
      tools/anvil-get-server-screenshot

@ -82,6 +82,14 @@ sub get_server_screenshot
my $resize_args = defined $parameters->{resize_args} ? $parameters->{resize_args} : '';
my $sh_domstate = $anvil->data->{path}{exe}{virsh}." domstate --domain ".$server_uuid;
my ($sh_domstate_output, $sh_domstate_return_code) = system_call({ debug => $debug, shell_call => $sh_domstate });
if ( ($sh_domstate_return_code != 0) || ($sh_domstate_output ne "running") )
{
return "";
}
my $shell_call = $anvil->data->{path}{exe}{virsh}." --quiet screenshot --domain ".$server_uuid." --file ".$anvil->data->{path}{devices}{stdout};
if ($resize_args =~ /^\d+x\d+$/)
@ -95,7 +103,7 @@ sub get_server_screenshot
my ($output, $return_code) = system_call({ debug => $debug, shell_call => $shell_call });
return $return_code == 0 ? $output : undef;
return $return_code == 0 ? $output : "";
}
$anvil->Get->switches;
@ -175,7 +183,7 @@ if ($server_uuid)
if ($request_host_uuid)
{
if (defined $encoded_image)
if (length($encoded_image))
{
my $request_host_ip_address = get_remote_call_requirements({ debug => $debug, host_uuid => $request_host_uuid });
my $remote_shell_call = $anvil->data->{path}{exe}{echo}." '".$encoded_image."' >".$anvil->data->{path}{directories}{tmp}."/".$server_uuid."_screenshot_".$out_file_id;
@ -189,6 +197,7 @@ if ($server_uuid)
else
{
$anvil->Job->update_progress({ progress => 100, message => "message_0265" });
$anvil->nice_exit({ exit_code => 1 });
}
}
else
@ -199,6 +208,7 @@ if ($server_uuid)
else
{
$anvil->Job->update_progress({ progress => 100, message => "message_0266" });
$anvil->nice_exit({ exit_code => 1 });
}
$anvil->nice_exit({ exit_code => 0 });

Loading…
Cancel
Save