diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm index bae03f08..9b42fc8a 100644 --- a/Anvil/Tools/Get.pm +++ b/Anvil/Tools/Get.pm @@ -747,7 +747,15 @@ ORDER BY =head2 bridges -This finds a list of bridges on the host. Bridges that are found are stored is ' +This finds a list of bridges on the host. Bridges that are found are stored in; + +* ::network::bridges::bridge::::found = 1 +* ::network::bridges::bridge::::flags = [array of flags] +* ::network::bridges::bridge::::connected_interface:: = 1 +* ::network::bridges::bridge:::: = [array reference or string variable] +* ::network::bridges::interface:::: = [array reference or string variable] + +Where 'host' is C<< Get->short_host_name() >>. This method takes no parameters. diff --git a/Anvil/Tools/Log.pm b/Anvil/Tools/Log.pm index 48efba6b..009400f2 100644 --- a/Anvil/Tools/Log.pm +++ b/Anvil/Tools/Log.pm @@ -859,6 +859,7 @@ sub variables my $list = defined $parameter->{list} ? $parameter->{list} : {}; my $facility = defined $parameter->{facility} ? $parameter->{facility} : $anvil->data->{defaults}{'log'}{facility}; my $prefix = defined $parameter->{prefix} ? $parameter->{prefix} : ""; + my $print = defined $parameter->{'print'} ? $parameter->{'print'} : ""; my $priority = defined $parameter->{priority} ? $parameter->{priority} : ""; my $secure = defined $parameter->{secure} ? $parameter->{secure} : 0; my $server = defined $parameter->{server} ? $parameter->{server} : $anvil->data->{defaults}{'log'}{server}; @@ -991,6 +992,7 @@ sub variables level => $level, line => $line, facility => $facility, + 'print' => $print, priority => $priority, raw => $raw, secure => $secure, diff --git a/Anvil/Tools/Network.pm b/Anvil/Tools/Network.pm index c2eeafbe..db738459 100644 --- a/Anvil/Tools/Network.pm +++ b/Anvil/Tools/Network.pm @@ -15,6 +15,7 @@ my $THIS_FILE = "Network.pm"; ### Methods; # bridge_info # check_internet +# check_network # download # find_matches # find_target_ip @@ -216,14 +217,15 @@ sub bridge_info } -=head2 check_bonds +=head2 check_network -This method checks to see if the links in a bond are up. It can simply report the bonds and their link states, and it can try to bring up links that are down. +This method checks to see if bridges and the links in bonds are up. It can simply report the bridge, bond and link states, or it can try to bring up interfaces that are down. This method returns C<< 0 >> if nothing was done. It returns C<< 1 >> if any repairs were done. Data is stored in the hash; +* bridge_health::::up = [0,1] * bond_health::::up = [0,1] * bond_health::::active_links = * bond_health::::up_links = @@ -246,7 +248,7 @@ Wen set to C<< none >>, no attempts will be made to bring up any interfaces. The B<< Note >>: Interfaces that show no carrier will not be started in any case. =cut -sub check_bonds +sub check_network { my $self = shift; my $parameter = shift; @@ -321,7 +323,6 @@ sub check_bonds # Process foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{raw_network}{interface}}) { - # Is this a bond? my $type = $anvil->data->{raw_network}{interface}{$interface}{variable}{TYPE}; my $device = $anvil->data->{raw_network}{interface}{$interface}{variable}{DEVICE}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { @@ -329,6 +330,15 @@ sub check_bonds type => $type, device => $device, }}); + + # Is this a bridge? + if (lc($type) eq "bond") + { + # Yup! + $anvil->data->{bridge_health}{$device}{up} = 0; + } + + # Is this a bond? if (lc($type) eq "bond") { # Yes! @@ -468,6 +478,23 @@ sub check_bonds } } + # Before we check the bonds, check the bridges. Bonds won't come up if they're in a bridge that is + # down. + my $bridge_count = keys %{$anvil->data->{bridge_health}}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { bridge_count => $bridge_count }}); + if ($bridge_count) + { + foreach my $bridge (sort {$a cmp $b} keys %{$anvil->data->{bridge_health}}) + { + my $up = $anvil->data->{bridge_health}{$bridge}{up}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + bridge => $bridge, + up => $up, + }}); + + } + } + foreach my $bond (sort {$a cmp $b} keys %{$anvil->data->{bond_health}}) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -2855,7 +2882,7 @@ sub read_nmcli } # Reading locally or remote? - my $shell_call = $anvil->data->{path}{exe}{nmcli}." --colors no --fields all --terse connection show"; + my $shell_call = $anvil->data->{path}{exe}{nmcli}." --colors no --terse --fields name,device,state,type,uuid,filename connection show"; my $output = ""; my $is_local = $anvil->Network->is_local({host => $target}); if ($is_local) @@ -2891,34 +2918,47 @@ sub read_nmcli $line =~ s/\\:/!col!/g; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { 'line <<' => $line }}); - # NAME UUID TYPE TIMESTAMP TIMESTAMP-REAL AUTOCONNECT AUTOCONNECT-PRIORITY READONLY DBUS-PATH ACTIVE DEVICE STATE ACTIVE-PATH SLAVE FILENAME - my ($name, $uuid, $type, $timestamp_unix, $timestamp, $autoconnect, $autoconnect_priority, $read_only, $dbus_path, $active, $device, $state, $active_path, $slave, $filename) = (split/:/, $line); - $timestamp =~ s/!col!/:/g; + my ($name, $device, $state, $type, $uuid, $filename) = (split/:/, $line); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - 's1:name' => $name, - 's2:uuid' => $uuid, - 's3:type' => $type, - 's4:timestamp_unix' => $timestamp_unix, - 's5:timestamp' => $timestamp, - 's6:autoconnect' => $autoconnect, - 's7:autoconnect_priority' => $autoconnect_priority, - 's8:read_only' => $read_only, - 's9:dbus_path' => $dbus_path, - 's10:active' => $active, - 's11:device' => $device, - 's12:state' => $state, - 's13:active_path' => $active_path, - 's14:slave' => $slave, - 's15:filename' => $filename, + 's1:name' => $name, + 's2:device' => $device, + 's3:state' => $state, + 's4:type' => $type, + 's5:uuid' => $uuid, + 's6:filename' => $filename, }}); if ($uuid) { # Inactive interfaces have a name but not a device; if (not $device) { - $device = $name; - $device =~ s/ /_/g; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { device => $device }}); + # Read the file, see if we can find it there. + if (-e $filename) + { + my $file_body = $anvil->Storage->read_file({debug => ($debug+1), file => $filename}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { file_body => $file_body }}); + + foreach my $line (split/\n/, $file_body) + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }}); + $line =~ s/#.*$//; + if ($line =~ /DEVICE=(.*)$/) + { + $device = $1; + $device =~ s/^\s+//; + $device =~ s/\s+$//; + $device =~ s/"(.*)"$/$1/; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { device => $device }}); + } + } + } + + if (not $device) + { + # Odd. Well, pull the device off the file name. + $device = ($filename =~ /\/ifcfg-(.*)$/)[0]; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { device => $device }}); + } } # Make it easy to look up a device's UUID by device or name. @@ -2930,45 +2970,21 @@ sub read_nmcli }}); # Translate some values; - my $say_state = not $state ? 0 : 1; - my $say_active = $active eq "no" ? 0 : 1; - my $say_read_only = $read_only eq "no" ? 0 : 1; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - say_state => $say_state, - say_active => $say_active, - say_read_only => $say_read_only, - }}); + my $say_state = not $state ? 0 : 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { say_state => $say_state }}); # Now store the data - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{name} = $name; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{type} = $type; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{timestamp_unix} = $timestamp_unix; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{timestamp} = $timestamp; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{autoconnect} = $autoconnect; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{autoconnect_priority} = $autoconnect_priority; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{read_only} = $say_read_only; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{dbus_path} = $dbus_path; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{active} = $say_active; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{device} = $device; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{'state'} = $say_state; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{active_path} = $active_path; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{slave} = $slave; - $anvil->data->{nmcli}{$host}{uuid}{$uuid}{filename} = $filename; + $anvil->data->{nmcli}{$host}{uuid}{$uuid}{name} = $name; + $anvil->data->{nmcli}{$host}{uuid}{$uuid}{device} = $device; + $anvil->data->{nmcli}{$host}{uuid}{$uuid}{'state'} = $state; + $anvil->data->{nmcli}{$host}{uuid}{$uuid}{type} = $type; + $anvil->data->{nmcli}{$host}{uuid}{$uuid}{filename} = $filename; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - "nmcli::${host}::uuid::${uuid}::name" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{name}, - "nmcli::${host}::uuid::${uuid}::type" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{type}, - "nmcli::${host}::uuid::${uuid}::timestamp_unix" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{timestamp_unix}, - "nmcli::${host}::uuid::${uuid}::timestamp" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{timestamp}, - "nmcli::${host}::uuid::${uuid}::autoconnect" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{autoconnect}, - "nmcli::${host}::uuid::${uuid}::autoconnect_priority" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{autoconnect_priority}, - "nmcli::${host}::uuid::${uuid}::read_only" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{read_only}, - "nmcli::${host}::uuid::${uuid}::dbus_path" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{dbus_path}, - "nmcli::${host}::uuid::${uuid}::active" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{active}, - "nmcli::${host}::uuid::${uuid}::device" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{device}, - "nmcli::${host}::uuid::${uuid}::state" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{'state'}, - "nmcli::${host}::uuid::${uuid}::active_path" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{active_path}, - "nmcli::${host}::uuid::${uuid}::slave" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{slave}, - "nmcli::${host}::uuid::${uuid}::filename" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{filename}, + "nmcli::${host}::uuid::${uuid}::name" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{name}, + "nmcli::${host}::uuid::${uuid}::device" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{device}, + "nmcli::${host}::uuid::${uuid}::state" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{'state'}, + "nmcli::${host}::uuid::${uuid}::type" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{type}, + "nmcli::${host}::uuid::${uuid}::filename" => $anvil->data->{nmcli}{$host}{uuid}{$uuid}{filename}, }}); } } diff --git a/share/words.xml b/share/words.xml index 88773c66..485b9d12 100644 --- a/share/words.xml +++ b/share/words.xml @@ -1821,6 +1821,7 @@ The file: [#!variable!file!#] needs to be updated. The difference is: The bond: [#!variable!bond!#] is up, but at least one interface is down. Will try to recover now. The bond: [#!variable!bond!#]'s interface: [#!variable!interface!#] is not in this bond. Trying to bring it up now... The bond: [#!variable!bond!#] will now be brought up (even if it already is up). + Network device names have changed, rebooting to ensure they take effect. The job will restart once the network comes back up. The host name: [#!variable!target!#] does not resolve to an IP address. diff --git a/tools/anvil-configure-host b/tools/anvil-configure-host index 5e534dc0..7c168415 100755 --- a/tools/anvil-configure-host +++ b/tools/anvil-configure-host @@ -280,10 +280,10 @@ sub reconfigure_network } # Read the local network manager data. - $anvil->Network->read_nmcli({debug => 3}); + $anvil->Network->read_nmcli({debug => 2}); # Get the current list of IPs and MAC addresses. - $anvil->Network->get_ips({debug => 3}); + $anvil->Network->get_ips({debug => 2}); # If we're a striker, check apache's config. if ($type eq "striker") @@ -377,8 +377,13 @@ sub reconfigure_network { # If the user had the option to create a network but didn't, there will be no link1 # mac to set. - my $this_network = $network_type.$network_count; - my $link1_key = $this_network."_link1_mac_to_set"; + my $this_network = $network_type.$network_count; + my $link1_key = $this_network."_link1_mac_to_set"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + this_network => $this_network, + link1_key => $link1_key, + }}); + next if not exists $anvil->data->{variables}{form}{config_step2}{$link1_key}; next if not $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}; my $link2_key = $this_network."_link2_mac_to_set"; @@ -394,7 +399,6 @@ sub reconfigure_network $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ip_key => $ip_key, is_gateway => $is_gateway, - link1_key => $link1_key, link1_mac => $link1_mac, link2_key => $link2_key, link2_mac => $link2_mac, @@ -402,7 +406,6 @@ sub reconfigure_network old_link1_iface => $old_link1_iface, old_link2_iface => $old_link2_iface, subnet_mask_key => $subnet_mask_key, - this_network => $this_network, bridge => $bridge, }}); @@ -441,7 +444,7 @@ sub reconfigure_network # Skip if this doesn't exist or isn't a valid IPv4 address. if (not exists $anvil->data->{variables}{form}{config_step2}{$ip_key}{value}) { - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0176", variables => { ip_key => $ip_key }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0176", variables => { ip_key => $ip_key }}); next; } else @@ -703,11 +706,9 @@ sub reconfigure_network link2_config => $link2_config, }}); - # Make backups of existing files + # Decide if we need to reboot. if (($old_link1_file ne $new_link1_file) && (-e $new_link1_file)) { - $anvil->Storage->backup({debug => 2, file => $new_link1_file}); - $changes = 1; $anvil->data->{sys}{reboot} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -717,8 +718,6 @@ sub reconfigure_network } if (($old_link2_file ne $new_link2_file) && (-e $new_link2_file)) { - $anvil->Storage->backup({debug => 2, file => $new_link2_file}); - $changes = 1; $anvil->data->{sys}{reboot} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -893,6 +892,16 @@ sub reconfigure_network }); } + # Backup the old config files, if needed. + if (-e $old_link1_file) + { + $anvil->Storage->backup({file => $old_link1_file}); + } + if (-e $old_link2_file) + { + $anvil->Storage->backup({file => $old_link2_file}); + } + # If the NICs names have changed, rename them now. if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && @@ -924,7 +933,10 @@ sub reconfigure_network { # Delete the old interface $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0461", variables => { interface => $old_link1_nm_name }}); - my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -947,7 +959,10 @@ sub reconfigure_network { # Down the interface $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $old_link1_nm_name }}); - my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link1_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link1_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -962,7 +977,10 @@ sub reconfigure_network { # Delete the old interface $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0461", variables => { interface => $old_link2_nm_name }}); - my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link2_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link2_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -986,7 +1004,10 @@ sub reconfigure_network { # Down the interface $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $old_link2_nm_name }}); - my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link2_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link2_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -1086,12 +1107,6 @@ sub reconfigure_network $link1_config .= "NM_CONTROLLED=\"yes\"\n"; $link1_config .= "ZONE=\"".uc($say_interface)."\""; - # Backup the existing link1 file, if it exists and is different. - if (($new_link1_file ne $old_link1_file) && (-f $old_link1_file)) - { - $anvil->Storage->backup({debug => 2, file => $old_link1_file}); - } - # Link 1 my $update_link1 = 1; if (-f $new_link1_file) @@ -1132,6 +1147,12 @@ sub reconfigure_network }); } + # Backup the existing link1 file, if it exists and is different. + if (-e $old_link1_file) + { + $anvil->Storage->backup({file => $old_link1_file}); + } + # If the name differs from old, delete the old interface. if ((exists $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && ($anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}) && @@ -1139,7 +1160,10 @@ sub reconfigure_network { # 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->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection delete ".$old_link1_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + $anvil->System->call({debug => 2, shell_call => $shell_call}); rename_interface($anvil, $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface}, $new_link1_iface); @@ -1154,7 +1178,10 @@ sub reconfigure_network { # Down the interface $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0462", variables => { interface => $old_link1_nm_name }}); - $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link1_nm_name}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection down ".$old_link1_nm_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + $anvil->System->call({debug => 2, shell_call => $shell_call}); $changes = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { changes => $changes }}); @@ -1173,7 +1200,10 @@ sub reconfigure_network { # Re-read the config $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, 'print' => 1, key => "log_0463"}); - my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $anvil->data->{path}{exe}{nmcli}." connection reload"}); + + my $shell_call = $anvil->data->{path}{exe}{nmcli}." connection reload"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, @@ -1183,7 +1213,7 @@ sub reconfigure_network sleep 2; # Now check the bonds - my $repaired = $anvil->Network->check_bonds({heal => "all"}); + my $repaired = $anvil->Network->check_network({heal => "all"}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { repaired => $repaired }}); if ($repaired) { @@ -1192,9 +1222,16 @@ sub reconfigure_network } } - # Wait for a DB connection. We'll wait up to 5 minutes, as sometimes it takes a while for the network + # If we should reset, do so now. +# if ($anvil->data->{sys}{reboot}) +# { +# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, 'print' => 1, key => "log_0631"}); +# do_reboot($anvil); +# } + + # 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. - my $wait_until = time + 300; + my $wait_until = time + 130; until ($anvil->data->{sys}{database}{connections}) { $anvil->refresh(); @@ -1318,21 +1355,27 @@ sub rename_interface }}); # Take the old name down. - my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$old_link_name." down"}); + my $shell_call = $anvil->data->{path}{exe}{ip}." link set ".$old_link_name." down"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + my ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, }}); # Rename - ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$old_link_name." name ".$new_link_name}); + $shell_call = $anvil->data->{path}{exe}{ip}." link set ".$old_link_name." name ".$new_link_name; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, }}); # Bring up the new interface - ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $anvil->data->{path}{exe}{ip}." link set ".$new_link_name." up"}); + $shell_call = $anvil->data->{path}{exe}{ip}." link set ".$new_link_name." up"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }}); + ($output, $return_code) = $anvil->System->call({debug => 2, shell_call => $shell_call}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output => $output, return_code => $return_code, diff --git a/tools/anvil-daemon b/tools/anvil-daemon index 40e0e07e..b420a529 100755 --- a/tools/anvil-daemon +++ b/tools/anvil-daemon @@ -390,7 +390,7 @@ sub check_network $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { return_code => $return_code }}); } - $anvil->Network->check_bonds({heal => "all"}); + $anvil->Network->check_network({heal => "all"}); $anvil->data->{sys}{network}{initial_checks} = 1; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { @@ -399,7 +399,7 @@ sub check_network } else { - $anvil->Network->check_bonds({heal => "down_only"}); + $anvil->Network->check_network({heal => "down_only"}); } check_firewall($anvil);