* Standardized 'subnet_mask' over 'subnet' naming throughout.

* Created (and haven't finished yet) Striker->parse_all_status_json().

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent b2ff4c4c53
commit d5672e77eb
  1. 14
      Anvil/Tools.pm
  2. 68
      Anvil/Tools.t
  3. 94
      Anvil/Tools/Convert.pm
  4. 2
      Anvil/Tools/Database.pm
  5. 122
      Anvil/Tools/Network.pm
  6. 312
      Anvil/Tools/Striker.pm
  7. 116
      Anvil/Tools/System.pm
  8. 30
      Anvil/Tools/Validate.pm
  9. 252
      cgi-bin/striker
  10. 1
      html/skins/alteeve/anvil.html
  11. 24
      html/skins/alteeve/anvil.js
  12. 12
      html/skins/alteeve/config.html
  13. 28
      html/skins/alteeve/config.js
  14. 17
      html/skins/alteeve/pxe.txt
  15. 1
      share/words.xml
  16. 20
      tools/anvil-configure-host
  17. 40
      tools/anvil-manage-files
  18. 8
      tools/anvil-manage-firewall
  19. 20
      tools/anvil-update-states
  20. 26
      tools/striker-manage-install-target
  21. 61
      tools/striker-scan-network

@ -964,8 +964,8 @@ sub _set_defaults
network => { network => {
# BCN starts at 10.200(+n)/16 # BCN starts at 10.200(+n)/16
bcn => { bcn => {
subnet => "10.200.0.0", network => "10.200.0.0",
netmask => "255.255.0.0", subnet_mask => "255.255.0.0",
switch_octet3 => "1", switch_octet3 => "1",
pdu_octet3 => "2", pdu_octet3 => "2",
ups_octet3 => "3", ups_octet3 => "3",
@ -976,14 +976,14 @@ sub _set_defaults
# The IFN will not be under our control. So for suggestion to the user purpose only, # The IFN will not be under our control. So for suggestion to the user purpose only,
# IFN starts at 10.255/16 # IFN starts at 10.255/16
ifn => { ifn => {
subnet => "10.255.0.0", network => "10.255.0.0",
netmask => "255.255.0.0", subnet_mask => "255.255.0.0",
striker_octet3 => "4", striker_octet3 => "4",
}, },
# SN starts at 10.100(+n)/16 # SN starts at 10.100(+n)/16
sn => { sn => {
subnet => "10.100.0.0", network => "10.100.0.0",
netmask => "255.255.0.0", subnet_mask => "255.255.0.0",
}, },
test => { test => {
domains => ["alteeve.com", "redhat.com", "google.com"], domains => ["alteeve.com", "redhat.com", "google.com"],

@ -89,40 +89,40 @@ is($anvil->Convert->cidr({cidr => "29"}), "255.255.255.248", "Verifying that Con
is($anvil->Convert->cidr({cidr => "30"}), "255.255.255.252", "Verifying that Convert->cidr properly returned '255.255.255.252' when given a 'cidr' parameter of '30'."); is($anvil->Convert->cidr({cidr => "30"}), "255.255.255.252", "Verifying that Convert->cidr properly returned '255.255.255.252' when given a 'cidr' parameter of '30'.");
is($anvil->Convert->cidr({cidr => "31"}), "255.255.255.254", "Verifying that Convert->cidr properly returned '255.255.255.254' when given a 'cidr' parameter of '31'."); is($anvil->Convert->cidr({cidr => "31"}), "255.255.255.254", "Verifying that Convert->cidr properly returned '255.255.255.254' when given a 'cidr' parameter of '31'.");
is($anvil->Convert->cidr({cidr => "32"}), "255.255.255.255", "Verifying that Convert->cidr properly returned '255.255.255.255' when given a 'cidr' parameter of '32'."); is($anvil->Convert->cidr({cidr => "32"}), "255.255.255.255", "Verifying that Convert->cidr properly returned '255.255.255.255' when given a 'cidr' parameter of '32'.");
is($anvil->Convert->cidr({subnet => "fake"}), "", "Verifying that Convert->cidr properly returned an empty string for a bad 'subnet' parameter."); is($anvil->Convert->cidr({subnet_mask => "fake"}), "", "Verifying that Convert->cidr properly returned an empty string for a bad 'subnet' parameter.");
is($anvil->Convert->cidr({subnet => "0.0.0.0"}), "0", "Verifying that Convert->cidr properly returned '0' when given a 'subnet' parameter of '0.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "0.0.0.0"}), "0", "Verifying that Convert->cidr properly returned '0' when given a 'subnet' parameter of '0.0.0.0'.");
is($anvil->Convert->cidr({subnet => "128.0.0.0"}), "1", "Verifying that Convert->cidr properly returned '1' when given a 'subnet' parameter of '128.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "128.0.0.0"}), "1", "Verifying that Convert->cidr properly returned '1' when given a 'subnet' parameter of '128.0.0.0'.");
is($anvil->Convert->cidr({subnet => "192.0.0.0"}), "2", "Verifying that Convert->cidr properly returned '2' when given a 'subnet' parameter of '192.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "192.0.0.0"}), "2", "Verifying that Convert->cidr properly returned '2' when given a 'subnet' parameter of '192.0.0.0'.");
is($anvil->Convert->cidr({subnet => "224.0.0.0"}), "3", "Verifying that Convert->cidr properly returned '3' when given a 'subnet' parameter of '224.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "224.0.0.0"}), "3", "Verifying that Convert->cidr properly returned '3' when given a 'subnet' parameter of '224.0.0.0'.");
is($anvil->Convert->cidr({subnet => "240.0.0.0"}), "4", "Verifying that Convert->cidr properly returned '4' when given a 'subnet' parameter of '240.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "240.0.0.0"}), "4", "Verifying that Convert->cidr properly returned '4' when given a 'subnet' parameter of '240.0.0.0'.");
is($anvil->Convert->cidr({subnet => "248.0.0.0"}), "5", "Verifying that Convert->cidr properly returned '5' when given a 'subnet' parameter of '248.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "248.0.0.0"}), "5", "Verifying that Convert->cidr properly returned '5' when given a 'subnet' parameter of '248.0.0.0'.");
is($anvil->Convert->cidr({subnet => "252.0.0.0"}), "6", "Verifying that Convert->cidr properly returned '6' when given a 'subnet' parameter of '252.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "252.0.0.0"}), "6", "Verifying that Convert->cidr properly returned '6' when given a 'subnet' parameter of '252.0.0.0'.");
is($anvil->Convert->cidr({subnet => "254.0.0.0"}), "7", "Verifying that Convert->cidr properly returned '7' when given a 'subnet' parameter of '254.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "254.0.0.0"}), "7", "Verifying that Convert->cidr properly returned '7' when given a 'subnet' parameter of '254.0.0.0'.");
is($anvil->Convert->cidr({subnet => "255.0.0.0"}), "8", "Verifying that Convert->cidr properly returned '8' when given a 'subnet' parameter of '255.0.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.0.0.0"}), "8", "Verifying that Convert->cidr properly returned '8' when given a 'subnet' parameter of '255.0.0.0'.");
is($anvil->Convert->cidr({subnet => "255.128.0.0"}), "9", "Verifying that Convert->cidr properly returned '9' when given a 'subnet' parameter of '255.128.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.128.0.0"}), "9", "Verifying that Convert->cidr properly returned '9' when given a 'subnet' parameter of '255.128.0.0'.");
is($anvil->Convert->cidr({subnet => "255.192.0.0"}), "10", "Verifying that Convert->cidr properly returned '10' when given a 'subnet' parameter of '255.192.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.192.0.0"}), "10", "Verifying that Convert->cidr properly returned '10' when given a 'subnet' parameter of '255.192.0.0'.");
is($anvil->Convert->cidr({subnet => "255.224.0.0"}), "11", "Verifying that Convert->cidr properly returned '11' when given a 'subnet' parameter of '255.224.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.224.0.0"}), "11", "Verifying that Convert->cidr properly returned '11' when given a 'subnet' parameter of '255.224.0.0'.");
is($anvil->Convert->cidr({subnet => "255.240.0.0"}), "12", "Verifying that Convert->cidr properly returned '12' when given a 'subnet' parameter of '255.240.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.240.0.0"}), "12", "Verifying that Convert->cidr properly returned '12' when given a 'subnet' parameter of '255.240.0.0'.");
is($anvil->Convert->cidr({subnet => "255.248.0.0"}), "13", "Verifying that Convert->cidr properly returned '13' when given a 'subnet' parameter of '255.248.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.248.0.0"}), "13", "Verifying that Convert->cidr properly returned '13' when given a 'subnet' parameter of '255.248.0.0'.");
is($anvil->Convert->cidr({subnet => "255.252.0.0"}), "14", "Verifying that Convert->cidr properly returned '14' when given a 'subnet' parameter of '255.252.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.252.0.0"}), "14", "Verifying that Convert->cidr properly returned '14' when given a 'subnet' parameter of '255.252.0.0'.");
is($anvil->Convert->cidr({subnet => "255.254.0.0"}), "15", "Verifying that Convert->cidr properly returned '15' when given a 'subnet' parameter of '255.254.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.254.0.0"}), "15", "Verifying that Convert->cidr properly returned '15' when given a 'subnet' parameter of '255.254.0.0'.");
is($anvil->Convert->cidr({subnet => "255.255.0.0"}), "16", "Verifying that Convert->cidr properly returned '16' when given a 'subnet' parameter of '255.255.0.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.0.0"}), "16", "Verifying that Convert->cidr properly returned '16' when given a 'subnet' parameter of '255.255.0.0'.");
is($anvil->Convert->cidr({subnet => "255.255.128.0"}), "17", "Verifying that Convert->cidr properly returned '17' when given a 'subnet' parameter of '255.255.128.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.128.0"}), "17", "Verifying that Convert->cidr properly returned '17' when given a 'subnet' parameter of '255.255.128.0'.");
is($anvil->Convert->cidr({subnet => "255.255.192.0"}), "18", "Verifying that Convert->cidr properly returned '18' when given a 'subnet' parameter of '255.255.192.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.192.0"}), "18", "Verifying that Convert->cidr properly returned '18' when given a 'subnet' parameter of '255.255.192.0'.");
is($anvil->Convert->cidr({subnet => "255.255.224.0"}), "19", "Verifying that Convert->cidr properly returned '19' when given a 'subnet' parameter of '255.255.224.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.224.0"}), "19", "Verifying that Convert->cidr properly returned '19' when given a 'subnet' parameter of '255.255.224.0'.");
is($anvil->Convert->cidr({subnet => "255.255.240.0"}), "20", "Verifying that Convert->cidr properly returned '20' when given a 'subnet' parameter of '255.255.240.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.240.0"}), "20", "Verifying that Convert->cidr properly returned '20' when given a 'subnet' parameter of '255.255.240.0'.");
is($anvil->Convert->cidr({subnet => "255.255.248.0"}), "21", "Verifying that Convert->cidr properly returned '21' when given a 'subnet' parameter of '255.255.248.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.248.0"}), "21", "Verifying that Convert->cidr properly returned '21' when given a 'subnet' parameter of '255.255.248.0'.");
is($anvil->Convert->cidr({subnet => "255.255.252.0"}), "22", "Verifying that Convert->cidr properly returned '22' when given a 'subnet' parameter of '255.255.252.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.252.0"}), "22", "Verifying that Convert->cidr properly returned '22' when given a 'subnet' parameter of '255.255.252.0'.");
is($anvil->Convert->cidr({subnet => "255.255.254.0"}), "23", "Verifying that Convert->cidr properly returned '23' when given a 'subnet' parameter of '255.255.254.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.254.0"}), "23", "Verifying that Convert->cidr properly returned '23' when given a 'subnet' parameter of '255.255.254.0'.");
is($anvil->Convert->cidr({subnet => "255.255.255.0"}), "24", "Verifying that Convert->cidr properly returned '24' when given a 'subnet' parameter of '255.255.255.0'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.0"}), "24", "Verifying that Convert->cidr properly returned '24' when given a 'subnet' parameter of '255.255.255.0'.");
is($anvil->Convert->cidr({subnet => "255.255.255.128"}), "25", "Verifying that Convert->cidr properly returned '25' when given a 'subnet' parameter of '255.255.255.128'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.128"}), "25", "Verifying that Convert->cidr properly returned '25' when given a 'subnet' parameter of '255.255.255.128'.");
is($anvil->Convert->cidr({subnet => "255.255.255.192"}), "26", "Verifying that Convert->cidr properly returned '26' when given a 'subnet' parameter of '255.255.255.192'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.192"}), "26", "Verifying that Convert->cidr properly returned '26' when given a 'subnet' parameter of '255.255.255.192'.");
is($anvil->Convert->cidr({subnet => "255.255.255.224"}), "27", "Verifying that Convert->cidr properly returned '27' when given a 'subnet' parameter of '255.255.255.224'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.224"}), "27", "Verifying that Convert->cidr properly returned '27' when given a 'subnet' parameter of '255.255.255.224'.");
is($anvil->Convert->cidr({subnet => "255.255.255.240"}), "28", "Verifying that Convert->cidr properly returned '28' when given a 'subnet' parameter of '255.255.255.240'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.240"}), "28", "Verifying that Convert->cidr properly returned '28' when given a 'subnet' parameter of '255.255.255.240'.");
is($anvil->Convert->cidr({subnet => "255.255.255.248"}), "29", "Verifying that Convert->cidr properly returned '29' when given a 'subnet' parameter of '255.255.255.248'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.248"}), "29", "Verifying that Convert->cidr properly returned '29' when given a 'subnet' parameter of '255.255.255.248'.");
is($anvil->Convert->cidr({subnet => "255.255.255.252"}), "30", "Verifying that Convert->cidr properly returned '30' when given a 'subnet' parameter of '255.255.255.252'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.252"}), "30", "Verifying that Convert->cidr properly returned '30' when given a 'subnet' parameter of '255.255.255.252'.");
is($anvil->Convert->cidr({subnet => "255.255.255.254"}), "31", "Verifying that Convert->cidr properly returned '31' when given a 'subnet' parameter of '255.255.255.254'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.254"}), "31", "Verifying that Convert->cidr properly returned '31' when given a 'subnet' parameter of '255.255.255.254'.");
is($anvil->Convert->cidr({subnet => "255.255.255.255"}), "32", "Verifying that Convert->cidr properly returned '32' when given a 'subnet' parameter of '255.255.255.255'."); is($anvil->Convert->cidr({subnet_mask => "255.255.255.255"}), "32", "Verifying that Convert->cidr properly returned '32' when given a 'subnet' parameter of '255.255.255.255'.");
### Anvil::Tools::Database tests ### Anvil::Tools::Database tests
# <none yet> # <none yet>

