Added an attempt to assemble storage groups if not yet exist.

Signed-off-by: digimer <mkelly@alteeve.ca>
main
digimer 10 months ago
parent 46b298e7e8
commit 091ded803c
  1. 2
      Anvil/Tools/System.pm
  2. 45
      tools/anvil-provision-server

@ -2936,7 +2936,7 @@ sub generate_state_json
{ {
my $type = $anvil->data->{network}{$host}{interface}{$interface}{type}; my $type = $anvil->data->{network}{$host}{interface}{$interface}{type};
my $uuid = $anvil->data->{network}{$host}{interface}{$interface}{uuid}; my $uuid = $anvil->data->{network}{$host}{interface}{$interface}{uuid};
my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu}; my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu} ? $anvil->data->{network}{$host}{interface}{$interface}{mtu} : 1500;
my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address}; my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address};
my $iface_hash = {}; my $iface_hash = {};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {

@ -99,6 +99,51 @@ $anvil->nice_exit({exit_code => 0});
# Functions # # Functions #
############################################################################################################# #############################################################################################################
# This checks to see if any storage groups exist yet. If they don't, an attempt to assemble the storage
# groups will be made
sub check_Storage_groups
{
my ($anvil) = @_;
# Make sure we have an anvil_uuid
if ($anvil->data->{new_server}{anvil_uuid})
{
# Nope, nothing to do.
return(1);
}
my $anvil_uuid = $anvil->data->{new_server}{anvil_uuid};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
# Load Storage Group data
$anvil->Database->get_storage_group_data({debug => 2});
if (exists $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid})
{
my $count = 0;
if ((exists $anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_name}) &&
(ref($anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_name}) eq "HASH"))
{
$count = keys %{$anvil->data->{storage_groups}{anvil_uuid}{$anvil_uuid}{storage_group_name}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { count => $count }});
}
if ($count)
{
# There's a storage group already, nothing to do.
return(0);
}
# Still alive? Try to assemble a storage group.
$anvil->Cluster->assemble_storage_groups({
debug => 2,
anvil_uuid => $anvil_uuid,
});
}
return(0);
}
# This actually provisions a VM. # This actually provisions a VM.
sub run_jobs sub run_jobs
{ {

Loading…
Cancel
Save