diff --git a/Anvil/Tools/Convert.pm b/Anvil/Tools/Convert.pm index d4ee6740..071383f5 100644 --- a/Anvil/Tools/Convert.pm +++ b/Anvil/Tools/Convert.pm @@ -125,7 +125,7 @@ sub add_commas return ($number); } - local($_) = $whole ? $whole : ""; + local($_) = defined $whole ? $whole : ""; 1 while s/^(-?\d+)(\d{3})/$1,$2/; $whole = $_; @@ -249,53 +249,53 @@ sub bytes_to_human_readable { # Yebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 80))); - $suffix = "YiB"; + $suffix = $anvil->Words->string({key => "suffix_0030"}); } elsif ($unit =~ /Z/i) { # Zebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 70))); - $suffix = "ZiB"; + $suffix = $anvil->Words->string({key => "suffix_0029"}); } elsif ($unit =~ /E/i) { # Exbibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 60))); - $suffix = "EiB"; + $suffix = $anvil->Words->string({key => "suffix_0028"}); } elsif ($unit =~ /P/i) { # Pebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 50))); - $suffix = "PiB"; + $suffix = $anvil->Words->string({key => "suffix_0027"}); } elsif ($unit =~ /T/i) { # Tebibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 40))); - $suffix = "TiB"; + $suffix = $anvil->Words->string({key => "suffix_0026"}); } elsif ($unit =~ /G/i) { # Gibibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 30))); - $suffix = "GiB"; + $suffix = $anvil->Words->string({key => "suffix_0025"}); } elsif ($unit =~ /M/i) { # Mebibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 20))); - $suffix = "MiB"; + $suffix = $anvil->Words->string({key => "suffix_0024"}); } elsif ($unit =~ /K/i) { # Kibibyte $human_readable_size = sprintf("%.1f", ($human_readable_size /= (2 ** 10))); - $suffix = "KiB"; + $suffix = $anvil->Words->string({key => "suffix_0023"}); } else { - $suffix = "B"; + $suffix = $anvil->Words->string({key => "suffix_0014"}); } } else @@ -305,53 +305,53 @@ sub bytes_to_human_readable { # Yebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 80))); - $suffix = "YiB"; + $suffix = $anvil->Words->string({key => "suffix_0030"}); } elsif ($human_readable_size >= (2 ** 70)) { # Zebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 70))); - $suffix = "ZiB"; + $suffix = $anvil->Words->string({key => "suffix_0029"}); } elsif ($human_readable_size >= (2 ** 60)) { # Exbibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 60))); - $suffix = "EiB"; + $suffix = $anvil->Words->string({key => "suffix_0028"}); } elsif ($human_readable_size >= (2 ** 50)) { # Pebibyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (2 ** 50))); - $suffix = "PiB"; + $suffix = $anvil->Words->string({key => "suffix_0027"}); } elsif ($human_readable_size >= (2 ** 40)) { # Tebibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 40))); - $suffix = "TiB"; + $suffix = $anvil->Words->string({key => "suffix_0026"}); } elsif ($human_readable_size >= (2 ** 30)) { # Gibibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 30))); - $suffix = "GiB"; + $suffix = $anvil->Words->string({key => "suffix_0025"}); } elsif ($human_readable_size >= (2 ** 20)) { # Mebibyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (2 ** 20))); - $suffix = "MiB"; + $suffix = $anvil->Words->string({key => "suffix_0024"}); } elsif ($human_readable_size >= (2 ** 10)) { # Kibibyte $human_readable_size = sprintf("%.1f", ($human_readable_size /= (2 ** 10))); - $suffix = "KiB"; + $suffix = $anvil->Words->string({key => "suffix_0023"}); } else { - $suffix = "B"; + $suffix = $anvil->Words->string({key => "suffix_0014"}); } } } @@ -365,53 +365,53 @@ sub bytes_to_human_readable { # Yottabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 24))); - $suffix = "YB"; + $suffix = $anvil->Words->string({key => "suffix_0022"}); } elsif ($unit =~ /Z/i) { # Zettabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 21))); - $suffix = "ZB"; + $suffix = $anvil->Words->string({key => "suffix_0021"}); } elsif ($unit =~ /E/i) { # Exabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 18))); - $suffix = "EB"; + $suffix = $anvil->Words->string({key => "suffix_0020"}); } elsif ($unit =~ /P/i) { # Petabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 15))); - $suffix = "PB"; + $suffix = $anvil->Words->string({key => "suffix_0019"}); } elsif ($unit =~ /T/i) { # Terabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 12))); - $suffix = "TB"; + $suffix = $anvil->Words->string({key => "suffix_0018"}); } elsif ($unit =~ /G/i) { # Gigabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 9))); - $suffix = "GB"; + $suffix = $anvil->Words->string({key => "suffix_0017"}); } elsif ($unit =~ /M/i) { # Megabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 6))); - $suffix = "MB"; + $suffix = $anvil->Words->string({key => "suffix_0016"}); } elsif ($unit =~ /K/i) { # Kilobyte $human_readable_size = sprintf("%.1f", ($human_readable_size /= (10 ** 3))); - $suffix = "KB"; + $suffix = $anvil->Words->string({key => "suffix_0015"}); } else { - $suffix = "b"; + $suffix = $anvil->Words->string({key => "suffix_0014"}); } } else @@ -421,53 +421,54 @@ sub bytes_to_human_readable { # Yottabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 24))); - $suffix = "YB"; + $suffix = $anvil->Words->string({key => "suffix_0022"}); } elsif ($human_readable_size >= (10 ** 21)) { # Zettabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 21))); - $suffix = "ZB"; + $suffix = $anvil->Words->string({key => "suffix_0021"}); } elsif ($human_readable_size >= (10 ** 18)) { # Exabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 18))); - $suffix = "EB"; + $suffix = $anvil->Words->string({key => "suffix_0020"}); } elsif ($human_readable_size >= (10 ** 15)) { # Petabyte $human_readable_size = sprintf("%.3f", ($human_readable_size /= (10 ** 15))); - $suffix = "PB"; + $suffix = $anvil->Words->string({key => "suffix_0019"}); } elsif ($human_readable_size >= (10 ** 12)) { # Terabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 12))); - $suffix = "TB"; + $suffix = $anvil->Words->string({key => "suffix_0018"}); } elsif ($human_readable_size >= (10 ** 9)) { # Gigabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 9))); - $suffix = "GB"; + $suffix = $anvil->Words->string({key => "suffix_0017"}); } elsif ($human_readable_size >= (10 ** 6)) { # Megabyte $human_readable_size = sprintf("%.2f", ($human_readable_size /= (10 ** 6))); - $suffix = "MB"; + $suffix = $anvil->Words->string({key => "suffix_0016"}); } elsif ($human_readable_size >= (10 ** 3)) { # Kilobyte $human_readable_size = sprintf("%.1f", ($human_readable_size /= (10 ** 3))); - $suffix = "KB"; + $suffix = $anvil->Words->string({key => "suffix_0015"}); } else { - $suffix = "b"; + # Bytes + $suffix = $anvil->Words->string({key => "suffix_0014"}); } } } diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm index da355343..548d7251 100644 --- a/Anvil/Tools/Database.pm +++ b/Anvil/Tools/Database.pm @@ -4437,7 +4437,16 @@ sub insert_or_update_network_interfaces { # See if I know this NIC by referencing it's MAC and name. The name is needed because virtual # devices can share the MAC with the real interface. - my $query = "SELECT network_interface_uuid FROM network_interfaces WHERE network_interface_mac_address = ".$anvil->Database->quote($network_interface_mac_address)." AND network_interface_name = ".$anvil->Database->quote($network_interface_name).";"; + my $query = " +SELECT + network_interface_uuid +FROM + network_interfaces +WHERE + network_interface_mac_address = ".$anvil->Database->quote($network_interface_mac_address)." +AND + network_interface_name = ".$anvil->Database->quote($network_interface_name)." +;"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }}); $network_interface_uuid = $anvil->Database->query({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__})->[0]->[0]; diff --git a/Anvil/Tools/Network.pm b/Anvil/Tools/Network.pm index 0fb7c4cd..e8c215f7 100755 --- a/Anvil/Tools/Network.pm +++ b/Anvil/Tools/Network.pm @@ -805,10 +805,10 @@ FROM AND bond_host_uuid = ".$anvil->Database->quote($host_uuid)." ;"; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, 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 => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, count => $count, }}); @@ -893,10 +893,10 @@ WHERE AND bridge_host_uuid = ".$anvil->Database->quote($host_uuid)." ;"; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, 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 => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, count => $count, }}); @@ -966,10 +966,10 @@ AND ORDER BY modified_date DESC ;"; - $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0124", variables => { query => $query }}); + $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, 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 => 3, list => { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { results => $results, count => $count, }}); @@ -991,11 +991,19 @@ ORDER BY if (($network_interface_bond_uuid) && (defined $anvil->data->{network}{$host}{bond_uuid}{$network_interface_bond_uuid}{name})) { $bond_name = $anvil->data->{network}{$host}{bond_uuid}{$network_interface_bond_uuid}{name}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + network_interface_name => $network_interface_name, + bond_name => $bond_name, + }}); push @{$anvil->data->{network}{$host}{interface}{$bond_name}{interfaces}}, $network_interface_name; } if (($network_interface_bridge_uuid) && (defined $anvil->data->{network}{$host}{bridge_uuid}{$network_interface_bridge_uuid}{name})) { $bridge_name = $anvil->data->{network}{$host}{bridge_uuid}{$network_interface_bridge_uuid}{name}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { + network_interface_name => $network_interface_name, + bridge_name => $bridge_name, + }}); push @{$anvil->data->{network}{$host}{interface}{$bridge_name}{interfaces}}, $network_interface_name; } $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { diff --git a/share/words.xml b/share/words.xml index b3cbbd30..df319f44 100644 --- a/share/words.xml +++ b/share/words.xml @@ -1029,6 +1029,15 @@ If you are comfortable that the target has changed for a known reason, you can s Exbibytes Zebibytes Yobibytes + bps + Kbps + Mbps + Gbps + Tbps + Pbps + Ebps + Zbps + Ybps [ Error ] - [ Warning ] - @@ -1250,6 +1259,14 @@ Failed to generate an RSA public key for the user: [#!variable!user!#]. The outp No None Unknown + ]]> + Balance Round-Robin + Active/Backup + Balanced Exclusive OR + Broadcast + Dynamic Link Aggregation (802.3ad) + Balanced Transmit Load balancing + Balanced Adaptive Load balancing diff --git a/tools/anvil-update-states b/tools/anvil-update-states index 2ec8475f..ea0512ab 100755 --- a/tools/anvil-update-states +++ b/tools/anvil-update-states @@ -87,6 +87,12 @@ sub update_network my $media = "unknown"; my $type = "interface"; + # If the NIC is a bond member, the MAC address could be virtual. + if (-e $full_path."/bonding_slave/perm_hwaddr") + { + $mac_address = $anvil->Storage->read_file({file => $full_path."/bonding_slave/perm_hwaddr"}); + } + # Clean up some newlines. $mac_address =~ s/\n$//; $link_state =~ s/\n$//;