@ -40,7 +40,7 @@ Provides all methods related to converting data.
# Access to methods using '$anvil->Convert->X'. # Access to methods using '$anvil->Convert->X'.
# #
# Example using 'cidr()'; # Example using 'cidr()';
my $subnet = $anvil->Convert->codr({cidr => "24"}); my $subnet_mask = $anvil->Convert->codr({cidr => "24"});
=head1 METHODS =head1 METHODS
@ -488,15 +488,15 @@ sub bytes_to_human_readable
=head2 cidr =head2 cidr
This takes an IPv4 CIDR notation and returns the dotted-decimal subnet, or the reverse. This takes an IPv4 CIDR notation and returns the dotted-decimal subnet mask, or the reverse.
# Convert a CIDR notation to a subnet. # Convert a CIDR notation to a subnet mask.
my $subnet = $anvil->Convert->cidr({cidr => "24"}); my $subnet_mask = $anvil->Convert->cidr({cidr => "24"});
In the other direction; In the other direction;
# Convert a subnet to a CIDR notation. # Convert a subnet mask to a CIDR notation.
my $cidr = $anvil->Convert->cidr({subnet => "255.255.255.0"}); my $cidr = $anvil->Convert->cidr({subnet_mask => "255.255.255.0"});
If the input data is invalid, an empty string will be returned. If the input data is invalid, an empty string will be returned.
@ -508,9 +508,9 @@ There are two parameters, each of which is optional, but one of them is required
This is a CIDR notation (between 0 and 24) to convert to a dotted-decimal address. This is a CIDR notation (between 0 and 24) to convert to a dotted-decimal address.
=head3 subnet (optional) =head3 subnet_mask (optional)
This is a dotted-decimal subnet to convert to a CIDR notation. This is a dotted-decimal subnet mask to convert to a CIDR notation.
=cut =cut
sub cidr sub cidr
@ -520,17 +520,17 @@ sub cidr
my $anvil = $self->parent; my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $cidr = defined $parameter->{cidr} ? $parameter->{cidr} : ""; my $cidr = defined $parameter->{cidr} ? $parameter->{cidr} : "";
my $subnet = defined $parameter->{subnet} ? $parameter->{subnet} : ""; my $subnet_mask = defined $parameter->{subnet_mask} ? $parameter->{subnet_mask} : "";
my $output = ""; my $output = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
cidr => $cidr, cidr => $cidr,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
if ($cidr =~ /^\d{1,2}$/) if ($cidr =~ /^\d{1,2}$/)
{ {
# Convert a cidr to a subnet # Convert a cidr to a subnet mask
if ($cidr eq "0") { $output = "0.0.0.0"; } if ($cidr eq "0") { $output = "0.0.0.0"; }
elsif ($cidr eq "1") { $output = "128.0.0.0"; } elsif ($cidr eq "1") { $output = "128.0.0.0"; }
elsif ($cidr eq "2") { $output = "192.0.0.0"; } elsif ($cidr eq "2") { $output = "192.0.0.0"; }
@ -565,41 +565,41 @@ sub cidr
elsif ($cidr eq "31") { $output = "255.255.255.254"; } elsif ($cidr eq "31") { $output = "255.255.255.254"; }
elsif ($cidr eq "32") { $output = "255.255.255.255"; } elsif ($cidr eq "32") { $output = "255.255.255.255"; }
} }
elsif ($anvil->Validate->is_ipv4({ip => $subnet})) elsif ($anvil->Validate->is_ipv4({ip => $subnet_mask}))
{ {
if ($subnet eq "0.0.0.0" ) { $output = "0"; } if ($subnet_mask eq "0.0.0.0" ) { $output = "0"; }
elsif ($subnet eq "128.0.0.0" ) { $output = "1"; } elsif ($subnet_mask eq "128.0.0.0" ) { $output = "1"; }
elsif ($subnet eq "192.0.0.0" ) { $output = "2"; } elsif ($subnet_mask eq "192.0.0.0" ) { $output = "2"; }
elsif ($subnet eq "224.0.0.0" ) { $output = "3"; } elsif ($subnet_mask eq "224.0.0.0" ) { $output = "3"; }
elsif ($subnet eq "240.0.0.0" ) { $output = "4"; } elsif ($subnet_mask eq "240.0.0.0" ) { $output = "4"; }
elsif ($subnet eq "248.0.0.0" ) { $output = "5"; } elsif ($subnet_mask eq "248.0.0.0" ) { $output = "5"; }
elsif ($subnet eq "252.0.0.0" ) { $output = "6"; } elsif ($subnet_mask eq "252.0.0.0" ) { $output = "6"; }
elsif ($subnet eq "254.0.0.0" ) { $output = "7"; } elsif ($subnet_mask eq "254.0.0.0" ) { $output = "7"; }
elsif ($subnet eq "255.0.0.0" ) { $output = "8"; } elsif ($subnet_mask eq "255.0.0.0" ) { $output = "8"; }
elsif ($subnet eq "255.128.0.0" ) { $output = "9"; } elsif ($subnet_mask eq "255.128.0.0" ) { $output = "9"; }
elsif ($subnet eq "255.192.0.0" ) { $output = "10"; } elsif ($subnet_mask eq "255.192.0.0" ) { $output = "10"; }
elsif ($subnet eq "255.224.0.0" ) { $output = "11"; } elsif ($subnet_mask eq "255.224.0.0" ) { $output = "11"; }
elsif ($subnet eq "255.240.0.0" ) { $output = "12"; } elsif ($subnet_mask eq "255.240.0.0" ) { $output = "12"; }
elsif ($subnet eq "255.248.0.0" ) { $output = "13"; } elsif ($subnet_mask eq "255.248.0.0" ) { $output = "13"; }
elsif ($subnet eq "255.252.0.0" ) { $output = "14"; } elsif ($subnet_mask eq "255.252.0.0" ) { $output = "14"; }
elsif ($subnet eq "255.254.0.0" ) { $output = "15"; } elsif ($subnet_mask eq "255.254.0.0" ) { $output = "15"; }
elsif ($subnet eq "255.255.0.0" ) { $output = "16"; } elsif ($subnet_mask eq "255.255.0.0" ) { $output = "16"; }
elsif ($subnet eq "255.255.128.0" ) { $output = "17"; } elsif ($subnet_mask eq "255.255.128.0" ) { $output = "17"; }
elsif ($subnet eq "255.255.192.0" ) { $output = "18"; } elsif ($subnet_mask eq "255.255.192.0" ) { $output = "18"; }
elsif ($subnet eq "255.255.224.0" ) { $output = "19"; } elsif ($subnet_mask eq "255.255.224.0" ) { $output = "19"; }
elsif ($subnet eq "255.255.240.0" ) { $output = "20"; } elsif ($subnet_mask eq "255.255.240.0" ) { $output = "20"; }
elsif ($subnet eq "255.255.248.0" ) { $output = "21"; } elsif ($subnet_mask eq "255.255.248.0" ) { $output = "21"; }
elsif ($subnet eq "255.255.252.0" ) { $output = "22"; } elsif ($subnet_mask eq "255.255.252.0" ) { $output = "22"; }
elsif ($subnet eq "255.255.254.0" ) { $output = "23"; } elsif ($subnet_mask eq "255.255.254.0" ) { $output = "23"; }
elsif ($subnet eq "255.255.255.0" ) { $output = "24"; } elsif ($subnet_mask eq "255.255.255.0" ) { $output = "24"; }
elsif ($subnet eq "255.255.255.128" ) { $output = "25"; } elsif ($subnet_mask eq "255.255.255.128" ) { $output = "25"; }
elsif ($subnet eq "255.255.255.192" ) { $output = "26"; } elsif ($subnet_mask eq "255.255.255.192" ) { $output = "26"; }
elsif ($subnet eq "255.255.255.224" ) { $output = "27"; } elsif ($subnet_mask eq "255.255.255.224" ) { $output = "27"; }
elsif ($subnet eq "255.255.255.240" ) { $output = "28"; } elsif ($subnet_mask eq "255.255.255.240" ) { $output = "28"; }
elsif ($subnet eq "255.255.255.248" ) { $output = "29"; } elsif ($subnet_mask eq "255.255.255.248" ) { $output = "29"; }
elsif ($subnet eq "255.255.255.252" ) { $output = "30"; } elsif ($subnet_mask eq "255.255.255.252" ) { $output = "30"; }
elsif ($subnet eq "255.255.255.254" ) { $output = "31"; } elsif ($subnet_mask eq "255.255.255.254" ) { $output = "31"; }
elsif ($subnet eq "255.255.255.255" ) { $output = "32"; } elsif ($subnet_mask eq "255.255.255.255" ) { $output = "32"; }
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});

@ -1930,7 +1930,7 @@ sub get_local_uuid
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}})
{ {
my $ip_address = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $ip_address = $anvil->data->{network}{'local'}{interface}{$interface}{ip};
my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ip_address => $ip_address, ip_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,

@ -615,10 +615,10 @@ This takes two hash keys from prior C<< Network->get_ips() >> or C<< ->load_ips(
A hash reference is returned using the format: A hash reference is returned using the format:
* <first>::<interface>::ip = <ip_address> * <first>::<interface>::ip = <ip_address>
* <first>::<interface>::subnet = <subnet_mask> * <first>::<interface>::subnet_mask = <subnet_mask>
* <second>::<interface>::ip = <ip_address> * <second>::<interface>::ip = <ip_address>
* <second>::<interface>::subnet = <subnet_mask> * <second>::<interface>::subnet_mask = <subnet_mask>
Where C<< first >> and C<< second >> are the parameters passed in below and C<< interface >> is the name of the interface on the fist/second machine that can talk to one another. Where C<< first >> and C<< second >> are the parameters passed in below and C<< interface >> is the name of the interface on the fist/second machine that can talk to one another.
@ -659,46 +659,46 @@ sub find_matches
return(""); return("");
} }
# Loop through the first, and on each interface with an IP/subnet, look for a match in the second. # Loop through the first, and on each interface with an IP/subnet mask, look for a match in the second.
my $match = {}; my $match = {};
foreach my $first_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$first}{interface}}) foreach my $first_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$first}{interface}})
{ {
my $first_ip = $anvil->data->{network}{$first}{interface}{$first_interface}{ip}; my $first_ip = $anvil->data->{network}{$first}{interface}{$first_interface}{ip};
my $first_subnet = $anvil->data->{network}{$first}{interface}{$first_interface}{subnet}; my $first_subnet_mask = $anvil->data->{network}{$first}{interface}{$first_interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
first => $first, first => $first,
first_interface => $first_interface, first_interface => $first_interface,
first_ip => $first_ip, first_ip => $first_ip,
first_subnet => $first_subnet, first_subnet_mask => $first_subnet_mask,
}}); }});
if (($first_ip) && ($first_subnet)) if (($first_ip) && ($first_subnet_mask))
{ {
# Look for a match. # Look for a match.
my $first_network = $anvil->Network->get_network({ my $first_network = $anvil->Network->get_network({
debug => $debug, debug => $debug,
ip => $first_ip, ip => $first_ip,
subnet => $first_subnet, subnet_mask => $first_subnet_mask,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { a_network => $first_network }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { a_network => $first_network }});
foreach my $second_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$second}{interface}}) foreach my $second_interface (sort {$b cmp $a} keys %{$anvil->data->{network}{$second}{interface}})
{ {
my $second_ip = $anvil->data->{network}{$second}{interface}{$second_interface}{ip}; my $second_ip = $anvil->data->{network}{$second}{interface}{$second_interface}{ip};
my $second_subnet = $anvil->data->{network}{$second}{interface}{$second_interface}{subnet}; my $second_subnet_mask = $anvil->data->{network}{$second}{interface}{$second_interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
second => $second, second => $second,
second_interface => $second_interface, second_interface => $second_interface,
second_ip => $second_ip, second_ip => $second_ip,
second_subnet => $second_subnet, second_subnet_mask => $second_subnet_mask,
}}); }});
if (($second_ip) && ($second_subnet)) if (($second_ip) && ($second_subnet_mask))
{ {
# Do we have a match? # Do we have a match?
my $second_network = $anvil->Network->get_network({ my $second_network = $anvil->Network->get_network({
debug => $debug, debug => $debug,
ip => $second_ip, ip => $second_ip,
subnet => $second_subnet, subnet_mask => $second_subnet_mask,
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
a_network => $first_network, a_network => $first_network,
@ -708,15 +708,15 @@ sub find_matches
if ($first_network eq $second_network) if ($first_network eq $second_network)
{ {
# Match! # Match!
$match->{$first}{$first_interface}{ip} = $first_ip; $match->{$first}{$first_interface}{ip} = $first_ip;
$match->{$first}{$first_interface}{subnet} = $second_network; $match->{$first}{$first_interface}{subnet_mask} = $second_network;
$match->{$second}{$second_interface}{ip} = $second_ip; $match->{$second}{$second_interface}{ip} = $second_ip;
$match->{$second}{$second_interface}{subnet} = $first_network; $match->{$second}{$second_interface}{subnet_mask} = $first_network;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"${first}::${first_interface}::ip" => $match->{$first}{$first_interface}{ip}, "${first}::${first_interface}::ip" => $match->{$first}{$first_interface}{ip},
"${first}::${first_interface}::subnet" => $match->{$first}{$first_interface}{subnet}, "${first}::${first_interface}::subnet_mask" => $match->{$first}{$first_interface}{subnet_mask},
"${second}::${second_interface}::ip" => $match->{$second}{$second_interface}{ip}, "${second}::${second_interface}::ip" => $match->{$second}{$second_interface}{ip},
"${second}::${second_interface}::subnet" => $match->{$second}{$second_interface}{subnet}, "${second}::${second_interface}::subnet_mask" => $match->{$second}{$second_interface}{subnet_mask},
}}); }});
} }
} }
@ -1079,7 +1079,7 @@ C<< Note >>: IP addresses that have been deleted will be marked so by C<< ip >>
The loaded data will be stored as: The loaded data will be stored as:
* C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set * C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set
* C<< network::<target>::interface::<iface_name>::subnet >> - If an IP is set * C<< network::<target>::interface::<iface_name>::subnet_mask >> - If an IP is set
* C<< network::<target>::interface::<iface_name>::mac >> - Always set. * C<< network::<target>::interface::<iface_name>::mac >> - Always set.
* C<< network::<target>::interface::<iface_name>::default_gateway >> = C<< 0 >> if not the default gateway, C<< 1 >> if so. * C<< network::<target>::interface::<iface_name>::default_gateway >> = C<< 0 >> if not the default gateway, C<< 1 >> if so.
* C<< network::<target>::interface::<iface_name>::gateway >> = If the default gateway, this is the gateway IP address. * C<< network::<target>::interface::<iface_name>::gateway >> = If the default gateway, this is the gateway IP address.
@ -1205,7 +1205,7 @@ WHERE
$anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac; $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac;
$anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address; $anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address;
$anvil->data->{network}{$host}{interface}{$interface_name}{subnet} = $ip_address_subnet_mask; $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask} = $ip_address_subnet_mask;
$anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns; $anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns;
@ -1213,7 +1213,7 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address}, "network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address},
"network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip}, "network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip},
"network::${host}::interface::${interface_name}::subnet" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet}, "network::${host}::interface::${interface_name}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask},
"network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway}, "network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway},
"network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway}, "network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway},
"network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns}, "network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns},
@ -1248,7 +1248,7 @@ WHERE
$anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac; $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac;
$anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address; $anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address;
$anvil->data->{network}{$host}{interface}{$interface_name}{subnet} = $ip_address_subnet_mask; $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask} = $ip_address_subnet_mask;
$anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns; $anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns;
@ -1256,7 +1256,7 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address}, "network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address},
"network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip}, "network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip},
"network::${host}::interface::${interface_name}::subnet" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet}, "network::${host}::interface::${interface_name}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask},
"network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway}, "network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway},
"network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway}, "network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway},
"network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns}, "network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns},
@ -1291,7 +1291,7 @@ WHERE
$anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac; $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address} = $interface_mac;
$anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address; $anvil->data->{network}{$host}{interface}{$interface_name}{ip} = $ip_address_address;
$anvil->data->{network}{$host}{interface}{$interface_name}{subnet} = $ip_address_subnet_mask; $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask} = $ip_address_subnet_mask;
$anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway} = $ip_address_default_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway; $anvil->data->{network}{$host}{interface}{$interface_name}{gateway} = $ip_address_gateway;
$anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns; $anvil->data->{network}{$host}{interface}{$interface_name}{dns} = $ip_address_dns;
@ -1299,7 +1299,7 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address}, "network::${host}::interface::${interface_name}::mac_address" => $anvil->data->{network}{$host}{interface}{$interface_name}{mac_address},
"network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip}, "network::${host}::interface::${interface_name}::ip" => $anvil->data->{network}{$host}{interface}{$interface_name}{ip},
"network::${host}::interface::${interface_name}::subnet" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet}, "network::${host}::interface::${interface_name}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$interface_name}{subnet_mask},
"network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway}, "network::${host}::interface::${interface_name}::default_gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{default_gateway},
"network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway}, "network::${host}::interface::${interface_name}::gateway" => $anvil->data->{network}{$host}{interface}{$interface_name}{gateway},
"network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns}, "network::${host}::interface::${interface_name}::dns" => $anvil->data->{network}{$host}{interface}{$interface_name}{dns},
@ -1387,7 +1387,7 @@ sub get_company_from_mac
This method checks the local system for interfaces and stores them in: This method checks the local system for interfaces and stores them in:
* C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set * C<< network::<target>::interface::<iface_name>::ip >> - If an IP address is set
* C<< network::<target>::interface::<iface_name>::subnet >> - If an IP is set * C<< network::<target>::interface::<iface_name>::subnet_mask >> - If an IP is set
* C<< network::<target>::interface::<iface_name>::mac >> - Always set. * C<< network::<target>::interface::<iface_name>::mac >> - Always set.
* C<< network::<target>::interface::<iface_name>::default_gateway >> = C<< 0 >> if not the default gateway, C<< 1 >> if so. * C<< network::<target>::interface::<iface_name>::default_gateway >> = C<< 0 >> if not the default gateway, C<< 1 >> if so.
* C<< network::<target>::interface::<iface_name>::gateway >> = If the default gateway, this is the gateway IP address. * C<< network::<target>::interface::<iface_name>::gateway >> = If the default gateway, this is the gateway IP address.
@ -1488,7 +1488,7 @@ sub get_ips
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_iface => $in_iface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_iface => $in_iface }});
$anvil->data->{network}{$host}{interface}{$in_iface}{ip} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{ip}; $anvil->data->{network}{$host}{interface}{$in_iface}{ip} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{ip};
$anvil->data->{network}{$host}{interface}{$in_iface}{subnet} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{subnet}; $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask};
$anvil->data->{network}{$host}{interface}{$in_iface}{mac_address} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{mac_address}; $anvil->data->{network}{$host}{interface}{$in_iface}{mac_address} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{mac_address};
$anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway}; $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway} = 0 if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{default_gateway};
$anvil->data->{network}{$host}{interface}{$in_iface}{gateway} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{gateway}; $anvil->data->{network}{$host}{interface}{$in_iface}{gateway} = "" if not defined $anvil->data->{network}{$host}{interface}{$in_iface}{gateway};
@ -1507,19 +1507,19 @@ sub get_ips
my $cidr = $2; my $cidr = $2;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip, cidr => $cidr }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip, cidr => $cidr }});
my $subnet = $cidr; my $subnet_mask = $cidr;
if (($cidr =~ /^\d{1,2}$/) && ($cidr >= 0) && ($cidr <= 32)) if (($cidr =~ /^\d{1,2}$/) && ($cidr >= 0) && ($cidr <= 32))
{ {
# Convert to subnet # Convert to subnet mask
$subnet = $anvil->Convert->cidr({cidr => $cidr}); $subnet_mask = $anvil->Convert->cidr({cidr => $cidr});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { subnet => $subnet }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { subnet_mask => $subnet_mask }});
} }
$anvil->data->{network}{$host}{interface}{$in_iface}{ip} = $ip; $anvil->data->{network}{$host}{interface}{$in_iface}{ip} = $ip;
$anvil->data->{network}{$host}{interface}{$in_iface}{subnet} = $subnet; $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask} = $subnet_mask;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:network::${host}::interface::${in_iface}::ip" => $anvil->data->{network}{$host}{interface}{$in_iface}{ip}, "s1:network::${host}::interface::${in_iface}::ip" => $anvil->data->{network}{$host}{interface}{$in_iface}{ip},
"s2:network::${host}::interface::${in_iface}::subnet" => $anvil->data->{network}{$host}{interface}{$in_iface}{subnet}, "s2:network::${host}::interface::${in_iface}::subnet_mask" => $anvil->data->{network}{$host}{interface}{$in_iface}{subnet_mask},
}}); }});
} }
if ($line =~ /ether ([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}) /i) if ($line =~ /ether ([0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}:[0-9a-f]{2}) /i)
@ -1791,7 +1791,7 @@ sub get_ips
This takes an IP address and subnet and returns the network it belongs too. For example; This takes an IP address and subnet and returns the network it belongs too. For example;
my $network = $anvil->Network->get_network({ip => "10.2.4.1", subnet => "255.255.0.0"}); my $network = $anvil->Network->get_network({ip => "10.2.4.1", subnet_mask => "255.255.0.0"});
This would set C<< $network >> to C<< 10.2.0.0 >>. This would set C<< $network >> to C<< 10.2.0.0 >>.
@ -1803,9 +1803,9 @@ Parameters;
This is the IPv4 IP address being calculated. This is the IPv4 IP address being calculated.
=head3 subnet (required) =head3 subnet_mask (required)
This is the subnet of the IP address being calculated. This is the subnet mask of the IP address being calculated.
=cut =cut
sub get_network sub get_network
@ -1815,12 +1815,12 @@ sub get_network
my $anvil = $self->parent; my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $network = ""; my $network = "";
my $ip = defined $parameter->{ip} ? $parameter->{ip} : ""; my $ip = defined $parameter->{ip} ? $parameter->{ip} : "";
my $subnet = defined $parameter->{subnet} ? $parameter->{subnet} : ""; my $subnet_mask = defined $parameter->{subnet_mask} ? $parameter->{subnet_mask} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
if (not $ip) if (not $ip)
@ -1828,13 +1828,13 @@ sub get_network
$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->get_network()", parameter => "ip" }});
return(""); return("");
} }
if (not $subnet) if (not $subnet_mask)
{ {
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->get_network()", parameter => "subnet" }}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Network->get_network()", parameter => "subnet_mask" }});
return(""); return("");
} }
my $block = Net::Netmask->new($ip."/".$subnet); my $block = Net::Netmask->new($ip."/".$subnet_mask);
my $base = $block->base(); my $base = $block->base();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { base => $base }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { base => $base }});

