* Renamed 'ip' to 'ip_address' in Striker->parse_all_status_json() and related functions.

* Got the menu for mapping a host's network displaying (much work still to be done).
* Updated the anvil.js funtion to run dependent on the page being shown. For the main menu, the json is now properly reread and display updated as json content changes.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 0b2439edc3
commit 0dfd2ddbf0
  1. 14
      Anvil/Tools/Striker.pm
  2. 13
      Anvil/Tools/System.pm
  3. 293
      cgi-bin/striker
  4. 150
      html/skins/alteeve/anvil.html
  5. 24
      html/skins/alteeve/anvil.js
  6. 6
      share/words.xml
  7. 4
      tools/striker-initialize-host
  8. 7
      tools/test.pl

@ -402,7 +402,7 @@ sub parse_all_status_json
foreach my $interface (sort {$a cmp $b} keys %{$match->{$short_name}}) foreach my $interface (sort {$a cmp $b} keys %{$match->{$short_name}})
{ {
$matched_interface = $interface; $matched_interface = $interface;
$matched_ip_address = $match->{$short_name}{$interface}{ip}; $matched_ip_address = $match->{$short_name}{$interface}{ip_address};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
matched_interface => $matched_interface, matched_interface => $matched_interface,
matched_ip_address => $matched_ip_address, matched_ip_address => $matched_ip_address,
@ -422,7 +422,8 @@ sub parse_all_status_json
{ {
my $interface_name = $interface_hash->{name}; my $interface_name = $interface_hash->{name};
my $interface_type = $interface_hash->{type}; my $interface_type = $interface_hash->{type};
my $ip = $interface_hash->{ip}; my $mac_address = $interface_hash->{mac_address};
my $ip_address = $interface_hash->{ip_address};
my $subnet_mask = $interface_hash->{subnet_mask}; my $subnet_mask = $interface_hash->{subnet_mask};
my $default_gateway = $interface_hash->{default_gateway}; my $default_gateway = $interface_hash->{default_gateway};
my $gateway = $interface_hash->{gateway}; my $gateway = $interface_hash->{gateway};
@ -430,7 +431,8 @@ sub parse_all_status_json
$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_name => $interface_name,
interface_type => $interface_type, interface_type => $interface_type,
ip => $ip, mac_address => $mac_address,
ip_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,
default_gateway => $default_gateway, default_gateway => $default_gateway,
gateway => $gateway, gateway => $gateway,
@ -446,7 +448,8 @@ sub parse_all_status_json
# Record the rest of the data. # Record the rest of the data.
$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}{uuid} = $interface_hash->{uuid};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mtu} = $interface_hash->{mtu}; $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mtu} = $interface_hash->{mtu};
$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}{mac_address} = $interface_hash->{mac_address};
$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{ip_address} = $interface_hash->{ip_address};
$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}{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}{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}{gateway} = $interface_hash->{gateway};
@ -454,7 +457,8 @@ sub parse_all_status_json
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { $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}::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}::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}::mac_address" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{mac_address},
"json::all_status::hosts::${host_name}::network_interface::${interface_type}::${interface_name}::ip_address" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{ip_address},
"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}::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}::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}::gateway" => $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{$interface_type}{$interface_name}{gateway},

