* Updated Database->get_storage_group_data() to record the VG name for a given host's VG in a given storage group.

* Updated anvil-provision-server to fix more bugs related to --ci-test.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent d26a16e711
commit 572167d034
  1. 9
      Anvil/Tools/Database.pm
  2. 88
      tools/anvil-provision-server

@ -5003,6 +5003,7 @@ ORDER BY
{ {
my $query = " my $query = "
SELECT SELECT
scan_lvm_vg_name,
scan_lvm_vg_size, scan_lvm_vg_size,
scan_lvm_vg_free scan_lvm_vg_free
FROM FROM
@ -5021,9 +5022,11 @@ WHERE
if ($count) if ($count)
{ {
$anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size} = $results->[0]->[0]; $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_name} = $results->[0]->[0];
$anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free} = $results->[0]->[1]; $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size} = $results->[0]->[1];
$anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free} = $results->[0]->[2];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"storage_groups::anvil_uuid::${storage_group_anvil_uuid}::storage_group_uuid::${storage_group_uuid}::host_uuid::${storage_group_member_host_uuid}::vg_name" => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_name},
"storage_groups::anvil_uuid::${storage_group_anvil_uuid}::storage_group_uuid::${storage_group_uuid}::host_uuid::${storage_group_member_host_uuid}::vg_size" => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size}}).")", "storage_groups::anvil_uuid::${storage_group_anvil_uuid}::storage_group_uuid::${storage_group_uuid}::host_uuid::${storage_group_member_host_uuid}::vg_size" => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_size}}).")",
"storage_groups::anvil_uuid::${storage_group_anvil_uuid}::storage_group_uuid::${storage_group_uuid}::host_uuid::${storage_group_member_host_uuid}::vg_free" => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free}}).")", "storage_groups::anvil_uuid::${storage_group_anvil_uuid}::storage_group_uuid::${storage_group_uuid}::host_uuid::${storage_group_member_host_uuid}::vg_free" => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{storage_groups}{anvil_uuid}{$storage_group_anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$storage_group_member_host_uuid}{vg_free}}).")",
}}); }});
@ -5068,11 +5071,13 @@ WHERE
my $storage_group_member_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{storage_group_member_uuid}; my $storage_group_member_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{storage_group_member_uuid};
my $internal_vg_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_internal_uuid}; my $internal_vg_uuid = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_internal_uuid};
my $vg_size = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_size}; my $vg_size = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_size};
my $vg_name = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$this_host_uuid}{vg_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
this_host_uuid => $this_host_uuid, this_host_uuid => $this_host_uuid,
storage_group_member_uuid => $storage_group_member_uuid, storage_group_member_uuid => $storage_group_member_uuid,
internal_vg_uuid => $internal_vg_uuid, internal_vg_uuid => $internal_vg_uuid,
vg_size => $anvil->Convert->add_commas({number => $vg_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size}).")", vg_size => $anvil->Convert->add_commas({number => $vg_size})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $vg_size}).")",
vg_name => $vg_name,
}}); }});
if ($vg_size > $size_to_match) if ($vg_size > $size_to_match)