@ -7,6 +7,7 @@ use strict;
use warnings; use warnings;
use Data::Dumper; use Data::Dumper;
use Scalar::Util qw(weaken isweak); use Scalar::Util qw(weaken isweak);
use JSON;
our $VERSION = "3.0.0"; our $VERSION = "3.0.0";
my $THIS_FILE = "Striker.pm"; my $THIS_FILE = "Striker.pm";
@ -14,6 +15,7 @@ my $THIS_FILE = "Striker.pm";
### Methods; ### Methods;
# get_local_repo # get_local_repo
# get_peer_data # get_peer_data
# parse_all_status_json
=pod =pod
@ -312,6 +314,316 @@ sub get_peer_data
return($connected, $data); return($connected, $data);
} }
=head2 parse_all_status_json
This parses the c<< all_status.json >> file is a way that Striker can more readily use. If the read or parse failes, C<< 1 >> is returned. Otherwise C<< 0 >> is returned.
This method doesn't take any parameters.
=cut
sub parse_all_status_json
{
my $self = shift;
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 => "Striker->get_peer_data()" }});
# Read it in
my $json_file = $anvil->data->{path}{directories}{status}."/".$anvil->data->{path}{json}{all_status};
if (not -e $json_file)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "error_0105", variables => { file => $json_file }});
return(1);
}
my $body = $anvil->Storage->read_file({debug => $debug, file => $json_file});
if ($body eq "!!error!!")
{
return(1);
}
my $json = JSON->new->allow_nonref;
my $data = $json->decode($body);
if (exists $anvil->data->{json}{all_status})
{
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}})
{
my $host_name = $host_hash->{name};
my $short_name = $host_hash->{short_name};
$anvil->data->{json}{all_status}{hosts}{$host_name}{host_uuid} = $host_hash->{host_uuid};
$anvil->data->{json}{all_status}{hosts}{$host_name}{type} = $host_hash->{type};
$anvil->data->{json}{all_status}{hosts}{$host_name}{short_host_name} = $host_hash->{short_name};
$anvil->data->{json}{all_status}{hosts}{$host_name}{configured} = $host_hash->{configured};
$anvil->data->{json}{all_status}{hosts}{$host_name}{ssh_fingerprint} = $host_hash->{ssh_fingerprint};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"json::all_status::hosts::${host_name}::host_uuid" => $anvil->data->{json}{all_status}{hosts}{$host_name}{host_uuid},
"json::all_status::hosts::${host_name}::type" => $anvil->data->{json}{all_status}{hosts}{$host_name}{type},
"json::all_status::hosts::${host_name}::short_host_name" => $anvil->data->{json}{all_status}{hosts}{$host_name}{short_host_name},
"json::all_status::hosts::${host_name}::configured" => $anvil->data->{json}{all_status}{hosts}{$host_name}{configured},
"json::all_status::hosts::${host_name}::ssh_fingerprint" => $anvil->data->{json}{all_status}{hosts}{$host_name}{ssh_fingerprint},
}});
print "Host: [".$host_name." (".$anvil->data->{json}{all_status}{hosts}{$host_name}{short_host_name}.")], Type: [".$anvil->data->{json}{all_status}{hosts}{$host_name}{type}."], Configured: [".$anvil->data->{json}{all_status}{hosts}{$host_name}{configured}."], \n";
print " - Host UUID: ..... [".$anvil->data->{json}{all_status}{hosts}{$host_name}{host_uuid}."]\n";
print " - SSH Fingerprint: [".$anvil->data->{json}{all_status}{hosts}{$host_name}{ssh_fingerprint}."]\n";
print Dumper @{$host_hash->{network_interfaces}};
foreach my $interface_hash (@{$host_hash->{network_interfaces}})
{
my $interface_name = $interface_hash->{name};
my $interface_type = $interface_hash->{type};
my $ip = $interface_hash->{ip};
my $subnet_mask = $interface_hash->{subnet_mask};
my $default_gateway = $interface_hash->{default_gateway};
my $gateway = $interface_hash->{gateway};
my $dns = $interface_hash->{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
interface_name => $interface_name,
interface_type => $interface_type,
ip => $ip,
subnet_mask => $subnet_mask,
default_gateway => $default_gateway,
gateway => $gateway,
dns => $dns,
}});
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{uuid} = $interface_hash->{uuid};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mtu} = $interface_hash->{mtu}." ".$anvil->Words->string({key => "suffix_0014"});
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{ip} = $interface_hash->{ip};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{subnet_mask} = $interface_hash->{subnet_mask};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{default_gateway} = $interface_hash->{default_gateway};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{gateway} = $interface_hash->{gateway};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{dns} = $interface_hash->{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::uuid" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{uuid},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::mtu" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mtu},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::ip" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{ip},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::subnet_mask" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{subnet_mask},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::default_gateway" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{default_gateway},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::gateway" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{gateway},
"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->{connected}) && (ref($interface_hash->{connected}) eq "ARRAY"))
{
foreach my $interface_name (sort {$a cmp $b} @{$interface_hash->{connected}})
{
# We'll sort out the types after
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{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}::${interface_name}::mode" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mode},
}});
}
}
if ($interface_type eq "bond")
{
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mode} = $interface_hash->{mode};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{active_interface} = $interface_hash->{active_slave};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{primary_interface} = $interface_hash->{primary_slave};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{primary_reselect} = $interface_hash->{primary_reselect};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{up_delay} = $interface_hash->{up_delay};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{down_delay} = $interface_hash->{down_delay};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{operational} = $interface_hash->{operational};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mii_polling_interval} = $interface_hash->{mii_polling_interval}." ".$anvil->Words->string({key => "suffix_0012"});
# Translate some values
my $say_mode = $interface_hash->{mode};
if (($say_mode eq "0") or ($say_mode eq "balance-rr"))
{
$say_mode = $anvil->Words->string({key => "unit_0006"});
}
elsif (($say_mode eq "1") or ($say_mode eq "active-backup"))
{
$say_mode = $anvil->Words->string({key => "unit_0007"});
}
elsif (($say_mode eq "2") or ($say_mode eq "balanced-xor"))
{
$say_mode = $anvil->Words->string({key => "unit_0008"});
}
elsif (($say_mode eq "3") or ($say_mode eq "broadcast"))
{
$say_mode = $anvil->Words->string({key => "unit_0009"});
}
elsif (($say_mode eq "4") or ($say_mode eq "802.3ad"))
{
$say_mode = $anvil->Words->string({key => "unit_0010"});
}
elsif (($say_mode eq "5") or ($say_mode eq "balanced-tlb"))
{
$say_mode = $anvil->Words->string({key => "unit_0011"});
}
elsif (($say_mode eq "6") or ($say_mode eq "balanced-alb"))
{
$say_mode = $anvil->Words->string({key => "unit_0012"});
}
my $say_operational = $interface_hash->{operational};
if ($say_operational eq "up")
{
$say_operational = $anvil->Words->string({key => "unit_0013"});
}
elsif ($say_operational eq "down")
{
$say_operational = $anvil->Words->string({key => "unit_0014"});
}
elsif ($say_operational eq "unknown")
{
$say_operational = $anvil->Words->string({key => "unit_0004"});
}
my $say_primary_reselect = $interface_hash->{primary_reselect};
if (($say_primary_reselect eq "always") or ($say_primary_reselect eq "0"))
{
$say_primary_reselect = $anvil->Words->string({key => "unit_0017"});
}
elsif (($say_primary_reselect eq "better") or ($say_primary_reselect eq "1"))
{
$say_primary_reselect = $anvil->Words->string({key => "unit_0018"});
}
elsif (($say_primary_reselect eq "failure") or ($say_primary_reselect eq "2"))
{
$say_primary_reselect = $anvil->Words->string({key => "unit_0019"});
}
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_up_delay} = $interface_hash->{up_delay}." ".$anvil->Words->string({key => "suffix_0012"});
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_down_delay} = $interface_hash->{say_down_delay}." ".$anvil->Words->string({key => "suffix_0012"});
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_mode} = $say_mode;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_operational} = $say_operational;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_primary_reselect} = $say_primary_reselect;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::mode" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mode},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::active_interface" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{active_interface},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::primary_interface" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{primary_interface},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::primary_reselect" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{primary_reselect},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::up_delay" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{up_delay},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::down_delay" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{down_delay},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::operational" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{operational},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::mii_polling_interval" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mii_polling_interval},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_up_delay" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_up_delay},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_down_delay" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_down_delay},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_mode" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_mode},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_operational" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_operational},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_primary_reselect" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_primary_reselect},
}});
}
elsif ($interface_type eq "bridge")
{
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bridge_id} = $interface_hash->{bridge_id};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{stp_enabled} = $interface_hash->{stp_enabled};
my $say_stp_enabled = $interface_hash->{stp_enabled};
if (($say_stp_enabled eq "0") or ($say_stp_enabled eq "disabled"))
{
$say_stp_enabled = $anvil->Words->string({key => "unit_0020"});
}
elsif (($say_stp_enabled eq "1") or ($say_stp_enabled eq "enabled_kernel"))
{
$say_stp_enabled = $anvil->Words->string({key => "unit_0021"});
}
elsif (($say_stp_enabled eq "2") or ($say_stp_enabled eq "enabled_userland"))
{
$say_stp_enabled = $anvil->Words->string({key => "unit_0022"});
}
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_stp_enabled} = $interface_hash->{say_stp_enabled};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::bridge_id" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bridge_id},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::stp_enabled" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{stp_enabled},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_stp_enabled" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_stp_enabled},
}});
}
else
{
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{speed} = $interface_hash->{speed};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{link_state} = $interface_hash->{link_state};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{operational} = $interface_hash->{operational};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{duplex} = $interface_hash->{duplex};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{medium} = $interface_hash->{medium};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bond_name} = $interface_hash->{bond_name};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bridge_name} = $interface_hash->{bridge_name};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{changed_order} = $interface_hash->{changed_order};
my $say_speed = $anvil->Convert->add_commas({number => $interface_hash->{speed}})." ".$anvil->Words->string({key => "suffix_0050"});
if ($interface_hash->{speed} >= 1000)
{
# Report in Gbps
$say_speed = $anvil->Convert->add_commas({number => ($interface_hash->{speed} / 1000)})." ".$anvil->Words->string({key => "suffix_0051"});
}
my $say_duplex = $interface_hash->{duplex};
if ($say_duplex eq "full")
{
$say_duplex = $anvil->Words->string({key => "unit_0015"});
}
elsif ($say_duplex eq "half")
{
$say_duplex = $anvil->Words->string({key => "unit_0016"});
}
elsif ($say_duplex eq "unknown")
{
$say_duplex = $anvil->Words->string({key => "unit_0004"});
}
my $say_link_state = $interface_hash->{link_state};
if ($say_link_state eq "1")
{
$say_link_state = $anvil->Words->string({key => "unit_0013"});
}
elsif ($say_link_state eq "0")
{
$say_link_state = $anvil->Words->string({key => "unit_0014"});
}
my $say_operational = $interface_hash->{operational};
if ($say_operational eq "up")
{
$say_operational = $anvil->Words->string({key => "unit_0013"});
}
elsif ($say_operational eq "down")
{
$say_operational = $anvil->Words->string({key => "unit_0014"});
}
elsif ($say_operational eq "unknown")
{
$say_operational = $anvil->Words->string({key => "unit_0004"});
}
# This will be flushed out later. For now, we just send out what we've got.
my $say_medium = $interface_hash->{medium};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_speed} = $say_speed;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_duplex} = $say_duplex;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_link_state} = $say_link_state;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_operationa} = $say_operational;
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_medium} = $say_medium;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::speed" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{speed},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::link_state" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{link_state},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::operational" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{operational},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::duplex" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{duplex},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::medium" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{medium},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::bond_name" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bond_name},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::bridge_name" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{bridge_name},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::changed_order" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{changed_order},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_speed" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_speed},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_duplex" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_duplex},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_link_state" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_link_state},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_operationa" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_operationa},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::say_medium" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{say_medium},
}});
}
}
}
return(0);
}
1; 1;