@ -831,7 +831,7 @@ sub generate_state_json
my $configured = defined $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} ? $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} : 0; my $configured = defined $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} ? $anvil->data->{machine}{host_uuid}{$host_uuid}{variables}{'system::configured'} : 0;
my $ifaces_array = []; my $ifaces_array = [];
my $host = $short_host_name; my $host = $short_host_name;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"s1:host_name" => $host_name, "s1:host_name" => $host_name,
"s2:short_host_name" => $short_host_name, "s2:short_host_name" => $short_host_name,
"s3:host_type" => $host_type, "s3:host_type" => $host_type,
@ -882,7 +882,7 @@ sub generate_state_json
my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu}; 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 => 2, list => {
"s1:interface" => $interface, "s1:interface" => $interface,
"s2:mac_address" => $mac_address, "s2:mac_address" => $mac_address,
"s3:type" => $type, "s3:type" => $type,
@ -895,6 +895,7 @@ sub generate_state_json
$iface_hash->{type} = $type; $iface_hash->{type} = $type;
$iface_hash->{mtu} = $mtu; $iface_hash->{mtu} = $mtu;
$iface_hash->{uuid} = $uuid; $iface_hash->{uuid} = $uuid;
$iface_hash->{mac_address} = $mac_address;
if ($type eq "bridge") if ($type eq "bridge")
{ {
my $id = $anvil->data->{network}{$host}{interface}{$interface}{id}; my $id = $anvil->data->{network}{$host}{interface}{$interface}{id};
@ -1138,28 +1139,28 @@ sub generate_state_json
}; };
# Is there an IP on this interface? # Is there an IP on this interface?
my $ip = ""; my $ip_address = "";
my $subnet_mask = ""; my $subnet_mask = "";
my $default_gateway = 0; my $default_gateway = 0;
my $gateway = ""; my $gateway = "";
my $dns = ""; my $dns = "";
if ((exists $anvil->data->{network}{$host}{interface}{$interface}{ip}) && ($anvil->data->{network}{$host}{interface}{$interface}{ip})) if ((exists $anvil->data->{network}{$host}{interface}{$interface}{ip}) && ($anvil->data->{network}{$host}{interface}{$interface}{ip}))
{ {
$ip = $anvil->data->{network}{$host}{interface}{$interface}{ip}; $ip_address = $anvil->data->{network}{$host}{interface}{$interface}{ip};
$subnet_mask = $anvil->data->{network}{$host}{interface}{$interface}{subnet_mask}; $subnet_mask = $anvil->data->{network}{$host}{interface}{$interface}{subnet_mask};
$default_gateway = $anvil->data->{network}{$host}{interface}{$interface}{default_gateway}; $default_gateway = $anvil->data->{network}{$host}{interface}{$interface}{default_gateway};
$gateway = $anvil->data->{network}{$host}{interface}{$interface}{gateway}; $gateway = $anvil->data->{network}{$host}{interface}{$interface}{gateway};
$dns = $anvil->data->{network}{$host}{interface}{$interface}{dns}; $dns = $anvil->data->{network}{$host}{interface}{$interface}{dns};
} }
$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_address => $ip_address,
subnet_mask => $subnet_mask, subnet_mask => $subnet_mask,
default_gateway => $default_gateway, default_gateway => $default_gateway,
gateway => $gateway, gateway => $gateway,
dns => $dns, dns => $dns,
}}); }});
$iface_hash->{ip} = $ip; $iface_hash->{ip_address} = $ip_address;
$iface_hash->{subnet_mask} = $subnet_mask; $iface_hash->{subnet_mask} = $subnet_mask;
$iface_hash->{default_gateway} = $default_gateway; $iface_hash->{default_gateway} = $default_gateway;
$iface_hash->{gateway} = $gateway; $iface_hash->{gateway} = $gateway;

