* Switched all hash 'local' keys to be the host's short user name. Untested, likely bugs to be fixed in the next commit.

Signed-off-by: Madison Kelly <mkelly@alteeve.ca>
This commit is contained in:
Madison Kelly 2020-08-18 19:34:08 -04:00
parent 47203490a9
commit 30f2b3fa8e
16 changed files with 310 additions and 287 deletions

View File

@ -2614,13 +2614,14 @@ sub get_local_uuid
$anvil->Network->get_ips({debug => $debug}); $anvil->Network->get_ips({debug => $debug});
# Look for matches # Look for matches
my $host = $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { local_uuid => $local_uuid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { local_uuid => $local_uuid }});
if (not $local_uuid) if (not $local_uuid)
{ {
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$host}{interface}})
{ {
my $ip_address = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $ip_address = $anvil->data->{network}{$host}{interface}{$interface}{ip};
my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; my $subnet_mask = $anvil->data->{network}{$host}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ip_address => $ip_address, ip_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,

View File

@ -266,9 +266,10 @@ sub bridges
}}); }});
# Delete any previously known data # Delete any previously known data
if (exists $anvil->data->{'local'}{network}{bridges}) my $host = $anvil->_short_host_name();
if (exists $anvil->data->{$host}{network}{bridges})
{ {
delete $anvil->data->{'local'}{network}{bridges}; delete $anvil->data->{$host}{network}{bridges};
}; };
my $bridge_data = ""; my $bridge_data = "";
@ -304,9 +305,9 @@ sub bridges
type => $type, type => $type,
}}); }});
$anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found} = 1; $anvil->data->{$host}{network}{bridges}{bridge}{$interface}{found} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${interface}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found}, "${host}::network::bridges::bridge::${interface}::found" => $anvil->data->{$host}{network}{bridges}{bridge}{$interface}{found},
}}); }});
} }
if ($interface) if ($interface)
@ -325,11 +326,11 @@ sub bridges
else else
{ {
# It's an interface, store it under the bridge. # It's an interface, store it under the bridge.
$type = "interface"; $type = "interface";
$anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface} = 1; $anvil->data->{$host}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
type => $type, type => $type,
"local::network::bridges::bridge::${master_bridge}::connected_interface::${interface}" => $anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface}, "${host}::network::bridges::bridge::${master_bridge}::connected_interface::${interface}" => $anvil->data->{$host}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface},
}}); }});
} }
} }
@ -346,7 +347,7 @@ sub bridges
foreach my $flag (split/,/, $flags) foreach my $flag (split/,/, $flags)
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { flag => $flag }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { flag => $flag }});
push @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{flags}}, $flag; push @{$anvil->data->{$host}{network}{bridges}{$type}{$interface}{flags}}, $flag;
} }
} }
} }
@ -364,9 +365,9 @@ sub bridges
my $value = $word; my $value = $word;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { value => $value }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { value => $value }});
$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$variable} = $value eq "on" ? "true" : "false"; $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$variable} = $value eq "on" ? "true" : "false";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::${type}::${interface}::${variable}" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$variable}, "${host}::network::bridges::${type}::${interface}::${variable}" => $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$variable},
}}); }});
$variable = ""; $variable = "";
} }
@ -390,17 +391,17 @@ sub bridges
if ($interface eq $master_bridge) if ($interface eq $master_bridge)
{ {
$type = "bridge"; $type = "bridge";
$anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found} = 1; $anvil->data->{$host}{network}{bridges}{bridge}{$interface}{found} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${interface}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found}, "${host}::network::bridges::bridge::${interface}::found" => $anvil->data->{$host}{network}{bridges}{bridge}{$interface}{found},
}}); }});
} }
else else
{ {
# Store this interface under the bridge. # Store this interface under the bridge.
$anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface} = 1; $anvil->data->{$host}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${master_bridge}::connected_interface::${interface}" => $anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface}, "${host}::network::bridges::bridge::${master_bridge}::connected_interface::${interface}" => $anvil->data->{$host}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface},
}}); }});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -412,23 +413,23 @@ sub bridges
{ {
if (ref($hash_ref->{$key}) eq "ARRAY") if (ref($hash_ref->{$key}) eq "ARRAY")
{ {
$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key} = []; $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key} = [];
foreach my $value (sort {$a cmp $b} @{$hash_ref->{$key}}) foreach my $value (sort {$a cmp $b} @{$hash_ref->{$key}})
{ {
push @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}}, $value; push @{$anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key}}, $value;
} }
for (my $i = 0; $i < @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}}; $i++) for (my $i = 0; $i < @{$anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key}}; $i++)
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::${type}::${interface}::${key}->[$i]" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}->[$i], "${host}::network::bridges::${type}::${interface}::${key}->[$i]" => $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key}->[$i],
}}); }});
} }
} }
else else
{ {
$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key} = $hash_ref->{$key}; $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key} = $hash_ref->{$key};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::${type}::${interface}::${key}" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}, "${host}::network::bridges::${type}::${interface}::${key}" => $anvil->data->{$host}{network}{bridges}{$type}{$interface}{$key},
}}); }});
} }
} }
@ -436,10 +437,10 @@ sub bridges
} }
# Summary of found bridges. # Summary of found bridges.
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{'local'}{network}{bridges}{bridge}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{$host}{network}{bridges}{bridge}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${interface}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found}, "${host}::network::bridges::bridge::${interface}::found" => $anvil->data->{$host}{network}{bridges}{bridge}{$interface}{found},
}}); }});
} }

View File

@ -186,7 +186,7 @@ sub bridge_info
{ {
my $bridge = $hash_ref->{master}; my $bridge = $hash_ref->{master};
my $interface = $hash_ref->{ifname}; my $interface = $hash_ref->{ifname};
my $host = $target ? $target : "local"; my $host = $target ? $target : $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:bridge' => $bridge, 's1:bridge' => $bridge,
's2:interface' => $interface, 's2:interface' => $interface,
@ -1490,7 +1490,7 @@ sub get_ips
}}); }});
# This is used in the hash reference when storing the data. # This is used in the hash reference when storing the data.
my $host = $target ? $target : "local"; my $host = $target ? $target : $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }});
if (exists $anvil->data->{network}{$host}) if (exists $anvil->data->{network}{$host})
@ -1946,14 +1946,15 @@ sub is_local
else else
{ {
# Get the list of current IPs and see if they match. # Get the list of current IPs and see if they match.
if (not exists $anvil->data->{network}{'local'}{interface}) my $local_host = $anvil->_short_host_name();
if (not exists $anvil->data->{network}{$local_host}{interface})
{ {
$anvil->Network->get_ips({debug => 9999}); $anvil->Network->get_ips({debug => 9999});
} }
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
#$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "network::local::interface::${interface}::ip" => $anvil->data->{network}{'local'}{interface}{$interface}{ip} }}); #$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "network::local::interface::${interface}::ip" => $anvil->data->{network}{$local_host}{interface}{$interface}{ip} }});
if ($host eq $anvil->data->{network}{'local'}{interface}{$interface}{ip}) if ($host eq $anvil->data->{network}{$local_host}{interface}{$interface}{ip})
{ {
$anvil->data->{cache}{is_local}{$host} = 1; $anvil->data->{cache}{is_local}{$host} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "cache::is_local::${host}" => $anvil->data->{cache}{is_local}{$host} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "cache::is_local::${host}" => $anvil->data->{cache}{is_local}{$host} }});
@ -2198,7 +2199,7 @@ sub ping
my $output = ""; my $output = "";
my $error = ""; my $error = "";
# If the 'target' is set, we'll call over SSH unless 'target' is 'local' or our host name. # If the 'target' is set, we'll call over SSH unless 'target' is our host name.
if ($anvil->Network->is_local({host => $target})) if ($anvil->Network->is_local({host => $target}))
{ {
### Local calls ### Local calls
@ -2297,7 +2298,7 @@ Where C<< name >> is the value in the interface set by the C<< NAME= >> variable
Parameters; Parameters;
=head3 host (optional, default 'target' or 'local') =head3 host (optional, default 'target' or local short host name)
This is the hash key under which the parsed C<< nmcli >> data is stored. By default, this is C<< local >> when called locally, or it will be C<< target >> if C<< target >> is passed. This is the hash key under which the parsed C<< nmcli >> data is stored. By default, this is C<< local >> when called locally, or it will be C<< target >> if C<< target >> is passed.
@ -2342,7 +2343,7 @@ sub read_nmcli
if (not $host) if (not $host)
{ {
$host = $target ? $target : "local"; $host = $target ? $target : $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }});
} }

View File

@ -310,8 +310,8 @@ sub call
ssh_fh_key => $ssh_fh_key, ssh_fh_key => $ssh_fh_key,
}}); }});
# In case 'target' is 'local', change it to ''. # In case 'target' is our short host name, change it to ''.
if ($target eq "local") if ($target eq $anvil->_short_host_name())
{ {
$target = ""; $target = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { target => $target }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { target => $target }});

View File