@ -798,7 +798,9 @@ sub check_storage
=head2 generate_state_json =head2 generate_state_json
This method generates the C<< all_status.json >> file. This method generates the C<< all_status.json >> file.
B<< Note >>: Contained in are translations of some values, for the sake of JSON readers. Developers should note to translate values in-situ as the language used here may not be the user's desired language.
This method takes no parameters. This method takes no parameters.
@ -831,6 +833,10 @@ sub generate_state_json
"s6:host_key" => $host_key, "s6:host_key" => $host_key,
}}); }});
$anvil->Network->load_interfces({
host_uuid => $host_uuid,
host => $short_host_name,
});
$anvil->Network->load_interfces({ $anvil->Network->load_interfces({
host_uuid => $host_uuid, host_uuid => $host_uuid,
host => $short_host_name, host => $short_host_name,
@ -839,7 +845,7 @@ sub generate_state_json
{ {
my $type = $anvil->data->{network}{$host}{interface}{$interface}{type}; my $type = $anvil->data->{network}{$host}{interface}{$interface}{type};
my $uuid = $anvil->data->{network}{$host}{interface}{$interface}{uuid}; my $uuid = $anvil->data->{network}{$host}{interface}{$interface}{uuid};
my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu}." ".$anvil->Words->string({key => "suffix_0014"});; my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu};
my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address}; my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address};
my $iface_hash = {}; my $iface_hash = {};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -860,10 +866,10 @@ sub generate_state_json
my $primary_slave = $anvil->data->{network}{$host}{interface}{$interface}{primary_slave}; my $primary_slave = $anvil->data->{network}{$host}{interface}{$interface}{primary_slave};
my $primary_reselect = $anvil->data->{network}{$host}{interface}{$interface}{primary_reselect}; my $primary_reselect = $anvil->data->{network}{$host}{interface}{$interface}{primary_reselect};
my $active_slave = $anvil->data->{network}{$host}{interface}{$interface}{active_slave}; my $active_slave = $anvil->data->{network}{$host}{interface}{$interface}{active_slave};
my $mii_polling_interval = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{mii_polling_interval}})." ".$anvil->Words->string({key => "suffix_0012"}); my $mii_polling_interval = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{mii_polling_interval}});
my $say_up_delay = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{up_delay}})." ".$anvil->Words->string({key => "suffix_0012"}); my $say_up_delay = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{up_delay}});
my $up_delay = $anvil->data->{network}{$host}{interface}{$interface}{up_delay}; my $up_delay = $anvil->data->{network}{$host}{interface}{$interface}{up_delay};
my $say_down_delay = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{down_delay}})." ".$anvil->Words->string({key => "suffix_0012"}); my $say_down_delay = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{down_delay}});
my $down_delay = $anvil->data->{network}{$host}{interface}{$interface}{down_delay}; my $down_delay = $anvil->data->{network}{$host}{interface}{$interface}{down_delay};
my $operational = $anvil->data->{network}{$host}{interface}{$interface}{operational}; my $operational = $anvil->data->{network}{$host}{interface}{$interface}{operational};
my $interfaces = $anvil->data->{network}{$host}{interface}{$interface}{interfaces}; my $interfaces = $anvil->data->{network}{$host}{interface}{$interface}{interfaces};
@ -927,8 +933,8 @@ sub generate_state_json
mode => $mode, mode => $mode,
active_interface => $active_slave, active_interface => $active_slave,
primary_interface => $primary_slave, primary_interface => $primary_slave,
say_reselect_policy => $say_primary_reselect, say_primary_reselect => $say_primary_reselect,
reselect_policy => $primary_reselect, primary_reselect => $primary_reselect,
say_up_delay => $up_delay, say_up_delay => $up_delay,
up_delay => $anvil->data->{network}{$host}{interface}{$interface}{up_delay}, up_delay => $anvil->data->{network}{$host}{interface}{$interface}{up_delay},
say_down_delay => $down_delay, say_down_delay => $down_delay,
@ -947,7 +953,7 @@ sub generate_state_json
$iface_hash->{mode} = $mode; $iface_hash->{mode} = $mode;
$iface_hash->{active_interface} = $active_slave; $iface_hash->{active_interface} = $active_slave;
$iface_hash->{primary_interface} = $primary_slave; $iface_hash->{primary_interface} = $primary_slave;
$iface_hash->{reselect_policy} = $primary_reselect; $iface_hash->{primary_reselect} = $primary_reselect;
$iface_hash->{say_up_delay} = $say_up_delay; $iface_hash->{say_up_delay} = $say_up_delay;
$iface_hash->{up_delay} = $up_delay; $iface_hash->{up_delay} = $up_delay;
$iface_hash->{say_down_delay} = $say_down_delay; $iface_hash->{say_down_delay} = $say_down_delay;
@ -995,7 +1001,8 @@ sub generate_state_json
} }
else else
{ {
my $speed = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{speed}})." ".$anvil->Words->string({key => "suffix_0050"}); my $speed = $anvil->data->{network}{$host}{interface}{$interface}{speed};
my $say_speed = $anvil->Convert->add_commas({number => $anvil->data->{network}{$host}{interface}{$interface}{speed}})." ".$anvil->Words->string({key => "suffix_0050"});
my $link_state = $anvil->data->{network}{$host}{interface}{$interface}{link_state}; my $link_state = $anvil->data->{network}{$host}{interface}{$interface}{link_state};
my $operational = $anvil->data->{network}{$host}{interface}{$interface}{operational}; my $operational = $anvil->data->{network}{$host}{interface}{$interface}{operational};
my $duplex = $anvil->data->{network}{$host}{interface}{$interface}{duplex}; my $duplex = $anvil->data->{network}{$host}{interface}{$interface}{duplex};
@ -1005,12 +1012,12 @@ sub generate_state_json
my $changed_order = $anvil->data->{network}{$host}{interface}{$interface}{changed_order}; my $changed_order = $anvil->data->{network}{$host}{interface}{$interface}{changed_order};
my $say_link_state = $link_state; my $say_link_state = $link_state;
my $say_operational = $operational; my $say_operational = $operational;
my $say_medium = $medium; my $say_medium = $medium; # This will be flushed out later. For now, we just send out what we've got.
my $say_duplex = $duplex; my $say_duplex = $duplex;
if ($anvil->data->{network}{$host}{interface}{$interface}{speed} >= 1000) if ($anvil->data->{network}{$host}{interface}{$interface}{speed} >= 1000)
{ {
# Report in Gbps # Report in Gbps
$speed = $anvil->Convert->add_commas({number => ($anvil->data->{network}{$host}{interface}{$interface}{speed} / 1000)})." ".$anvil->Words->string({key => "suffix_0051"}); $say_speed = $anvil->Convert->add_commas({number => ($anvil->data->{network}{$host}{interface}{$interface}{speed} / 1000)})." ".$anvil->Words->string({key => "suffix_0051"});
} }
if ($duplex eq "full") if ($duplex eq "full")
{ {
@ -1036,7 +1043,16 @@ sub generate_state_json
{ {
$say_operational = $anvil->Words->string({key => "unit_0004"}); $say_operational = $anvil->Words->string({key => "unit_0004"});
} }
if ($link_state eq "1")
{
$say_link_state = $anvil->Words->string({key => "unit_0013"});
}
elsif ($link_state eq "0")
{
$say_link_state = $anvil->Words->string({key => "unit_0014"});
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
say_speed => $say_speed,
speed => $speed, speed => $speed,
say_link_state => $say_link_state, say_link_state => $say_link_state,
link_state => $link_state, link_state => $link_state,
@ -1051,6 +1067,7 @@ sub generate_state_json
changed_order => $changed_order, changed_order => $changed_order,
}}); }});
$iface_hash->{say_speed} = $say_speed;
$iface_hash->{speed} = $speed; $iface_hash->{speed} = $speed;
$iface_hash->{say_link_state} = $say_link_state; $iface_hash->{say_link_state} = $say_link_state;
$iface_hash->{link_state} = $link_state; $iface_hash->{link_state} = $link_state;
@ -1064,9 +1081,38 @@ sub generate_state_json
$iface_hash->{bridge_name} = $bridge_name; $iface_hash->{bridge_name} = $bridge_name;
$iface_hash->{changed_order} = $changed_order; $iface_hash->{changed_order} = $changed_order;
}; };
# Is there an IP on this interface?
my $ip = "";
my $subnet_mask = "";
my $default_gateway = 0;
my $gateway = "";
my $dns = "";
if ((exists $anvil->data->{network}{$host}{interface}{$interface}{ip}) && ($anvil->data->{network}{$host}{interface}{$interface}{ip}))
{
$ip = $anvil->data->{network}{$host}{interface}{$interface}{ip};
$subnet_mask = $anvil->data->{network}{$host}{interface}{$interface}{subnet_mask};
$default_gateway = $anvil->data->{network}{$host}{interface}{$interface}{default_gateway};
$gateway = $anvil->data->{network}{$host}{interface}{$interface}{gateway};
$dns = $anvil->data->{network}{$host}{interface}{$interface}{dns};
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
ip => $ip,
subnet_mask => $subnet_mask,
default_gateway => $default_gateway,
gateway => $gateway,
dns => $dns,
}});
$iface_hash->{ip} = $ip;
$iface_hash->{subnet_mask} = $subnet_mask;
$iface_hash->{default_gateway} = $default_gateway;
$iface_hash->{gateway} = $gateway;
$iface_hash->{dns} = $dns;
push @{$ifaces_array}, $iface_hash; push @{$ifaces_array}, $iface_hash;
} }
push @{$anvil->data->{json}{all_systems}{hosts}}, { push @{$anvil->data->{json}{all_systems}{hosts}}, {
name => $host_name, name => $host_name,
short_name => $short_host_name, short_name => $short_host_name,
@ -1078,7 +1124,7 @@ sub generate_state_json
}; };
} }
my $json = encode_json $anvil->data->{json}{all_systems}; my $json = JSON->new->utf8->encode($anvil->data->{json}{all_systems});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { json => $json }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { json => $json }});
# Write it out. # Write it out.
@ -1131,60 +1177,60 @@ sub get_bridges
{ {
# If the ifname and master are the same, it's a bridge. # If the ifname and master are the same, it's a bridge.
my $type = "interface"; my $type = "interface";
my $interface_name = $hash_ref->{ifname}; my $interface = $hash_ref->{ifname};
my $master_bridge = $hash_ref->{master}; my $master_bridge = $hash_ref->{master};
if ($interface_name eq $master_bridge) if ($interface eq $master_bridge)
{ {
$type = "bridge"; $type = "bridge";
$anvil->data->{'local'}{network}{bridges}{bridge}{$interface_name}{found} = 1; $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${interface_name}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface_name}{found}, "local::network::bridges::bridge::${interface}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found},
}}); }});
} }
else else
{ {
# Store this interface under the bridge. # Store this interface under the bridge.
$anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface_name} = 1; $anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${master_bridge}::connected_interface::${interface_name}" => $anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface_name}, "local::network::bridges::bridge::${master_bridge}::connected_interface::${interface}" => $anvil->data->{'local'}{network}{bridges}{bridge}{$master_bridge}{connected_interface}{$interface},
}}); }});
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
interface_name => $interface_name, interface => $interface,
master_bridge => $master_bridge, master_bridge => $master_bridge,
type => $type, type => $type,
}}); }});
foreach my $key (sort {$a cmp $b} keys %{$hash_ref}) foreach my $key (sort {$a cmp $b} keys %{$hash_ref})
{ {
if (ref($hash_ref->{$key}) eq "ARRAY") if (ref($hash_ref->{$key}) eq "ARRAY")
{ {
$anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key} = []; $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key} = [];
foreach my $value (sort {$a cmp $b} @{$hash_ref->{$key}}) foreach my $value (sort {$a cmp $b} @{$hash_ref->{$key}})
{ {
push @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key}}, $value; push @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}}, $value;
} }
for (my $i = 0; $i < @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key}}; $i++) for (my $i = 0; $i < @{$anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}}; $i++)
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::${type}::${interface_name}::${key}->[$i]" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key}->[$i], "local::network::bridges::${type}::${interface}::${key}->[$i]" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key}->[$i],
}}); }});
} }
} }
else else
{ {
$anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key} = $hash_ref->{$key}; $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key} = $hash_ref->{$key};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::${type}::${interface_name}::${key}" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface_name}{$key}, "local::network::bridges::${type}::${interface}::${key}" => $anvil->data->{'local'}{network}{bridges}{$type}{$interface}{$key},
}}); }});
} }
} }
} }
# Summary of found bridges. # Summary of found bridges.
foreach my $interface_name (sort {$a cmp $b} keys %{$anvil->data->{'local'}{network}{bridges}{bridge}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{'local'}{network}{bridges}{bridge}})
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"local::network::bridges::bridge::${interface_name}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface_name}{found}, "local::network::bridges::bridge::${interface}::found" => $anvil->data->{'local'}{network}{bridges}{bridge}{$interface}{found},
}}); }});
} }
@ -1400,14 +1446,14 @@ sub find_matching_ip
{ {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { interface => $interface }});
next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip}; next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip};
my $this_ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $this_ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip};
my $this_subnet = $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; my $this_subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:this_ip" => $this_ip, "s1:this_ip" => $this_ip,
"s2:this_subnet" => $this_subnet, "s2:this_subnet_mask" => $this_subnet_mask,
}}); }});
my $network_range = $this_ip."/".$this_subnet; my $network_range = $this_ip."/".$this_subnet_mask;
my $network = NetAddr::IP->new($network_range); my $network = NetAddr::IP->new($network_range);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:network_range" => $network_range, "s1:network_range" => $network_range,

