From 0dfd2ddbf05b07889d44908c7171612dd8c76b66 Mon Sep 17 00:00:00 2001 From: Digimer Date: Fri, 29 Nov 2019 23:37:11 -0500 Subject: [PATCH] * 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 --- Anvil/Tools/Striker.pm | 14 +- Anvil/Tools/System.pm | 23 +-- cgi-bin/striker | 299 ++++++++++++++++++++++++++-------- html/skins/alteeve/anvil.html | 150 ++++++++++++++++- html/skins/alteeve/anvil.js | 254 ++++++++++++++++------------- share/words.xml | 6 + tools/striker-initialize-host | 4 +- tools/test.pl | 7 +- 8 files changed, 552 insertions(+), 205 deletions(-) diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm index 51347f6a..953a2061 100644 --- a/Anvil/Tools/Striker.pm +++ b/Anvil/Tools/Striker.pm @@ -402,7 +402,7 @@ sub parse_all_status_json foreach my $interface (sort {$a cmp $b} keys %{$match->{$short_name}}) { $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 => { matched_interface => $matched_interface, matched_ip_address => $matched_ip_address, @@ -422,7 +422,8 @@ sub parse_all_status_json { my $interface_name = $interface_hash->{name}; 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 $default_gateway = $interface_hash->{default_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 => { interface_name => $interface_name, interface_type => $interface_type, - ip => $ip, + mac_address => $mac_address, + ip_address => $ip_address, subnet_mask => $subnet_mask, default_gateway => $default_gateway, gateway => $gateway, @@ -446,7 +448,8 @@ sub parse_all_status_json # 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}{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}{default_gateway} = $interface_hash->{default_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 => { "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}::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}::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}, diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm index 46432506..e5529006 100644 --- a/Anvil/Tools/System.pm +++ b/Anvil/Tools/System.pm @@ -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 $ifaces_array = []; 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, "s2:short_host_name" => $short_host_name, "s3:host_type" => $host_type, @@ -882,7 +882,7 @@ sub generate_state_json my $mtu = $anvil->data->{network}{$host}{interface}{$interface}{mtu}; my $mac_address = $anvil->data->{network}{$host}{interface}{$interface}{mac_address}; 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, "s2:mac_address" => $mac_address, "s3:type" => $type, @@ -891,10 +891,11 @@ sub generate_state_json "s6:host_uuid" => $host_uuid, "s7:host_key" => $host_key, }}); - $iface_hash->{name} = $interface; - $iface_hash->{type} = $type; - $iface_hash->{mtu} = $mtu; - $iface_hash->{uuid} = $uuid; + $iface_hash->{name} = $interface; + $iface_hash->{type} = $type; + $iface_hash->{mtu} = $mtu; + $iface_hash->{uuid} = $uuid; + $iface_hash->{mac_address} = $mac_address; if ($type eq "bridge") { my $id = $anvil->data->{network}{$host}{interface}{$interface}{id}; @@ -1119,7 +1120,7 @@ sub generate_state_json bridge_name => $bridge_name, changed_order => $changed_order, }}); - + $iface_hash->{say_speed} = $say_speed; $iface_hash->{speed} = $speed; $iface_hash->{say_link_state} = $say_link_state; @@ -1138,28 +1139,28 @@ sub generate_state_json }; # Is there an IP on this interface? - my $ip = ""; + my $ip_address = ""; 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}; + $ip_address = $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, + ip_address => $ip_address, subnet_mask => $subnet_mask, default_gateway => $default_gateway, gateway => $gateway, dns => $dns, }}); - $iface_hash->{ip} = $ip; + $iface_hash->{ip_address} = $ip_address; $iface_hash->{subnet_mask} = $subnet_mask; $iface_hash->{default_gateway} = $default_gateway; $iface_hash->{gateway} = $gateway; diff --git a/cgi-bin/striker b/cgi-bin/striker index 550205ea..1f4039ec 100755 --- a/cgi-bin/striker +++ b/cgi-bin/striker @@ -718,74 +718,243 @@ sub process_prep_network { my ($anvil) = @_; - my $host_name = defined $anvil->data->{cgi}{host_name}{value} ? $anvil->data->{cgi}{host_name}{value} : ""; - my $host_ip_address = defined $anvil->data->{cgi}{host_ip_address}{value} ? $anvil->data->{cgi}{host_ip_address}{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} : ""; - $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { - host_name => $host_name, - host_ip_address => $host_ip_address, - host_password => $anvil->Log->is_secure($host_password), - confirm => $confirm, - }}); + # Do I know which machine we're configuring? + if (not $anvil->data->{cgi}{host_uuid}{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); + } - # We need to a pick a machine to initialize. + # Pull the host's data out of the JSON file. + $anvil->Striker->parse_all_status_json(); - # Do I know which machine we're initializing yet? - if ($anvil->data->{cgi}{host_uuid}{value}) + my $host_name = ""; + foreach my $host (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}}) { - # Yup, build the config page. + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + "cgi::host_uuid::value" => $anvil->data->{cgi}{host_uuid}{value}, + "json::all_status::hosts::${host}::host_uuid" => $anvil->data->{json}{all_status}{hosts}{$host}{host_uuid}, + }}); + 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; + } } - else + + 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); + } + + # How many actual interfaces do we have? We need at least six. For each two above that, we'll add an + # 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+/)) + { + # Ignore it. + next; + } + + # 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); - } - -# 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} }}); -# } + } + + # Get the interface count + my $interface_count = keys %{$interfaces}; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { interface_count => $interface_count }}); + + if ($interface_count < 6) + { + # 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 } }) }}); + $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); + } + + # TODO: For now, we're only allowing one BCN and SN. So at this time, we'll show one BCN pair, one SN + # pair and N-IFN pairs. + my $bcn_pair_count = 1; + my $sn_pair_count = 1; + my $ifn_pair_count = int(($interface_count - 4) / 2); + $ifn_pair_count = 1 if $ifn_pair_count < 1; + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { + bcn_pair_count => $bcn_pair_count, + sn_pair_count => $sn_pair_count, + ifn_pair_count => $ifn_pair_count, + }}); + + my $interface_form = ""; + # NOTE: We don't assign IPs at this point, unless the user manually sets one. We'll set all to 'dhcp' + # until set during the Anvil! build later. + foreach my $network ("bcn", "sn", "ifn") + { + $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { network => $network }}); + my $name_key = ""; + my $description_key = ""; + my $count = 1; + if ($network eq "bcn") + { + $name_key = "striker_0018"; + $description_key = "striker_0019"; + $count = $bcn_pair_count; + } + elsif ($network eq "sn") + { + $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); } @@ -1984,7 +2153,7 @@ ORDER BY my $server_ip = $ENV{SERVER_ADDR}; $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? # 2. Is it the interface with the gateway? # 3. If no gateway or DNS was specified, alert that there will be no outside access. @@ -2007,7 +2176,7 @@ ORDER BY $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "s1:nets->this_net" => $nets->{$this_net}, "s2:ip" => $ip, - "s3:subnet_mask" => $subnet_mask, + "s3:subnet_mask" => $subnet_mask, "s4:iface1_mac" => $iface1_mac, "s5:iface2_mac" => $iface2_mac, "s6:template" => $template, diff --git a/html/skins/alteeve/anvil.html b/html/skins/alteeve/anvil.html index d8d1f46b..298b6fcd 100644 --- a/html/skins/alteeve/anvil.html +++ b/html/skins/alteeve/anvil.html @@ -58,6 +58,152 @@ + + + + + + + + + + + + + + + + + + + + + + +
+ #!variable!field!#: +
+ #!variable!description!# +
+ #!string!striker_0024!# + + + + +   + + #!string!striker_0029!# + + #!variable!iface1_select!# +
+ #!string!striker_0025!# + + + + +   + + #!string!striker_0030!# + + #!variable!iface2_select!# +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+   +
+ #!string!striker_0141!# +
+   +
+ #!string!striker_0142!# +
+
+
+   +
+ +
+ +
+ + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + +
+#!variable!host_name_form!# +
+   +
+#!variable!interface_form!# +
+#!variable!gateway_form!# +
+#!variable!dns_form!# +
+
+
+
+
+
+ +
+
+ + @@ -87,7 +233,9 @@ - #!variable!form!# + diff --git a/html/skins/alteeve/anvil.js b/html/skins/alteeve/anvil.js index fec1d437..56f4919d 100644 --- a/html/skins/alteeve/anvil.js +++ b/html/skins/alteeve/anvil.js @@ -13,126 +13,146 @@ $( window ).on( "load", function() //var newURL = location.href.split("?")[0]; //window.history.pushState('object', document.title, newURL); - // Toggle the table with the list of hosts that can be configured. - $("#toggle_unconfigured_icon").click(function(){ - $("#unconfigured_hosts").toggle(); - }); - $("#toggle_unconfigured_text").click(function(){ - $("#unconfigured_hosts").toggle(); - }); - - // Walk through the network.json file and use it to pre-fill the form. - $.getJSON('/status/all_status.json', { get_param: 'value' }, function(data) { - //console.log('read /status/all_status.json'); - var show_none = 1; - var say_none = $('#unconfigured_hosts').data('none'); - var say_yes = $('#unconfigured_hosts').data('yes'); - var say_no = $('#unconfigured_hosts').data('no'); - var say_unconfigured = $('#unconfigured_hosts').data('unconfigured'); - var say_configured = $('#unconfigured_hosts').data('configured'); - var say_type = $('#unconfigured_hosts').data('type'); - var say_accessible = $('#unconfigured_hosts').data('accessible'); - var say_at_ip = $('#unconfigured_hosts').data('at-ip'); - - // Open the table - var body = '
+#!variable!form!# +
'; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - $.each(data.hosts, function(index, element) { - if (element.type === 'dashboard') { - // Skip - return true; - }; - if (element.configured != 1) { - show_none = 0; - if (element.matched_ip_address) { - //console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']'); - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - } else { - //console.log('Show: ['+element.short_name+'], not accessible from here'); - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - } - } + // 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_unconfigured_icon").click(function(){ + $("#unconfigured_hosts").toggle(); + }); + $("#toggle_unconfigured_text").click(function(){ + $("#unconfigured_hosts").toggle(); }); - if (show_none) { - body += ''; - body += ''; - body += '' ; - } - // Now show configured ones (in case the user wants to reconfigure a host) - show_none = 1; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - $.each(data.hosts, function(index, element) { - if (element.type === 'dashboard') { - // Skip - return true; - }; - if (element.configured == 1) { - show_none = 0; - if (element.matched_ip_address) { - //console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']'); + // Walk through the network.json file and use it to pre-fill the form. + setInterval(function() { + $.getJSON('/status/all_status.json', function(data) { + //console.log('read /status/all_status.json'); + var show_none = 1; + var say_none = $('#unconfigured_hosts').data('none'); + var say_yes = $('#unconfigured_hosts').data('yes'); + var say_no = $('#unconfigured_hosts').data('no'); + var say_unconfigured = $('#unconfigured_hosts').data('unconfigured'); + var say_configured = $('#unconfigured_hosts').data('configured'); + var say_type = $('#unconfigured_hosts').data('type'); + var say_accessible = $('#unconfigured_hosts').data('accessible'); + var say_at_ip = $('#unconfigured_hosts').data('at-ip'); + + // Open the table + var body = '
'+say_unconfigured+'   '+say_type+'   '+say_accessible+'   '+say_at_ip+'
'+element.short_name+'   '+element.type+'   '+say_yes+'   '+element.matched_ip_address+'
'+element.short_name+'   '+element.type+'   '+say_no+'   --
<'+say_none+'>
'+say_configured+'   '+say_type+'   '+say_accessible+'   '+say_at_ip+'
'; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + $.each(data.hosts, function(index, element) { + if (element.type === 'dashboard') { + // Skip + return true; + }; + if (element.configured != 1) { + show_none = 0; + if (element.matched_ip_address) { + //console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']'); + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + } else { + //console.log('Show: ['+element.short_name+'], not accessible from here'); + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + } + } + }); + if (show_none) { body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - } else { - //console.log('Show: ['+element.short_name+'], not accessible from here'); + body += ''; + body += '' ; + } + + // Now show configured ones (in case the user wants to reconfigure a host) + show_none = 1; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + $.each(data.hosts, function(index, element) { + if (element.type === 'dashboard') { + // Skip + return true; + }; + if (element.configured == 1) { + show_none = 0; + if (element.matched_ip_address) { + //console.log('Show: ['+element.short_name+'], connect via: ['+element.matched_ip_address+']'); + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + } else { + //console.log('Show: ['+element.short_name+'], not accessible from here'); + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + body += ''; + } + } + }); + if (show_none) { body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; - body += ''; + body += ''; + body += '' ; } - } - }); - if (show_none) { - body += ''; - body += ''; - body += '' ; - } - // Close the table - body += '
'+say_unconfigured+'   '+say_type+'   '+say_accessible+'   '+say_at_ip+'
'+element.short_name+'   '+element.type+'   '+say_yes+'   '+element.matched_ip_address+'
'+element.short_name+'   '+element.type+'   '+say_no+'   --
'+element.short_name+'   '+element.type+'   '+say_yes+'   '+element.matched_ip_address+'
<'+say_none+'>
'+say_configured+'   '+say_type+'   '+say_accessible+'   '+say_at_ip+'
'+element.short_name+'   '+element.type+'   '+say_yes+'   '+element.matched_ip_address+'
'+element.short_name+'   '+element.type+'   '+say_no+'   --
'+element.short_name+'   '+element.type+'   '+say_no+'   --
<'+say_none+'>
<'+say_none+'>
'; - $( "#unconfigured_hosts" ).append(body); - }); + // Close the table + body += ''; + + // clear + append can't be the best way to do this... + $( "#unconfigured_hosts" ).empty(); + $( "#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); + }; + }) diff --git a/share/words.xml b/share/words.xml index b2dbb7db..af3ba601 100644 --- a/share/words.xml +++ b/share/words.xml @@ -985,6 +985,10 @@ If you are comfortable that the target has changed for a known reason, you can s New host name ]]> 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]). + Configure the network interfaces for this host. + 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. + 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. + This is the network gateway used to access the outside world. We'll match it to the appropriate network interface. #!variable!number!#/sec @@ -1138,6 +1142,8 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec The SSH port is not a valid (usually it is 22, but it has to be between 1 ~ 65536) Failed to log into the host. Is the IP or root user's password right? Click here to resolve.]]> + The host UUID: [#!variable!host_uuid!#] was not found in the #!data!path::json::all_status!# file on the local dashboard. + 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. 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). diff --git a/tools/striker-initialize-host b/tools/striker-initialize-host index 0f78878a..777382b8 100755 --- a/tools/striker-initialize-host +++ b/tools/striker-initialize-host @@ -53,8 +53,8 @@ if (not $anvil->data->{sys}{database}{connections}) $anvil->data->{job}{progress} = 0; get_job_details($anvil); wait_for_access($anvil); -#set_host_name($anvil); -#add_repos($anvil); +set_host_name($anvil); +add_repos($anvil); add_databases($anvil); update_progress($anvil, 100, "job_0047"); diff --git a/tools/test.pl b/tools/test.pl index 036622f2..a58efa7a 100755 --- a/tools/test.pl +++ b/tools/test.pl @@ -30,11 +30,10 @@ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure = $anvil->System->generate_state_json({debug => 3}); $anvil->Striker->parse_all_status_json({debug => 3}); -# print Dumper $anvil->data->{json}{all_status}{hosts}; -die; +#print Dumper $anvil->data->{json}{all_status}{hosts}{'el8-a01n01.digimer.ca'}; +#die; -#foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}}) -foreach my $host_name ("el8-a01n02.digimer.ca") +foreach my $host_name (sort {$a cmp $b} keys %{$anvil->data->{json}{all_status}{hosts}}) { 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";