@ -337,7 +337,7 @@ sub get_status
}}); }});
# This is used in the hash reference when storing the data. # This is used in the hash reference when storing the data.
my $host = $target ? $target : "local"; my $host = $target ? $target : $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }});
if (not $server) if (not $server)
@ -541,7 +541,7 @@ sub map_network
}); });
# This is used in the hash reference when storing the data. # This is used in the hash reference when storing the data.
my $host = $target ? $target : "local"; my $host = $target ? $target : $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { host => $host }});
foreach my $mac (sort {$a cmp $b} keys %{$anvil->data->{server}{$host}{$server}{from_memory}{device}{interface}}) foreach my $mac (sort {$a cmp $b} keys %{$anvil->data->{server}{$host}{$server}{from_memory}{device}{interface}})
{ {
@ -972,7 +972,7 @@ sub _parse_definition
my $source = defined $parameter->{source} ? $parameter->{source} : ""; my $source = defined $parameter->{source} ? $parameter->{source} : "";
my $definition = defined $parameter->{definition} ? $parameter->{definition} : ""; my $definition = defined $parameter->{definition} ? $parameter->{definition} : "";
my $host = defined $parameter->{host} ? $parameter->{host} : $anvil->_short_host_name; my $host = defined $parameter->{host} ? $parameter->{host} : $anvil->_short_host_name;
my $target = "local"; my $target = $anvil->_short_host_name();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
server => $server, server => $server,
source => $source, source => $source,

View File

@ -519,19 +519,20 @@ sub get_local_repo
# What are my IPs? # What are my IPs?
$anvil->Network->get_ips(); $anvil->Network->get_ips();
my $base_url = ""; my $base_url = "";
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) my $host = $anvil->_short_host_name();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$host}{interface}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }});
if ($anvil->data->{network}{'local'}{interface}{$interface}{ip}) if ($anvil->data->{network}{$host}{interface}{$interface}{ip})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "network::local::interface::${interface}::ip" => $anvil->data->{network}{'local'}{interface}{$interface}{ip} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "network::local::interface::${interface}::ip" => $anvil->data->{network}{$host}{interface}{$interface}{ip} }});
if (not $base_url) if (not $base_url)
{ {
$base_url = "baseurl=http://".$anvil->data->{network}{'local'}{interface}{$interface}{ip}.$directory; $base_url = "baseurl=http://".$anvil->data->{network}{$host}{interface}{$interface}{ip}.$directory;
} }
else else
{ {
$base_url .= "\n http://".$anvil->data->{network}{'local'}{interface}{$interface}{ip}.$directory; $base_url .= "\n http://".$anvil->data->{network}{$host}{interface}{$interface}{ip}.$directory;
} }
} }
} }
@ -1070,7 +1071,7 @@ sub parse_all_status_json
# We're going to look for matches as we go, so look # We're going to look for matches as we go, so look
$anvil->Network->load_ips({ $anvil->Network->load_ips({
debug => $debug, debug => $debug,
host => 'local', host => $anvil->_short_host_name(),
host_uuid => $anvil->data->{sys}{host_uuid}, host_uuid => $anvil->data->{sys}{host_uuid},
}); });
@ -1109,7 +1110,7 @@ sub parse_all_status_json
}); });
my ($match) = $anvil->Network->find_matches({ my ($match) = $anvil->Network->find_matches({
debug => 3, debug => 3,
first => 'local', first => $anvil->_short_host_name(),
second => $short_name, second => $short_name,
}); });
if ($match) if ($match)

View File

@ -156,7 +156,8 @@ sub activate_lv
$anvil->System->check_storage({debug => $debug, scan => 2}); $anvil->System->check_storage({debug => $debug, scan => 2});
# Check if it worked. # Check if it worked.
$activated = $anvil->data->{lvm}{'local'}{lv}{$path}{active}; my $host = $anvil->_short_host_name();
$activated = $anvil->data->{lvm}{$host}{lv}{$path}{active};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { activated => $activated }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { activated => $activated }});
return($activated); return($activated);
@ -1054,6 +1055,7 @@ sub check_storage
### DRBD devices being "wrong medium type" when Secondary. We check for and ignore these ### DRBD devices being "wrong medium type" when Secondary. We check for and ignore these
### warnings. ### warnings.
# Gather PV data. # Gather PV data.
my $host = $anvil->_short_host_name();
my ($pvs_output, $pvs_return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{pvs}." --units b --noheadings --separator \\\#\\\!\\\# -o pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pv_used,pv_uuid 2>/dev/null"}); my ($pvs_output, $pvs_return_code) = $anvil->System->call({debug => $debug, shell_call => $anvil->data->{path}{exe}{pvs}." --units b --noheadings --separator \\\#\\\!\\\# -o pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pv_used,pv_uuid 2>/dev/null"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
pvs_output => $pvs_output, pvs_output => $pvs_output,
@ -1071,19 +1073,19 @@ sub check_storage
$free_size =~ s/B$//; $free_size =~ s/B$//;
$used_size =~ s/B$//; $used_size =~ s/B$//;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{used_by_vg} = $used_by_vg; $anvil->data->{lvm}{$host}{pv}{$this_pv}{used_by_vg} = $used_by_vg;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{attributes} = $attributes; $anvil->data->{lvm}{$host}{pv}{$this_pv}{attributes} = $attributes;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{total_size} = $total_size; $anvil->data->{lvm}{$host}{pv}{$this_pv}{total_size} = $total_size;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{free_size} = $free_size; $anvil->data->{lvm}{$host}{pv}{$this_pv}{free_size} = $free_size;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{used_size} = $used_size; $anvil->data->{lvm}{$host}{pv}{$this_pv}{used_size} = $used_size;
$anvil->data->{lvm}{'local'}{pv}{$this_pv}{uuid} = $uuid; $anvil->data->{lvm}{$host}{pv}{$this_pv}{uuid} = $uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::local::pv::${this_pv}::used_by_vg" => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{used_by_vg}, "lvm::${host}::pv::${this_pv}::used_by_vg" => $anvil->data->{lvm}{$host}{pv}{$this_pv}{used_by_vg},
"lvm::local::pv::${this_pv}::attributes" => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{attributes}, "lvm::${host}::pv::${this_pv}::attributes" => $anvil->data->{lvm}{$host}{pv}{$this_pv}{attributes},
"lvm::local::pv::${this_pv}::total_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{total_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{total_size}}).")", "lvm::${host}::pv::${this_pv}::total_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{pv}{$this_pv}{total_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{pv}{$this_pv}{total_size}}).")",
"lvm::local::pv::${this_pv}::free_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{free_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{free_size}}).")", "lvm::${host}::pv::${this_pv}::free_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{pv}{$this_pv}{free_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{pv}{$this_pv}{free_size}}).")",
"lvm::local::pv::${this_pv}::used_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{used_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{used_size}}).")", "lvm::${host}::pv::${this_pv}::used_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{pv}{$this_pv}{used_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{pv}{$this_pv}{used_size}}).")",
"lvm::local::pv::${this_pv}::uuid" => $anvil->data->{lvm}{'local'}{pv}{$this_pv}{uuid}, "lvm::${host}::pv::${this_pv}::uuid" => $anvil->data->{lvm}{$host}{pv}{$this_pv}{uuid},
}}); }});
} }
@ -1120,25 +1122,25 @@ sub check_storage
{ {
$used_space = $vg_size - $vg_free; $used_space = $vg_size - $vg_free;
} }
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{pe_size} = $pe_size; $anvil->data->{lvm}{$host}{vg}{$this_vg}{pe_size} = $pe_size;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{total_pe} = $total_pe; $anvil->data->{lvm}{$host}{vg}{$this_vg}{total_pe} = $total_pe;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{uuid} = $uuid; $anvil->data->{lvm}{$host}{vg}{$this_vg}{uuid} = $uuid;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{size} = $vg_size; $anvil->data->{lvm}{$host}{vg}{$this_vg}{size} = $vg_size;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{used_pe} = $used_pe; $anvil->data->{lvm}{$host}{vg}{$this_vg}{used_pe} = $used_pe;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{used_space} = $used_space; $anvil->data->{lvm}{$host}{vg}{$this_vg}{used_space} = $used_space;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{free_pe} = $free_pe; $anvil->data->{lvm}{$host}{vg}{$this_vg}{free_pe} = $free_pe;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{free_space} = $vg_free; $anvil->data->{lvm}{$host}{vg}{$this_vg}{free_space} = $vg_free;
$anvil->data->{lvm}{'local'}{vg}{$this_vg}{pv_name} = $pv_name; $anvil->data->{lvm}{$host}{vg}{$this_vg}{pv_name} = $pv_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::local::vg::${this_vg}::pe_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{pe_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{pe_size}}).")", "lvm::${host}::vg::${this_vg}::pe_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{vg}{$this_vg}{pe_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{vg}{$this_vg}{pe_size}}).")",
"lvm::local::vg::${this_vg}::total_pe" => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{total_pe}, "lvm::${host}::vg::${this_vg}::total_pe" => $anvil->data->{lvm}{$host}{vg}{$this_vg}{total_pe},
"lvm::local::vg::${this_vg}::uuid" => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{uuid}, "lvm::${host}::vg::${this_vg}::uuid" => $anvil->data->{lvm}{$host}{vg}{$this_vg}{uuid},
"lvm::local::vg::${this_vg}::size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{size}}).")", "lvm::${host}::vg::${this_vg}::size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{vg}{$this_vg}{size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{vg}{$this_vg}{size}}).")",
"lvm::local::vg::${this_vg}::used_pe" => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{used_pe}, "lvm::${host}::vg::${this_vg}::used_pe" => $anvil->data->{lvm}{$host}{vg}{$this_vg}{used_pe},
"lvm::local::vg::${this_vg}::used_space" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{used_space}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{used_space}}).")", "lvm::${host}::vg::${this_vg}::used_space" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{vg}{$this_vg}{used_space}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{vg}{$this_vg}{used_space}}).")",
"lvm::local::vg::${this_vg}::free_pe" => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{free_pe}, "lvm::${host}::vg::${this_vg}::free_pe" => $anvil->data->{lvm}{$host}{vg}{$this_vg}{free_pe},
"lvm::local::vg::${this_vg}::free_space" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{free_space}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{free_space}}).")", "lvm::${host}::vg::${this_vg}::free_space" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{vg}{$this_vg}{free_space}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{vg}{$this_vg}{free_space}}).")",
"lvm::local::vg::${this_vg}::pv_name" => $anvil->data->{lvm}{'local'}{vg}{$this_vg}{pv_name}, "lvm::${host}::vg::${this_vg}::pv_name" => $anvil->data->{lvm}{$host}{vg}{$this_vg}{pv_name},
}}); }});
} }
@ -1160,21 +1162,21 @@ sub check_storage
$total_size =~ s/B$//; $total_size =~ s/B$//;
$devices =~ s/\(\d+\)//g; # Strip the starting PE number $devices =~ s/\(\d+\)//g; # Strip the starting PE number
$anvil->data->{lvm}{'local'}{lv}{$path}{name} = $lv_name; $anvil->data->{lvm}{$host}{lv}{$path}{name} = $lv_name;
$anvil->data->{lvm}{'local'}{lv}{$path}{on_vg} = $on_vg; $anvil->data->{lvm}{$host}{lv}{$path}{on_vg} = $on_vg;
$anvil->data->{lvm}{'local'}{lv}{$path}{active} = ($attributes =~ /.{4}(.{1})/)[0] eq "a" ? 1 : 0; $anvil->data->{lvm}{$host}{lv}{$path}{active} = ($attributes =~ /.{4}(.{1})/)[0] eq "a" ? 1 : 0;
$anvil->data->{lvm}{'local'}{lv}{$path}{attributes} = $attributes; $anvil->data->{lvm}{$host}{lv}{$path}{attributes} = $attributes;
$anvil->data->{lvm}{'local'}{lv}{$path}{total_size} = $total_size; $anvil->data->{lvm}{$host}{lv}{$path}{total_size} = $total_size;
$anvil->data->{lvm}{'local'}{lv}{$path}{uuid} = $uuid; $anvil->data->{lvm}{$host}{lv}{$path}{uuid} = $uuid;
$anvil->data->{lvm}{'local'}{lv}{$path}{on_devices} = $devices; $anvil->data->{lvm}{$host}{lv}{$path}{on_devices} = $devices;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"lvm::local::lv::${path}::name" => $anvil->data->{lvm}{'local'}{lv}{$path}{name}, "lvm::${host}::lv::${path}::name" => $anvil->data->{lvm}{$host}{lv}{$path}{name},
"lvm::local::lv::${path}::on_vg" => $anvil->data->{lvm}{'local'}{lv}{$path}{on_vg}, "lvm::${host}::lv::${path}::on_vg" => $anvil->data->{lvm}{$host}{lv}{$path}{on_vg},
"lvm::local::lv::${path}::active" => $anvil->data->{lvm}{'local'}{lv}{$path}{active}, "lvm::${host}::lv::${path}::active" => $anvil->data->{lvm}{$host}{lv}{$path}{active},
"lvm::local::lv::${path}::attributes" => $anvil->data->{lvm}{'local'}{lv}{$path}{attributes}, "lvm::${host}::lv::${path}::attributes" => $anvil->data->{lvm}{$host}{lv}{$path}{attributes},
"lvm::local::lv::${path}::total_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{'local'}{lv}{$path}{total_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{'local'}{lv}{$path}{total_size}}).")", "lvm::${host}::lv::${path}::total_size" => $anvil->Convert->add_commas({number => $anvil->data->{lvm}{$host}{lv}{$path}{total_size}})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $anvil->data->{lvm}{$host}{lv}{$path}{total_size}}).")",
"lvm::local::lv::${path}::uuid" => $anvil->data->{lvm}{'local'}{lv}{$path}{uuid}, "lvm::${host}::lv::${path}::uuid" => $anvil->data->{lvm}{$host}{lv}{$path}{uuid},
"lvm::local::lv::${path}::on_devices" => $anvil->data->{lvm}{'local'}{lv}{$path}{on_devices}, "lvm::${host}::lv::${path}::on_devices" => $anvil->data->{lvm}{$host}{lv}{$path}{on_devices},
}}); }});
} }
@ -1905,7 +1907,7 @@ sub generate_state_json
# We're going to look for matches as we go, so look # We're going to look for matches as we go, so look
$anvil->Network->load_ips({ $anvil->Network->load_ips({
debug => $debug, debug => $debug,
host => 'local', host => $anvil->_short_host_name(),
host_uuid => $anvil->data->{sys}{host_uuid}, host_uuid => $anvil->data->{sys}{host_uuid},
}); });
@ -1943,7 +1945,7 @@ sub generate_state_json
# Don't need to call 'local_ips', it was called by load_interfaces above. # Don't need to call 'local_ips', it was called by load_interfaces above.
my ($match) = $anvil->Network->find_matches({ my ($match) = $anvil->Network->find_matches({
debug => $debug, debug => $debug,
first => 'local', first => $anvil->_short_host_name(),
second => $short_host_name, second => $short_host_name,
}); });
@ -2381,12 +2383,13 @@ sub find_matching_ip
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }});
# Look through our IPs. First match wins. # Look through our IPs. First match wins.
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) my $local_host = $anvil->_short_host_name();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }});
next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip}; next if not $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
my $this_ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $this_ip = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
my $this_subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; my $this_subnet_mask = $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:this_ip" => $this_ip, "s1:this_ip" => $this_ip,
"s2:this_subnet_mask" => $this_subnet_mask, "s2:this_subnet_mask" => $this_subnet_mask,
@ -2857,7 +2860,7 @@ This is the TCP port to use when connecting to a remote machine. If not set, but
If C<< target >> is set, this will be the user we connect to the remote machine as. If C<< target >> is set, this will be the user we connect to the remote machine as.
=head3 target (optional, default 'local') =head3 target (optional, default local shost host name)
This is the IP or host name of the machine to manage keys on. If not passed, the keys on the local machine will be managed. This is the IP or host name of the machine to manage keys on. If not passed, the keys on the local machine will be managed.

