diff --git a/Anvil/Tools/Network.pm b/Anvil/Tools/Network.pm index 04223c60..073d96f7 100755 --- a/Anvil/Tools/Network.pm +++ b/Anvil/Tools/Network.pm @@ -758,7 +758,7 @@ sub load_interfces my $parameter = shift; my $anvil = $self->parent; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->find_matches()" }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Network->load_interfces()" }}); my $clear = defined $parameter->{clear} ? $parameter->{clear} : 1; my $host_uuid = defined $parameter->{host_uuid} ? $parameter->{host_uuid} : $anvil->data->{sys}{host_uuid}; @@ -771,7 +771,7 @@ sub load_interfces if (not $host_uuid) { - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->get_network()", parameter => "ip" }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->load_interfces()", parameter => "host_uuid" }}); return(""); } diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm index fd9fbe11..188aac63 100644 --- a/Anvil/Tools/Striker.pm +++ b/Anvil/Tools/Striker.pm @@ -350,9 +350,6 @@ sub parse_all_status_json delete $anvil->data->{json}{all_status}; } -# print Dumper $data; -# die; - # We'll be adding data to this JSON file over time. So this will be an ever evolving method. foreach my $host_hash (@{$data->{hosts}}) { @@ -393,6 +390,9 @@ sub parse_all_status_json # This lets us easily map interface names to types. $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface_name_to_type}{$interface_name} = $interface_type; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + "json::all_status::hosts::${host_name}::network_interface_name_to_type::${interface_name}" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface_name_to_type}{$interface_name}, + }}); # Record the rest of the data. $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{uuid} = $interface_hash->{uuid}; @@ -412,14 +412,16 @@ sub parse_all_status_json "json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::dns" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{dns}, }}); - if ((exists $interface_hash->{interfaces}) && (ref($interface_hash->{interfaces}) eq "ARRAY")) + if ((exists $interface_hash->{connected_interfaces}) && (ref($interface_hash->{connected_interfaces}) eq "ARRAY")) { - foreach my $connected_interface_name (sort {$a cmp $b} @{$interface_hash->{interfaces}}) + my $connected_interfaces_count = @{$interface_hash->{connected_interfaces}}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { connected_interfaces_count => $connected_interfaces_count }}); + foreach my $connected_interface_name (sort {$a cmp $b} @{$interface_hash->{connected_interfaces}}) { # We'll sort out the types after - $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected}{$connected_interface_name}{type} = ""; + $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected_interfaces}{$connected_interface_name}{type} = ""; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "json::all_status::hosts::${host_name}::network_interface::${interface_type}::${connected_interface_name}::mode" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$connected_interface_name}{mode}, + "json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::connected_interfaces::${connected_interface_name}::type" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected_interfaces}{$connected_interface_name}{type}, }}); } } @@ -632,14 +634,14 @@ sub parse_all_status_json foreach my $interface_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}}) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface_name => $interface_name }}); - foreach my $connected_interface_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected}}) + foreach my $connected_interface_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected_interfaces}}) { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { connected_interface_name => $connected_interface_name }}); if (defined $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface_name_to_type}{$connected_interface_name}) { - $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected}{$connected_interface_name}{type} = $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface_name_to_type}{$connected_interface_name}; + $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected_interfaces}{$connected_interface_name}{type} = $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface_name_to_type}{$connected_interface_name}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { - "json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::connected::${connected_interface_name}::type" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected}{$connected_interface_name}{type}, + "json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::connected_interfaces::${connected_interface_name}::type" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{connected_interfaces}{$connected_interface_name}{type}, }}); } } diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index cdd763af..1074d032 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -811,7 +811,7 @@ sub generate_state_json my $parameter = shift; my $anvil = $self->parent; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->get_bridges()" }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "System->generate_state_json()" }}); $anvil->data->{json}{all_systems}{hosts} = []; $anvil->Database->get_hosts_info({debug => 3}); @@ -834,7 +834,7 @@ sub generate_state_json }}); $anvil->Network->load_interfces({ - debug => 2, + debug => $debug, host_uuid => $host_uuid, host => $short_host_name, }); @@ -941,11 +941,15 @@ sub generate_state_json operational => $operational, mii_polling_interval => $mii_polling_interval, }}); - my $connected = []; - foreach my $iface (sort {$a cmp $b} @{$interfaces}) + my $connected_interfaces = []; + foreach my $connected_interface_name (sort {$a cmp $b} @{$interfaces}) { - push @{$connected}, $iface; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { iface => $iface }}); + push @{$connected_interfaces}, $connected_interface_name; + my $connected_interface_count = @{$connected_interfaces}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + connected_interface_count => $connected_interface_count, + connected_interface_name => $connected_interface_name, + }}); } $iface_hash->{say_mode} = $say_mode; $iface_hash->{mode} = $mode; @@ -959,7 +963,7 @@ sub generate_state_json $iface_hash->{say_operational} = $say_operational; $iface_hash->{operational} = $operational; $iface_hash->{mii_polling_interval} = $mii_polling_interval; - $iface_hash->{interfaces} = $connected; + $iface_hash->{connected_interfaces} = $connected_interfaces; } elsif ($type eq "bridge") { @@ -984,18 +988,22 @@ sub generate_state_json stp_enabled => $stp_enabled, say_stp_enabled => $say_stp_enabled, }}); - - my $connected = []; - foreach my $iface (sort {$a cmp $b} @{$interfaces}) + + my $connected_interfaces = []; + foreach my $connected_interface_name (sort {$a cmp $b} @{$interfaces}) { - push @{$connected}, $iface; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { iface => $iface }}); + push @{$connected_interfaces}, $connected_interface_name; + my $connected_interface_count = @{$connected_interfaces}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + connected_interface_count => $connected_interface_count, + connected_interface_name => $connected_interface_name, + }}); } - - $iface_hash->{bridge_id} = $id; - $iface_hash->{stp_enabled} = $stp_enabled; - $iface_hash->{say_stp_enabled} = $say_stp_enabled; - $iface_hash->{interfaces} = $connected; + + $iface_hash->{bridge_id} = $id; + $iface_hash->{stp_enabled} = $stp_enabled; + $iface_hash->{say_stp_enabled} = $say_stp_enabled; + $iface_hash->{connected_interfaces} = $connected_interfaces; } else { @@ -1131,7 +1139,7 @@ sub generate_state_json my $json_file = $anvil->data->{path}{directories}{status}."/".$anvil->data->{path}{json}{all_status}; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { json_file => $json_file }}); my $error = $anvil->Storage->write_file({ - debug => 2, + debug => $debug, overwrite => 1, backup => 0, file => $json_file, @@ -1142,6 +1150,9 @@ sub generate_state_json }); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { error => $error }}); + # Clear out the records. + delete $anvil->data->{json}{all_systems}; + return(0); }