From 4427fe9f0dd31d73aa655754b639f8fe7861c8b3 Mon Sep 17 00:00:00 2001 From: Digimer Date: Mon, 30 Aug 2021 17:59:39 -0400 Subject: [PATCH] * Found the source of the vnet constantly cycling back to 'up' bug. The anvil-update-state tool was marking the vnet device operational state back to 'unknown' and scan-network was marking it back up. Signed-off-by: Digimer --- tools/anvil-update-states | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/tools/anvil-update-states b/tools/anvil-update-states index 8de29695..5c9f8445 100755 --- a/tools/anvil-update-states +++ b/tools/anvil-update-states @@ -65,13 +65,13 @@ sub process_interface_cache # Does the file exist? If so, read it in. if (-e $anvil->data->{path}{data}{network_cache}) { - my $body = $anvil->Storage->read_file({debug => 3, cache => 0, force_read => 1, file => $anvil->data->{path}{data}{network_cache}}); + my $body = $anvil->Storage->read_file({debug => 2, cache => 0, force_read => 1, file => $anvil->data->{path}{data}{network_cache}}); foreach my $line (split/\n/, $body) { - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }}); + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }}); next if $line =~ /^#/; my ($interface, $timestamp, $mac_address, $speed, $link_state, $operational) = (split/,/, $line); - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface, timestamp => $timestamp, speed => $speed, @@ -83,7 +83,7 @@ sub process_interface_cache if ($anvil->data->{sys}{database}{connections}) { my ($network_interface_uuid) = $anvil->Database->insert_or_update_network_interfaces({ - debug => 3, + debug => 2, link_only => 1, timestamp => $timestamp, network_interface_name => $interface, @@ -222,10 +222,21 @@ sub update_network $speed =~ s/\n$//; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface, - speed => $speed, mac_address => $mac_address, + link_state => $link_state, + mtu => $mtu, + duplex => $duplex, + operational => $operational, + speed => $speed, }}); + # If this a vnet device, set 'operational' to 'up'. + if (($interface =~ /^vnet/) && ($operational ne "up")) + { + $operational = "up"; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { operational => $operational }}); + } + # These are variables that will be needed if this is a bond interface. my $ip_address = ""; my $subnet_mask = "";