diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index 1d7a4bf5..aae61758 100755 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -2859,7 +2859,7 @@ sub insert_or_update_network_interfaces my $file = defined $parameter->{file} ? $parameter->{file} : ""; my $line = defined $parameter->{line} ? $parameter->{line} : ""; my $network_interface_bond_uuid = defined $parameter->{network_interface_bond_uuid} ? $parameter->{network_interface_bond_uuid} : 'NULL'; - my $network_interface_bridge_uuid = defined $parameter->{network_interface_bridge_uuid} ? $parameter->{network_interface_bridge_uuid} : ""; + my $network_interface_bridge_uuid = defined $parameter->{network_interface_bridge_uuid} ? $parameter->{network_interface_bridge_uuid} : 'NULL'; my $network_interface_duplex = defined $parameter->{network_interface_duplex} ? $parameter->{network_interface_duplex} : "unknown"; my $network_interface_host_uuid = defined $parameter->{network_interface_host_uuid} ? $parameter->{network_interface_host_uuid} : $anvil->Get->host_uuid; my $network_interface_link_state = defined $parameter->{network_interface_link_state} ? $parameter->{network_interface_link_state} : "unknown"; @@ -2904,10 +2904,16 @@ sub insert_or_update_network_interfaces $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_name" }}); return(""); } + if (($network_interface_bond_uuid ne 'NULL') && (not $anvil->Validate->is_uuid({uuid => $network_interface_bond_uuid}))) + { + # Bad UUID. + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_bond_uuid", uuid => $network_interface_bond_uuid }}); + return(""); + } if (($network_interface_bridge_uuid ne 'NULL') && (not $anvil->Validate->is_uuid({uuid => $network_interface_bridge_uuid}))) { # Bad UUID. - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_name", uuid => $network_interface_bridge_uuid }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0130", variables => { method => "Database->insert_or_update_network_interfaces()", parameter => "network_interface_bridge_uuid", uuid => $network_interface_bridge_uuid }}); return(""); } @@ -2964,8 +2970,8 @@ WHERE my $old_network_interface_operational = $row->[6]; my $old_network_interface_duplex = $row->[7]; my $old_network_interface_medium = $row->[8]; - my $old_network_interface_bond_uuid = defined $row->[9] ? $row->[9] : 'NULL'; - my $old_network_interface_bridge_uuid = $row->[10]; + my $old_network_interface_bond_uuid = defined $row->[9] ? $row->[9] : 'NULL'; + my $old_network_interface_bridge_uuid = defined $row->[10] ? $row->[10] : 'NULL'; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { old_network_interface_host_uuid => $old_network_interface_host_uuid, old_network_interface_mac_address => $old_network_interface_mac_address, diff --git a/tools/anvil-update-states b/tools/anvil-update-states index e8566b30..6fb2ee58 100755 --- a/tools/anvil-update-states +++ b/tools/anvil-update-states @@ -318,6 +318,8 @@ sub report_network { my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({ debug => 2, + file => $THIS_FILE, + line => __LINE__, ip_address_on_type => $type, ip_address_on_uuid => $network_interface_uuid, ip_address_address => $ip_address, @@ -331,6 +333,7 @@ sub report_network elsif ($type eq "bond") { my $bond_uuid = $anvil->Database->insert_or_update_bonds({ + debug => 2, file => $THIS_FILE, line => __LINE__, bond_name => $interface, @@ -352,6 +355,8 @@ sub report_network { my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({ debug => 2, + file => $THIS_FILE, + line => __LINE__, ip_address_on_type => $type, ip_address_on_uuid => $bond_uuid, ip_address_address => $ip_address, @@ -504,8 +509,8 @@ ORDER BY my $network_interface_operational = $row->[6]; my $network_interface_duplex = $row->[7]; my $network_interface_medium = $row->[8]; - my $network_interface_bond_uuid = defined $row->[9] ? $row->[9] : 'NULL'; - my $network_interface_bridge_uuid = $row->[10]; + my $network_interface_bond_uuid = defined $row->[9] ? $row->[9] : 'NULL'; + my $network_interface_bridge_uuid = defined $row->[10] ? $row->[10] : 'NULL'; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_interface_mac_address => $network_interface_mac_address, network_interface_name => $network_interface_name, @@ -565,7 +570,7 @@ ORDER BY my $network_interface_duplex = $row->[6]; my $network_interface_medium = $row->[7]; my $network_interface_bond_uuid = defined $row->[8] ? $row->[8] : 'NULL'; - my $network_interface_bridge_uuid = $row->[9]; + my $network_interface_bridge_uuid = defined $row->[9] ? $row->[9] : 'NULL'; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_interface_mac_address => $network_interface_mac_address, network_interface_name => $network_interface_name, diff --git a/tools/anvil.sql b/tools/anvil.sql index 20c1f263..98bd53d5 100644 --- a/tools/anvil.sql +++ b/tools/anvil.sql @@ -447,7 +447,7 @@ CREATE TABLE network_interfaces ( network_interface_duplex text not null, -- This is 'full', 'half' or 'unknown' network_interface_medium text not null, -- This is 'tp' (twisted pair), 'fiber' or whatever they invent in the future. network_interface_bond_uuid uuid, -- If this iface is in a bond, this will contain the 'bonds -> bond_uuid' that it is slaved to. - network_interface_bridge_uuid uuid not null, -- If this iface is attached to a bridge, this will contain the 'bridgess -> bridge_uuid' that it is connected to. + network_interface_bridge_uuid uuid, -- If this iface is attached to a bridge, this will contain the 'bridgess -> bridge_uuid' that it is connected to. modified_date timestamp with time zone not null ); ALTER TABLE network_interfaces OWNER TO #!variable!user!#;