* Created new anvil-monitor-network daemon to trigger scan-server via
anvil-monitor-network on network events.
* Moved functionality into scan-network
Signed-off-by: digimer <mkelly@alteeve.ca>
$anvil->data->{variables}{form}{config_step2}{striker_password}{value} = "" if not defined $anvil->data->{variables}{form}{config_step2}{striker_password}{value};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => {
if ($anvil->data->{variables}{form}{config_step2}{striker_password}{value})
my $password = $anvil->data->{variables}{form}{config_step2}{striker_password}{value};
my $password = $anvil->data->{config}{striker_password};
my $temp_file = "/tmp/anvil-".$anvil->Get->uuid;
my $temp_file = "/tmp/anvil-".$anvil->Get->uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { password => $password }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { password => $password }});
@ -235,17 +237,17 @@ sub reconfigure_network
{
{
my ($anvil) = @_;
my ($anvil) = @_;
my $local_host = $anvil->Get->short_host_name();
my $reboot_needed = 0;
my $reboot_needed = 0;
my $prefix = exists $anvil->data->{variables}{form}{config_step1}{prefix}{value} ? $anvil->data->{variables}{form}{config_step1}{prefix}{value} : "";
my $local_host = $anvil->Get->short_host_name();
my $sequence = exists $anvil->data->{variables}{form}{config_step1}{sequence}{value} ? $anvil->data->{variables}{form}{config_step1}{sequence}{value} : "";
my $prefix = $anvil->data->{config}{prefix};
my $domain = exists $anvil->data->{variables}{form}{config_step1}{domain}{value} ? $anvil->data->{variables}{form}{config_step1}{domain}{value} : "";
my $sequence = $anvil->data->{config}{sequence};
my $organization = exists $anvil->data->{variables}{form}{config_step1}{organization}{value} ? $anvil->data->{variables}{form}{config_step1}{organization}{value} : "";
my $domain = $anvil->data->{config}{domain};
my $bcn_count = exists $anvil->data->{variables}{form}{config_step1}{bcn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{bcn_count}{value} : 1;
my $new_host_name = $anvil->data->{config}{host_name};
my $sn_count = exists $anvil->data->{variables}{form}{config_step1}{sn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{sn_count}{value} : 0;
my $organization = $anvil->data->{config}{organization};
my $mn_count = exists $anvil->data->{variables}{form}{config_step1}{mn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{mn_count}{value} : 0;
my $bcn_count = $anvil->data->{config}{bcn_count};
my $ifn_count = exists $anvil->data->{variables}{form}{config_step1}{ifn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{ifn_count}{value} : 1;
my $ifn_count = $anvil->data->{config}{ifn_count};
my $new_host_name = exists $anvil->data->{variables}{form}{config_step2}{host_name}{value} ? $anvil->data->{variables}{form}{config_step2}{host_name}{value} : "";
my $sn_count = $anvil->data->{config}{sn_count};
my $mn_count = $anvil->data->{config}{mn_count};
my $type = $anvil->Get->host_type();
my $type = $anvil->Get->host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
prefix => $prefix,
prefix => $prefix,
@ -260,18 +262,6 @@ sub reconfigure_network
type => $type,
type => $type,
}});
}});
# Clear the network mapping flag.
$anvil->Database->insert_or_update_variables({
debug => 2,
variable_name => "config::map_network",
variable_value => 0,
variable_default => "",
variable_description => "striker_0202",
variable_section => "config",
variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts",
});
# If we're configuring a dashboard and no host name was given, generate it.
# If we're configuring a dashboard and no host name was given, generate it.
if (($type eq "striker") && (not $new_host_name))
if (($type eq "striker") && (not $new_host_name))
{
{
@ -349,7 +339,7 @@ sub reconfigure_network
}
}
# Now configure the network.
# Now configure the network.
my $dns = defined $anvil->data->{variables}{form}{config_step2}{dns}{value} ? [split/,/, $anvil->data->{variables}{form}{config_step2}{dns}{value}] : [];
my $dns = $anvil->data->{config}{dns} ? [split/,/, $anvil->data->{config}{dns}] : [];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dns => $dns }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dns => $dns }});
for (my $i = 0; $i < @{$dns}; $i++)
for (my $i = 0; $i < @{$dns}; $i++)
{
{
@ -357,8 +347,8 @@ sub reconfigure_network
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "dns->[$i]" => $dns->[$i] }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "dns->[$i]" => $dns->[$i] }});
}
}
my $gateway = defined $anvil->data->{variables}{form}{config_step2}{gateway}{value} ? $anvil->data->{variables}{form}{config_step2}{gateway}{value} : "";
my $gateway = $anvil->data->{config}{gateway};
my $gateway_interface = defined $anvil->data->{variables}{form}{config_step2}{gateway_interface}{value} ? $anvil->data->{variables}{form}{config_step2}{gateway_interface}{value} : "";
my $gateway_interface = $anvil->data->{config}{gateway_interface};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
gateway => $gateway,
gateway => $gateway,
gateway_interface => $gateway_interface,
gateway_interface => $gateway_interface,
@ -384,7 +374,8 @@ sub reconfigure_network
{
{
my $ip_key = $network_type.$network_count."_ip";
my $ip_key = $network_type.$network_count."_ip";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ip_key => $ip_key }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ip_key => $ip_key }});
if ((exists $anvil->data->{variables}{form}{config_step2}{$ip_key}{value}) && ($anvil->data->{variables}{form}{config_step2}{$ip_key}{value} eq "dhcp"))
if ((exists $anvil->data->{config}{$ip_key}) && ($anvil->data->{config}{$ip_key} eq "dhcp"))
next if not exists $anvil->data->{variables}{form}{config_step2}{$link1_key};
next if not $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
next if not exists $anvil->data->{config}{$link1_key};
next if not $anvil->data->{config}{$link1_key};
my $link2_key = $this_network."_link2_mac_to_set";
my $link2_key = $this_network."_link2_mac_to_set";
my $subnet_mask_key = $this_network."_subnet_mask";
my $subnet_mask_key = $this_network."_subnet_mask";
my $ip_key = $this_network."_ip";
my $ip_key = $this_network."_ip";
my $bridge_key = $this_network."_create_bridge";
my $bridge_key = $this_network."_create_bridge";
my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
my $link1_mac = $anvil->data->{config}{$link1_key};
my $is_gateway = $this_network eq $gateway_interface ? 1 : 0;
my $is_gateway = $this_network eq $gateway_interface ? 1 : 0;
my $link2_mac = defined $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} : "";
my $link2_mac = defined $anvil->data->{config}{$link2_key} ? $anvil->data->{config}{$link2_key} : "";
my $old_link1_iface = $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} : "";
my $old_link1_iface = $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link1_mac}{interface} : "";
my $old_link2_iface = defined $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} : "";
my $old_link2_iface = defined $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} ? $anvil->data->{network}{$local_host}{mac_address}{$link2_mac}{interface} : "";
my $bridge = defined $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} : 0;
my $bridge = defined $anvil->data->{config}{$bridge_key} ? $anvil->data->{config}{$bridge_key} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip_key => $ip_key,
ip_key => $ip_key,
is_gateway => $is_gateway,
is_gateway => $is_gateway,
@ -572,30 +943,30 @@ ORDER BY
}
}
# Skip if this doesn't exist or isn't a valid IPv4 address.
# Skip if this doesn't exist or isn't a valid IPv4 address.
if (not exists $anvil->data->{variables}{form}{config_step2}{$ip_key}{value})
ip => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value},
ip => $anvil->data->{config}{$ip_key},
}});
}});
next;
next;
}
}
# The IP could be 'dhcp', we'll handle that in a bit.
# The IP could be 'dhcp', we'll handle that in a bit.
my $ip_address = $anvil->data->{variables}{form}{config_step2}{$ip_key}{value};
my $ip_address = $anvil->data->{config}{$ip_key};
my $subnet_mask = defined $anvil->data->{variables}{form}{config_step2}{$subnet_mask_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$subnet_mask_key}{value} : "";
my $subnet_mask = defined $anvil->data->{config}{$subnet_mask_key} ? $anvil->data->{config}{$subnet_mask_key} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
@ -58,10 +55,6 @@ elsif (($anvil->data->{switches}{'database-active'}) or ($anvil->data->{switches
{
{
update_database($anvil);
update_database($anvil);
}
}
elsif (($anvil->data->{switches}{'enable-network-mapping'}) or ($anvil->data->{switches}{'disable-network-mapping'}) or ($anvil->data->{switches}{'check-network-mapping'}))