* Fixed a bug with anvil-provision-server where running the command line menu from a Striker would not assign the job to the target Anvil!.

* Updated Server->parse_definition() to check if a failed 'virsh list' output was passed in. Also changed it to not exit if the XML can't be parsed.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 2 years ago
parent 069fab6a69
commit 29a28ee97a
  1. 12
      Anvil/Tools/Server.pm
  2. 7
      share/words.xml
  3. 37
      tools/anvil-provision-server

@ -1362,6 +1362,14 @@ sub parse_definition
return(1); return(1);
} }
# If whoever called us did so after a 'virsh dumpxml <server>' while the server was off, the "definition"
# will contain the string 'error: failed to get domain'. In such a case, return.
if ($definition =~ /error: failed to get domain/gs)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0367", variables => { definition => $definition }});
return(1);
}
### TODO: Switch this away from XML::Simple ### TODO: Switch this away from XML::Simple
local $@; local $@;
my $xml = XML::Simple->new(); my $xml = XML::Simple->new();
@ -1370,12 +1378,12 @@ sub parse_definition
if (not $test) if (not $test)
{ {
chomp $@; chomp $@;
my $error = "[ Error ] - The was a problem parsing: [$definition]. The error was:\n"; my $error = "[ Error ] - The was a problem parsing: [".$definition."]. The error was:\n";
$error .= "===========================================================\n"; $error .= "===========================================================\n";
$error .= $@."\n"; $error .= $@."\n";
$error .= "===========================================================\n"; $error .= "===========================================================\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", list => { error => $error }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", list => { error => $error }});
$anvil->nice_exit({exit_code => 1}); return(1);
} }
$anvil->data->{server}{$target}{$server}{$source}{parsed} = $server_xml; $anvil->data->{server}{$target}{$server}{$source}{parsed} = $server_xml;

