@ -1147,6 +1152,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<keyname="job_0068">Adding the database connection information for the dashboard: [#!variable!host_name!#] to the target's anvil.conf file.</key>
<keyname="job_0069">Unable to find a matching network, skipping this database.</key>
<keyname="job_0070">Something went wrong adding this database. Please see: [#!data!path::log::main!#] for details.</key>
<keyname="job_0071">The network configuration will be updated based on the variables stored in the database. When complete, the system will reboot.</key>
<!-- Warnings -->
<keyname="warning_0001">The IP address will change. You will need to reconnect after applying these changes.</key>
@ -57,11 +55,11 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->nice_exit({exit_code => 2});
}
pickup_job_details($anvil);
# Set maintenance mode
$anvil->System->maintenance_mode({set => 1});
pickup_job_details($anvil);
my ($reboot_needed) = reconfigure_network($anvil);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, list => { reboot_needed => $reboot_needed }});
@ -114,16 +112,14 @@ sub update_passwords
{
my ($anvil) = @_;
# Is this a striker dashboard, node or DR host?
my $type = $anvil->System->get_host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => { type => $type }});
if ($type eq "dashboard")
# Have we been asked to set a password?
$anvil->data->{variables}{form}{config_step2}{striker_password}{value} = "" if not defined $anvil->data->{variables}{form}{config_step2}{striker_password}{value};
if ($anvil->data->{variables}{form}{config_step2}{striker_password}{value})
{
# Set the passwords
my $password = $anvil->data->{variables}{form}{config_step2}{striker_password}{value};
my $temp_file = "/tmp/anvil-".$anvil->Get->uuid;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 1, list => { password => $password }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, secure => 1, list => { password => $password }});
# Write the password into a temporary file.
my $error = $anvil->Storage->write_file({
@ -162,17 +158,6 @@ sub update_passwords
}
}
}
else
{
if ($type eq "node")
{
# We'll need to update pcsd's password as well.
}
# Set passwords that are common to nodes and DR hosts.
}
$anvil->Job->update_progress({
progress => 95,
@ -188,59 +173,93 @@ sub reconfigure_network
my ($anvil) = @_;
my $reboot_needed = 0;
my $prefix = $anvil->data->{variables}{form}{config_step1}{prefix}{value};
my $sequence = $anvil->data->{variables}{form}{config_step1}{sequence}{value};
my $domain = $anvil->data->{variables}{form}{config_step1}{domain}{value};
my $organization = $anvil->data->{variables}{form}{config_step1}{organization}{value};
my $bcn_count = 1; # TODO: This should be coming from the form, even though it's only '1' for now.
my $sn_count = 0; # TODO: This should be coming from the form, even though it's always '0' for Strikers.
my $ifn_count = $anvil->data->{variables}{form}{config_step1}{ifn_count}{value};
my $new_host_name = defined $anvil->data->{variables}{form}{config_step2}{host_name}{value} ? $anvil->data->{variables}{form}{config_step2}{host_name}{value} : $prefix."-striker".sprintf("%02d", $sequence).".".$domain;
my $pretty_host_name = $organization." - Striker ".sprintf("%02d", $sequence);
my $prefix = exists $anvil->data->{variables}{form}{config_step1}{prefix}{value} ? $anvil->data->{variables}{form}{config_step1}{prefix}{value} : "";
my $sequence = exists $anvil->data->{variables}{form}{config_step1}{sequence}{value} ? $anvil->data->{variables}{form}{config_step1}{sequence}{value} : "";
my $domain = exists $anvil->data->{variables}{form}{config_step1}{domain}{value} ? $anvil->data->{variables}{form}{config_step1}{domain}{value} : "";
my $organization = exists $anvil->data->{variables}{form}{config_step1}{organization}{value} ? $anvil->data->{variables}{form}{config_step1}{organization}{value} : "";
my $bcn_count = exists $anvil->data->{variables}{form}{config_step1}{bcn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{bcn_count}{value} : 1;
my $sn_count = exists $anvil->data->{variables}{form}{config_step1}{sn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{sn_count}{value} : 0;
my $ifn_count = exists $anvil->data->{variables}{form}{config_step1}{ifn_count}{value} ? $anvil->data->{variables}{form}{config_step1}{ifn_count}{value} : 1;
my $new_host_name = exists $anvil->data->{variables}{form}{config_step2}{host_name}{value} ? $anvil->data->{variables}{form}{config_step2}{host_name}{value} : "";
my $type = $anvil->System->get_host_type();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, list => {
my $dns = defined $anvil->data->{variables}{form}{config_step2}{dns}{value} ? [split/,/, $anvil->data->{variables}{form}{config_step2}{dns}{value}] : [];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, 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} : "";
@ -275,22 +294,26 @@ sub reconfigure_network
my $link2_key = $this_network."_link2_mac_to_set";
my $subnet_mask_key = $this_network."_subnet_mask";
my $ip_key = $this_network."_ip";
my $is_gateway = $this_network eq $gateway_interface ? 1 : 0;
my $bridge_key = $this_network."_create_bridge";
my $link1_mac = $anvil->data->{variables}{form}{config_step2}{$link1_key}{value};
my $link2_mac = defined $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$link2_key}{value} : "";
my $old_link1_iface = $anvil->data->{sys}{mac}{$link1_mac}{iface} ? $anvil->data->{sys}{mac}{$link1_mac}{iface} : "";
my $old_link2_iface = defined $anvil->data->{sys}{mac}{$link2_mac}{iface} ? $anvil->data->{sys}{mac}{$link2_mac}{iface} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
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 $old_link1_iface = $anvil->data->{sys}{mac}{$link1_mac}{iface} ? $anvil->data->{sys}{mac}{$link1_mac}{iface} : "";
my $old_link2_iface = defined $anvil->data->{sys}{mac}{$link2_mac}{iface} ? $anvil->data->{sys}{mac}{$link2_mac}{iface} : "";
my $bridge = defined $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$bridge_key}{value} : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip_key => $ip_key,
is_gateway => $is_gateway,
link1_key => $link1_key,
link1_mac => $link1_mac,
link2_key => $link2_key,
link2_mac => $link2_mac,
bridge_key => $bridge_key,
old_link1_iface => $old_link1_iface,
old_link2_iface => $old_link2_iface,
subnet_mask_key => $subnet_mask_key,
this_network => $this_network,
bridge => $bridge,
}});
# Skip if this doesn't exist or isn't a valid IPv4 address.
@ -301,9 +324,11 @@ sub reconfigure_network
}
else
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "variables::form::config_step2::${ip_key}::value" => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "variables::form::config_step2::${ip_key}::value" => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value} }});
}
if (($anvil->data->{variables}{form}{config_step2}{$ip_key}{value}) and (not $anvil->Validate->is_ipv4({ip => $anvil->data->{variables}{form}{config_step2}{$ip_key}{value}})))
if (($anvil->data->{variables}{form}{config_step2}{$ip_key}{value}) &&
($anvil->data->{variables}{form}{config_step2}{$ip_key}{value} ne "dhcp") &&
my $ip = $anvil->data->{variables}{form}{config_step2}{$ip_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 => {
ip => $ip,
# 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 $subnet_mask = defined $anvil->data->{variables}{form}{config_step2}{$subnet_mask_key}{value} ? $anvil->data->{variables}{form}{config_step2}{$subnet_mask_key}{value} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
ip_address => $ip_address,
subnet_mask => $subnet_mask,
}});
# Are we building bonded interfaces?
if ($anvil->Validate->is_mac({mac => $link2_mac}))
{
### TODO: Handle when bridges exist. Detect when the host is a node and/or have a "use as bridge" option?