@ -18,7 +18,7 @@ my $THIS_FILE = "Validate.pm";
# is_ipv4 # is_ipv4
# is_mac # is_mac
# is_positive_integer # is_positive_integer
# is_subnet # is_subnet_mask
# is_uuid # is_uuid
=pod =pod
@ -114,7 +114,7 @@ This is the type to be checked. Valid options are;
If this type is used, you can use the C<< zero >> parameter which can be set to C<< 1 >> to have a value of C<< 0 >> be considered valid. If this type is used, you can use the C<< zero >> parameter which can be set to C<< 1 >> to have a value of C<< 0 >> be considered valid.
=head4 subnet =head4 subnet_mask
=head4 uuid =head4 uuid
@ -191,7 +191,7 @@ sub form_field
$anvil->data->{cgi}{$name}{alert} = 1; $anvil->data->{cgi}{$name}{alert} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { valid => $valid, "cgi::${name}::alert" => $anvil->data->{cgi}{$name}{alert} }});
} }
elsif (($type eq "subnet") && (not $anvil->Validate->is_subnet({subnet => $anvil->data->{cgi}{$name}{value}}))) elsif (($type eq "subnet_mask") && (not $anvil->Validate->is_subnet_mask({subnet_mask => $anvil->data->{cgi}{$name}{value}})))
{ {
$valid = 0; $valid = 0;
$anvil->data->{cgi}{$name}{alert} = 1; $anvil->data->{cgi}{$name}{alert} = 1;
@ -503,35 +503,37 @@ sub is_positive_integer
return($valid); return($valid);
} }
=head2 is_subnet =head2 is_subnet_mask
This method takes a subnet string and checks to see if it is a valid IPv4 address or CIDR notation. It returns 'C<< 1 >>' if it is a valid address. Otherwise it returns 'C<< 0 >>'. This method takes a subnet mask string and checks to see if it is a valid IPv4 address or CIDR notation. It returns 'C<< 1 >>' if it is a valid address. Otherwise it returns 'C<< 0 >>'.
Parameters; Parameters;
=head3 subnet (required) =head3 subnet_mask (required)
This is the address to verify. This is the address to verify.
=cut =cut
sub is_subnet sub is_subnet_mask
{ {
my $self = shift; my $self = shift;
my $parameter = shift; my $parameter = shift;
my $anvil = $self->parent; my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3; my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
my $valid = 0; my $valid = 0;
my $subnet = defined $parameter->{subnet} ? $parameter->{subnet} : 0; my $subnet_mask = defined $parameter->{subnet_mask} ? $parameter->{subnet_mask} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { subnet => $subnet }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
subnet_mask => $subnet_mask,
}});
if ($subnet) if ($subnet_mask)
{ {
# We have something. Is it an IPv4 address? # We have something. Is it an IPv4 address?
if ($anvil->Validate->is_ipv4({ip => $subnet})) if ($anvil->Validate->is_ipv4({ip => $subnet_mask}))
{ {
# It is. Try converting it to a CIDR notation. If we get an empty string back, it isn't valid. # It is. Try converting it to a CIDR notation. If we get an empty string back, it isn't valid.
my $cidr = $anvil->Convert->cidr({subnet => $subnet}); my $cidr = $anvil->Convert->cidr({subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cidr => $cidr }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { cidr => $cidr }});
if ($cidr) if ($cidr)
{ {
@ -542,7 +544,7 @@ sub is_subnet
else else
{ {
# OK, maybe it's a CIDR notation? # OK, maybe it's a CIDR notation?
my $ip = $anvil->Convert->cidr({cidr => $subnet}); my $ip = $anvil->Convert->cidr({cidr => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { ip => $ip }});
if ($ip) if ($ip)
{ {

@ -694,9 +694,9 @@ sub process_anvil_menu
{ {
process_prep_host_page($anvil); process_prep_host_page($anvil);
} }
elsif ($anvil->data->{cgi}{task}{value} eq "configure-network") elsif ($anvil->data->{cgi}{task}{value} eq "prep-network")
{ {
process_configure_network($anvil); process_prep_network($anvil);
} }
elsif ($anvil->data->{cgi}{task}{value} eq "manifest") elsif ($anvil->data->{cgi}{task}{value} eq "manifest")
{ {
@ -714,7 +714,7 @@ sub process_anvil_menu
} }
# This handles configuring a remote target's network interfaces (renaming them, bonding and bridging them). # This handles configuring a remote target's network interfaces (renaming them, bonding and bridging them).
sub process_configure_network sub process_prep_network
{ {
my ($anvil) = @_; my ($anvil) = @_;
@ -729,6 +729,64 @@ sub process_configure_network
confirm => $confirm, confirm => $confirm,
}}); }});
# We need to a pick a machine to initialize.
# Do I know which machine we're initializing yet?
if ($anvil->data->{cgi}{host_uuid}{value})
{
# Yup, build the config page.
}
else
{
# Nope, show the list of unconfigured servers.
$anvil->System->parse_status_json($anvil);
}
# if ((not $anvil->data->{form}{body}) or ($anvil->data->{form}{error_massage}))
# {
# my $node_checked = "checked";
# my $dr_checked = "";
# if ($type eq "dr")
# {
# $node_checked = "";
# $dr_checked = "checked";
# }
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# node_checked => $node_checked,
# dr_checked => $dr_checked,
# }});
#
# my $host_name = $anvil->_host_name;
# $host_name =~ s/striker\d\d/xxx/;
# my $default_host_name = $host_name;
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# default_host_name => $default_host_name,
# host_name => $host_name,
# }});
# if ((exists $anvil->data->{cgi}{host_name}) && ($anvil->data->{cgi}{host_name}{value}))
# {
# $host_name = $anvil->data->{cgi}{host_name}{value};
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_name => $host_name }});
# }
#
# my $form_body = $anvil->Template->get({file => "anvil.html", name => "host-setup-menu1", variables => {
# host_name => $host_name,
# default_host_name => $default_host_name,
# host_ip_address => $host_ip_address,
# node_checked => $node_checked,
# dr_checked => $dr_checked,
# }});
#
# $anvil->data->{form}{refresh_link} = "?anvil=true&task=prep-network";
# $anvil->data->{form}{back_link} = "?anvil=true";
# $anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value};
# $anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value};
# $anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "prep-host-main", variables => {
# form => $form_body,
# }});
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }});
# }
return(0); return(0);
} }
@ -1281,7 +1339,7 @@ sub process_sync_page
{ {
next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/)); next if (($interface !~ /^bcn/) && ($interface !~ /^ifn/));
next if not $anvil->Validate->is_ipv4({ip => $anvil->data->{network}{'local'}{interface}{$interface}{ip}}); next if not $anvil->Validate->is_ipv4({ip => $anvil->data->{network}{'local'}{interface}{$interface}{ip}});
next if not $anvil->Validate->is_subnet({subnet => $anvil->data->{network}{'local'}{interface}{$interface}{subnet}}); next if not $anvil->Validate->is_subnet_mask({subnet_mask => $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask}});
my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/); my ($network_type, $network_number) = ($interface =~ /^(.*?)(\d+)_/);
my $database_user = $anvil->data->{database}{$host_uuid}{user} ? $anvil->data->{database}{$host_uuid}{user} : $anvil->data->{sys}{database}{user}; my $database_user = $anvil->data->{database}{$host_uuid}{user} ? $anvil->data->{database}{$host_uuid}{user} : $anvil->data->{sys}{database}{user};
@ -1935,11 +1993,11 @@ ORDER BY
foreach my $this_net (sort {$a cmp $b} keys %{$nets}) foreach my $this_net (sort {$a cmp $b} keys %{$nets})
{ {
my $ip_key = $this_net."_ip"; my $ip_key = $this_net."_ip";
my $subnet_key = $this_net."_subnet"; my $subnet_mask_key = $this_net."_subnet_mask";
my $iface1_key = $this_net."_link1_mac_to_set"; my $iface1_key = $this_net."_link1_mac_to_set";
my $iface2_key = $this_net."_link2_mac_to_set"; my $iface2_key = $this_net."_link2_mac_to_set";
my $ip = $anvil->data->{cgi}{$ip_key}{value}; my $ip = $anvil->data->{cgi}{$ip_key}{value};
my $subnet = $anvil->data->{cgi}{$subnet_key}{value}; my $subnet_mask = $anvil->data->{cgi}{$subnet_mask_key}{value};
my $iface1_mac = $anvil->data->{cgi}{$iface1_key}{value}; my $iface1_mac = $anvil->data->{cgi}{$iface1_key}{value};
my $iface2_mac = ((defined $anvil->data->{cgi}{$iface2_key}{value}) && ($anvil->data->{cgi}{$iface2_key}{value})) ? $anvil->data->{cgi}{$iface2_key}{value} : ""; my $iface2_mac = ((defined $anvil->data->{cgi}{$iface2_key}{value}) && ($anvil->data->{cgi}{$iface2_key}{value})) ? $anvil->data->{cgi}{$iface2_key}{value} : "";
my $template = $iface2_mac ? "step3_bonded_interface" : "step3_single_interface"; my $template = $iface2_mac ? "step3_bonded_interface" : "step3_single_interface";
@ -1949,7 +2007,7 @@ ORDER BY
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:nets->this_net" => $nets->{$this_net}, "s1:nets->this_net" => $nets->{$this_net},
"s2:ip" => $ip, "s2:ip" => $ip,
"s3:subnet" => $subnet, "s3:subnet_mask" => $subnet_mask,
"s4:iface1_mac" => $iface1_mac, "s4:iface1_mac" => $iface1_mac,
"s5:iface2_mac" => $iface2_mac, "s5:iface2_mac" => $iface2_mac,
"s6:template" => $template, "s6:template" => $template,
@ -1958,7 +2016,7 @@ ORDER BY
}}); }});
# Add to the networks template. # Add to the networks template.
my $say_ip = $ip."/".$subnet; my $say_ip = $ip."/".$subnet_mask;
if (($gateway) && ($anvil->data->{cgi}{gateway}{value})) if (($gateway) && ($anvil->data->{cgi}{gateway}{value}))
{ {
$template .= "_with_gateway"; $template .= "_with_gateway";
@ -1969,7 +2027,7 @@ ORDER BY
column => $anvil->Words->string({key => $column, variables => { number => $link_number }}), column => $anvil->Words->string({key => $column, variables => { number => $link_number }}),
ip_address => $say_ip, ip_address => $say_ip,
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
primary => $iface1_mac, primary => $iface1_mac,
backup => $iface2_mac, backup => $iface2_mac,
gateway => $anvil->data->{cgi}{gateway}{value}, gateway => $anvil->data->{cgi}{gateway}{value},
@ -2095,13 +2153,13 @@ ORDER BY
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bcn => $bcn }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { bcn => $bcn }});
push @{$links}, "bcn_link".$bcn; push @{$links}, "bcn_link".$bcn;
my $this_ip_key = "bcn".$bcn."_ip"; my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet"; my $this_subnet_mask_key = "bcn".$bcn."_subnet_mask";
my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set"; my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set";
my $this_iface2_key = "bcn".$bcn."_link2_mac_to_set"; my $this_iface2_key = "bcn".$bcn."_link2_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.","; $cgi .= $this_ip_key.",".$this_subnet_mask_key.",".$this_iface1_key.",".$this_iface2_key.",";
my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
my $this_subnet_class = $anvil->data->{cgi}{$this_subnet_key}{alert} ? "input_alert" : "input_clear"; my $this_subnet_mask_class = $anvil->data->{cgi}{$this_subnet_mask_key}{alert} ? "input_alert" : "input_clear";
my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear"; my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear";
my $this_iface2_class = $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear"; my $this_iface2_class = $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear";
@ -2123,18 +2181,18 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "config.html", name => "bonded_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "config.html", name => "bonded_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}),
description => "#!string!striker_0019!#", description => "#!string!striker_0019!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_mask_key => $this_subnet_mask_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "", subnet_mask_value => defined $anvil->data->{cgi}{$this_subnet_mask_key}{value} ? $anvil->data->{cgi}{$this_subnet_mask_key}{value} : "",
subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask}, subnet_mask_value_default => $anvil->data->{defaults}{network}{bcn}{subnet_mask},
subnet_class => $this_subnet_class, subnet_mask_class => $this_subnet_mask_class,
iface1_select => $this_iface1_form, iface1_select => $this_iface1_form,
iface2_select => $this_iface2_form, iface2_select => $this_iface2_form,
}}); }});
} }
@ -2146,13 +2204,13 @@ ORDER BY
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ifn => $ifn }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ifn => $ifn }});
push @{$links}, "ifn_link".$ifn; push @{$links}, "ifn_link".$ifn;
my $this_ip_key = "ifn".$ifn."_ip"; my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet"; my $this_subnet_mask_key = "ifn".$ifn."_subnet_mask";
my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set"; my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set";
my $this_iface2_key = "ifn".$ifn."_link2_mac_to_set"; my $this_iface2_key = "ifn".$ifn."_link2_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.",".$this_iface2_key.","; $cgi .= $this_ip_key.",".$this_subnet_mask_key.",".$this_iface1_key.",".$this_iface2_key.",";
my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
my $this_subnet_class = $anvil->data->{cgi}{$this_subnet_key}{alert} ? "input_alert" : "input_clear"; my $this_subnet_mask_class = $anvil->data->{cgi}{$this_subnet_mask_key}{alert} ? "input_alert" : "input_clear";
my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear"; my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear";
my $this_iface2_class = $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear"; my $this_iface2_class = $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear";
@ -2174,18 +2232,18 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "config.html", name => "bonded_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "config.html", name => "bonded_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}),
description => "#!string!striker_0023!#", description => "#!string!striker_0023!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_mask_key => $this_subnet_mask_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : "", subnet_mask_value => defined $anvil->data->{cgi}{$this_subnet_mask_key}{value} ? $anvil->data->{cgi}{$this_subnet_mask_key}{value} : "",
subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask}, subnet_mask_value_default => $anvil->data->{defaults}{network}{ifn}{subnet_mask},
subnet_class => $this_subnet_class, subnet_mask_class => $this_subnet_mask_class,
iface1_select => $this_iface1_form, iface1_select => $this_iface1_form,
iface2_select => $this_iface2_form, iface2_select => $this_iface2_form,
}}); }});
} }
} }
@ -2198,12 +2256,12 @@ ORDER BY
{ {
push @{$links}, "bcn_link".$bcn; push @{$links}, "bcn_link".$bcn;
my $this_ip_key = "bcn".$bcn."_ip"; my $this_ip_key = "bcn".$bcn."_ip";
my $this_subnet_key = "bcn".$bcn."_subnet"; my $this_subnet_mask_key = "bcn".$bcn."_subnet_mask";
my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set"; my $this_iface1_key = "bcn".$bcn."_link1_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.","; $cgi .= $this_ip_key.",".$this_subnet_mask_key.",".$this_iface1_key.",";
my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "bcn", $bcn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
my $this_subnet_class = $anvil->data->{cgi}{$this_subnet_key}{alert} ? "input_alert" : "input_clear"; my $this_subnet_mask_class = $anvil->data->{cgi}{$this_subnet_mask_key}{alert} ? "input_alert" : "input_clear";
my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear"; my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear";
# Build the interface select boxes... # Build the interface select boxes...
@ -2217,17 +2275,17 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "config.html", name => "single_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "config.html", name => "single_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}), field => $anvil->Words->string({key => "striker_0018", variables => { number => $bcn }}),
description => "#!string!striker_0019!#", description => "#!string!striker_0019!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_mask_key => $this_subnet_mask_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{bcn}{netmask}, subnet_mask_value => defined $anvil->data->{cgi}{$this_subnet_mask_key}{value} ? $anvil->data->{cgi}{$this_subnet_mask_key}{value} : $anvil->data->{defaults}{network}{bcn}{subnet_mask},
subnet_value_default => $anvil->data->{defaults}{network}{bcn}{netmask}, subnet_mask_value_default => $anvil->data->{defaults}{network}{bcn}{subnet_mask},
subnet_class => $this_subnet_class, subnet_mask_class => $this_subnet_mask_class,
iface1_select => $this_iface1_form, iface1_select => $this_iface1_form,
}}); }});
} }
@ -2237,12 +2295,12 @@ ORDER BY
{ {
push @{$links}, "ifn_link".$ifn; push @{$links}, "ifn_link".$ifn;
my $this_ip_key = "ifn".$ifn."_ip"; my $this_ip_key = "ifn".$ifn."_ip";
my $this_subnet_key = "ifn".$ifn."_subnet"; my $this_subnet_mask_key = "ifn".$ifn."_subnet_mask";
my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set"; my $this_iface1_key = "ifn".$ifn."_link1_mac_to_set";
$cgi .= $this_ip_key.",".$this_subnet_key.",".$this_iface1_key.","; $cgi .= $this_ip_key.",".$this_subnet_mask_key.",".$this_iface1_key.",";
my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value}); my $this_ip = generate_ip($anvil, "ifn", $ifn, $anvil->data->{cgi}{sequence}{value});
my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear"; my $this_ip_class = $anvil->data->{cgi}{$this_ip_key}{alert} ? "input_alert" : "input_clear";
my $this_subnet_class = $anvil->data->{cgi}{$this_subnet_key}{alert} ? "input_alert" : "input_clear"; my $this_subnet_mask_class = $anvil->data->{cgi}{$this_subnet_mask_key}{alert} ? "input_alert" : "input_clear";
my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear"; my $this_iface1_class = $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear";
# Build the interface select boxes... # Build the interface select boxes...
@ -2256,17 +2314,17 @@ ORDER BY
# Assemble the form # Assemble the form
$interface_form .= $anvil->Template->get({file => "config.html", name => "single_interface_form", variables => { $interface_form .= $anvil->Template->get({file => "config.html", name => "single_interface_form", variables => {
field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}), field => $anvil->Words->string({key => "striker_0022", variables => { number => $ifn }}),
description => "#!string!striker_0023!#", description => "#!string!striker_0023!#",
ip_key => $this_ip_key, ip_key => $this_ip_key,
ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "", ip_value => defined $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "",
ip_value_default => $this_ip, ip_value_default => $this_ip,
ip_class => $this_ip_class, ip_class => $this_ip_class,
subnet_key => $this_subnet_key, subnet_mask_key => $this_subnet_mask_key,
subnet_value => defined $anvil->data->{cgi}{$this_subnet_key}{value} ? $anvil->data->{cgi}{$this_subnet_key}{value} : $anvil->data->{defaults}{network}{ifn}{netmask}, subnet_mask_value => defined $anvil->data->{cgi}{$this_subnet_mask_key}{value} ? $anvil->data->{cgi}{$this_subnet_mask_key}{value} : $anvil->data->{defaults}{network}{ifn}{subnet_mask},
subnet_value_default => $anvil->data->{defaults}{network}{ifn}{netmask}, subnet_mask_value_default => $anvil->data->{defaults}{network}{ifn}{subnet_mask},
subnet_class => $this_subnet_class, subnet_mask_class => $this_subnet_mask_class,
iface1_select => $this_iface1_form, iface1_select => $this_iface1_form,
}}); }});
} }
} }
@ -2510,17 +2568,17 @@ sub sanity_check_step2
{ {
my $this_network = $network.$count; my $this_network = $network.$count;
my $this_ip_key = $this_network."_ip"; my $this_ip_key = $this_network."_ip";
my $this_subnet_key = $this_network."_subnet"; my $this_subnet_mask_key = $this_network."_subnet_mask";
my $this_iface1_key = $this_network."_link1_mac_to_set"; my $this_iface1_key = $this_network."_link1_mac_to_set";
my $this_iface2_key = $this_network."_link2_mac_to_set"; my $this_iface2_key = $this_network."_link2_mac_to_set";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
count => $count, count => $count,
this_ip_key => $this_ip_key, this_ip_key => $this_ip_key,
this_subnet_key => $this_subnet_key, this_subnet_mask_key => $this_subnet_mask_key,
this_iface1_key => $this_iface1_key, this_iface1_key => $this_iface1_key,
this_iface2_key => $this_iface2_key, this_iface2_key => $this_iface2_key,
"cgi::${this_ip_key}::value" => $anvil->data->{cgi}{$this_ip_key}{value}, "cgi::${this_ip_key}::value" => $anvil->data->{cgi}{$this_ip_key}{value},
"cgi::${this_subnet_key}::value" => $anvil->data->{cgi}{$this_subnet_key}{value}, "cgi::${this_subnet_mask_key}::value" => $anvil->data->{cgi}{$this_subnet_mask_key}{value},
"cgi::${this_iface1_key}::value" => $anvil->data->{cgi}{$this_iface1_key}{value}, "cgi::${this_iface1_key}::value" => $anvil->data->{cgi}{$this_iface1_key}{value},
"cgi::${this_iface2_key}::value" => $anvil->data->{cgi}{$this_iface2_key}{value}, "cgi::${this_iface2_key}::value" => $anvil->data->{cgi}{$this_iface2_key}{value},
}}); }});
@ -2555,27 +2613,27 @@ sub sanity_check_step2
}); });
} }
# What about the subnet? # What about the subnet mask?
if (not $anvil->Validate->form_field({name => $this_subnet_key, type => "subnet"})) if (not $anvil->Validate->form_field({name => $this_subnet_mask_key, type => "subnet_mask"}))
{ {
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $anvil->Words->string({key => "error_0016", variables => { network => $say_network }}) }}); $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $anvil->Words->string({key => "error_0016", variables => { network => $say_network }}) }});
$anvil->data->{cgi}{$this_subnet_key}{alert} = 1; $anvil->data->{cgi}{$this_subnet_mask_key}{alert} = 1;
$sane = 0; $sane = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 1, list => { sane => $sane }});
} }
elsif ($ip_ok) elsif ($ip_ok)
{ {
# We'll use the dotted-decimal subnet. If it already is, great. If not, convert it. # We'll use the dotted-decimal subnet_mask. If it already is, great. If not, convert it.
my $say_subnet = $anvil->data->{cgi}{$this_subnet_key}{value} =~ /^\d{1,2}$/ ? $anvil->Convert->cide({cidr => $anvil->data->{cgi}{$this_subnet_key}{value}}) : $anvil->data->{cgi}{$this_subnet_key}{value}; my $say_subnet_mask = $anvil->data->{cgi}{$this_subnet_mask_key}{value} =~ /^\d{1,2}$/ ? $anvil->Convert->cide({cidr => $anvil->data->{cgi}{$this_subnet_mask_key}{value}}) : $anvil->data->{cgi}{$this_subnet_mask_key}{value};
my $full_ip = $anvil->data->{cgi}{$this_ip_key}{value}."/".$anvil->data->{cgi}{$this_subnet_key}{value}; my $full_ip = $anvil->data->{cgi}{$this_ip_key}{value}."/".$anvil->data->{cgi}{$this_subnet_mask_key}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_subnet => $say_subnet, full_ip => $full_ip }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { say_subnet_mask => $say_subnet_mask, full_ip => $full_ip }});
$networks->{$this_network} = $full_ip; $networks->{$this_network} = $full_ip;
# Save the subnet # Save the subnet mask
$anvil->Database->insert_or_update_variables({ $anvil->Database->insert_or_update_variables({
variable_name => "form::config_step2::${this_subnet_key}::value", variable_name => "form::config_step2::${this_subnet_mask_key}::value",
variable_value => $anvil->data->{cgi}{$this_subnet_key}{value}, variable_value => $anvil->data->{cgi}{$this_subnet_mask_key}{value},
variable_default => "", variable_default => "",
variable_description => "striker_0025", variable_description => "striker_0025",
variable_section => "config_step2", variable_section => "config_step2",
@ -2704,16 +2762,16 @@ sub sanity_check_step2
# Match this gateway to one of the interfaces. # Match this gateway to one of the interfaces.
foreach my $this_network (sort {$a cmp $b} keys %{$networks}) foreach my $this_network (sort {$a cmp $b} keys %{$networks})
{ {
my ($this_ip, $this_subnet) = ($networks->{$this_network} =~ /^(.*?)\/(.*)$/); my ($this_ip, $this_subnet_mask) = ($networks->{$this_network} =~ /^(.*?)\/(.*)$/);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:this_network" => $this_network, "s1:this_network" => $this_network,
"s2:networks->$this_network" => $networks->{$this_network}, "s2:networks->$this_network" => $networks->{$this_network},
"s3:this_ip" => $this_ip, "s3:this_ip" => $this_ip,
"s4:this_subnet" => $this_subnet, "s4:this_subnet_mask" => $this_subnet_mask,
}}); }});
my $first = NetAddr::IP->new("$this_ip/$this_subnet"); my $first = NetAddr::IP->new("$this_ip/$this_subnet_mask");
my $second = NetAddr::IP->new("$gateway/$this_subnet"); my $second = NetAddr::IP->new("$gateway/$this_subnet_mask");
if ($second->within($first)) if ($second->within($first))
{ {
@ -3174,14 +3232,14 @@ sub get_network_details
# Only one entry. Fix the hash. # Only one entry. Fix the hash.
my $address = $data->{ip}{address}; my $address = $data->{ip}{address};
my $on = $data->{ip}{on}; my $on = $data->{ip}{on};
my $subnet = $data->{ip}{subnet}; my $subnet_mask = $data->{ip}{subnet_mask};
my $gateway = $data->{ip}{gateway}; my $gateway = $data->{ip}{gateway};
my $default_gateway = $data->{ip}{default_gateway}; my $default_gateway = $data->{ip}{default_gateway};
my $dns = $data->{ip}{dns}; my $dns = $data->{ip}{dns};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
address => $address, address => $address,
on => $on, on => $on,
subnet => $subnet, subnet_mask => $subnet_mask,
gateway => $gateway, gateway => $gateway,
default_gateway => $default_gateway, default_gateway => $default_gateway,
dns => $dns, dns => $dns,
@ -3189,14 +3247,14 @@ sub get_network_details
$anvil->data->{ip}{$address} = { $anvil->data->{ip}{$address} = {
on => $on, on => $on,
subnet => $subnet, subnet_mask => $subnet_mask,
gateway => $gateway, gateway => $gateway,
default_gateway => $default_gateway, default_gateway => $default_gateway,
dns => $dns, dns => $dns,
}; };
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"ip::${address}::on" => $anvil->data->{ip}{$address}{on}, "ip::${address}::on" => $anvil->data->{ip}{$address}{on},
"ip::${address}::subnet" => $anvil->data->{ip}{$address}{subnet}, "ip::${address}::subnet_mask" => $anvil->data->{ip}{$address}{subnet_mask},
"ip::${address}::gateway" => $anvil->data->{ip}{$address}{gateway}, "ip::${address}::gateway" => $anvil->data->{ip}{$address}{gateway},
"ip::${address}::default_gateway" => $anvil->data->{ip}{$address}{default_gateway}, "ip::${address}::default_gateway" => $anvil->data->{ip}{$address}{default_gateway},
"ip::${address}::dns" => $anvil->data->{ip}{$address}{dns}, "ip::${address}::dns" => $anvil->data->{ip}{$address}{dns},
@ -3209,14 +3267,14 @@ sub get_network_details
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { address => $address }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { address => $address }});
$anvil->data->{ip}{$address} = { $anvil->data->{ip}{$address} = {
on => $data->{ip}{$address}{on}, on => $data->{ip}{$address}{on},
subnet => $data->{ip}{$address}{subnet}, subnet_mask => $data->{ip}{$address}{subnet_mask},
gateway => $data->{ip}{$address}{gateway}, gateway => $data->{ip}{$address}{gateway},
default_gateway => $data->{ip}{$address}{default_gateway}, default_gateway => $data->{ip}{$address}{default_gateway},
dns => $data->{ip}{$address}{dns}, dns => $data->{ip}{$address}{dns},
}; };
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"ip::${address}::on" => $anvil->data->{ip}{$address}{on}, "ip::${address}::on" => $anvil->data->{ip}{$address}{on},
"ip::${address}::subnet" => $anvil->data->{ip}{$address}{subnet}, "ip::${address}::subnet_mask" => $anvil->data->{ip}{$address}{subnet_mask},
"ip::${address}::gateway" => $anvil->data->{ip}{$address}{gateway}, "ip::${address}::gateway" => $anvil->data->{ip}{$address}{gateway},
"ip::${address}::default_gateway" => $anvil->data->{ip}{$address}{default_gateway}, "ip::${address}::default_gateway" => $anvil->data->{ip}{$address}{default_gateway},
"ip::${address}::dns" => $anvil->data->{ip}{$address}{dns}, "ip::${address}::dns" => $anvil->data->{ip}{$address}{dns},
@ -3325,15 +3383,15 @@ sub generate_ip
# An empty string is returned if we can't make a sane guess at what should be set. # An empty string is returned if we can't make a sane guess at what should be set.
my $ip = ""; my $ip = "";
# The subnet's second octet will be '+X' where 'X' is the sequence. # The subnet mask's second octet will be '+X' where 'X' is the sequence.
my $default_ip = $anvil->data->{defaults}{network}{$network}{subnet}; my $default_ip = $anvil->data->{defaults}{network}{$network}{network};
my $default_netmark = $anvil->data->{defaults}{network}{$network}{netmask}; my $default_subnet_mask = $anvil->data->{defaults}{network}{$network}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
default_ip => $default_ip, default_ip => $default_ip,
default_netmark => $default_netmark, default_subnet_mask => $default_subnet_mask,
}}); }});
if (($anvil->Validate->is_ipv4({ip => $default_ip})) && ($anvil->Validate->is_ipv4({ip => $default_netmark}))) if (($anvil->Validate->is_ipv4({ip => $default_ip})) && ($anvil->Validate->is_ipv4({ip => $default_subnet_mask})))
{ {
# Valid values. # Valid values.
my ($ip_octet1, $ip_octet2, $ip_octet3, $ip_octet4) = (split/\./, $default_ip); my ($ip_octet1, $ip_octet2, $ip_octet3, $ip_octet4) = (split/\./, $default_ip);
@ -3344,7 +3402,7 @@ sub generate_ip
ip_octet4 => $ip_octet4, ip_octet4 => $ip_octet4,
}}); }});
if ($default_netmark eq "255.255.0.0") if ($default_subnet_mask eq "255.255.0.0")
{ {
# We can work with this. # We can work with this.
if ($network ne "ifn") if ($network ne "ifn")

@ -1,5 +1,6 @@
<!-- start main-menu --> <!-- start main-menu -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr> <tr>
<td colspan="2"> <td colspan="2">
&nbsp; &nbsp;

@ -0,0 +1,24 @@
$.ajaxSetup({
cache: false
});
$(function() {
});
$( window ).on( "load", function()
{
// NOTE: Disabled for now. Breaks viewing the source.
// Clears the URL to remove everything off after '?'.
//var newURL = location.href.split("?")[0];
//window.history.pushState('object', document.title, newURL);
//console.log('onload fired.');
// Walk through the network.json file and use it to pre-fill the form.
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.ips, function(index, element) {
//console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet_mask: ['+element.subnet_mask+'].');
//console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
});
});
})