View File

@ -6203,11 +6203,12 @@ sub process_sync_page
# We'll want to show the user way to access the local machine. For that, we'll loop through our own IPs. # We'll want to show the user way to access the local machine. For that, we'll loop through our own IPs.
my $inbound_table = ""; my $inbound_table = "";
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) my $local_host = $anvil->_short_host_name();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/)); next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/));
next if not $anvil->Validate->ipv4({ip => $anvil->data->{network}{'local'}{interface}{$interface}{ip}}); next if not $anvil->Validate->ipv4({ip => $anvil->data->{network}{$local_host}{interface}{$interface}{ip}});
next if not $anvil->Validate->subnet_mask({subnet_mask => $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}}); next if not $anvil->Validate->subnet_mask({subnet_mask => $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask}});
my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/); my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/);
my $database_user = $anvil->data->{database}{$host_uuid}{user} ? $anvil->data->{database}{$host_uuid}{user} : $anvil->data->{sys}{database}{user}; my $database_user = $anvil->data->{database}{$host_uuid}{user} ? $anvil->data->{database}{$host_uuid}{user} : $anvil->data->{sys}{database}{user};
@ -6216,18 +6217,18 @@ sub process_sync_page
my $say_network = $anvil->Words->string({key => $network_key, variables => { number => $network_number }}); my $say_network = $anvil->Words->string({key => $network_key, variables => { number => $network_number }});
# The user 'admin' and the port 5432 are default, so only show them if they're non-standard. # The user 'admin' and the port 5432 are default, so only show them if they're non-standard.
my $access_string = $database_user."\@".$anvil->data->{network}{'local'}{interface}{$interface}{ip}.":".$database_port; my $access_string = $database_user."\@".$anvil->data->{network}{$local_host}{interface}{$interface}{ip}.":".$database_port;
if (($database_port eq "5432") && ($database_user eq "admin")) if (($database_port eq "5432") && ($database_user eq "admin"))
{ {
$access_string = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; $access_string = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
} }
elsif ($database_port eq "5432") elsif ($database_port eq "5432")
{ {
$access_string = $database_user."\@".$anvil->data->{network}{'local'}{interface}{$interface}{ip}; $access_string = $database_user."\@".$anvil->data->{network}{$local_host}{interface}{$interface}{ip};
} }
elsif ($database_user eq "admin") elsif ($database_user eq "admin")
{ {
$access_string = $anvil->data->{network}{'local'}{interface}{$interface}{ip}.":".$database_port; $access_string = $anvil->data->{network}{$local_host}{interface}{$interface}{ip}.":".$database_port;
} }
$inbound_table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-inbound", variables => { $inbound_table .= $anvil->Template->get({file => "striker.html", name => "striker-sync-inbound", variables => {
access => $access_string, access => $access_string,

View File

