diff --git a/AN/Tools.pm b/AN/Tools.pm
index db86b2dc..26ade5ed 100755
--- a/AN/Tools.pm
+++ b/AN/Tools.pm
@@ -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",
diff --git a/cgi-bin/home b/cgi-bin/home
index 3d192219..9154235c 100755
--- a/cgi-bin/home
+++ b/cgi-bin/home
@@ -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();
diff --git a/cgi-bin/words.xml b/cgi-bin/words.xml
index 4b7c8507..a3055252 100644
--- a/cgi-bin/words.xml
+++ b/cgi-bin/words.xml
@@ -27,7 +27,7 @@ This is the AN::Tools master 'words' file.
Link Speed (Mbps)
- Welcome! Lets setup your #!string!brand_0003!# dashboard!
+ Welcome! Lets setup your #!string!brand_0003!# dashboard...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!Organization nameThis 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.
@@ -42,6 +42,11 @@ This is the AN::Tools master 'words' file.
NextStep 1IFN Count
+ Host name
+ This is the hostname for this Striker dashboard. Generally it is a good idea to stick with the default.
+
+
+ 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).Up
diff --git a/html/skins/alteeve/main.css b/html/skins/alteeve/main.css
index 3d71e5be..2d6fca12 100644
--- a/html/skins/alteeve/main.css
+++ b/html/skins/alteeve/main.css
@@ -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;
}
diff --git a/html/skins/alteeve/main.html b/html/skins/alteeve/main.html
index 5200003c..622ee7b2 100644
--- a/html/skins/alteeve/main.html
+++ b/html/skins/alteeve/main.html
@@ -89,10 +89,21 @@