@ -33,8 +33,8 @@
#!string!striker_0025!# #!string!striker_0025!#
</td> </td>
<td> <td>
<input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#"> <input type="text" name="#!variable!subnet_mask_key!#" id="#!variable!subnet_mask_key!#" value="#!variable!subnet_mask_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_mask_class!#">
<input type="hidden" name="#!variable!subnet_key!#_default" id="#!variable!subnet_key!#_default" value="#!variable!subnet_value_default!#"> <input type="hidden" name="#!variable!subnet_mask_key!#_default" id="#!variable!subnet_mask_key!#_default" value="#!variable!subnet_mask_value_default!#">
</td> </td>
<td> <td>
&nbsp; &nbsp;
@ -434,8 +434,8 @@
#!string!striker_0025!# #!string!striker_0025!#
</td> </td>
<td> <td>
<input type="text" name="#!variable!subnet_key!#" id="#!variable!subnet_key!#" value="#!variable!subnet_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_class!#"> <input type="text" name="#!variable!subnet_mask_key!#" id="#!variable!subnet_mask_key!#" value="#!variable!subnet_mask_value!#" placeholder="#!string!striker_0025!#" class="#!variable!subnet_mask_class!#">
<input type="hidden" name="#!variable!subnet_key!#_default" id="#!variable!subnet_key!#_default" value="#!variable!subnet_value_default!#"> <input type="hidden" name="#!variable!subnet_mask_key!#_default" id="#!variable!subnet_mask_key!#_default" value="#!variable!subnet_mask_value_default!#">
</td> </td>
<td> <td>
&nbsp; &nbsp;
@ -467,8 +467,8 @@
#!variable!ip_address!# #!variable!ip_address!#
</td> </td>
</tr> </tr>
<input type="hidden" name="ip" id="ip" value="#!variable!ip!#"> <input type="hidden" name="ip" id="ip" value="#!variable!ip!#">
<input type="hidden" name="subnet" id="subnet" value="#!variable!subnet!#"> <input type="hidden" name="subnet_mask" id="subnet_mask" value="#!variable!subnet_mask!#">
<tr> <tr>
<td> <td>
&nbsp; &bull; #!string!striker_0029!#: &nbsp; &bull; #!string!striker_0029!#:

@ -47,7 +47,7 @@ $( window ).on( "load", function()
// Walk through the network.json file and use it to pre-fill the form. // Walk through the network.json file and use it to pre-fill the form.
$.getJSON('/status/network.json', { get_param: 'value' }, function(data) { $.getJSON('/status/network.json', { get_param: 'value' }, function(data) {
$.each(data.ips, function(index, element) { $.each(data.ips, function(index, element) {
//console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].'); //console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet_mask: ['+element.subnet_mask+'].');
//console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].'); //console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
// If this is the default gateway, see about setting the Gateway IP and DNS. // If this is the default gateway, see about setting the Gateway IP and DNS.
@ -66,18 +66,18 @@ $( window ).on( "load", function()
// Does this IP match any of the fields? // Does this IP match any of the fields?
if(element.on.match(new RegExp('_'))) { if(element.on.match(new RegExp('_'))) {
var network_prefix = element.on.match(/^(.*)_/).pop(); var network_prefix = element.on.match(/^(.*)_/).pop();
var network_ip_key = network_prefix+'_ip' var network_ip_key = network_prefix+'_ip'
var network_subnet_key = network_prefix+'_subnet' var network_subnet_mask_key = network_prefix+'_subnet_mask'
//console.log('Matching: ['+network_ip_key+'] and: ['+network_subnet_key+'].'); //console.log('Matching: ['+network_ip_key+'] and: ['+network_subnet_mask_key+'].');
if ($("#"+network_ip_key).val() == '') if ($("#"+network_ip_key).val() == '')
{ {
$("#"+network_ip_key).val(element.address); $("#"+network_ip_key).val(element.address);
} }
if ($("#"+network_subnet_key).val() == '') if ($("#"+network_subnet_mask_key).val() == '')
{ {
$("#"+network_subnet_key).val(element.subnet); $("#"+network_subnet_mask_key).val(element.subnet_mask);
} }
} }
}); });
@ -92,7 +92,7 @@ $( window ).on( "load", function()
$("#dns").val($("#dns_default").val()); $("#dns").val($("#dns_default").val());
} }
// Now set any other default IP/subnets // Now set any other default IP/subnet masks
jQuery.each("bcn sn ifn".split(" "), function(index, network) { jQuery.each("bcn sn ifn".split(" "), function(index, network) {
//console.log('Network: ['+network+'].'); //console.log('Network: ['+network+'].');
if($("#"+network+"_count").val()) { if($("#"+network+"_count").val()) {
@ -100,18 +100,18 @@ $( window ).on( "load", function()
//console.log(network+' count: ['+count+'].'); //console.log(network+' count: ['+count+'].');
for (var i = 1; i <= count; i++) { for (var i = 1; i <= count; i++) {
var network_name = network+i; var network_name = network+i;
//console.log('Network: ['+network_name+'], IP set: ['+$("#"+network_name+"_ip").val()+'/'+$("#"+network_name+"_subnet").val()+'].'); //console.log('Network: ['+network_name+'], IP set: ['+$("#"+network_name+"_ip").val()+'/'+$("#"+network_name+"_subnet_mask").val()+'].');
//console.log('- default: ['+$("#"+network_name+"_ip_default").val()+'/'+$("#"+network_name+"_subnet_default").val()+'].'); //console.log('- default: ['+$("#"+network_name+"_ip_default").val()+'/'+$("#"+network_name+"_subnet_mask_default").val()+'].');
if ($("#"+network_name+"_ip").val() == '') if ($("#"+network_name+"_ip").val() == '')
{ {
var ip = $("#"+network_name+"_ip_default").val(); var ip = $("#"+network_name+"_ip_default").val();
$("#"+network_name+"_ip").val(ip); $("#"+network_name+"_ip").val(ip);
} }
if ($("#"+network_name+"_subnet").val() == '') if ($("#"+network_name+"_subnet_mask").val() == '')
{ {
var subnet = $("#"+network_name+"_subnet_default").val(); var subnet_mask = $("#"+network_name+"_subnet_mask_default").val();
$("#"+network_name+"_subnet").val(subnet); $("#"+network_name+"_subnet_mask").val(subnet_mask);
} }
}; };
}; };
@ -136,7 +136,7 @@ $( window ).on( "load", function()
$.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) { $.getJSON('/status/jobs.json', { get_param: 'value' }, function(data) {
$.each(data.ips, function(index, element) { $.each(data.ips, function(index, element) {
//console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet: ['+element.subnet+'].'); //console.log('- entry: ['+index+'], on: ['+element.on+'], address: ['+element.address+'], subnet_mask: ['+element.subnet_mask+'].');
//console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].'); //console.log('- gateway: ['+element.gateway+'], dns: ['+element.dns+'], default gateway: ['+element.default_gateway+'].');
}); });
}); });

@ -73,9 +73,26 @@ selinux --permissive
%packages %packages
@^minimal-environment @^minimal-environment
alteeve-el8-repo alteeve-el8-repo
createrepo
dhcp-server
firefox
gcc
gdm
gnome-terminal
httpd
nmap
perl-CGI
perl-CGI-Carp
perl-Data-Dumper
perl-interpreter perl-interpreter
perl-NetAddr-IP
postgresql-server
rsync rsync
syslinux
syslinux-nonlinux
tftp-server
vim vim
virt-manager
%end %end

@ -1254,6 +1254,7 @@ Failed to generate an RSA public key for the user: [#!variable!user!#]. The outp
<key name="error_0102">Failed to check the existence and size of the file: [#!variable!file!#] on the target: [#!variable!target!#] as: [#!variable!remote_user!#]. The error (if any) was: [#!variable!error!#] and the output (if any) was: [#!variable!output!#].</key> <key name="error_0102">Failed to check the existence and size of the file: [#!variable!file!#] on the target: [#!variable!target!#] as: [#!variable!remote_user!#]. The error (if any) was: [#!variable!error!#] and the output (if any) was: [#!variable!output!#].</key>
<key name="error_0103">The file: [#!variable!file!#] wasn't found.</key> <key name="error_0103">The file: [#!variable!file!#] wasn't found.</key>
<key name="error_0104">The parameter get_company_from_oui->mac must be a valid MAC address or be in the format 'xx:xx:xx'. Received: [#!variable!mac!#].</key> <key name="error_0104">The parameter get_company_from_oui->mac must be a valid MAC address or be in the format 'xx:xx:xx'. Received: [#!variable!mac!#].</key>
<key name="error_0105">The file: [#!variable!file!#] was not found.</key>
<!-- These are units, words and so on used when displaying information. --> <!-- These are units, words and so on used when displaying information. -->
<key name="unit_0001">Yes</key> <key name="unit_0001">Yes</key>

@ -273,7 +273,7 @@ sub reconfigure_network
my $this_network = $network_type.$network_count; my $this_network = $network_type.$network_count;
my $link1_key = $this_network."_link1_mac_to_set"; my $link1_key = $this_network."_link1_mac_to_set";
my $link2_key = $this_network."_link2_mac_to_set"; my $link2_key = $this_network."_link2_mac_to_set";
my $subnet_key = $this_network."_subnet"; my $subnet_mask_key = $this_network."_subnet_mask";
my $ip_key = $this_network."_ip"; my $ip_key = $this_network."_ip";
my $is_gateway = $this_network eq $gateway_interface ? 1 : 0; my $is_gateway = $this_network eq $gateway_interface ? 1 : 0;
my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value}; my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
@ -289,7 +289,7 @@ sub reconfigure_network
link2_mac => $link2_mac, link2_mac => $link2_mac,
old_link1_iface => $old_link1_iface, old_link1_iface => $old_link1_iface,
old_link2_iface => $old_link2_iface, old_link2_iface => $old_link2_iface,
subnet_key => $subnet_key, subnet_mask_key => $subnet_mask_key,
this_network => $this_network, this_network => $this_network,
}}); }});
@ -313,11 +313,11 @@ sub reconfigure_network
next; next;
} }
my $ip = $anvil->data->{variables}{form}{config_step2}{$ip_key}{value}; my $ip = $anvil->data->{variables}{form}{config_step2}{$ip_key}{value};
my $subnet = $anvil->data->{variables}{form}{config_step2}{$subnet_key}{value}; my $subnet_mask = $anvil->data->{variables}{form}{config_step2}{$subnet_mask_key}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
# Are we building bonded interfaces? # Are we building bonded interfaces?
@ -347,7 +347,7 @@ sub reconfigure_network
$interface_prefix = "IFN"; $interface_prefix = "IFN";
} }
my $say_defroute = $is_gateway ? "yes" : "no"; my $say_defroute = $is_gateway ? "yes" : "no";
my $cidr = $anvil->Convert->cidr({subnet => $subnet}); my $cidr = $anvil->Convert->cidr({subnet_mask => $subnet_mask});
my $bond_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Bond_1"; my $bond_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Bond_1";
my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1"; my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1";
my $new_link2_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_2"; my $new_link2_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_2";
@ -400,7 +400,7 @@ sub reconfigure_network
$bond_config .= "IPV6INIT=\"no\"\n"; $bond_config .= "IPV6INIT=\"no\"\n";
$bond_config .= "ONBOOT=\"yes\"\n"; $bond_config .= "ONBOOT=\"yes\"\n";
$bond_config .= "IPADDR=\"".$ip."\"\n"; $bond_config .= "IPADDR=\"".$ip."\"\n";
$bond_config .= $cidr ? "PREFIX=\"".$cidr."\"\n" : "NETMASK=\"".$subnet."\"\n"; $bond_config .= $cidr ? "PREFIX=\"".$cidr."\"\n" : "NETMASK=\"".$subnet_mask."\"\n";
if ($is_gateway) if ($is_gateway)
{ {
$bond_config .= "GATEWAY=\"".$gateway."\"\n"; $bond_config .= "GATEWAY=\"".$gateway."\"\n";
@ -572,7 +572,7 @@ sub reconfigure_network
$interface_prefix = "IFN"; $interface_prefix = "IFN";
} }
my $say_defroute = $is_gateway ? "yes" : "no"; my $say_defroute = $is_gateway ? "yes" : "no";
my $cidr = $anvil->Convert->cidr({subnet => $subnet}); my $cidr = $anvil->Convert->cidr({subnet_mask => $subnet_mask});
my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1"; my $new_link1_file = $anvil->data->{path}{directories}{ifcfg}."/ifcfg-".$interface_prefix."_".$network_count."_-_Link_1";
my $old_link1_file = $new_link1_file; my $old_link1_file = $new_link1_file;
my $new_link1_iface = $say_interface."_link1"; my $new_link1_iface = $say_interface."_link1";
@ -602,7 +602,7 @@ sub reconfigure_network
$link1_config .= "IPV6INIT=\"no\"\n"; $link1_config .= "IPV6INIT=\"no\"\n";
$link1_config .= "ONBOOT=\"yes\"\n"; $link1_config .= "ONBOOT=\"yes\"\n";
$link1_config .= "IPADDR=\"".$ip."\"\n"; $link1_config .= "IPADDR=\"".$ip."\"\n";
$link1_config .= $cidr ? "PREFIX=\"".$cidr."\"\n" : "NETMASK=\"".$subnet."\"\n"; $link1_config .= $cidr ? "PREFIX=\"".$cidr."\"\n" : "NETMASK=\"".$subnet_mask."\"\n";
if ($is_gateway) if ($is_gateway)
{ {
$link1_config .= "GATEWAY=\"".$gateway."\"\n"; $link1_config .= "GATEWAY=\"".$gateway."\"\n";

@ -247,15 +247,15 @@ sub find_file
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{'local'}{interface}})
{ {
next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip}; next if not $anvil->data->{network}{'local'}{interface}{$interface}{ip};
next if not $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; next if not $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
my $ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; my $ip = $anvil->data->{network}{'local'}{interface}{$interface}{ip};
my $subnet = $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
my $network = $anvil->Network->get_network({ip => $ip, subnet => $subnet}); my $network = $anvil->Network->get_network({ip => $ip, subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:interface' => $interface, 's1:interface' => $interface,
's2:ip' => $ip, 's2:ip' => $ip,
's3:subnet' => $subnet, 's3:subnet_mask' => $subnet_mask,
's4:network' => $network, 's4:network' => $network,
}}); }});
my $type = "other"; my $type = "other";
@ -269,21 +269,21 @@ sub find_file
's2:sort' => $sort, 's2:sort' => $sort,
}}); }});
} }
$anvil->data->{local_ip}{by_network}{$network}{type} = $type; $anvil->data->{local_ip}{by_network}{$network}{type} = $type;
$anvil->data->{local_ip}{by_network}{$network}{'sort'} = $sort; $anvil->data->{local_ip}{by_network}{$network}{'sort'} = $sort;
$anvil->data->{local_ip}{by_network}{$network}{interface} = $interface; $anvil->data->{local_ip}{by_network}{$network}{interface} = $interface;
$anvil->data->{local_ip}{by_network}{$network}{ip} = $ip; $anvil->data->{local_ip}{by_network}{$network}{ip} = $ip;
$anvil->data->{local_ip}{by_network}{$network}{subnet} = $subnet; $anvil->data->{local_ip}{by_network}{$network}{subnet_mask} = $subnet_mask;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"s1:local_ip::by_network::${network}::type" => $anvil->data->{local_ip}{by_network}{$network}{type}, "s1:local_ip::by_network::${network}::type" => $anvil->data->{local_ip}{by_network}{$network}{type},
"s1:local_ip::by_network::${network}::sort" => $anvil->data->{local_ip}{by_network}{$network}{'sort'}, "s1:local_ip::by_network::${network}::sort" => $anvil->data->{local_ip}{by_network}{$network}{'sort'},
"s2:local_ip::by_network::${network}::interface" => $anvil->data->{local_ip}{by_network}{$network}{interface}, "s2:local_ip::by_network::${network}::interface" => $anvil->data->{local_ip}{by_network}{$network}{interface},
"s3:local_ip::by_network::${network}::ip" => $anvil->data->{local_ip}{by_network}{$network}{ip}, "s3:local_ip::by_network::${network}::ip" => $anvil->data->{local_ip}{by_network}{$network}{ip},
"s4:local_ip::by_network::${network}::subnet" => $anvil->data->{local_ip}{by_network}{$network}{subnet}, "s4:local_ip::by_network::${network}::subnet_mask" => $anvil->data->{local_ip}{by_network}{$network}{subnet_mask},
}}); }});
} }
# Create a hash we can sort through that are on the same subnet as us. # Create a hash we can sort through that are on the same subnet_mask as us.
my $query = " my $query = "
SELECT SELECT
a.host_uuid, a.host_uuid,
@ -360,7 +360,7 @@ AND
{ {
my $ip_address_address = $row->[0]; my $ip_address_address = $row->[0];
my $ip_address_subnet_mask = $row->[1]; my $ip_address_subnet_mask = $row->[1];
my $network = $anvil->Network->get_network({ip => $ip_address_address, subnet => $ip_address_subnet_mask}); my $network = $anvil->Network->get_network({ip => $ip_address_address, subnet_mask => $ip_address_subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_address_address => $ip_address_address, ip_address_address => $ip_address_address,
ip_address_subnet_mask => $ip_address_subnet_mask, ip_address_subnet_mask => $ip_address_subnet_mask,

@ -121,11 +121,11 @@ sub check_initial_setup
} }
push @{$needed_zones}, $zone; push @{$needed_zones}, $zone;
$anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip} = $anvil->data->{network}{'local'}{interface}{$interface}{ip}; $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip} = $anvil->data->{network}{'local'}{interface}{$interface}{ip};
$anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet} = $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask} = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
"firewall::zone::${zone}::interface::${interface}::ip" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip}, "firewall::zone::${zone}::interface::${interface}::ip" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{ip},
"firewall::zone::${zone}::interface::${interface}::subnet" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet}, "firewall::zone::${zone}::interface::${interface}::subnet_mask" => $anvil->data->{firewall}{zone}{$zone}{interface}{$interface}{subnet_mask},
}}); }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {

@ -49,8 +49,8 @@ sub update_network
$anvil->Network->get_ips({debug => 3}); $anvil->Network->get_ips({debug => 3});
# We'll read through '/sys/class/net' looking for network interfaces. # We'll read through '/sys/class/net' looking for network interfaces.
# * 'network::local::interface::<iface_name>::ip' - If an IP address is set # * 'network::local::interface::<iface_name>::ip' - If an IP address is set
# * 'network::local::interface::<iface_name>::subnet' - If an IP is set # * 'network::local::interface::<iface_name>::subnet_mask' - If an IP is set
my $directory = "/sys/class/net"; my $directory = "/sys/class/net";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { directory => $directory }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { directory => $directory }});
@ -125,9 +125,9 @@ sub update_network
# Explicitly check for the existing of the hash so that we don't auto-vivivate the interface. # Explicitly check for the existing of the hash so that we don't auto-vivivate the interface.
if (exists $anvil->data->{network}{'local'}{interface}{$interface}) if (exists $anvil->data->{network}{'local'}{interface}{$interface})
{ {
$ip_address = defined $anvil->data->{network}{'local'}{interface}{$interface}{ip} ? $anvil->data->{network}{'local'}{interface}{$interface}{ip} : ""; $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} : ""; $subnet_mask = defined $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} ? $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} : "";
$type = defined $anvil->data->{network}{'local'}{interface}{$interface}{type} ? $anvil->data->{network}{'local'}{interface}{$interface}{type} : "interface"; $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 => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
ip_address => $ip_address, ip_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,
@ -317,7 +317,7 @@ sub update_network
$anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect} = $primary_reselect; $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect} = $primary_reselect;
$anvil->data->{network}{'local'}{interface}{$interface}{primary_slave} = $primary_slave; $anvil->data->{network}{'local'}{interface}{$interface}{primary_slave} = $primary_slave;
$anvil->data->{network}{'local'}{interface}{$interface}{speed} = $speed; $anvil->data->{network}{'local'}{interface}{$interface}{speed} = $speed;
$anvil->data->{network}{'local'}{interface}{$interface}{subnet} = $subnet_mask; $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask} = $subnet_mask;
$anvil->data->{network}{'local'}{interface}{$interface}{type} = $type; $anvil->data->{network}{'local'}{interface}{$interface}{type} = $type;
$anvil->data->{network}{'local'}{interface}{$interface}{up_delay} = $up_delay; $anvil->data->{network}{'local'}{interface}{$interface}{up_delay} = $up_delay;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
@ -338,7 +338,7 @@ sub update_network
"network::local::interface::${interface}::primary_reselect" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect}, "network::local::interface::${interface}::primary_reselect" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect},
"network::local::interface::${interface}::primary_slave" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_slave}, "network::local::interface::${interface}::primary_slave" => $anvil->data->{network}{'local'}{interface}{$interface}{primary_slave},
"network::local::interface::${interface}::speed" => $anvil->data->{network}{'local'}{interface}{$interface}{speed}, "network::local::interface::${interface}::speed" => $anvil->data->{network}{'local'}{interface}{$interface}{speed},
"network::local::interface::${interface}::subnet" => $anvil->data->{network}{'local'}{interface}{$interface}{subnet}, "network::local::interface::${interface}::subnet_mask" => $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask},
"network::local::interface::${interface}::type" => $anvil->data->{network}{'local'}{interface}{$interface}{type}, "network::local::interface::${interface}::type" => $anvil->data->{network}{'local'}{interface}{$interface}{type},
"network::local::interface::${interface}::up_delay" => $anvil->data->{network}{'local'}{interface}{$interface}{up_delay}, "network::local::interface::${interface}::up_delay" => $anvil->data->{network}{'local'}{interface}{$interface}{up_delay},
}}); }});
@ -380,7 +380,7 @@ sub update_network
my $primary_reselect = $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect}; my $primary_reselect = $anvil->data->{network}{'local'}{interface}{$interface}{primary_reselect};
my $primary_slave = $anvil->data->{network}{'local'}{interface}{$interface}{primary_slave}; my $primary_slave = $anvil->data->{network}{'local'}{interface}{$interface}{primary_slave};
my $speed = $anvil->data->{network}{'local'}{interface}{$interface}{speed}; my $speed = $anvil->data->{network}{'local'}{interface}{$interface}{speed};
my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet}; my $subnet_mask = $anvil->data->{network}{'local'}{interface}{$interface}{subnet_mask};
my $up_delay = $anvil->data->{network}{'local'}{interface}{$interface}{up_delay}; my $up_delay = $anvil->data->{network}{'local'}{interface}{$interface}{up_delay};
my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway}; my $default_gateway = $anvil->data->{network}{'local'}{interface}{$interface}{default_gateway};
my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway}; my $gateway = $anvil->data->{network}{'local'}{interface}{$interface}{gateway};
@ -838,8 +838,8 @@ WHERE
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, 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"; $network_json .= " { \"address\":\"$ip_address_address\", \"on\":\"$say_on\", \"subnet_mask\":\"$ip_address_subnet_mask\", \"gateway\":\"$ip_address_gateway\", \"default_gateway\":\"$ip_address_default_gateway\", \"dns\":\"$ip_address_dns\" },\n";
$network_xml .= " <ip 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"; $network_xml .= " <ip address=\"$ip_address_address\" on=\"$say_on\" subnet_mask=\"$ip_address_subnet_mask\" gateway=\"$ip_address_gateway\" default_gateway=\"$ip_address_default_gateway\" dns=\"$ip_address_dns\" />\n";
} }
# Now verify that the interface is connected to this bridge # Now verify that the interface is connected to this bridge