@ -686,9 +686,10 @@ sub stop_drbd_resource
{ {
my ($anvil) = @_; my ($anvil) = @_;
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $local_host = $anvil->_short_host_name();
my $host = $anvil->_short_host_name; my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $peer = $anvil->data->{drbd}{config}{$host}{peer}; my $host = $anvil->_short_host_name;
my $peer = $anvil->data->{drbd}{config}{$host}{peer};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server, server => $server,
host => $host, host => $host,
@ -696,7 +697,7 @@ sub stop_drbd_resource
}}); }});
# Start DRBD locally. # Start DRBD locally.
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{resource}})
{ {
my $peer_ip = $anvil->data->{drbd}{config}{$host}{resource}{$resource}{connection}{$peer}{ip_address}; my $peer_ip = $anvil->data->{drbd}{config}{$host}{resource}{$resource}{connection}{$peer}{ip_address};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0408", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0408", variables => {
@ -742,7 +743,7 @@ sub start_drbd_resource
# Do we need startup? # Do we need startup?
my $startup_needed = 0; my $startup_needed = 0;
$anvil->DRBD->get_status({debug => 3}); $anvil->DRBD->get_status({debug => 3});
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{resource}})
{ {
# Is the current resource up locally already? If it is, we're done. # Is the current resource up locally already? If it is, we're done.
my $role = defined $anvil->data->{drbd}{status}{$host}{resource}{$resource}{role} ? $anvil->data->{drbd}{status}{$host}{resource}{$resource}{role} : ""; my $role = defined $anvil->data->{drbd}{status}{$host}{resource}{$resource}{role} ? $anvil->data->{drbd}{status}{$host}{resource}{$resource}{role} : "";
@ -774,7 +775,7 @@ sub start_drbd_resource
} }
# Start DRBD locally. # Start DRBD locally.
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{resource}})
{ {
my $peer_ip = $anvil->data->{drbd}{config}{$host}{resource}{$resource}{connection}{$peer}{ip_address}; my $peer_ip = $anvil->data->{drbd}{config}{$host}{resource}{$resource}{connection}{$peer}{ip_address};
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0419", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0419", variables => {
@ -844,7 +845,7 @@ sub start_drbd_resource
# If auto-promote isn't set, promote the resource. # If auto-promote isn't set, promote the resource.
if (not $anvil->data->{drbd}{config}{$host}{'auto-promote'}) if (not $anvil->data->{drbd}{config}{$host}{'auto-promote'})
{ {
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{resource}})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0420", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0420", variables => {
server => $server, server => $server,
@ -1260,7 +1261,7 @@ sub migrate_server
host => $host, host => $host,
peer_name => $peer_name, peer_name => $peer_name,
}}); }});
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{resource}}) foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{resource}})
{ {
my $connection_state = $anvil->data->{drbd}{status}{$host}{resource}{$resource}{connection}{$peer_name}{'connection-state'}; my $connection_state = $anvil->data->{drbd}{status}{$host}{resource}{$resource}{connection}{$peer_name}{'connection-state'};
my $peer_node_id = $anvil->data->{drbd}{status}{$host}{resource}{$resource}{connection}{$peer_name}{'peer-node-id'}; my $peer_node_id = $anvil->data->{drbd}{status}{$host}{resource}{$resource}{connection}{$peer_name}{'peer-node-id'};
@ -1471,17 +1472,18 @@ sub validate_bridges
$anvil->Get->bridges({debug => 3}); $anvil->Get->bridges({debug => 3});
# Find the Optical drives and DRBD devices. # Find the Optical drives and DRBD devices.
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $local_host = $anvil->_short_host_name();
foreach my $mac (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{from_disk}{device}{interface}}) my $server = $anvil->data->{environment}{OCF_RESKEY_name};
foreach my $mac (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{from_disk}{device}{interface}})
{ {
# See if we have this bridge # See if we have this bridge
my $found = 0; my $found = 0;
my $bridge = $anvil->data->{server}{'local'}{$server}{from_disk}{device}{interface}{$mac}{bridge}; my $bridge = $anvil->data->{server}{$local_host}{$server}{from_disk}{device}{interface}{$mac}{bridge};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridge => $bridge }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bridge => $bridge }});
foreach my $interface_name (sort {$a cmp $b} keys %{$anvil->data->{'local'}{network}{bridges}{bridge}}) foreach my $interface_name (sort {$a cmp $b} keys %{$anvil->data->{$local_host}{network}{bridges}{bridge}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface_name => $interface_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface_name => $interface_name }});
if ((exists $anvil->data->{'local'}{network}{bridges}{bridge}{$interface_name}) && ($anvil->data->{'local'}{network}{bridges}{bridge}{$interface_name}{found})) if ((exists $anvil->data->{$local_host}{network}{bridges}{bridge}{$interface_name}) && ($anvil->data->{$local_host}{network}{bridges}{bridge}{$interface_name}{found}))
{ {
$found = 1; $found = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { found => $found }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { found => $found }});
@ -1517,8 +1519,9 @@ sub validate_storage
server => $server, server => $server,
target => $target, target => $target,
}}); }});
my $local_host = $anvil->_short_host_name();
my $xml_source = "from_disk"; my $xml_source = "from_disk";
if ($anvil->data->{server}{'local'}{$server}{from_memory}{host}) if ($anvil->data->{server}{$local_host}{$server}{from_memory}{host})
{ {
$xml_source = "from_memory"; $xml_source = "from_memory";
} }
@ -1531,13 +1534,13 @@ sub validate_storage
### For now, we just fault out. ### For now, we just fault out.
# Do the optical discs in the drive exist? If not, we'll eject it if we're about to boot and fail if # Do the optical discs in the drive exist? If not, we'll eject it if we're about to boot and fail if
# we're about to migrate. We skip this check if we're migrating off or shutting down the server. # we're about to migrate. We skip this check if we're migrating off or shutting down the server.
if ((exists $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}) && (not $target) && (not $anvil->data->{switches}{stop})) if ((exists $anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{cdrom}) && (not $target) && (not $anvil->data->{switches}{stop}))
{ {
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}}) foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{cdrom}{target}})
{ {
if ($anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path}) if ($anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path})
{ {
my $file = $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path}; my $file = $anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{cdrom}{target}{$device_target}{path};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file => $file }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { file => $file }});
if (not -e $file) if (not -e $file)
{ {
@ -1577,24 +1580,25 @@ sub validate_storage_drbd
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $xml_source = "from_disk"; my $xml_source = "from_disk";
my $host = $anvil->_short_host_name; my $host = $anvil->_short_host_name;
my $local_host = $anvil->_short_host_name();
# Did I find a resource for each disk? # Did I find a resource for each disk?
foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{device}}) foreach my $device_path (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{device}})
{ {
next if not $device_path; next if not $device_path;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"server::local::${server}::device::${device_path}::resource" => $anvil->data->{server}{'local'}{$server}{device}{$device_path}{resource}, "server::${local_host}::${server}::device::${device_path}::resource" => $anvil->data->{server}{$local_host}{$server}{device}{$device_path}{resource},
}}); }});
if (not $anvil->data->{server}{'local'}{$server}{device}{$device_path}{resource}) if (not $anvil->data->{server}{$local_host}{$server}{device}{$device_path}{resource})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 0, priority => "err", key => "log_0414", variables => { drbd_device => $device_path }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 0, priority => "err", key => "log_0414", variables => { drbd_device => $device_path }});
$anvil->nice_exit({exit_code => 5}); $anvil->nice_exit({exit_code => 5});
} }
} }
foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{'local'}{$server}{$xml_source}{device}{disk}{target}}) foreach my $device_target (sort {$a cmp $b} keys %{$anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{disk}{target}})
{ {
my $drbd_device = $anvil->data->{server}{'local'}{$server}{$xml_source}{device}{disk}{target}{$device_target}{path}; my $drbd_device = $anvil->data->{server}{$local_host}{$server}{$xml_source}{device}{disk}{target}{$device_target}{path};
my $drbd_resource = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} : ""; my $drbd_resource = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{resource} : "";
my $on_lv = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} : ""; my $on_lv = defined $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} ? $anvil->data->{drbd}{config}{$host}{drbd_path}{$drbd_device}{on} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
@ -1615,13 +1619,13 @@ sub validate_storage_drbd
} }
# If the logical volume here here and active? # If the logical volume here here and active?
if ((not $on_lv) or (not exists $anvil->data->{lvm}{'local'}{lv}{$on_lv})) if ((not $on_lv) or (not exists $anvil->data->{lvm}{$local_host}{lv}{$on_lv}))
{ {
# LV not found # LV not found
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 0, priority => "err", key => "log_0374", variables => { drbd_device => $drbd_device, lv_path => $on_lv }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 0, priority => "err", key => "log_0374", variables => { drbd_device => $drbd_device, lv_path => $on_lv }});
$anvil->nice_exit({exit_code => 5}); $anvil->nice_exit({exit_code => 5});
} }
elsif (not $anvil->data->{lvm}{'local'}{lv}{$on_lv}{active}) elsif (not $anvil->data->{lvm}{$local_host}{lv}{$on_lv}{active})
{ {
# LV not active. If we're starting the server or we're the migration target, try to # LV not active. If we're starting the server or we're the migration target, try to
# activate it. # activate it.
@ -1657,11 +1661,12 @@ sub validate_emulator
my ($anvil) = @_; my ($anvil) = @_;
# What emulator is this using? # What emulator is this using?
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $local_host = $anvil->_short_host_name();
my $emulator = $anvil->data->{server}{'local'}{$server}{from_disk}{info}{emulator}; my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $emulator = $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{emulator};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
emulator => $emulator, emulator => $emulator,
"server::local::${server}::from_disk::info::emulator" => $anvil->data->{server}{'local'}{$server}{from_disk}{info}{emulator} "server::${local_host}::${server}::from_disk::info::emulator" => $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{emulator}
}}); }});
if (not -e $emulator) if (not -e $emulator)
{ {
@ -1688,14 +1693,16 @@ sub validate_name
{ {
my ($anvil) = @_; my ($anvil) = @_;
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $local_host = $anvil->_short_host_name();
my $local_host = $anvil->_short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
server => $server, server => $server,
"server::local::${server}::from_disk::info::name" => $anvil->data->{server}{'local'}{$server}{from_disk}{info}{name}, "server::${local_host}::${server}::from_disk::info::name" => $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{name},
}}); }});
# If we failed to read the XML, the server probably doesn't exist. # If we failed to read the XML, the server probably doesn't exist.
if (not $anvil->data->{server}{'local'}{$server}{from_disk}{xml}) if (not $anvil->data->{server}{$local_host}{$server}{from_disk}{xml})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0403", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0403", variables => {
server => $server, server => $server,
@ -1705,11 +1712,11 @@ sub validate_name
} }
# Is the name in the definition file what we expect? # Is the name in the definition file what we expect?
if ($server ne $anvil->data->{server}{'local'}{$server}{from_disk}{info}{name}) if ($server ne $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{name})
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0403", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0403", variables => {
server => $server, server => $server,
name => $anvil->data->{server}{'local'}{$server}{from_disk}{info}{name}, name => $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{name},
}}); }});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -1724,8 +1731,9 @@ sub validate_ram
my ($anvil) = @_; my ($anvil) = @_;
# How mcuh RAM does the server need and how much do we have free? # How mcuh RAM does the server need and how much do we have free?
my $local_host = $anvil->_short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name}; my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $server_ram_bytes = $anvil->data->{server}{'local'}{$server}{from_disk}{memory}; my $server_ram_bytes = $anvil->data->{server}{$local_host}{$server}{from_disk}{memory};
my $available = $anvil->Get->free_memory({debug => 3}); my $available = $anvil->Get->free_memory({debug => 3});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
server_ram_bytes => $anvil->Convert->add_commas({number => $server_ram_bytes})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_ram_bytes}).")", server_ram_bytes => $anvil->Convert->add_commas({number => $server_ram_bytes})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_ram_bytes}).")",