@ -521,7 +521,7 @@ sub provision_server
progress => 70, progress => 70,
message => "job_0199,!!shell_call!".$shell_call."!!", message => "job_0199,!!shell_call!".$shell_call."!!",
}); });
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0199", variables => { shell_call => $shell_call }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0199", variables => { shell_call => $shell_call }});
# Write the command out to /mnt/shared/provision/ # Write the command out to /mnt/shared/provision/
my $provision_file = $anvil->data->{path}{directories}{shared}{provision}."/".$server.".sh"; my $provision_file = $anvil->data->{path}{directories}{shared}{provision}."/".$server.".sh";
@ -1109,11 +1109,29 @@ sub create_lv
} }
else else
{ {
# Make sure we have enough space. # Make sure we have enough space. This checks on the local system as the other node could
# record less free space before we create our LV.
my $anvil_uuid = $anvil->data->{job}{anvil_uuid}; my $anvil_uuid = $anvil->data->{job}{anvil_uuid};
my $storage_group_uuid = $anvil->data->{job}{storage_group_uuid}; my $storage_group_uuid = $anvil->data->{job}{storage_group_uuid};
if ($anvil->data->{job}{storage_size} > $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}) if ($anvil->data->{job}{storage_size} > $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size})
{ {
# How's the local storage?
$anvil->System->check_storage({debug => 2});
my $host_name = $anvil->Get->short_host_name();
my $host_uuid = $anvil->Get->host_uuid();
my $vg_name = $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_uuid}{$storage_group_uuid}{host_uuid}{$host_uuid}{vg_name};
my $free_space = $anvil->data->{lvm}{$host_name}{vg}{$vg_name}{free_space};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:host_name' => $host_name,
's2:host_uuid' => $host_uuid,
's3:vg_name' => $vg_name,
's4:free_space' => $free_space." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $free_space}).")",
's5:job::storage_size' => $anvil->data->{job}{storage_size}." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{job}{storage_size}}).")"
}});
if ((not $free_space) or ($free_space =~ /\D/) or ($anvil->data->{job}{storage_size} > $free_space))
{
# We're out.
my $say_available_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}})." (".$anvil->Convert->add_commas({number => $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}}).")"; my $say_available_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}})." (".$anvil->Convert->add_commas({number => $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}}).")";
my $say_requested_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{job}{storage_size}})." (".$anvil->Convert->add_commas({number => $anvil->data->{job}{storage_size}}).")"; my $say_requested_size = $anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{job}{storage_size}})." (".$anvil->Convert->add_commas({number => $anvil->data->{job}{storage_size}}).")";
my $say_storage_group = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{group_name}; my $say_storage_group = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{group_name};
@ -1130,6 +1148,7 @@ sub create_lv
}}); }});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
}
# Create the LV. # Create the LV.
my $host_uuid = $anvil->Get->host_uuid(); my $host_uuid = $anvil->Get->host_uuid();
@ -2576,13 +2595,8 @@ sub interactive_ask_server_confirm
if ($anvil->data->{switches}{'ci-test'}) if ($anvil->data->{switches}{'ci-test'})
{ {
# Show available options; ### NOTE: Show available options;
# anvil-provision-server --ci-test --options # anvil-provision-server --ci-test --options
# Minimal Example;
# anvil-provision-server --ci-test --name srv01-test \
# All options
# anvil-provision-server --ci-test --name srv01-test --uuid <server uuid> \
check_anvil($anvil); check_anvil($anvil);
if (not $anvil->data->{new_server}{anvil_uuid}) if (not $anvil->data->{new_server}{anvil_uuid})
{ {
@ -2592,8 +2606,19 @@ sub interactive_ask_server_confirm
} }
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 }});
$anvil->Get->available_resources({anvil_uuid => $anvil_uuid, debug => 2}); $anvil->Get->available_resources({anvil_uuid => $anvil_uuid, debug => 2});
$anvil->data->{new_server}{name} = "";
$anvil->data->{new_server}{uuid} = "";
$anvil->data->{new_server}{os} = "";
$anvil->data->{new_server}{cpu} = "";
$anvil->data->{new_server}{ram} = "";
$anvil->data->{new_server}{storage_group} = "";
$anvil->data->{new_server}{storage_size} = "";
$anvil->data->{new_server}{install_media} = "";
$anvil->data->{new_server}{driver_disc} = "";
my $problem = 0; my $problem = 0;
if (not $anvil->data->{switches}{name}) if (not $anvil->data->{switches}{name})
{ {
@ -2610,6 +2635,10 @@ sub interactive_ask_server_confirm
# Make sure it's valid. # Make sure it's valid.
my $os_key = "os_list_".$anvil->data->{switches}{os}; my $os_key = "os_list_".$anvil->data->{switches}{os};
my $os_name = $anvil->Words->string({key => $os_key}); my $os_name = $anvil->Words->string({key => $os_key});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
os_key => $os_key,
os_name => $os_name,
}});
if ($os_name =~ /#!not_found/) if ($os_name =~ /#!not_found/)
{ {
print "The OS: [".$anvil->data->{switches}{os}."] was not found. If you're sure the OS is valid, please run 'striker-parse-os-list --xml --new' and add the output to 'words.xml'.\n" if not $anvil->data->{switches}{options}; print "The OS: [".$anvil->data->{switches}{os}."] was not found. If you're sure the OS is valid, please run 'striker-parse-os-list --xml --new' and add the output to 'words.xml'.\n" if not $anvil->data->{switches}{options};
@ -2672,11 +2701,19 @@ sub interactive_ask_server_confirm
{ {
$storage_group_uuid = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group_name}{$storage_group}{storage_group_uuid}; $storage_group_uuid = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group_name}{$storage_group}{storage_group_uuid};
$max_storage_group_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}; $max_storage_group_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
storage_group_uuid => $storage_group_uuid,
max_storage_group_size => $max_storage_group_size." (".$anvil->Convert->bytes_to_human_readable({"bytes" => $max_storage_group_size}).")",
}});
} }
elsif (exists $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group}) elsif (exists $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group})
{ {
$storage_group_uuid = $storage_group; $storage_group_uuid = $storage_group;
$max_storage_group_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size}; $max_storage_group_size = $anvil->data->{anvil_resources}{$anvil_uuid}{storage_group}{$storage_group_uuid}{free_size};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
storage_group_uuid => $storage_group_uuid,
max_storage_group_size => $max_storage_group_size." (".$anvil->Convert->bytes_to_human_readable({"bytes" => $max_storage_group_size}).")",
}});
} }
else else
{ {
@ -2721,6 +2758,9 @@ sub interactive_ask_server_confirm
if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{uuid}})) if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{uuid}}))
{ {
$anvil->data->{new_server}{uuid} = $anvil->data->{switches}{uuid}; $anvil->data->{new_server}{uuid} = $anvil->data->{switches}{uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'new_server::uuid' => $anvil->data->{new_server}{uuid},
}});
} }
if (not $anvil->data->{switches}{'install-media'}) if (not $anvil->data->{switches}{'install-media'})
{ {
@ -2735,6 +2775,7 @@ sub interactive_ask_server_confirm
{ {
my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid}; my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid};
my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type}; my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type};
my $file_directory = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_directory};
if ($file_name eq $anvil->data->{switches}{'install-media'}) if ($file_name eq $anvil->data->{switches}{'install-media'})
{ {
# Found it. # Found it.
@ -2742,7 +2783,10 @@ sub interactive_ask_server_confirm
if ($file_type eq "iso") if ($file_type eq "iso")
{ {
# We're good # We're good
$anvil->data->{new_server}{install_media} = $anvil->data->{switches}{'install-media'}; $anvil->data->{new_server}{install_media} = $file_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'new_server::install_media' => $anvil->data->{new_server}{install_media},
}});
} }
else else
{ {
@ -2768,6 +2812,7 @@ sub interactive_ask_server_confirm
{ {
my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid}; my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid};
my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type}; my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type};
my $file_directory = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_directory};
if ($file_name eq $anvil->data->{switches}{'driver-disc'}) if ($file_name eq $anvil->data->{switches}{'driver-disc'})
{ {
# Found it. # Found it.
@ -2775,7 +2820,10 @@ sub interactive_ask_server_confirm
if ($file_type eq "iso") if ($file_type eq "iso")
{ {
# We're good # We're good
$anvil->data->{new_server}{install_media} = $anvil->data->{switches}{'driver-disc'}; $anvil->data->{new_server}{driver_disc} = $file_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'new_server::driver_disc' => $anvil->data->{new_server}{driver_disc},
}});
} }
else else
{ {
@ -2810,8 +2858,15 @@ sub interactive_ask_server_confirm
my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid}; my $file_uuid = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_name}{$file_name}{file_uuid};
my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type}; my $file_type = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_type};
my $file_size = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_size}; my $file_size = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{file_uuid}{$file_uuid}{file_size};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:file_name' => $file_name,
's2:file_uuid' => $file_uuid,
's3:file_type' => $file_type,
's4:file_size' => $file_size,
}});
next if $file_type ne "iso"; next if $file_type ne "iso";
my $say_size = $anvil->Convert->bytes_to_human_readable({"bytes" => $file_size}); my $say_size = $anvil->Convert->bytes_to_human_readable({"bytes" => $file_size});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { say_size => $say_size }});
print "iso_file:name=".$file_name.",uuid=".$file_uuid.",size=".$say_size."\n"; print "iso_file:name=".$file_name.",uuid=".$file_uuid.",size=".$say_size."\n";
} }
} }
@ -2858,8 +2913,17 @@ sub interactive_ask_server_confirm
$anvil->data->{new_server}{ram} = $anvil->data->{switches}{ram}; $anvil->data->{new_server}{ram} = $anvil->data->{switches}{ram};
$anvil->data->{new_server}{storage_group} = $storage_group_uuid; $anvil->data->{new_server}{storage_group} = $storage_group_uuid;
$anvil->data->{new_server}{storage_size} = $anvil->data->{switches}{'storage-size'}; $anvil->data->{new_server}{storage_size} = $anvil->data->{switches}{'storage-size'};
$anvil->data->{new_server}{install_media} = $anvil->data->{switches}{'install-media'}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->data->{new_server}{driver_disc} = $anvil->data->{switches}{'driver-disc'}; 's1:new_server::name' => $anvil->data->{new_server}{name},
's1:new_server::uuid' => $anvil->data->{new_server}{uuid},
's2:new_server::os' => $anvil->data->{new_server}{os},
's3:new_server::cpu' => $anvil->data->{new_server}{cpu},
's4:new_server::ram' => $anvil->data->{new_server}{ram},
's5: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::install_media' => $anvil->data->{new_server}{install_media},
's8: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};

Loading…
Cancel
Save