@ -718,74 +718,243 @@ sub process_prep_network
{ {
my ($anvil) = @_; my ($anvil) = @_;
my $host_name = defined $anvil->data->{cgi}{host_name}{value} ? $anvil->data->{cgi}{host_name}{value} : ""; # Do I know which machine we're configuring?
my $host_ip_address = defined $anvil->data->{cgi}{host_ip_address}{value} ? $anvil->data->{cgi}{host_ip_address}{value} : ""; if (not $anvil->data->{cgi}{host_uuid}{value})
my $host_password = defined $anvil->data->{cgi}{host_password}{value} ? $anvil->data->{cgi}{host_password}{value} : ""; {
my $confirm = defined $anvil->data->{cgi}{confirm}{value} ? $anvil->data->{cgi}{confirm}{value} : ""; # Nope, send the user back.
$anvil->data->{cgi}{task}{value} = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "cgi::task::value" => $anvil->data->{cgi}{task}{value} }});
process_anvil_menu($anvil);
}
# Pull the host's data out of the JSON file.
$anvil->Striker->parse_all_status_json();
my $host_name = "";
foreach my $host (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
host_name => $host_name, "cgi::host_uuid::value" => $anvil->data->{cgi}{host_uuid}{value},
host_ip_address => $host_ip_address, "json::all_status::hosts::${host}::host_uuid" => $anvil->data->{json}{all_status}{hosts}{$host}{host_uuid},
host_password => $anvil->Log->is_secure($host_password),
confirm => $confirm,
}}); }});
if ($anvil->data->{cgi}{host_uuid}{value} eq $anvil->data->{json}{all_status}{hosts}{$host}{host_uuid})
{
# Found it.
$host_name = $host;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_name => $host_name }});
last;
}
}
# We need to a pick a machine to initialize. if (not $host_name)
{
# Didn't find it.
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $anvil->Words->string({key => "striker_warning_0014", variables => { host_uuid => $anvil->data->{cgi}{host_uuid}{value} } }) }});
$anvil->data->{cgi}{task}{value} = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"cgi::task::value" => $anvil->data->{cgi}{task}{value},
"form::error_massage" => $anvil->data->{form}{error_massage},
}});
process_anvil_menu($anvil);
}
# Do I know which machine we're initializing yet? # How many actual interfaces do we have? We need at least six. For each two above that, we'll add an
if ($anvil->data->{cgi}{host_uuid}{value}) # additional bond option per network.
my $interfaces = {};
my $interface_options = [];
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{interface}})
{
# if any interfaces are called 'virbrX-nic', ignore it as it will be removed. Likewise, ignore any 'vnetX' devices.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface => $interface }});
if (($interface =~ /^virbr\d+-nic/) or ($interface =~ /^vnet\d+/))
{ {
# Yup, build the config page. # Ignore it.
next;
} }
else
# Store the mac used in the select box
my $mac_address = $anvil->data->{json}{all_status}{hosts}{$host_name}{network_interface}{interface}{$interface}{mac_address};
push @{$interface_options}, $mac_address."#!#".$mac_address." (".$interface.")";
# Store the mac address .
$interfaces->{$interface} = $mac_address;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "interfaces->{".$interface."}" => $interfaces->{$interface} }});
}
foreach my $interface (sort {$a cmp $b} keys %{$anvil->data->{interfaces}})
{ {
# Nope, show the list of unconfigured servers. }
$anvil->System->parse_status_json($anvil);
} # Get the interface count
my $interface_count = keys %{$interfaces};
# if ((not $anvil->data->{form}{body}) or ($anvil->data->{form}{error_massage})) $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface_count => $interface_count }});
# {
# my $node_checked = "checked"; if ($interface_count < 6)
# my $dr_checked = ""; {
# if ($type eq "dr") # Not enough interfaces.
# { $anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $anvil->Words->string({key => "striker_warning_0015", variables => { interface_count => $interface_count } }) }});
# $node_checked = ""; $anvil->data->{cgi}{task}{value} = "";
# $dr_checked = "checked"; $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# } "cgi::task::value" => $anvil->data->{cgi}{task}{value},
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "form::error_massage" => $anvil->data->{form}{error_massage},
# node_checked => $node_checked, }});
# dr_checked => $dr_checked, process_anvil_menu($anvil);
# }}); }
#
# my $host_name = $anvil->_host_name; # TODO: For now, we're only allowing one BCN and SN. So at this time, we'll show one BCN pair, one SN
# $host_name =~ s/striker\d\d/xxx/; # pair and N-IFN pairs.
# my $default_host_name = $host_name; my $bcn_pair_count = 1;
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { my $sn_pair_count = 1;
# default_host_name => $default_host_name, my $ifn_pair_count = int(($interface_count - 4) / 2);
# host_name => $host_name, $ifn_pair_count = 1 if $ifn_pair_count < 1;
# }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# if ((exists $anvil->data->{cgi}{host_name}) && ($anvil->data->{cgi}{host_name}{value})) bcn_pair_count => $bcn_pair_count,
# { sn_pair_count => $sn_pair_count,
# $host_name = $anvil->data->{cgi}{host_name}{value}; ifn_pair_count => $ifn_pair_count,
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_name => $host_name }}); }});
# }
# my $interface_form = "";
# my $form_body = $anvil->Template->get({file => "anvil.html", name => "host-setup-menu1", variables => { # NOTE: We don't assign IPs at this point, unless the user manually sets one. We'll set all to 'dhcp'
# host_name => $host_name, # until set during the Anvil! build later.
# default_host_name => $default_host_name, foreach my $network ("bcn", "sn", "ifn")
# host_ip_address => $host_ip_address, {
# node_checked => $node_checked, $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }});
# dr_checked => $dr_checked, my $name_key = "";
# }}); my $description_key = "";
# my $count = 1;
# $anvil->data->{form}{refresh_link} = "?anvil=true&task=prep-network"; if ($network eq "bcn")
# $anvil->data->{form}{back_link} = "?anvil=true"; {
# $anvil->data->{cgi}{task}{value} = "" if not defined $anvil->data->{cgi}{task}{value}; $name_key = "striker_0018";
# $anvil->data->{cgi}{action}{value} = "" if not defined $anvil->data->{cgi}{action}{value}; $description_key = "striker_0019";
# $anvil->data->{form}{body} = $anvil->Template->get({file => "anvil.html", name => "prep-host-main", variables => { $count = $bcn_pair_count;
# form => $form_body, }
# }}); elsif ($network eq "sn")
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }}); {
# } $name_key = "striker_0020";
$description_key = "striker_0021";
$count = $sn_pair_count;
}
elsif ($network eq "ifn")
{
$name_key = "striker_0022";
$description_key = "striker_0023";
$count = $ifn_pair_count;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
name_key => $name_key,
description_key => $description_key,
count => $count,
}});
foreach my $i (1..$count)
{
my $this_ip_key = $network.$i."_ip";
my $this_subnet_mask_key = $network.$i."_subnet_mask";
my $this_iface1_key = $network.$i."_link1_mac_to_set";
my $this_iface2_key = $network.$i."_link2_mac_to_set";
my $this_ip = exists $anvil->data->{cgi}{$this_ip_key}{value} ? $anvil->data->{cgi}{$this_ip_key}{value} : "dhcp";
my $this_ip_class = $anvil->data->{cgi}{$this_ip_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_iface2_class = $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
this_ip_key => $this_ip_key,
this_subnet_mask_key => $this_subnet_mask_key,
this_iface1_key => $this_iface1_key,
this_iface2_key => $this_iface2_key,
this_ip => $this_ip,
this_ip_class => $this_ip_class,
this_subnet_mask_class => $this_subnet_mask_class,
this_iface1_class => $this_iface1_class,
this_iface2_class => $this_iface2_class,
}});
# Build the interface select boxes...
my $this_iface1_form = $anvil->Template->select_form({
name => $this_iface1_key,
options => $interface_options,
blank => 1,
selected => defined $anvil->data->{cgi}{$this_iface1_key}{value} ? $anvil->data->{cgi}{$this_iface1_key}{value} : "",
class => $anvil->data->{cgi}{$this_iface1_key}{alert} ? "input_alert" : "input_clear",
});
my $this_iface2_form = $anvil->Template->select_form({
name => $this_iface2_key,
options => $interface_options,
blank => 1,
selected => defined $anvil->data->{cgi}{$this_iface2_key}{value} ? $anvil->data->{cgi}{$this_iface2_key}{value} : "",
class => $anvil->data->{cgi}{$this_iface2_key}{alert} ? "input_alert" : "input_clear",
});
# Assemble the form
$interface_form .= $anvil->Template->get({file => "anvil.html", name => "network_interface_form", variables => {
field => $anvil->Words->string({key => $name_key, variables => { number => $i }}),
description => "#!string!".$description_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_default => $this_ip,
ip_class => $this_ip_class,
subnet_mask_key => $this_subnet_mask_key,
subnet_mask_value => defined $anvil->data->{cgi}{$this_subnet_mask_key}{value} ? $anvil->data->{cgi}{$this_subnet_mask_key}{value} : "",
subnet_mask_value_default => $anvil->data->{defaults}{network}{bcn}{subnet_mask},
subnet_mask_class => $this_subnet_mask_class,
iface1_select => $this_iface1_form,
iface2_select => $this_iface2_form,
}});
}
}
# Host name
my $say_host_name = defined $anvil->data->{cgi}{host_name}{value} ? $anvil->data->{cgi}{host_name}{value} : $host_name;
my $host_name_class = $anvil->data->{cgi}{host_name}{alert} ? "input_alert" : "input_clear";
my $say_host_name = $anvil->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "host_name",
id => "host_name",
field => "#!string!striker_0016!#",
description => "#!string!striker_0143!#",
value => defined $anvil->data->{cgi}{host_name}{value} ? $anvil->data->{cgi}{host_name}{value} : $say_host_name,
default_value => "",
class => $host_name_class,
extra => "",
}});
### NOTE: We'll figure out the IFN this belongs to by matching the DG to one of the IFN IPs.
# Gateway
my $gateway_class = $anvil->data->{cgi}{gateway}{alert} ? "input_alert" : "input_clear";
my $say_gateway = $anvil->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "gateway",
id => "gateway",
field => "#!string!striker_0035!#",
description => "#!string!striker_0144!#",
value => defined $anvil->data->{cgi}{gateway}{value} ? $anvil->data->{cgi}{gateway}{value} : "",
default_value => "",
class => $gateway_class,
extra => "",
}});
# DNS
my $dns_class = $anvil->data->{cgi}{dns}{alert} ? "input_alert" : "input_clear";
my $say_dns = $anvil->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "dns",
id => "dns",
field => "#!string!striker_0037!#",
description => "#!string!striker_0038!#",
value => defined $anvil->data->{cgi}{dns}{value} ? $anvil->data->{cgi}{dns}{value} : "",
default_value => $anvil->data->{defaults}{network}{dns},
class => $dns_class,
extra => "",
}});
# Store the previous CGI variables and display the new fields.
$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 => "config-network-main", variables => {
interface_form => $interface_form,
gateway_form => $say_gateway,
dns_form => $say_dns,
host_name_form => $say_host_name,
host_name => $host_name, # This is the current host name, used to find the data in the all_status.json
}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { 'form::body' => $anvil->data->{form}{body} }});
return(0); return(0);
} }
@ -1984,7 +2153,7 @@ ORDER BY
my $server_ip = $ENV{SERVER_ADDR}; my $server_ip = $ENV{SERVER_ADDR};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_ip => $server_ip }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_ip => $server_ip }});
# We'll need ot show how networks will be configured. This depends on; # We'll need to show how networks will be configured. This depends on;
# 1. Is it a bonded or single interface? # 1. Is it a bonded or single interface?
# 2. Is it the interface with the gateway? # 2. Is it the interface with the gateway?
# 3. If no gateway or DNS was specified, alert that there will be no outside access. # 3. If no gateway or DNS was specified, alert that there will be no outside access.