View File

@ -165,6 +165,7 @@ sub reconfigure_network
{ {
my ($anvil) = @_; my ($anvil) = @_;
my $local_host = $anvil->_short_host_name();
my $reboot_needed = 0; my $reboot_needed = 0;
my $prefix = exists $anvil->data->{variables}{form}{config_step1}{prefix}{value} ? $anvil->data->{variables}{form}{config_step1}{prefix}{value} : ""; my $prefix = exists $anvil->data->{variables}{form}{config_step1}{prefix}{value} ? $anvil->data->{variables}{form}{config_step1}{prefix}{value} : "";
my $sequence = exists $anvil->data->{variables}{form}{config_step1}{sequence}{value} ? $anvil->data->{variables}{form}{config_step1}{sequence}{value} : ""; my $sequence = exists $anvil->data->{variables}{form}{config_step1}{sequence}{value} ? $anvil->data->{variables}{form}{config_step1}{sequence}{value} : "";
@ -345,8 +346,8 @@ sub reconfigure_network
my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}; my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
my $is_gateway = $this_network eq $gateway_interface ? 1 : 0; my $is_gateway = $this_network eq $gateway_interface ? 1 : 0;
my $link2_mac = defined $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} : ""; my $link2_mac = defined $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} : "";
my $old_link1_iface = $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface} ? $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface} : ""; my $old_link1_iface = $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} : "";
my $old_link2_iface = defined $anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface} ? $anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface} : ""; my $old_link2_iface = defined $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} : "";
my $bridge = defined $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} : 0; my $bridge = defined $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip_key => $ip_key, ip_key => $ip_key,
@ -367,9 +368,9 @@ sub reconfigure_network
# 'old_link1_iface' is the name reported by 'ip', the 'DEVICE=xxx' value in the ifcfg-xxx file. # 'old_link1_iface' is the name reported by 'ip', the 'DEVICE=xxx' value in the ifcfg-xxx file.
my $old_link1_nm_name = $old_link1_iface; my $old_link1_nm_name = $old_link1_iface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link1_nm_name => $old_link1_nm_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link1_nm_name => $old_link1_nm_name }});
if ((exists $anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link1_iface}) && ($anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link1_iface})) if ((exists $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link1_iface}) && ($anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link1_iface}))
{ {
$old_link1_nm_name = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link1_iface}; $old_link1_nm_name = $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link1_iface};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link1_nm_name => $old_link1_nm_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link1_nm_name => $old_link1_nm_name }});
} }
@ -379,9 +380,9 @@ sub reconfigure_network
{ {
$old_link2_nm_name = $old_link2_iface; $old_link2_nm_name = $old_link2_iface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link2_nm_name => $old_link2_nm_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link2_nm_name => $old_link2_nm_name }});
if ((exists $anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link2_iface}) && ($anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link2_iface})) if ((exists $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link2_iface}) && ($anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link2_iface}))
{ {
$old_link2_nm_name = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$old_link2_iface}; $old_link2_nm_name = $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$old_link2_iface};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link2_nm_name => $old_link2_nm_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { old_link2_nm_name => $old_link2_nm_name }});
} }
} }
@ -458,13 +459,13 @@ sub reconfigure_network
my $boot_proto = $ip_address eq "dhcp" ? "dhcp" : "none"; my $boot_proto = $ip_address eq "dhcp" ? "dhcp" : "none";
my $link1_uuid = get_uuid_from_interface_file($anvil, $old_link1_file); my $link1_uuid = get_uuid_from_interface_file($anvil, $old_link1_file);
my $link2_uuid = get_uuid_from_interface_file($anvil, $old_link2_file); my $link2_uuid = get_uuid_from_interface_file($anvil, $old_link2_file);
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface})) if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}))
{ {
$old_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}; $old_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface};
} }
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface}) && ($anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface})) if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface}))
{ {
$old_link2_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface}; $old_link2_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface};
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
bond_file => $bond_file, bond_file => $bond_file,
@ -769,17 +770,17 @@ sub reconfigure_network
}); });
# If the NICs names have changed, rename them now. # If the NICs names have changed, rename them now.
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface} ne $new_link1_iface)) ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} ne $new_link1_iface))
{ {
rename_interface($anvil, $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}, $new_link1_iface); rename_interface($anvil, $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}, $new_link1_iface);
} }
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface}) && if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface} ne $new_link2_iface)) ($anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} ne $new_link2_iface))
{ {
rename_interface($anvil, $anvil->data->{network}{'local'}{mac_address}{$link2_mac}{interface}, $new_link2_iface); rename_interface($anvil, $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface}, $new_link2_iface);
} }
} }
elsif ((exists $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}) && ($anvil->Validate->mac({mac => $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}}))) elsif ((exists $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}) && ($anvil->Validate->mac({mac => $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}})))
@ -817,9 +818,9 @@ sub reconfigure_network
my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1"; my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1";
my $old_link1_file = $new_link1_file; my $old_link1_file = $new_link1_file;
my $new_link1_iface = $say_interface."_link1"; my $new_link1_iface = $say_interface."_link1";
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface})) if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}))
{ {
$old_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}; $old_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface};
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
cidr => $cidr, cidr => $cidr,
@ -884,15 +885,15 @@ sub reconfigure_network
}); });
# If the name differs from old, delete the old interface. # If the name differs from old, delete the old interface.
if ((exists $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) &&
($anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface} ne $new_link1_iface)) ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} ne $new_link1_iface))
{ {
# Delete the old interface # Delete the old interface
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "log_0461", variables => { interface => $old_link1_nm_name }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "log_0461", variables => { interface => $old_link1_nm_name }});
$anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name}); $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name});
rename_interface($anvil, $anvil->data->{network}{'local'}{mac_address}{$link1_mac}{interface}, $new_link1_iface); rename_interface($anvil, $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}, $new_link1_iface);
} }
else else
{ {

View File

@ -1067,6 +1067,7 @@ sub check_local_network
my ($anvil) = @_; my ($anvil) = @_;
# What host name and IP(s) should I have? # What host name and IP(s) should I have?
my $local_host = $anvil->_short_host_name();
my $machine = $anvil->data->{sys}{machine}; my $machine = $anvil->data->{sys}{machine};
my $manifest_uuid = $anvil->data->{sys}{manifest_uuid}; my $manifest_uuid = $anvil->data->{sys}{manifest_uuid};
@ -1129,9 +1130,9 @@ sub check_local_network
# This will be set when the first IFN with a gateway is set. # This will be set when the first IFN with a gateway is set.
my $default_gateway_interface = ""; my $default_gateway_interface = "";
foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
if ($anvil->data->{network}{'local'}{interface}{$in_iface}{default_gateway}) if ($anvil->data->{network}{$local_host}{interface}{$in_iface}{default_gateway})
{ {
$default_gateway_interface = $in_iface; $default_gateway_interface = $in_iface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { default_gateway_interface => $default_gateway_interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { default_gateway_interface => $default_gateway_interface }});
@ -1178,17 +1179,17 @@ sub check_local_network
's4:cidr' => $cidr, 's4:cidr' => $cidr,
's5:gateway' => $gateway, 's5:gateway' => $gateway,
}}); }});
foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
# Only one interface will start with the network name and have an IP address. # Only one interface will start with the network name and have an IP address.
next if $in_iface !~ /^${network}_/; next if $in_iface !~ /^${network}_/;
next if not $anvil->data->{network}{'local'}{interface}{$in_iface}{ip}; next if not $anvil->data->{network}{$local_host}{interface}{$in_iface}{ip};
my $current_ip = $anvil->data->{network}{'local'}{interface}{$in_iface}{ip}; my $current_ip = $anvil->data->{network}{$local_host}{interface}{$in_iface}{ip};
my $current_subnet = $anvil->data->{network}{'local'}{interface}{$in_iface}{subnet_mask}; my $current_subnet = $anvil->data->{network}{$local_host}{interface}{$in_iface}{subnet_mask};
my $current_gateway = $anvil->data->{network}{'local'}{interface}{$in_iface}{gateway}; my $current_gateway = $anvil->data->{network}{$local_host}{interface}{$in_iface}{gateway};
my $current_dns = $anvil->data->{network}{'local'}{interface}{$in_iface}{dns}; my $current_dns = $anvil->data->{network}{$local_host}{interface}{$in_iface}{dns};
my $current_mtu = $anvil->data->{network}{'local'}{interface}{$in_iface}{mtu}; my $current_mtu = $anvil->data->{network}{$local_host}{interface}{$in_iface}{mtu};
my $mac_address = $anvil->data->{network}{'local'}{interface}{$in_iface}{mac_address}; my $mac_address = $anvil->data->{network}{$local_host}{interface}{$in_iface}{mac_address};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:in_iface' => $in_iface, 's1:in_iface' => $in_iface,
's2:current_ip' => $current_ip, 's2:current_ip' => $current_ip,
@ -1275,9 +1276,9 @@ sub check_local_network
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0078,!!interface!".$in_iface."!!"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0078,!!interface!".$in_iface."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0078", variables => { interface => $in_iface }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "job_0078", variables => { interface => $in_iface }});
my $interface_uuid = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$in_iface}; my $interface_uuid = $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$in_iface};
my $filename = $anvil->data->{nmcli}{'local'}{uuid}{$interface_uuid}{filename}; my $filename = $anvil->data->{nmcli}{$local_host}{uuid}{$interface_uuid}{filename};
my $interface_name = $anvil->data->{nmcli}{'local'}{uuid}{$interface_uuid}{name}; my $interface_name = $anvil->data->{nmcli}{$local_host}{uuid}{$interface_uuid}{name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:in_iface' => $in_iface, 's1:in_iface' => $in_iface,
's2:interface_name' => $interface_name, 's2:interface_name' => $interface_name,
@ -1627,7 +1628,7 @@ sub check_local_network
} }
# Remove virbr0 if it exists. # Remove virbr0 if it exists.
if (exists $anvil->data->{network}{'local'}{interface}{virbr0}) if (exists $anvil->data->{network}{$local_host}{interface}{virbr0})
{ {
# Remove the NAT'ed bridge # Remove the NAT'ed bridge
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0085"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "job_0085"});
@ -1648,10 +1649,10 @@ sub check_local_network
update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0086"); update_progress($anvil, ($anvil->data->{job}{progress} += 2), "job_0086");
# Update MTUs (running interface and config) if needed. # Update MTUs (running interface and config) if needed.
foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
# Only one interface will start with the network name and have an IP address. # Only one interface will start with the network name and have an IP address.
my $current_mtu = $anvil->data->{network}{'local'}{interface}{$in_iface}{mtu}; my $current_mtu = $anvil->data->{network}{$local_host}{interface}{$in_iface}{mtu};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:in_iface' => $in_iface, 's1:in_iface' => $in_iface,
's2:current_mtu' => $current_mtu, 's2:current_mtu' => $current_mtu,
@ -1680,9 +1681,9 @@ sub check_local_network
$anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu}); $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$in_iface." mtu ".$mtu});
# Now update the config file. # Now update the config file.
my $interface_uuid = $anvil->data->{nmcli}{'local'}{device_to_uuid}{$in_iface}; my $interface_uuid = $anvil->data->{nmcli}{$local_host}{device_to_uuid}{$in_iface};
my $filename = $anvil->data->{nmcli}{'local'}{uuid}{$interface_uuid}{filename}; my $filename = $anvil->data->{nmcli}{$local_host}{uuid}{$interface_uuid}{filename};
my $interface_name = $anvil->data->{nmcli}{'local'}{uuid}{$interface_uuid}{name}; my $interface_name = $anvil->data->{nmcli}{$local_host}{uuid}{$interface_uuid}{name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:interface_name' => $interface_name, 's1:interface_name' => $interface_name,
's2:filename' => $filename, 's2:filename' => $filename,

View File

@ -243,13 +243,14 @@ sub find_file
my $found = 0; my $found = 0;
# What are my IPs? # What are my IPs?
my $local_host = $anvil->_short_host_name();
$anvil->Network->get_ips(); $anvil->Network->get_ips();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip}; next if not $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
next if not $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; next if not $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask};
my $ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $ip = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; my $subnet_mask = $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask};
my $network = $anvil->Network->get_network({ip => $ip, subnet_mask => $subnet_mask}); my $network = $anvil->Network->get_network({ip => $ip, subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:interface' => $interface, 's1:interface' => $interface,

View File

@ -104,7 +104,8 @@ sub check_initial_setup
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "firewall::default_zone" => $anvil->data->{firewall}{default_zone} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "firewall::default_zone" => $anvil->data->{firewall}{default_zone} }});
my $internet_zone = ""; my $internet_zone = "";
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) my $local_host = $anvil->_short_host_name();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface }});
if ($interface =~ /^((bcn|ifn|sn)\d+)_/) if ($interface =~ /^((bcn|ifn|sn)\d+)_/)
@ -113,22 +114,22 @@ sub check_initial_setup
# always be overridden by the ZONE="" variable in each interface's config. # always be overridden by the ZONE="" variable in each interface's config.
my $zone = $1; my $zone = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { zone => $zone }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { zone => $zone }});
if ((exists $anvil->data->{network}{'local'}{interface}{$interface}{variable}{ZONE}) && ($anvil->data->{network}{'local'}{interface}{$interface}{variable}{ZONE})) if ((exists $anvil->data->{network}{$local_host}{interface}{$interface}{variable}{ZONE}) && ($anvil->data->{network}{$local_host}{interface}{$interface}{variable}{ZONE}))
{ {
$zone = $anvil->data->{network}{'local'}{interface}{$interface}{variable}{ZONE}; $zone = $anvil->data->{network}{$local_host}{interface}{$interface}{variable}{ZONE};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { zone => $zone }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { zone => $zone }});
} }
push @{$needed_zones}, $zone; push @{$needed_zones}, $zone;
$anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip} = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip} = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
$anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask} = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask} = $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"firewall::zone::${zone}::interface::${interface}::ip" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip}, "firewall::zone::${zone}::interface::${interface}::ip" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip},
"firewall::zone::${zone}::interface::${interface}::subnet_mask" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask}, "firewall::zone::${zone}::interface::${interface}::subnet_mask" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask},
"network::local::interface::${interface}::default_gateway" => $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}, "network::${local_host}::interface::${interface}::default_gateway" => $anvil->data->{network}{$local_host}{interface}{$interface}{default_gateway},
}}); }});
if ($anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}) if ($anvil->data->{network}{$local_host}{interface}{$interface}{default_gateway})
{ {
$internet_zone = $zone; $internet_zone = $zone;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { internet_zone => $internet_zone }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { internet_zone => $internet_zone }});