@ -457,25 +457,25 @@ sub setup_boot_environment
$anvil->nice_exit({code => 2}); $anvil->nice_exit({code => 2});
} }
my $bcn_ip = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{ip}; my $bcn_ip = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{ip};
my $bcn_subnet = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{subnet}; my $bcn_subnet_mask = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{subnet_mask};
my $bcn_network = $anvil->Network->get_network({ip => $bcn_ip, subnet => $bcn_subnet}); my $bcn_network = $anvil->Network->get_network({ip => $bcn_ip, subnet_mask => $bcn_subnet_mask});
my $dns = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} ? $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} : $anvil->data->{defaults}{network}{dns}; my $dns = $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} ? $anvil->data->{network}{'local'}{interface}{$bcn_interface}{dns} : $anvil->data->{defaults}{network}{dns};
my $domain = "localdomain"; my $domain = "localdomain";
my $base_url = "http://".$bcn_ip."/".$anvil->data->{host_os}{os_type}."/".$anvil->data->{host_os}{os_arch}; my $base_url = "http://".$bcn_ip."/".$anvil->data->{host_os}{os_type}."/".$anvil->data->{host_os}{os_arch};
if ($anvil->_host_name =~ /\./) if ($anvil->_host_name =~ /\./)
{ {
$domain = $anvil->_host_name; $domain = $anvil->_host_name;
$domain =~ s/^.*?\.//; $domain =~ s/^.*?\.//;
} }
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
bcn_interface => $bcn_interface, bcn_interface => $bcn_interface,
bcn_ip => $bcn_ip, bcn_ip => $bcn_ip,
bcn_subnet => $bcn_subnet, bcn_subnet_mask => $bcn_subnet_mask,
bcn_network => $bcn_network, bcn_network => $bcn_network,
dns => $dns, dns => $dns,
domain => $domain, domain => $domain,
base_url => $base_url, base_url => $base_url,
}}); }});
### NOTE: The DNS range is a bit tricky, so for now, we'll assume that the BCN is always a /16 ### NOTE: The DNS range is a bit tricky, so for now, we'll assume that the BCN is always a /16

@ -189,28 +189,28 @@ sub scan
# 'bcnX', 'snX', 'snX', find the network on the appropriate interfaces and use it's network. # 'bcnX', 'snX', 'snX', find the network on the appropriate interfaces and use it's network.
if ($anvil->data->{switches}{network} =~ /^(\d+.*?)\/(\d+.*)$/) if ($anvil->data->{switches}{network} =~ /^(\d+.*?)\/(\d+.*)$/)
{ {
my $ip = $1; my $ip = $1;
my $subnet = $2; my $subnet_mask = $2;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::network" => $anvil->data->{switches}{network} }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::network" => $anvil->data->{switches}{network} }});
my $ip_valid = $anvil->Validate->is_ipv4({ip => $ip}); my $ip_valid = $anvil->Validate->is_ipv4({ip => $ip});
my $subnet_valid = $anvil->Validate->is_ipv4({ip => $subnet}); my $subnet_mask_valid = $anvil->Validate->is_ipv4({ip => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip_valid => $ip_valid, ip_valid => $ip_valid,
subnet_valid => $subnet_valid, subnet_mask_valid => $subnet_mask_valid,
}}); }});
if (not $subnet_valid) if (not $subnet_mask_valid)
{ {
# Migt be cidr # Migt be cidr
if (($subnet =~ /^\d+$/) && ($subnet >= 0) && ($subnet <= 32)) if (($subnet_mask =~ /^\d+$/) && ($subnet_mask >= 0) && ($subnet_mask <= 32))
{ {
# Valid CIDR address # Valid CIDR address
$subnet_valid = 1; $subnet_mask_valid = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { subnet_valid => $subnet_valid }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { subnet_mask_valid => $subnet_mask_valid }});
} }
} }
if ((not $ip_valid) or (not $subnet_valid)) if ((not $ip_valid) or (not $subnet_mask_valid))
{ {
# Bail out. # Bail out.
update_progress($anvil, 100, "error_0097,!!range!".$anvil->data->{switches}{network}."!!"); update_progress($anvil, 100, "error_0097,!!range!".$anvil->data->{switches}{network}."!!");
@ -231,26 +231,26 @@ sub scan
my $to_scan = []; my $to_scan = [];
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$target}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$target}{interface}})
{ {
my $ip = $anvil->data->{network}{$target}{interface}{$interface}{ip}; my $ip = $anvil->data->{network}{$target}{interface}{$interface}{ip};
my $subnet = $anvil->data->{network}{$target}{interface}{$interface}{subnet}; my $subnet_mask = $anvil->data->{network}{$target}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
if (($ip) && ($subnet)) if (($ip) && ($subnet_mask))
{ {
# Is this one we're interested in? # Is this one we're interested in?
my $network_name = $anvil->data->{switches}{network}; my $network_name = $anvil->data->{switches}{network};
if ($interface =~ /^$network_name/) if ($interface =~ /^$network_name/)
{ {
# Yup! # Yup!
my $network = $anvil->Network->get_network({ip => $ip, subnet => $subnet}); my $network = $anvil->Network->get_network({ip => $ip, subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }});
if ($network) if ($network)
{ {
# Scan it. # Scan it.
my $address = $network."/".$subnet; my $address = $network."/".$subnet_mask;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { address => $address }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { address => $address }});
push @{$to_scan}, $address; push @{$to_scan}, $address;
} }
@ -273,21 +273,21 @@ sub scan
my $to_scan = []; my $to_scan = [];
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$target}{interface}}) foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{network}{$target}{interface}})
{ {
my $ip = $anvil->data->{network}{$target}{interface}{$interface}{ip}; my $ip = $anvil->data->{network}{$target}{interface}{$interface}{ip};
my $subnet = $anvil->data->{network}{$target}{interface}{$interface}{subnet}; my $subnet_mask = $anvil->data->{network}{$target}{interface}{$interface}{subnet_mask};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
if (($ip) && ($subnet)) if (($ip) && ($subnet_mask))
{ {
my $network = $anvil->Network->get_network({ip => $ip, subnet => $subnet}); my $network = $anvil->Network->get_network({ip => $ip, subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }});
if ($network) if ($network)
{ {
# Scan it. # Scan it.
my $address = $network."/".$subnet; my $address = $network."/".$subnet_mask;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { address => $address }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { address => $address }});
push @{$to_scan}, $address; push @{$to_scan}, $address;
} }
@ -325,15 +325,15 @@ sub call_nmap
my ($anvil, $address) = @_; my ($anvil, $address) = @_;
# The subnet can't be dotted decimal, so convert it to CIDR notation, if needed. # The subnet can't be dotted decimal, so convert it to CIDR notation, if needed.
my ($ip, $subnet) = ($address =~ /^(\d+.*?)\/(\d.*)$/); my ($ip, $subnet_mask) = ($address =~ /^(\d+.*?)\/(\d.*)$/);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip => $ip, ip => $ip,
subnet => $subnet, subnet_mask => $subnet_mask,
}}); }});
if ($anvil->Validate->is_ipv4({ip => $subnet})) if ($anvil->Validate->is_ipv4({ip => $subnet_mask}))
{ {
# Convert to CIDR # Convert to CIDR
my $cidr = $anvil->Convert->cidr({subnet => $subnet}); my $cidr = $anvil->Convert->cidr({subnet_mask => $subnet_mask});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cidr => $cidr }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { cidr => $cidr }});
if (($cidr >= 0) && ($cidr <= 32)) if (($cidr >= 0) && ($cidr <= 32))
@ -418,6 +418,7 @@ sub call_nmap
{ {
# Parse error # Parse error
$anvil->data->{progress} += 2; $anvil->data->{progress} += 2;
$section =~ s/\n//g;
update_progress($anvil, $anvil->data->{progress}, "log_0444,!!ip!".$this_ip."!!,!!mac!".$this_mac."!!,!!section!".$section."!!"); update_progress($anvil, $anvil->data->{progress}, "log_0444,!!ip!".$this_ip."!!,!!mac!".$this_mac."!!,!!section!".$section."!!");
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0444", variables => { $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "alert", key => "log_0444", variables => {
ip => $this_ip, ip => $this_ip,

Loading…
Cancel
Save