* Finished updating Network->check_network() to check/heal bridges.

* Updated anvil-configure-host to not reboot on network chane (will verify when this commit is function tested).

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 4 years ago
parent 4099461ca1
commit 08a958ec60
  1. 75
      Anvil/Tools/Network.pm
  2. 1
      share/words.xml
  3. 12
      tools/anvil-configure-host

@ -198,6 +198,11 @@ sub bridge_info
if ((not exists $anvil->data->{bridge}{$host}{$bridge}) or (ref($anvil->data->{bridge}{$host}{$bridge}{interfaces}) ne "ARRAY")) if ((not exists $anvil->data->{bridge}{$host}{$bridge}) or (ref($anvil->data->{bridge}{$host}{$bridge}{interfaces}) ne "ARRAY"))
{ {
$anvil->data->{bridge}{$host}{$bridge}{interfaces} = []; $anvil->data->{bridge}{$host}{$bridge}{interfaces} = [];
$anvil->data->{bridge}{$host}{$bridge}{found} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"bridge::${host}::${bridge}::interfaces" => $anvil->data->{bridge}{$host}{$bridge}{interfaces},
"bridge::${host}::${bridge}::found" => $anvil->data->{bridge}{$host}{$bridge}{found},
}});
} }
push @{$anvil->data->{bridge}{$host}{$bridge}{interfaces}}, $interface; push @{$anvil->data->{bridge}{$host}{$bridge}{interfaces}}, $interface;
@ -261,6 +266,10 @@ sub check_network
heal => $heal, heal => $heal,
}}); }});
# Find out the bonds that are up.
my $host = $anvil->Get->short_host_name();
$anvil->Network->bridge_info({debug => $debug});
# Read in the network configuration files to track which interfaces are bound to which bonds. # Read in the network configuration files to track which interfaces are bound to which bonds.
my $repaired = 0; my $repaired = 0;
my $interface = ""; my $interface = "";
@ -323,19 +332,31 @@ sub check_network
# Process # Process
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{raw_network}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{raw_network}{interface}})
{ {
my $type = $anvil->data->{raw_network}{interface}{$interface}{variable}{TYPE}; my $type = $anvil->data->{raw_network}{interface}{$interface}{variable}{TYPE};
my $device = $anvil->data->{raw_network}{interface}{$interface}{variable}{DEVICE}; my $device = $anvil->data->{raw_network}{interface}{$interface}{variable}{DEVICE};
my $name = defined $anvil->data->{raw_network}{interface}{$interface}{variable}{NAME} ? $anvil->data->{raw_network}{interface}{$interface}{variable}{NAME} : $device;
$name =~ s/ /_/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
interface => $interface, interface => $interface,
type => $type, type => $type,
device => $device, device => $device,
name => $name,
}}); }});
# Is this a bridge? # Is this a bridge?
if (lc($type) eq "bond") if (lc($type) eq "bridge")
{ {
# Yup! # Yup!
$anvil->data->{bridge_health}{$device}{up} = 0; $anvil->data->{bridge_health}{$device}{up} = 0;
$anvil->data->{bridge_health}{$device}{name} = $name;
if ((exists $anvil->data->{bridge}{$host}{$device}) && ($anvil->data->{bridge}{$host}{$device}{found}))
{
$anvil->data->{bridge_health}{$device}{up} = 1;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"bridge_health::${device}::up" => $anvil->data->{bridge_health}{$device}{up},
"bridge_health::${device}::name" => $anvil->data->{bridge_health}{$device}{name},
}});
} }
# Is this a bond? # Is this a bond?
@ -345,7 +366,7 @@ sub check_network
$anvil->data->{bond_health}{$device}{configured_links} = 0; $anvil->data->{bond_health}{$device}{configured_links} = 0;
$anvil->data->{bond_health}{$device}{active_links} = 0; $anvil->data->{bond_health}{$device}{active_links} = 0;
$anvil->data->{bond_health}{$device}{up_links} = 0; $anvil->data->{bond_health}{$device}{up_links} = 0;
$anvil->data->{bond_health}{$device}{name} = $interface; $anvil->data->{bond_health}{$device}{name} = $name;
# Find the links configured to be under this bond. # Find the links configured to be under this bond.
foreach my $this_interface (sort {$a cmp $b} keys %{$anvil->data->{raw_network}{interface}}) foreach my $this_interface (sort {$a cmp $b} keys %{$anvil->data->{raw_network}{interface}})
@ -482,16 +503,32 @@ sub check_network
# down. # down.
my $bridge_count = keys %{$anvil->data->{bridge_health}}; my $bridge_count = keys %{$anvil->data->{bridge_health}};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { bridge_count => $bridge_count }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { bridge_count => $bridge_count }});
if ($bridge_count) if (($bridge_count) && (not $heal eq "none"))
{ {
foreach my $bridge (sort {$a cmp $b} keys %{$anvil->data->{bridge_health}}) foreach my $bridge (sort {$a cmp $b} keys %{$anvil->data->{bridge_health}})
{ {
my $up = $anvil->data->{bridge_health}{$bridge}{up}; my $up = $anvil->data->{bridge_health}{$bridge}{up};
my $name = $anvil->data->{bridge_health}{$bridge}{name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
bridge => $bridge, bridge => $bridge,
name => $name,
up => $up, up => $up,
}}); }});
if (not $up)
{
# Try to recover the interface
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0632", variables => { bridge => $bridge }});
my $shell_call = $anvil->data->{path}{exe}{ifup}." ".$name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
'output' => $output,
'return_code' => $return_code,
}});
}
} }
} }
@ -533,6 +570,18 @@ sub check_network
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0628", variables => { bond => $bond }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0628", variables => { bond => $bond }});
} }
# For good measure, try to up the bond as well.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0630", variables => { bond => $bond }});
my $shell_call = $anvil->data->{path}{exe}{ifup}." ".$anvil->data->{bond_health}{$bond}{name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
'output' => $output,
'return_code' => $return_code,
}});
# If we're here, try to bring up down'ed interfaces. # If we're here, try to bring up down'ed interfaces.
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{bond_health}{$bond}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{bond_health}{$bond}{interface}})
{ {
@ -558,18 +607,6 @@ sub check_network
}}); }});
} }
} }
# # For good measure, try to up the bond as well.
# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, key => "log_0630", variables => { bond => $bond }});
#
# my $shell_call = $anvil->data->{path}{exe}{ifup}." ".$anvil->data->{bond_health}{$bond}{name};
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
#
# my ($output, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
# 'output' => $output,
# 'return_code' => $return_code,
# }});
} }
} }