View File

@ -125,9 +125,10 @@ sub update_network
$anvil->Network->get_ips(); $anvil->Network->get_ips();
# We'll read through '/sys/class/net' looking for network interfaces. # We'll read through '/sys/class/net' looking for network interfaces.
# * 'network::local::interface::<iface_name>::ip' - If an IP address is set # * 'network::${local_host}::interface::<iface_name>::ip' - If an IP address is set
# * 'network::local::interface::<iface_name>::subnet_mask' - If an IP is set # * 'network::${local_host}::interface::<iface_name>::subnet_mask' - If an IP is set
my $directory = "/sys/class/net"; my $local_host = $anvil->_short_host_name();
my $directory = "/sys/class/net";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { directory => $directory }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { directory => $directory }});
# We'll need to know what interfaces to remove, if any. This will store the interfaces we've seen and # We'll need to know what interfaces to remove, if any. This will store the interfaces we've seen and
@ -199,11 +200,11 @@ sub update_network
my $bridge_stp_enabled = ""; my $bridge_stp_enabled = "";
# Explicitly check for the existing of the hash so that we don't auto-vivivate the interface. # Explicitly check for the existing of the hash so that we don't auto-vivivate the interface.
if (exists $anvil->data->{network}{'local'}{interface}{$interface}) if (exists $anvil->data->{network}{$local_host}{interface}{$interface})
{ {
$ip_address = defined $anvil->data->{network}{'local'}{interface}{$interface}{ip} ? $anvil->data->{network}{'local'}{interface}{$interface}{ip} : ""; $ip_address = defined $anvil->data->{network}{$local_host}{interface}{$interface}{ip} ? $anvil->data->{network}{$local_host}{interface}{$interface}{ip} : "";
$subnet_mask = defined $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} ? $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} : ""; $subnet_mask = defined $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask} ? $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask} : "";
$type = defined $anvil->data->{network}{'local'}{interface}{$interface}{type} ? $anvil->data->{network}{'local'}{interface}{$interface}{type} : "interface"; $type = defined $anvil->data->{network}{$local_host}{interface}{$interface}{type} ? $anvil->data->{network}{$local_host}{interface}{$interface}{type} : "interface";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_address => $ip_address, ip_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,
@ -377,51 +378,51 @@ sub update_network
} }
# Store new information we found. # Store new information we found.
$anvil->data->{network}{'local'}{interface}{$interface}{active_interface} = $active_interface; $anvil->data->{network}{$local_host}{interface}{$interface}{active_interface} = $active_interface;
$anvil->data->{network}{'local'}{interface}{$interface}{bond_mode} = $bond_mode; $anvil->data->{network}{$local_host}{interface}{$interface}{bond_mode} = $bond_mode;
$anvil->data->{network}{'local'}{interface}{$interface}{bond_master} = $bond_master; $anvil->data->{network}{$local_host}{interface}{$interface}{bond_master} = $bond_master;
$anvil->data->{network}{'local'}{interface}{$interface}{bridge_id} = $bridge_id; $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_id} = $bridge_id;
$anvil->data->{network}{'local'}{interface}{$interface}{bridge_stp_enabled} = $bridge_stp_enabled; $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_stp_enabled} = $bridge_stp_enabled;
$anvil->data->{network}{'local'}{interface}{$interface}{down_delay} = $down_delay; $anvil->data->{network}{$local_host}{interface}{$interface}{down_delay} = $down_delay;
$anvil->data->{network}{'local'}{interface}{$interface}{duplex} = $duplex; $anvil->data->{network}{$local_host}{interface}{$interface}{duplex} = $duplex;
$anvil->data->{network}{'local'}{interface}{$interface}{ip} = $ip_address; $anvil->data->{network}{$local_host}{interface}{$interface}{ip} = $ip_address;
$anvil->data->{network}{'local'}{interface}{$interface}{link_state} = $link_state; $anvil->data->{network}{$local_host}{interface}{$interface}{link_state} = $link_state;
$anvil->data->{network}{'local'}{interface}{$interface}{mac_address} = $mac_address; $anvil->data->{network}{$local_host}{interface}{$interface}{mac_address} = $mac_address;
$anvil->data->{network}{'local'}{interface}{$interface}{media} = $media; $anvil->data->{network}{$local_host}{interface}{$interface}{media} = $media;
$anvil->data->{network}{'local'}{interface}{$interface}{mii_polling_interval} = $mii_polling_interval; $anvil->data->{network}{$local_host}{interface}{$interface}{mii_polling_interval} = $mii_polling_interval;
$anvil->data->{network}{'local'}{interface}{$interface}{mtu} = $mtu; $anvil->data->{network}{$local_host}{interface}{$interface}{mtu} = $mtu;
$anvil->data->{network}{'local'}{interface}{$interface}{operational} = $operational; $anvil->data->{network}{$local_host}{interface}{$interface}{operational} = $operational;
$anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect} = $primary_reselect; $anvil->data->{network}{$local_host}{interface}{$interface}{primary_reselect} = $primary_reselect;
$anvil->data->{network}{'local'}{interface}{$interface}{primary_interface} = $primary_interface; $anvil->data->{network}{$local_host}{interface}{$interface}{primary_interface} = $primary_interface;
$anvil->data->{network}{'local'}{interface}{$interface}{speed} = $speed; $anvil->data->{network}{$local_host}{interface}{$interface}{speed} = $speed;
$anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} = $subnet_mask; $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask} = $subnet_mask;
$anvil->data->{network}{'local'}{interface}{$interface}{type} = $type; $anvil->data->{network}{$local_host}{interface}{$interface}{type} = $type;
$anvil->data->{network}{'local'}{interface}{$interface}{up_delay} = $up_delay; $anvil->data->{network}{$local_host}{interface}{$interface}{up_delay} = $up_delay;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"network::local::interface::${interface}::active_interface" => $anvil->data->{network}{'local'}{interface}{$interface}{active_interface}, "network::${local_host}::interface::${interface}::active_interface" => $anvil->data->{network}{$local_host}{interface}{$interface}{active_interface},
"network::local::interface::${interface}::bond_mode" => $anvil->data->{network}{'local'}{interface}{$interface}{bond_mode}, "network::${local_host}::interface::${interface}::bond_mode" => $anvil->data->{network}{$local_host}{interface}{$interface}{bond_mode},
"network::local::interface::${interface}::bond_master" => $anvil->data->{network}{'local'}{interface}{$interface}{bond_master}, "network::${local_host}::interface::${interface}::bond_master" => $anvil->data->{network}{$local_host}{interface}{$interface}{bond_master},
"network::local::interface::${interface}::bridge_id" => $anvil->data->{network}{'local'}{interface}{$interface}{bridge_id}, "network::${local_host}::interface::${interface}::bridge_id" => $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_id},
"network::local::interface::${interface}::bridge_stp_enabled" => $anvil->data->{network}{'local'}{interface}{$interface}{bridge_stp_enabled}, "network::${local_host}::interface::${interface}::bridge_stp_enabled" => $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_stp_enabled},
"network::local::interface::${interface}::down_delay" => $anvil->data->{network}{'local'}{interface}{$interface}{down_delay}, "network::${local_host}::interface::${interface}::down_delay" => $anvil->data->{network}{$local_host}{interface}{$interface}{down_delay},
"network::local::interface::${interface}::duplex" => $anvil->data->{network}{'local'}{interface}{$interface}{duplex}, "network::${local_host}::interface::${interface}::duplex" => $anvil->data->{network}{$local_host}{interface}{$interface}{duplex},
"network::local::interface::${interface}::ip" => $anvil->data->{network}{'local'}{interface}{$interface}{ip}, "network::${local_host}::interface::${interface}::ip" => $anvil->data->{network}{$local_host}{interface}{$interface}{ip},
"network::local::interface::${interface}::link_state" => $anvil->data->{network}{'local'}{interface}{$interface}{link_state}, "network::${local_host}::interface::${interface}::link_state" => $anvil->data->{network}{$local_host}{interface}{$interface}{link_state},
"network::local::interface::${interface}::mac_address" => $anvil->data->{network}{'local'}{interface}{$interface}{mac_address}, "network::${local_host}::interface::${interface}::mac_address" => $anvil->data->{network}{$local_host}{interface}{$interface}{mac_address},
"network::local::interface::${interface}::media" => $anvil->data->{network}{'local'}{interface}{$interface}{media}, "network::${local_host}::interface::${interface}::media" => $anvil->data->{network}{$local_host}{interface}{$interface}{media},
"network::local::interface::${interface}::mii_polling_interval" => $anvil->data->{network}{'local'}{interface}{$interface}{mii_polling_interval}, "network::${local_host}::interface::${interface}::mii_polling_interval" => $anvil->data->{network}{$local_host}{interface}{$interface}{mii_polling_interval},
"network::local::interface::${interface}::mtu" => $anvil->data->{network}{'local'}{interface}{$interface}{mtu}, "network::${local_host}::interface::${interface}::mtu" => $anvil->data->{network}{$local_host}{interface}{$interface}{mtu},
"network::local::interface::${interface}::operational" => $anvil->data->{network}{'local'}{interface}{$interface}{operational}, "network::${local_host}::interface::${interface}::operational" => $anvil->data->{network}{$local_host}{interface}{$interface}{operational},
"network::local::interface::${interface}::primary_reselect" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect}, "network::${local_host}::interface::${interface}::primary_reselect" => $anvil->data->{network}{$local_host}{interface}{$interface}{primary_reselect},
"network::local::interface::${interface}::primary_interface" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_interface}, "network::${local_host}::interface::${interface}::primary_interface" => $anvil->data->{network}{$local_host}{interface}{$interface}{primary_interface},
"network::local::interface::${interface}::speed" => $anvil->data->{network}{'local'}{interface}{$interface}{speed}, "network::${local_host}::interface::${interface}::speed" => $anvil->data->{network}{$local_host}{interface}{$interface}{speed},
"network::local::interface::${interface}::subnet_mask" => $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}, "network::${local_host}::interface::${interface}::subnet_mask" => $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask},
"network::local::interface::${interface}::type" => $anvil->data->{network}{'local'}{interface}{$interface}{type}, "network::${local_host}::interface::${interface}::type" => $anvil->data->{network}{$local_host}{interface}{$interface}{type},
"network::local::interface::${interface}::up_delay" => $anvil->data->{network}{'local'}{interface}{$interface}{up_delay}, "network::${local_host}::interface::${interface}::up_delay" => $anvil->data->{network}{$local_host}{interface}{$interface}{up_delay},
}}); }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"network::local::interface::${interface}::link_state" => $anvil->data->{network}{'local'}{interface}{$interface}{link_state}, "network::${local_host}::interface::${interface}::link_state" => $anvil->data->{network}{$local_host}{interface}{$interface}{link_state},
"network::local::interface::${interface}::operational" => $anvil->data->{network}{'local'}{interface}{$interface}{operational}, "network::${local_host}::interface::${interface}::operational" => $anvil->data->{network}{$local_host}{interface}{$interface}{operational},
}}); }});
# If this is a link and there's no database connections, cache the data. # If this is a link and there's no database connections, cache the data.
@ -439,10 +440,10 @@ sub update_network
# Find what interfaces are connected to which bridges # Find what interfaces are connected to which bridges
$anvil->Network->bridge_info({debug => 3}); $anvil->Network->bridge_info({debug => 3});
delete $anvil->data->{interface_to_bridge} if exists $anvil->data->{interface_to_bridge}; delete $anvil->data->{interface_to_bridge} if exists $anvil->data->{interface_to_bridge};
foreach my $bridge_name (sort {$a cmp $b} keys %{$anvil->data->{bridge}{'local'}}) foreach my $bridge_name (sort {$a cmp $b} keys %{$anvil->data->{bridge}{$local_host}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bridge_name => $bridge_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bridge_name => $bridge_name }});
foreach my $interface_name (sort {$a cmp $b} @{$anvil->data->{bridge}{'local'}{$bridge_name}{interfaces}}) foreach my $interface_name (sort {$a cmp $b} @{$anvil->data->{bridge}{$local_host}{$bridge_name}{interfaces}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { interface_name => $interface_name }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { interface_name => $interface_name }});
@ -459,40 +460,40 @@ sub update_network
foreach my $processing ("bridge", "bond", "interface") foreach my $processing ("bridge", "bond", "interface")
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { processing => $processing }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { processing => $processing }});
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
# Skip if this isn't the device type we're working on. # Skip if this isn't the device type we're working on.
next if not defined $anvil->data->{network}{'local'}{interface}{$interface}{type}; next if not defined $anvil->data->{network}{$local_host}{interface}{$interface}{type};
my $type = $anvil->data->{network}{'local'}{interface}{$interface}{type}; my $type = $anvil->data->{network}{$local_host}{interface}{$interface}{type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:interface' => $interface, 's1:interface' => $interface,
's2:type' => $type, 's2:type' => $type,
's3:processing' => $processing, 's3:processing' => $processing,
}}); }});
next if $processing ne $anvil->data->{network}{'local'}{interface}{$interface}{type}; next if $processing ne $anvil->data->{network}{$local_host}{interface}{$interface}{type};
my $active_interface = $anvil->data->{network}{'local'}{interface}{$interface}{active_interface}; my $active_interface = $anvil->data->{network}{$local_host}{interface}{$interface}{active_interface};
my $bond_mode = $anvil->data->{network}{'local'}{interface}{$interface}{bond_mode}; my $bond_mode = $anvil->data->{network}{$local_host}{interface}{$interface}{bond_mode};
my $bond_master = $anvil->data->{network}{'local'}{interface}{$interface}{bond_master}; my $bond_master = $anvil->data->{network}{$local_host}{interface}{$interface}{bond_master};
my $bridge_id = $anvil->data->{network}{'local'}{interface}{$interface}{bridge_id}; my $bridge_id = $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_id};
my $bridge_stp_enabled = $anvil->data->{network}{'local'}{interface}{$interface}{bridge_stp_enabled}; my $bridge_stp_enabled = $anvil->data->{network}{$local_host}{interface}{$interface}{bridge_stp_enabled};
my $down_delay = $anvil->data->{network}{'local'}{interface}{$interface}{down_delay}; my $down_delay = $anvil->data->{network}{$local_host}{interface}{$interface}{down_delay};
my $duplex = $anvil->data->{network}{'local'}{interface}{$interface}{duplex}; my $duplex = $anvil->data->{network}{$local_host}{interface}{$interface}{duplex};
my $ip_address = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $ip_address = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
my $link_state = $anvil->data->{network}{'local'}{interface}{$interface}{link_state}; my $link_state = $anvil->data->{network}{$local_host}{interface}{$interface}{link_state};
my $mac_address = $anvil->data->{network}{'local'}{interface}{$interface}{mac_address}; my $mac_address = $anvil->data->{network}{$local_host}{interface}{$interface}{mac_address};
my $media = $anvil->data->{network}{'local'}{interface}{$interface}{media}; my $media = $anvil->data->{network}{$local_host}{interface}{$interface}{media};
my $mii_polling_interval = $anvil->data->{network}{'local'}{interface}{$interface}{mii_polling_interval}; my $mii_polling_interval = $anvil->data->{network}{$local_host}{interface}{$interface}{mii_polling_interval};
my $mtu = $anvil->data->{network}{'local'}{interface}{$interface}{mtu}; my $mtu = $anvil->data->{network}{$local_host}{interface}{$interface}{mtu};
my $operational = $anvil->data->{network}{'local'}{interface}{$interface}{operational}; my $operational = $anvil->data->{network}{$local_host}{interface}{$interface}{operational};
my $primary_reselect = $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect}; my $primary_reselect = $anvil->data->{network}{$local_host}{interface}{$interface}{primary_reselect};
my $primary_interface = $anvil->data->{network}{'local'}{interface}{$interface}{primary_interface}; my $primary_interface = $anvil->data->{network}{$local_host}{interface}{$interface}{primary_interface};
my $speed = $anvil->data->{network}{'local'}{interface}{$interface}{speed}; my $speed = $anvil->data->{network}{$local_host}{interface}{$interface}{speed};
my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}; my $subnet_mask = $anvil->data->{network}{$local_host}{interface}{$interface}{subnet_mask};
my $up_delay = $anvil->data->{network}{'local'}{interface}{$interface}{up_delay}; my $up_delay = $anvil->data->{network}{$local_host}{interface}{$interface}{up_delay};
my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}; my $default_gateway = $anvil->data->{network}{$local_host}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway}; my $gateway = $anvil->data->{network}{$local_host}{interface}{$interface}{gateway};
my $dns = $anvil->data->{network}{'local'}{interface}{$interface}{dns}; my $dns = $anvil->data->{network}{$local_host}{interface}{$interface}{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
active_interface => $active_interface, active_interface => $active_interface,
bond_mode => $bond_mode, bond_mode => $bond_mode,
@ -877,7 +878,7 @@ ORDER BY
}}); }});
# Make sure I've seen this interface in this scan and, if not, update this entry to remove it. # Make sure I've seen this interface in this scan and, if not, update this entry to remove it.
if (not exists $anvil->data->{network}{'local'}{interface}{$network_interface_name}) if (not exists $anvil->data->{network}{$local_host}{interface}{$network_interface_name})
{ {
# Mark it as deleted. # Mark it as deleted.
my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";"; my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";";

View File

@ -144,9 +144,10 @@ sub add_databases
password => $anvil->data->{data}{password}, password => $anvil->data->{data}{password},
port => $anvil->data->{data}{ssh_port}, port => $anvil->data->{data}{ssh_port},
}); });
my ($match) = $anvil->Network->find_matches({ my $local_host = $anvil->_short_host_name();
my ($match) = $anvil->Network->find_matches({
debug => 3, debug => 3,
first => 'local', first => $local_host,
second => $target, second => $target,
}); });
@ -156,9 +157,9 @@ sub add_databases
my $db_ping = 1, my $db_ping = 1,
my $db_port = ""; my $db_port = "";
my $db_password = ""; my $db_password = "";
foreach my $interface (sort {$a cmp $b} keys %{$match->{'local'}}) foreach my $interface (sort {$a cmp $b} keys %{$match->{$local_host}})
{ {
my $local_ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $local_ip = $anvil->data->{network}{$local_host}{interface}{$interface}{ip};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
interface => $interface, interface => $interface,
local_ip => $local_ip, local_ip => $local_ip,

View File

@ -456,13 +456,14 @@ sub setup_boot_environment
# Get my BCN IP and active OS. # Get my BCN IP and active OS.
$anvil->Network->get_ips(); $anvil->Network->get_ips();
my $bcn_interface = ""; my $bcn_interface = "";
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) my $local_host = $anvil->_short_host_name();
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { interface => $interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { interface => $interface }});
next if $interface !~ /^bcn/; next if $interface !~ /^bcn/;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "network::local::${interface}::ip" => $anvil->data->{network}{'local'}{interface}{$interface}{ip} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "network::local::${interface}::ip" => $anvil->data->{network}{$local_host}{interface}{$interface}{ip} }});
if ($anvil->Validate->ipv4({ip => $anvil->data->{network}{'local'}{interface}{$interface}{ip} })) if ($anvil->Validate->ipv4({ip => $anvil->data->{network}{$local_host}{interface}{$interface}{ip} }))
{ {
$bcn_interface = $interface; $bcn_interface = $interface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bcn_interface => $bcn_interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { bcn_interface => $bcn_interface }});
@ -478,10 +479,10 @@ sub setup_boot_environment
$anvil->nice_exit({exit_code => 2}); $anvil->nice_exit({exit_code => 2});
} }
my $bcn_ip = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{ip}; my $bcn_ip = $anvil->data->{network}{$local_host}{interface}{$bcn_interface}{ip};
my $bcn_subnet_mask = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{subnet_mask}; my $bcn_subnet_mask = $anvil->data->{network}{$local_host}{interface}{$bcn_interface}{subnet_mask};
my $bcn_network = $anvil->Network->get_network({ip => $bcn_ip, subnet_mask => $bcn_subnet_mask}); my $bcn_network = $anvil->Network->get_network({ip => $bcn_ip, subnet_mask => $bcn_subnet_mask});
my $dns = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} ? $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} : $anvil->data->{defaults}{network}{dns}; my $dns = $anvil->data->{network}{$local_host}{interface}{$bcn_interface}{dns} ? $anvil->data->{network}{$local_host}{interface}{$bcn_interface}{dns} : $anvil->data->{defaults}{network}{dns};
my $domain = "localdomain"; my $domain = "localdomain";
my $base_url = "http://".$bcn_ip."/".$anvil->data->{host_os}{os_type}."/".$anvil->data->{host_os}{os_arch}; my $base_url = "http://".$bcn_ip."/".$anvil->data->{host_os}{os_type}."/".$anvil->data->{host_os}{os_arch};
if ($anvil->_host_name =~ /\./) if ($anvil->_host_name =~ /\./)
@ -622,9 +623,9 @@ sub setup_boot_environment
# Add the IPs. # Add the IPs.
$anvil->Network->get_ips({}); $anvil->Network->get_ips({});
my $first_line = 1; my $first_line = 1;
foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $in_iface (sort {$a cmp $b} keys %{$anvil->data->{network}{$local_host}{interface}})
{ {
my $ip = $anvil->data->{network}{'local'}{interface}{$in_iface}{ip}; my $ip = $anvil->data->{network}{$local_host}{interface}{$in_iface}{ip};
if ($ip) if ($ip)
{ {
my $prefix = $first_line ? "baseurl=" : " "; my $prefix = $first_line ? "baseurl=" : " ";