* Made 'network_interface_bridge_uuid' allow NULL entries allow NULL entries.

* Fixed a sanity check in Database->insert_or_update_network_interfaces.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent 67c4f50bdc
commit d600a635d4
  1. 14
      Anvil/Tools/Database.pm
  2. 11
      tools/anvil-update-states
  3. 2
      tools/anvil.sql

@ -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,

@ -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,

@ -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!#;

Loading…
Cancel
Save