@ -58,6 +58,152 @@
</table> </table>
<!-- end main-menu --> <!-- end main-menu -->
<!-- start network_interface_form -->
<table>
<tr>
<td colspan="5" class="form_group_header1">
#!variable!field!#:
</td>
</tr>
<tr>
<td colspan="5" class="form_group_header2">
#!variable!description!#
</td>
</tr>
<tr>
<td>
#!string!striker_0024!#
</td>
<td>
<input type="text" name="#!variable!ip_key!#" id="#!variable!ip_key!#" value="#!variable!ip_value!#" placeholder="#!string!striker_0024!#" class="#!variable!ip_class!#">
<input type="hidden" name="#!variable!ip_key!#_default" id="#!variable!ip_key!#_default" value="#!variable!ip_value_default!#">
</td>
<td>
&nbsp;
</td>
<td>
#!string!striker_0029!#
</td>
<td>
#!variable!iface1_select!#
</td>
</tr>
<tr>
<td>
#!string!striker_0025!#
</td>
<td>
<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_mask_key!#_default" id="#!variable!subnet_mask_key!#_default" value="#!variable!subnet_mask_value_default!#">
</td>
<td>
&nbsp;
</td>
<td>
#!string!striker_0030!#
</td>
<td>
#!variable!iface2_select!#
</td>
</tr>
</table>
<!-- end network_interface_form -->
<!-- start config-network-main -->
<table align="center" class="anvil_main_menu">
<script type="text/javascript" src="/skins/alteeve/anvil.js"></script>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2" class="title">
#!string!striker_0141!#
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
#!string!striker_0142!#
</td>
</tr>
<form name="host_setup" action="" method="post">
<tr>
<td colspan="2">
<hr>
</td>
</tr>
<tr>
<td colspan="2">
&nbsp;
</td>
</tr>
<tr>
<td colspan="2">
<table width="100%">
<div id="network_config">
<form name="network_config_form" action="" method="post">
<tr>
<td width="75%" style="vertical-align: top;">
<table>
<tr>
<td>
#!variable!host_name_form!#
</td>
</tr>
<tr>
<td>
&nbsp;
</td>
</tr>
<tr>
<td>
#!variable!interface_form!#
</td>
</tr>
<tr>
<td>
#!variable!gateway_form!#
</td>
</tr>
<tr>
<td>
#!variable!dns_form!#
</td>
</tr>
</table>
</td>
<td width="25%" style="padding-left: 1em; vertical-align: top;">
<div id="network_interface_table" data-host-name="#!variable!host_name!#"/>
</td>
</tr>
<tr>
<td colspan="2">
<br />
<hr>
<input type="submit" name="next" id="next" class="button" value="#!string!striker_0013!#">
</td>
</tr>
<input type="hidden" name="bcn_count" id="bcn_count" value="#!variable!bcn_count!#">
<input type="hidden" name="sn_count" id="sn_count" value="#!variable!sn_count!#">
<input type="hidden" name="ifn_count" id="ifn_count" value="#!variable!ifn_count!#">
<input type="hidden" name="step" id="step" value="step2">
</form>
</div>
</table>
</td>
</tr>
<input type="hidden" name="anvil" id="anvil" value="1">
<input type="hidden" name="task" id="task" value="prep-host">
</form>
</table>
<!-- end config-network-main -->
<!-- start prep-host-main --> <!-- start prep-host-main -->
<table align="center" class="anvil_main_menu"> <table align="center" class="anvil_main_menu">
<tr> <tr>
@ -87,7 +233,9 @@
</tr> </tr>
<form name="host_setup" action="" method="post"> <form name="host_setup" action="" method="post">
<tr> <tr>
#!variable!form!# <td colspan="2">
#!variable!form!#
</td>
</tr> </tr>
<input type="hidden" name="anvil" id="anvil" value="1"> <input type="hidden" name="anvil" id="anvil" value="1">
<input type="hidden" name="task" id="task" value="prep-host"> <input type="hidden" name="task" id="task" value="prep-host">

