@ -20,10 +20,10 @@ if (($running_directory =~ /^\./) && ($ENV{PWD}))
my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2});
$anvil->Log->secure({set => 0});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Database->connect({debug => 3});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , secure => 0, key => "log_0132"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, exit.
@ -52,7 +52,7 @@ sub update_network
# * 'network::local::interface::<iface_name>::ip' - If an IP address is set
# * 'network::local::interface::<iface_name>::subnet' - If an IP is set
my $directory = "/sys/class/net";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { directory => $directory }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { directory => $directory }});
# We'll need to know what interfaces to remove, if any. This will store the interfaces we've seen and
# any others will be removed.
@ -65,16 +65,15 @@ sub update_network
# Walk through the sysfs files.
local(*DIRECTORY);
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0018", variables => { directory => $directory }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0018", variables => { directory => $directory }});
opendir(DIRECTORY, $directory);
while(my $file = readdir(DIRECTORY))
{
next if $file eq ".";
next if $file eq "..";
next if $file eq "lo";
next if $file =~ /virbr\d/;
my $full_path = "$directory/$file";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { full_path => $full_path }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { full_path => $full_path }});
if (-d $full_path)
{
# Pull out the data I want. Note that some of these don't exist with virtio-net interfaces.
@ -95,7 +94,7 @@ sub update_network
$duplex =~ s/\n$//;
$operational =~ s/\n$//;
$speed =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
interface => $interface,
speed => $speed,
mac_address => $mac_address,
@ -123,7 +122,7 @@ sub update_network
$ip_address = defined $anvil->data->{network}{'local'}{interface}{$interface}{ip} ? $anvil->data->{network}{'local'}{interface}{$interface}{ip} : "";
$subnet_mask = defined $anvil->data->{network}{'local'}{interface}{$interface}{subnet} ? $anvil->data->{network}{'local'}{interface}{$interface}{subnet} : "";
$type = defined $anvil->data->{network}{'local'}{interface}{$interface}{type} ? $anvil->data->{network}{'local'}{interface}{$interface}{type} : "interface";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
ip_address => $ip_address,
subnet_mask => $subnet_mask,
type => $type,
@ -138,7 +137,7 @@ sub update_network
# It's a slave.
$mac_address = $anvil->Storage->read_file({file => $mac_bond_file});
$mac_address =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { mac_address => $mac_address }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { mac_address => $mac_address }});
}
# If this is a virtual interface, set some fake values that don't actually exist on
@ -149,7 +148,7 @@ sub update_network
# Speed is "as fast as possible", so we'll record 100 Gbps, but that is really kind of arbitrary.
$speed = 100000 if ((not $speed) or ($speed eq "-1"));
$duplex = "full" if not $duplex;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
speed => $speed,
duplex => $duplex,
}});
@ -158,7 +157,7 @@ sub update_network
if (not $link_state)
{
$speed = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { speed => $speed }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { speed => $speed }});
}
# Is this a bond interface?
@ -185,7 +184,7 @@ sub update_network
$mii_polling_interval =~ s/\n$//;
$up_delay =~ s/\n$//;
$down_delay =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
active_slave => $active_slave,
bond_mode => $bond_mode,
mii_polling_interval => $mii_polling_interval,
@ -199,7 +198,7 @@ sub update_network
# No, but it's slaved to one.
my $target = readlink($full_path."/master");
$bond_master = ($target =~ /^.*\/(.*)$/)[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
target => $target,
bond_master => $bond_master,
}});
@ -212,7 +211,7 @@ sub update_network
$bridge_stp_enabled = $anvil->Storage->read_file({debug => 3, file => $full_path."/bridge/stp_state"});
$bridge_id =~ s/\n$//;
$bridge_stp_enabled =~ s/\n$//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
bridge_id => $bridge_id,
bridge_stp_enabled => $bridge_stp_enabled,
type => $type,
@ -229,10 +228,10 @@ sub update_network
{
$bridge_stp_enabled = "enabled_userland";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { bridge_stp_enabled => $bridge_stp_enabled }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { bridge_stp_enabled => $bridge_stp_enabled }});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
active_slave => $active_slave,
bond_master => $bond_master,
bond_mode => $bond_mode,
@ -267,31 +266,31 @@ sub update_network
# NOTE: This is probably 0 now... Though someday >100 Gbps will be reasonable
# and we'll need to change this.
$speed = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { speed => $speed }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { speed => $speed }});
}
# Find the media, if possible.
my ($ethtool, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{ethtool}." $interface"});
foreach my $line (split/\n/, $ethtool)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { line => $line }});
if ($line =~ /Supported ports: \[ (.*?) \]/i)
{
$media = lc($1);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { media => $media }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { media => $media }});
last;
}
}
# Record this interface
$anvil->data->{seen}{$type}{$interface} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "seen::${type}::${interface}" => $anvil->data->{seen}{$type}{$interface} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "seen::${type}::${interface}" => $anvil->data->{seen}{$type}{$interface} }});
# Record the IP, if set.
if ($ip_address)
{
$anvil->data->{seen}{ip}{$ip_address} = $interface;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "seen::ip::${ip_address}" => $anvil->data->{seen}{ip}{$ip_address} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "seen::ip::${ip_address}" => $anvil->data->{seen}{ip}{$ip_address} }});
}
# Store new information we found.
@ -315,7 +314,7 @@ sub update_network
$anvil->data->{network}{'local'}{interface}{$interface}{subnet} = $subnet_mask;
$anvil->data->{network}{'local'}{interface}{$interface}{type} = $type;
$anvil->data->{network}{'local'}{interface}{$interface}{up_delay} = $up_delay;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"network::local::interface::${interface}::active_slave" => $anvil->data->{network}{'local'}{interface}{$interface}{active_slave},
"network::local::interface::${interface}::bond_mode" => $anvil->data->{network}{'local'}{interface}{$interface}{bond_mode},
"network::local::interface::${interface}::bond_master" => $anvil->data->{network}{'local'}{interface}{$interface}{bond_master},
@ -345,13 +344,13 @@ sub update_network
# We need to record bonds first so that their UUIDs are available when recording interfaces.
foreach my $processing ("bond", "interface", "bridge")
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { processing => $processing }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { processing => $processing }});
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}})
{
# Skip if this isn't the device type we're working on.
next if not defined $anvil->data->{network}{'local'}{interface}{$interface}{type};
my $type = $anvil->data->{network}{'local'}{interface}{$interface}{type};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
's1:interface' => $interface,
's2:type' => $type,
's3:processing' => $processing,
@ -380,7 +379,7 @@ sub update_network
my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway};
my $dns = $anvil->data->{network}{'local'}{interface}{$interface}{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
active_slave => $active_slave,
bond_mode => $bond_mode,
bond_master => $bond_master,
@ -423,10 +422,10 @@ sub update_network
bond_up_delay => $up_delay,
bond_down_delay => $down_delay,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { bond_uuid => $bond_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { bond_uuid => $bond_uuid }});
$anvil->data->{bond_by_name}{$interface} = $bond_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "bond_by_name::${interface}" => $anvil->data->{bond_by_name}{$interface} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "bond_by_name::${interface}" => $anvil->data->{bond_by_name}{$interface} }});
if (($bond_uuid) && ($ip_address))
{
@ -448,11 +447,11 @@ sub update_network
if (($type eq $processing) && ($type eq "interface"))
{
my $say_bond_uuid = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { bond_master => $bond_master }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { bond_master => $bond_master }});
if (($bond_master) && ($anvil->data->{bond_by_name}{$bond_master}))
{
$say_bond_uuid = $anvil->data->{bond_by_name}{$bond_master};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"bond_by_name::${bond_master}" => $anvil->data->{bond_by_name}{$bond_master},
say_bond_uuid => $say_bond_uuid,
}});
@ -471,10 +470,10 @@ sub update_network
network_interface_mtu => $mtu,
network_interface_speed => $speed,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { network_interface_uuid => $network_interface_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { network_interface_uuid => $network_interface_uuid }});
$anvil->data->{interface_by_name}{$interface} = $network_interface_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "interface_by_name::${interface}" => $anvil->data->{interface_by_name}{$interface} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "interface_by_name::${interface}" => $anvil->data->{interface_by_name}{$interface} }});
if (($network_interface_uuid) && ($ip_address))
{
my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({
@ -504,10 +503,10 @@ sub update_network
bridge_mtu => $mtu,
bridge_stp_enabled => $bridge_stp_enabled,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { bridge_uuid => $bridge_uuid }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { bridge_uuid => $bridge_uuid }});
$anvil->data->{bridge_by_name}{$interface} = $bridge_uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { "bridge_by_name::${interface}" => $anvil->data->{bridge_by_name}{$interface} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { "bridge_by_name::${interface}" => $anvil->data->{bridge_by_name}{$interface} }});
if (($bridge_uuid) && ($ip_address))
{
my $ip_address_uuid = $anvil->Database->insert_or_update_ip_addresses({
@ -550,10 +549,10 @@ WHERE
AND
bond_mode != 'DELETED'
;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0124", variables => { query => $query }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0124", variables => { query => $query }});
my $results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
results => $results,
count => $count,
}});
@ -574,7 +573,7 @@ AND
bond_mac_address => $row->[10],
bond_operational => $row->[11],
};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"bonds::${bond_uuid}::bond_name" => $anvil->data->{bonds}{$bond_uuid}{bond_name},
"bonds::${bond_uuid}::bond_mode" => $anvil->data->{bonds}{$bond_uuid}{bond_mode},
"bonds::${bond_uuid}::bond_mtu" => $anvil->data->{bonds}{$bond_uuid}{bond_mtu},
@ -615,10 +614,10 @@ WHERE
AND
bridge_id != 'DELETED'
;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0124", variables => { query => $query }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0124", variables => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
results => $results,
count => $count,
}});
@ -637,7 +636,7 @@ AND
bridge_mtu => $bridge_mtu,
bridge_stp_enabled => $bridge_stp_enabled,
};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"bridges::${bridge_uuid}::bridge_name" => $anvil->data->{bridges}{$bridge_uuid}{bridge_name},
"bridges::${bridge_uuid}::bridge_id" => $anvil->data->{bridges}{$bridge_uuid}{bridge_id},
"bridges::${bridge_uuid}::bridge_mac" => $anvil->data->{bridges}{$bridge_uuid}{bridge_mac},
@ -650,13 +649,14 @@ AND
{
# Mark it as deleted.
my $query = "UPDATE bridges SET bridge_id = 'DELETED' WHERE bridge_uuid = ".$anvil->Database->quote($bridge_uuid).";";
$anvil->Database->write({debug => 2 , query => $query, source => $THIS_FILE, line => __LINE__});
$anvil->Database->write({debug => 3 , query => $query, source => $THIS_FILE, line => __LINE__});
# Remove it from the hash so we don't add it to the .json and .xml files.
delete $anvil->data->{bridges}{$bridge_uuid};
}
}
# Process interfaces
$query = "
SELECT
network_interface_uuid,
@ -673,19 +673,19 @@ SELECT
FROM
network_interfaces
WHERE
network_interface_host_uuid = ".$anvil->Database->quote($anvil->data->{sys}{host_uuid})."
AND
network_interface_operational != 'DELETED'
network_interface_host_uuid = ".$anvil->Database->quote($anvil->data->{sys}{host_uuid})."
ORDER BY
modified_date DESC
;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0124", variables => { query => $query }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0124", variables => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
query => $query,
results => $results,
count => $count,
}});
# The order will track the order the interfaces were last modified, which is a way to determine when
# they came up.
my $network_xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
@ -708,7 +708,7 @@ ORDER BY
network_interface_bond_uuid => defined $row->[9] ? $row->[9] : 'NULL',
network_interface_bridge_uuid => defined $row->[10] ? $row->[10] : 'NULL',
};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
"network_interfaces::${network_interface_uuid}::network_interface_mac_address" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_mac_address},
"network_interfaces::${network_interface_uuid}::network_interface_name" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_name},
"network_interfaces::${network_interface_uuid}::network_interface_speed" => $anvil->data->{network_interfaces}{$network_interface_uuid}{network_interface_speed},
@ -723,14 +723,14 @@ ORDER BY
}});
# Make sure I've seen this interface in this scan and, if not, update this entry to remove it.
if ((not exists $anvil->data->{seen}{interface}{$network_interface_name}) or (not $anvil->data->{seen}{interface}{$network_interface_name}) )
if (not exists $anvil->data->{network}{'local'}{interface}{$network_interface_name} )
{
# Mark it as deleted.
my $query = "UPDATE network_interfaces SET network_interface_operational = 'DELETED' WHERE network_interface_uuid = ".$anvil->Database->quote($network_interface_uuid).";";
$anvil->Database->write({query => $query, source => $THIS_FILE, line => __LINE__});
$anvil->Database->write({debug => 3, query => $query, source => $THIS_FILE, line => __LINE__});
# Remove it from the hash so we don't add it to the .json and .xml files.
delete $anvil->data->{interfaces }{$network_interface_uuid};
delete $anvil->data->{interface}{$network_interface_uuid};
# Loop so we don't try to process any further.
next;
@ -775,10 +775,10 @@ FROM
WHERE
ip_address_host_uuid = ".$anvil->Database->quote($anvil->data->{sys}{host_uuid})."
;";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2 , key => "log_0124", variables => { query => $query }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3 , key => "log_0124", variables => { query => $query }});
$results = $anvil->Database->query({query => $query, source => $THIS_FILE, line => __LINE__});
$count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
results => $results,
count => $count,
}});
@ -793,7 +793,7 @@ WHERE
my $ip_address_default_gateway = $row->[6];
my $ip_address_dns = $row->[7];
my $ip_address_note = $row->[8];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
ip_address_on_type => $ip_address_on_type,
ip_address_on_uuid => $ip_address_on_uuid,
ip_address_address => $ip_address_address,
@ -820,17 +820,17 @@ WHERE
if ($ip_address_on_type eq "interface")
{
$say_on = $anvil->data->{network_interfaces}{$ip_address_on_uuid}{network_interface_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { say_on => $say_on }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { say_on => $say_on }});
}
elsif ($ip_address_on_type eq "bond")
{
$say_on = $anvil->data->{bonds}{$ip_address_on_uuid}{bond_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { say_on => $say_on }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { say_on => $say_on }});
}
elsif ($ip_address_on_type eq "bridge")
{
$say_on = $anvil->data->{bridges}{$ip_address_on_uuid}{bridge_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { say_on => $say_on }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { say_on => $say_on }});
}
$network_json .= " { \"address\":\"$ip_address_address\", \"on\":\"$say_on\", \"subnet\":\"$ip_address_subnet_mask\", \"gateway\":\"$ip_address_gateway\", \"default_gateway\":\"$ip_address_default_gateway\", \"dns\":\"$ip_address_dns\" },\n";
@ -838,11 +838,11 @@ WHERE
}
# Now record the interfaces on bridges.
$anvil->Network->bridge_info({debug => 2 });
$anvil->Network->bridge_info({debug => 3 });
foreach my $bridge_name (sort {$a cmp $b} keys %{$anvil->data->{bridge}{'local'}})
{
my $bridge_uuid = $anvil->data->{bridge_by_name}{$bridge_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
bridge_name => $bridge_name,
bridge_uuid => $bridge_uuid,
}});
@ -850,19 +850,19 @@ WHERE
foreach my $interface_name (sort {$a cmp $b} @{$anvil->data->{bridge}{'local'}{$bridge_name}{interfaces}})
{
my $interface_uuid = exists $anvil->data->{bond_by_name}{$interface_name} ? $anvil->data->{bond_by_name}{$interface_name} : $anvil->data->{interface_by_name}{$interface_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
interface_name => $interface_name,
interface_uuid => $interface_uuid,
}});
my $bridge_interfaces_uuid = $anvil->Database->insert_or_update_bridge_interfaces({
debug => 2 ,
debug => 3 ,
file => $THIS_FILE,
line => __LINE__,
bridge_interface_bridge_uuid => $bridge_uuid,
bridge_interface_network_interface_uuid => $interface_uuid,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => {
bridge_interfaces_uuid => $bridge_interfaces_uuid,
}});
}
@ -870,34 +870,40 @@ WHERE
$network_json =~ s/,$//s;
$network_json .= "]}\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2 , list => { network_json => $network_json }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3 , list => { network_json => $network_json }});
$network_xml .= "</network>\n";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network_xml => $network_xml }});
# Write the JSON file.
my $output_json = $anvil->data->{path}{directories}{html}."/status/network.json";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output_xml => $output_json }});
$anvil->Storage->write_file({
file => $output_json,
body => $network_json,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { network_xml => $network_xml }});
# Write the XML file.
my $output_xml = $anvil->data->{path}{directories}{html}."/status/network.xml";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { output_xml => $output_xml }});
$anvil->Storage->write_file({
file => $output_xml,
body => $network_xml,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
# Write the JSON file, if we're a dashboard. Nodes and DR hosts don't have a WebUI, so they're not
# needed.
if ($anvil->System->get_host_type eq "dashboard")
{
my $output_json = $anvil->data->{path}{directories}{html}."/status/network.json";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output_xml => $output_json }});
$anvil->Storage->write_file({
backup => 0,
file => $output_json,
body => $network_json,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
# Write the XML file.
my $output_xml = $anvil->data->{path}{directories}{html}."/status/network.xml";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { output_xml => $output_xml }});
$anvil->Storage->write_file({
backup => 0,
file => $output_xml,
body => $network_xml,
overwrite => 1,
mode => "0644",
user => "apache",
group => "apache"
});
}
return(0);
}