@ -512,6 +512,13 @@ The output, if any, was;
<key name="error_0364">[ Error ] - There was a problem purging records. The details of the problem should be in the logs.</key> <key name="error_0364">[ Error ] - There was a problem purging records. The details of the problem should be in the logs.</key>
<key name="error_0365">The table: [#!variable!table!#] has an entry in the history schema that doesn't have a corresponding record in the public schema. This is likely a resync artifact of a deleted record. Purging the record: [#!variable!uuid_column!#:#!variable!column_uuid!#] from all databases.</key> <key name="error_0365">The table: [#!variable!table!#] has an entry in the history schema that doesn't have a corresponding record in the public schema. This is likely a resync artifact of a deleted record. Purging the record: [#!variable!uuid_column!#:#!variable!column_uuid!#] from all databases.</key>
<key name="error_0366">[ Error ] - Failed to reconnect to the database, and now no connections remain.</key> <key name="error_0366">[ Error ] - Failed to reconnect to the database, and now no connections remain.</key>
<key name="error_0367"><![CDATA[[ Error ] - I was asked to parse the server definition XML, but it looks like I was passed in the output of a 'virsh dumpxml <server>' for a server that was not running.
The definition data passed in was:
====
#!variable!definition!#
====
]]></key>
<!-- Files templates --> <!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable --> <!-- NOTE: Translating these files requires an understanding of which lines are translatable -->

@ -1599,6 +1599,9 @@ sub check_anvil
{ {
my ($anvil) = @_; my ($anvil) = @_;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"new_server::anvil_uuid" => $anvil->data->{new_server}{anvil_uuid},
}});
if (($anvil->data->{switches}{anvil}) && (not $anvil->data->{switches}{'anvil-uuid'}) && (not $anvil->data->{switches}{'anvil-name'})) if (($anvil->data->{switches}{anvil}) && (not $anvil->data->{switches}{'anvil-uuid'}) && (not $anvil->data->{switches}{'anvil-name'}))
{ {
if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{anvil}})) if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{anvil}}))
@ -1618,8 +1621,15 @@ sub check_anvil
} }
# Do we know or can we find the Anvil! UUID? # Do we know or can we find the Anvil! UUID?
if (not $anvil->data->{new_server}{anvil_uuid})
{
$anvil->data->{new_server}{anvil_uuid} = $anvil->data->{switches}{'anvil-uuid'} ? $anvil->data->{switches}{'anvil-uuid'} : ""; $anvil->data->{new_server}{anvil_uuid} = $anvil->data->{switches}{'anvil-uuid'} ? $anvil->data->{switches}{'anvil-uuid'} : "";
$anvil->data->{new_server}{anvil_name} = $anvil->data->{switches}{'anvil-name'} ? $anvil->data->{switches}{'anvil-name'} : ""; $anvil->data->{new_server}{anvil_name} = $anvil->data->{switches}{'anvil-name'} ? $anvil->data->{switches}{'anvil-name'} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"new_server::anvil_uuid" => $anvil->data->{new_server}{anvil_uuid},
"new_server::anvil_name" => $anvil->data->{new_server}{anvil_name},
}});
}
if ((not $anvil->data->{new_server}{anvil_uuid}) && (not $anvil->data->{new_server}{anvil_name})) if ((not $anvil->data->{new_server}{anvil_uuid}) && (not $anvil->data->{new_server}{anvil_name}))
{ {
@ -2334,6 +2344,7 @@ sub interactive_ask_server_install_media
$anvil->Database->get_files(); $anvil->Database->get_files();
$anvil->Database->get_file_locations(); $anvil->Database->get_file_locations();
my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid}; my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
# Create an array of install ISOs. # Create an array of install ISOs.
my $install_isos = [""]; my $install_isos = [""];
@ -2427,6 +2438,7 @@ sub interactive_ask_server_driver_disc
$anvil->Database->get_files(); $anvil->Database->get_files();
$anvil->Database->get_file_locations(); $anvil->Database->get_file_locations();
my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid}; my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
my $say_ram = $anvil->Convert->bytes_to_human_readable({"bytes" => $anvil->data->{new_server}{ram}}); my $say_ram = $anvil->Convert->bytes_to_human_readable({"bytes" => $anvil->data->{new_server}{ram}});
my $storage_group_uuid = $anvil->data->{new_server}{storage_group}; my $storage_group_uuid = $anvil->data->{new_server}{storage_group};
@ -2555,6 +2567,7 @@ sub interactive_ask_server_os
my $say_install_media = $anvil->data->{files}{file_uuid}{$install_media_file_uuid}{file_name}; my $say_install_media = $anvil->data->{files}{file_uuid}{$install_media_file_uuid}{file_name};
my $driver_disc_file_uuid = $anvil->data->{new_server}{driver_disc}; my $driver_disc_file_uuid = $anvil->data->{new_server}{driver_disc};
my $say_driver_disc = $driver_disc_file_uuid eq "none" ? "#!string!unit_0005!#" : $anvil->data->{files}{file_uuid}{$driver_disc_file_uuid}{file_name}; my $say_driver_disc = $driver_disc_file_uuid eq "none" ? "#!string!unit_0005!#" : $anvil->data->{files}{file_uuid}{$driver_disc_file_uuid}{file_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
print $terminal->Tputs('cl'); print $terminal->Tputs('cl');
print $anvil->Words->string({key => "job_0150"})."\n"; print $anvil->Words->string({key => "job_0150"})."\n";
@ -2624,6 +2637,10 @@ sub interactive_ask_server_confirm
$anvil->Database->get_files(); $anvil->Database->get_files();
$anvil->Database->get_file_locations(); $anvil->Database->get_file_locations();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"new_server::anvil_uuid" => $anvil->data->{new_server}{anvil_uuid},
"switches::ci-test" => $anvil->data->{switches}{'ci-test'},
}});
if ($anvil->data->{switches}{'ci-test'}) if ($anvil->data->{switches}{'ci-test'})
{ {
### NOTE: Show available options; ### NOTE: Show available options;
@ -2946,19 +2963,23 @@ sub interactive_ask_server_confirm
$anvil->data->{new_server}{storage_size} = $anvil->data->{switches}{'storage-size'}; $anvil->data->{new_server}{storage_size} = $anvil->data->{switches}{'storage-size'};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:new_server::name' => $anvil->data->{new_server}{name}, 's1:new_server::name' => $anvil->data->{new_server}{name},
's1:new_server::uuid' => $anvil->data->{new_server}{uuid}, 's2:new_server::uuid' => $anvil->data->{new_server}{uuid},
's2:new_server::os' => $anvil->data->{new_server}{os}, 's3:new_server::os' => $anvil->data->{new_server}{os},
's3:new_server::cpu' => $anvil->data->{new_server}{cpu}, 's4:new_server::cpu' => $anvil->data->{new_server}{cpu},
's4:new_server::ram' => $anvil->data->{new_server}{ram}, 's5:new_server::ram' => $anvil->data->{new_server}{ram},
's5:new_server::storage_group' => $anvil->data->{new_server}{storage_group}, 's6:new_server::storage_group' => $anvil->data->{new_server}{storage_group},
's6:new_server::storage_size' => $anvil->data->{new_server}{storage_size}." (".$anvil->Convert->bytes_to_human_readable({"bytes" => $max_storage_group_size}).")", 's7:new_server::storage_size' => $anvil->data->{new_server}{storage_size}." (".$anvil->Convert->bytes_to_human_readable({"bytes" => $max_storage_group_size}).")",
's7:new_server::install_media' => $anvil->data->{new_server}{install_media}, 's8:new_server::install_media' => $anvil->data->{new_server}{install_media},
's8:new_server::driver_disc' => $anvil->data->{new_server}{driver_disc}, 's9:new_server::driver_disc' => $anvil->data->{new_server}{driver_disc},
}}); }});
} }
my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid}; my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid};
my $node1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid}; my $node1_host_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_node1_host_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:anvil_uuid' => $anvil_uuid,
's2:node1_host_uuid' => $node1_host_uuid,
}});
my $storage_group_uuid = $anvil->data->{new_server}{storage_group}; my $storage_group_uuid = $anvil->data->{new_server}{storage_group};
my $say_ram = $anvil->Convert->bytes_to_human_readable({"bytes" => $anvil->data->{new_server}{ram}}); my $say_ram = $anvil->Convert->bytes_to_human_readable({"bytes" => $anvil->data->{new_server}{ram}});

Loading…
Cancel
Save