@ -13,6 +13,8 @@ $( window ).on( "load", function()
//var newURL = location.href.split("?")[0]; //var newURL = location.href.split("?")[0];
//window.history.pushState('object', document.title, newURL); //window.history.pushState('object', document.title, newURL);
// Show the list of unconfigured (and configured) hosts on the main page.
if ($('#unconfigured_hosts').length) {
// Toggle the table with the list of hosts that can be configured. // Toggle the table with the list of hosts that can be configured.
$("#toggle_unconfigured_icon").click(function(){ $("#toggle_unconfigured_icon").click(function(){
$("#unconfigured_hosts").toggle(); $("#unconfigured_hosts").toggle();
@ -22,7 +24,8 @@ $( 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/all_status.json', { get_param: 'value' }, function(data) { setInterval(function() {
$.getJSON('/status/all_status.json', function(data) {
//console.log('read /status/all_status.json'); //console.log('read /status/all_status.json');
var show_none = 1; var show_none = 1;
var say_none = $('#unconfigured_hosts').data('none'); var say_none = $('#unconfigured_hosts').data('none');
@ -55,7 +58,7 @@ $( window ).on( "load", function()
if (element.matched_ip_address) { if (element.matched_ip_address) {
//console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']'); //console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']');
body += '<tr class="data_row">'; body += '<tr class="data_row">';
body += '<td class="column_row_value_fixed"><a class="available" href="?anvil=true&task=prep-network&host='+element.host_uuid+'">'+element.short_name+'</a></td>'; body += '<td class="column_row_value_fixed"><a class="available" href="?anvil=true&task=prep-network&host_uuid='+element.host_uuid+'">'+element.short_name+'</a></td>';
body += '<td class="column_header"> &nbsp; </td>'; body += '<td class="column_header"> &nbsp; </td>';
body += '<td class="column_row_value_fixed">'+element.type+'</td>'; body += '<td class="column_row_value_fixed">'+element.type+'</td>';
body += '<td class="column_header"> &nbsp; </td>'; body += '<td class="column_header"> &nbsp; </td>';
@ -133,6 +136,23 @@ $( window ).on( "load", function()
} }
// Close the table // Close the table
body += '</table>'; body += '</table>';
// clear + append can't be the best way to do this...
$( "#unconfigured_hosts" ).empty();
$( "#unconfigured_hosts" ).append(body); $( "#unconfigured_hosts" ).append(body);
}); });
}, 1000);
};
// Run in we're showing a specific hosts' network.
if ($('#network_interface_table').length) {
var host_name = $('#network_interface_table').data('host-name');
//console.log('showing network info for: ['+host_name+']');
setInterval(function() {
$.getJSON('/status/all_status.json', function(data) {
//console.log('Reload: ['+host_name+']');
});
}, 1000);
};
}) })