@ -1822,6 +1822,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0629">The bond: [#!variable!bond!#]'s interface: [#!variable!interface!#] is not in this bond. Trying to bring it up now...</key> <key name="log_0629">The bond: [#!variable!bond!#]'s interface: [#!variable!interface!#] is not in this bond. Trying to bring it up now...</key>
<key name="log_0630">The bond: [#!variable!bond!#] will now be brought up (even if it already is up).</key> <key name="log_0630">The bond: [#!variable!bond!#] will now be brought up (even if it already is up).</key>
<key name="log_0631">Network device names have changed, rebooting to ensure they take effect. The job will restart once the network comes back up.</key> <key name="log_0631">Network device names have changed, rebooting to ensure they take effect. The job will restart once the network comes back up.</key>
<key name="log_0632">The bridge: [#!variable!bridge!#] is down, tryin to bring it up now.</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. --> <!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key> <key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>

@ -97,7 +97,7 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, 'print'
### it needs to reconfigure the system every run. ### it needs to reconfigure the system every run.
if ($anvil->data->{sys}{reboot}) if ($anvil->data->{sys}{reboot})
{ {
do_reboot($anvil); #do_reboot($anvil);
} }
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
@ -1223,11 +1223,11 @@ sub reconfigure_network
} }
# If we should reset, do so now. # If we should reset, do so now.
if ($anvil->data->{sys}{reboot}) # if ($anvil->data->{sys}{reboot})
{ # {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "log_0631"}); # $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "log_0631"});
do_reboot($anvil); # do_reboot($anvil);
} # }
# Wait for a DB connection. We'll wait up to 130 seconds, as sometimes it takes a while for the network # Wait for a DB connection. We'll wait up to 130 seconds, as sometimes it takes a while for the network
# to start routing traffic. # to start routing traffic.

Loading…
Cancel
Save