* Got some more work done on config_stage2. Working on sanity checking requested IFNs versus available interfaces.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 7 years ago
parent c4a857e8d8
commit 20d3f0e90b
  1. 1
      AN/Tools.pm
  2. 102
      cgi-bin/home
  3. 7
      cgi-bin/words.xml
  4. 6
      html/skins/alteeve/main.css
  5. 26
      html/skins/alteeve/main.html

@ -718,6 +718,7 @@ sub _set_paths
pgrep => "/usr/bin/pgrep",
psql => "/usr/bin/psql",
'postgresql-setup' => "/usr/bin/postgresql-setup",
'scancore-update-states' => "/sbin/striker/scancore-update-states",
su => "/usr/bin/su",
systemctl => "/usr/bin/systemctl",
touch => "/usr/bin/touch",

@ -55,7 +55,7 @@ elsif ($an->data->{cgi}{step}{value} eq "step1")
}
else
{
$body = get_network_details($an);
$body = get_network_details_form($an);
}
my $buttons = $an->Template->get({file => "main.html", name => "button_bar"});
my $footer = $an->Template->get({file => "main.html", name => "footer"});
@ -87,6 +87,55 @@ sub config_step2
{
my ($an) = @_;
# We need to decide how many IFNs there is, decide if we have enough NICs and then build the form
# either complaining about insufficient NICs or a list of interfaces (single or bond, depending on
# iface count), the IPs to assign and mapping MACs to ifaces. We'll also offer an option to
# "blind-map" as we did in v2.
get_network_details($an);
my $required_interfaces_for_single = 1 + $an->data->{cgi}{ifn_count}{value};
my $required_interfaces_for_bonds = 2 * $required_interfaces_for_single;
my $interface_count = keys %{$an->data->{interfaces}};
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
required_interfaces_for_single => $required_interfaces_for_single,
required_interfaces_for_bonds => $required_interfaces_for_bonds,
interface_count => $interface_count,
}});
my $problem = 0;
my $interface_form = "";
if ($interface_count < $required_interfaces_for_single)
{
# Build the error message.
my $say_message = $an->Words->string({key => "striker_error_0001", variables => {
interface_count => $interface_count,
required_interfaces_for_single => $required_interfaces_for_single,
}});
# Not enough interfaces found.
$problem = 1;
$interface_form = $an->Template->get({file => "main.html", name => "error_message", variables => { error_message => $say_message }});
}
elsif ($interface_count >= $required_interfaces_for_bonds)
{
# Show the bonded ifaces form.
}
else
{
# Show the single iface per network form.
}
my $say_default_hostname = $an->data->{cgi}{prefix}{value}."-striker0".$an->data->{cgi}{sequence}{value}.".".$an->data->{cgi}{domain}{value};
my $hostname_class = $an->data->{cgi}{hostname}{alert} ? "input_alert" : "input_clear";
my $say_hostname = $an->Template->get({file => "main.html", name => "input_text_form", variables => {
name => "hostname",
id => "hostname",
field => "#!string!striker_0016!#",
description => "#!string!striker_0017!#",
value => defined $an->data->{cgi}{hostname}{value} ? $an->data->{cgi}{hostname}{value} : $say_default_hostname,
class => $hostname_class,
extra => "",
}});
my $step2_body = $an->Template->get({file => "main.html", name => "config_step2", variables => {
step1_welcome_title_id => "",
step1_welcome_message_id => "",
@ -95,7 +144,8 @@ sub config_step2
domain => $an->data->{cgi}{domain}{value},
sequence => $an->data->{cgi}{sequence}{value},
ifn_count => $an->data->{cgi}{ifn_count}{value},
hostname_form => "",
interface_form => $interface_form,
hostname_form => $say_hostname,
cgi_list => "hostname",
}});
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { step2_body => $step2_body }});
@ -238,11 +288,57 @@ sub config_step1
return($step1_body);
}
# This reads the network status XML file and creates the template body.
# This reads the network status XML file and loads the data into $an->data->{network}{{...}.
sub get_network_details
{
my ($an) = @_;
### TODO: Daemonize this or solve selinux issues
### Refresh the network.xml
#$an->System->call({shell_call => $an->data->{path}{exe}{'scancore-update-states'}});
# Now read the network.xml
my $file = $an->data->{path}{directories}{html}."/status/network.xml";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
# Parse...
my $xml = XML::Simple->new();
my $data = "";
my $network = "";
eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name' }, ForceArray => [ 'interface', 'key' ]) };
if ($@)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$file]. The error was:\n";
$error .= "===========================================================\n";
$error .= $@."\n";
$error .= "===========================================================\n";
$an->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $error});
}
else
{
foreach my $interface (sort {$a cmp $b} keys %{$data->{interface}})
{
$an->data->{interfaces}{$interface} = {
mac => $data->{interface}{$interface}{mac},
speed => $data->{interface}{$interface}{speed},
'link' => $data->{interface}{$interface}{'link'}
};
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"interfaces::${interface}::mac" => $an->data->{interfaces}{$interface}{mac},
"interfaces::${interface}::speed" => $an->data->{interfaces}{$interface}{speed},
"interfaces::${interface}::link" => $an->data->{interfaces}{$interface}{'link'},
}});
}
}
return(0);
}
sub get_network_details_form
{
my ($an) = @_;
my $file = $an->data->{path}{directories}{html}."/status/network.xml";
$an->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
my $xml = XML::Simple->new();

@ -27,7 +27,7 @@ This is the AN::Tools master 'words' file.
<key name="header_0005">Link Speed (Mbps)</key>
<!-- General strings shown in Striker -->
<key name="striker_0001">Welcome! Lets setup your #!string!brand_0003!# dashboard!</key>
<key name="striker_0001">Welcome! Lets setup your #!string!brand_0003!# dashboard...</key>
<key name="striker_0002">We're going to ask you a few questions so that we can set things up for your environment. If you need help at any time, just click on the "[?]" icon in the top-right. Let's get started!</key>
<key name="striker_0003">Organization name</key>
<key name="striker_0004">This is the name of the company, organization or division that owns or maintains this #!string!brand_0006!#. This is a descriptive field and you can enter whatever makes most sense to you.</key>
@ -42,6 +42,11 @@ This is the AN::Tools master 'words' file.
<key name="striker_0013">Next</key>
<key name="striker_0014">Step 1</key>
<key name="striker_0015">IFN Count</key>
<key name="striker_0016">Host name</key>
<key name="striker_0017">This is the hostname for this Striker dashboard. Generally it is a good idea to stick with the default.</key>
<!-- Errors -->
<key name="striker_error_0001">There are not enuogh 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>
<!-- These are works and strings used by javascript/jqery -->
<key name="js_0001">Up</key>

@ -10,6 +10,12 @@ Colours;
- Footer text: #515151
*/
.error_message {
border: 3px solid #d02724;
background: #343434;
padding: 20px;
}
input[type=text].input_clear, input[type=number].input_clear {
border: 1px solid #9ba0a5;
}

@ -89,10 +89,21 @@
</td>
</tr>
<tr>
<td width="75%">
1.
<td width="75%" style="vertical-align: top;">
<table>
<tr>
<td>
#!variable!interface_form!#
</td>
</tr>
<tr>
<td>
#!variable!hostname_form!#
</td>
</tr>
</table>
</td>
<td width="25%">
<td width="25%" style="padding-left: 1em;">
<table class="data_table">
<tr>
<td class="column_header" colspan="2">
@ -152,11 +163,6 @@
</table>
</td>
</tr>
<tr>
<td>
2.
</td>
</tr>
<tr>
<td colspan="2">
<br />
@ -171,6 +177,10 @@
</table>
<!-- end config_step2 -->
<!-- start error_message -->
<div class="error_message"> #!variable!error_message!# </div><br />
<!-- end error_message -->
<!-- start select_form -->
#!variable!description!#<br />
<input type="select" name="#!variable!name!#" id="#!variable!id!#" #!variable!extra!#>#!variable!options!#</select>

Loading…
Cancel
Save