@ -985,6 +985,10 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0138">New host name</key> <key name="striker_0138">New host name</key>
<key name="striker_0139"><![CDATA[<unchanged>]]></key> <key name="striker_0139"><![CDATA[<unchanged>]]></key>
<key name="striker_0140">Indicates when the last time the networks connected to this host were scanned. The scan is done to help find the IP addresses assigned to hosted servers and virtual machine equipment. The scan is a simple, sequential nmap ping scan in an attempt to be as non-invasive as possible. The frequency of these scans can be controlled by setting 'network-scan::scan-period' to a number of seconds (the current value is: [#!data!network-scan::scan-period!# seconds]).</key> <key name="striker_0140">Indicates when the last time the networks connected to this host were scanned. The scan is done to help find the IP addresses assigned to hosted servers and virtual machine equipment. The scan is a simple, sequential nmap ping scan in an attempt to be as non-invasive as possible. The frequency of these scans can be controlled by setting 'network-scan::scan-period' to a number of seconds (the current value is: [#!data!network-scan::scan-period!# seconds]).</key>
<key name="striker_0141">Configure the network interfaces for this host.</key>
<key name="striker_0142">This step renames the real network interfaces, pairs them into redundant bonds and creates brodges for connecting to hosted servers. IPs and host names are optional, and can be set when assembling this host into an Anvil! system.</key>
<key name="striker_0143">If you would like to change the host name now, you can do so here. When adding this machine to an Anvil!, the host name will be set there as well making this optional.</key>
<key name="striker_0144">This is the network gateway used to access the outside world. We'll match it to the appropriate network interface.</key>
<!-- These are generally units and appended to numbers --> <!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key> <key name="suffix_0001">#!variable!number!#/sec</key>
@ -1138,6 +1142,8 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
<key name="striker_warning_0011">The SSH port is not a valid (usually it is 22, but it has to be between 1 ~ 65536)</key> <key name="striker_warning_0011">The SSH port is not a valid (usually it is 22, but it has to be between 1 ~ 65536)</key>
<key name="striker_warning_0012">Failed to log into the host. Is the IP or root user's password right?</key> <key name="striker_warning_0012">Failed to log into the host. Is the IP or root user's password right?</key>
<key name="striker_warning_0013"><![CDATA[The target's host key has changed. If the target has been rebuilt, or the target IP reused, the old key will need to be removed. <a href="?striker=true&task=keys" target="_new">Click here</a> to resolve.]]></key> <key name="striker_warning_0013"><![CDATA[The target's host key has changed. If the target has been rebuilt, or the target IP reused, the old key will need to be removed. <a href="?striker=true&task=keys" target="_new">Click here</a> to resolve.]]></key>
<key name="striker_warning_0014">The host UUID: [#!variable!host_uuid!#] was not found in the #!data!path::json::all_status!# file on the local dashboard.</key>
<key name="striker_warning_0015">To configure a host as either an Anvil! node or a disaster recovery host, there must be at least 6 network interfaces. This machine only has: [#!variable!interface_count!#] interfaces.</key>
<!-- Errors --> <!-- Errors -->
<key name="error_0001">There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network).</key> <key name="error_0001">There are not enough network interfaces on this machine. You have: [#!variable!interface_count!#] interface(s), and you need at least: [#!variable!required_interfaces_for_single!#] interfaces to connect to the requested networks (one for Back-Channel and one for each Internet-Facing network).</key>

@ -53,8 +53,8 @@ if (not $anvil->data->{sys}{database}{connections})
$anvil->data->{job}{progress} = 0; $anvil->data->{job}{progress} = 0;
get_job_details($anvil); get_job_details($anvil);
wait_for_access($anvil); wait_for_access($anvil);
#set_host_name($anvil); set_host_name($anvil);
#add_repos($anvil); add_repos($anvil);
add_databases($anvil); add_databases($anvil);
update_progress($anvil, 100, "job_0047"); update_progress($anvil, 100, "job_0047");

@ -30,11 +30,10 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure =
$anvil->System->generate_state_json({debug => 3}); $anvil->System->generate_state_json({debug => 3});
$anvil->Striker->parse_all_status_json({debug => 3}); $anvil->Striker->parse_all_status_json({debug => 3});
# print Dumper $anvil->data->{json}{all_status}{hosts}; #print Dumper $anvil->data->{json}{all_status}{hosts}{'el8-a01n01.digimer.ca'};
die; #die;
#foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}}) foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}})
foreach my $host_name ("el8-a01n02.digimer.ca")
{ {
print "\n"; print "\n";
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: [".$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";

Loading…
Cancel
Save