* Updated striker's first config page to pre-fill with values (Org name, prefix, sequence and domain name) if they can be devined from the existing system config.

* Updated System->hostname() to return the "pretty" host name as well as the traditional host name.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 42c4cd01f9
commit d3d28d8ec5
  1. 26
      Anvil/Tools/System.pm
  2. 74
      cgi-bin/striker
  3. 3
      notes
  4. 2
      tools/anvil-configure-striker

@ -884,7 +884,18 @@ sub get_ips
=head2 hostname =head2 hostname
Get our set the local hostname. The current host name (or the new hostname if C<< set >> was used) is returned as a string. Get or set the local hostname. The current (or new) "static" (traditional) host name and the "pretty" (descriptive) host names are returned.
# Get the current host name.
my ($traditional_hostname, $descriptive_hostname) = $anvil->System->hostname();
# Set the traditional host name.
my ($traditional_hostname, $descriptive_hostname) = $anvil->System->hostname({set => "an-striker01.alteeve.com");
# Set the traditional and descriptive host names.
my ($traditional_hostname, $descriptive_hostname) = $anvil->System->hostname({set => "an-striker01.alteeve.com", pretty => "Alteeve - Striker 01");
The current host name (or the new hostname if C<< set >> was used) is returned as a string.
Parameters; Parameters;
@ -935,14 +946,15 @@ sub hostname
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { output => $output }});
} }
# Get # Get the static (traditional) hostname
my $shell_call = $anvil->data->{path}{exe}{hostnamectl}." --static"; my $hostname = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{hostnamectl}." --static"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { shell_call => $shell_call }});
my $hostname = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { hostname => $hostname }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { hostname => $hostname }});
return($hostname); # Get the pretty (descriptive) hostname
my $descriptive = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{hostnamectl}." --pretty"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { descriptive => $descriptive }});
return($hostname, $descriptive);
} }
=head2 is_local =head2 is_local

@ -2118,7 +2118,7 @@ sub config_step1
variable_source_uuid => $anvil->Get->host_uuid, variable_source_uuid => $anvil->Get->host_uuid,
variable_source_table => "hosts", variable_source_table => "hosts",
}); });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
organization => $organization, organization => $organization,
prefix => $prefix, prefix => $prefix,
domain => $domain, domain => $domain,
@ -2129,15 +2129,83 @@ sub config_step1
$anvil->data->{cgi}{organization}{value} = $organization ne "" ? $organization : ""; $anvil->data->{cgi}{organization}{value} = $organization ne "" ? $organization : "";
$anvil->data->{cgi}{prefix}{value} = $prefix ne "" ? $prefix : ""; $anvil->data->{cgi}{prefix}{value} = $prefix ne "" ? $prefix : "";
$anvil->data->{cgi}{domain}{value} = $domain ne "" ? $domain : ""; $anvil->data->{cgi}{domain}{value} = $domain ne "" ? $domain : "";
$anvil->data->{cgi}{sequence}{value} = $sequence ne "" ? $sequence : 1; $anvil->data->{cgi}{sequence}{value} = $sequence ne "" ? $sequence : "";
$anvil->data->{cgi}{ifn_count}{value} = $ifn_count ne "" ? $ifn_count : 1; $anvil->data->{cgi}{ifn_count}{value} = $ifn_count ne "" ? $ifn_count : 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::organization::value' => $anvil->data->{cgi}{organization}{value}, 'cgi::organization::value' => $anvil->data->{cgi}{organization}{value},
'cgi::prefix::value' => $anvil->data->{cgi}{prefix}{value}, 'cgi::prefix::value' => $anvil->data->{cgi}{prefix}{value},
'cgi::domain::value' => $anvil->data->{cgi}{domain}{value}, 'cgi::domain::value' => $anvil->data->{cgi}{domain}{value},
'cgi::sequence::value' => $anvil->data->{cgi}{sequence}{value}, 'cgi::sequence::value' => $anvil->data->{cgi}{sequence}{value},
'cgi::ifn_count::value' => $anvil->data->{cgi}{ifn_count}{value}, 'cgi::ifn_count::value' => $anvil->data->{cgi}{ifn_count}{value},
}}); }});
# If we don't have an organization name, prefix, domain name or sequence number, try to parse it from
# the current static and pretty hostnames.
my ($traditional_hostname, $descriptive_hostname) = $anvil->System->hostname();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
traditional_hostname => $traditional_hostname,
descriptive_hostname => $descriptive_hostname,
}});
if ($descriptive_hostname =~ /^(.*?) - Striker (\d+)/)
{
my $organization = $1;
my $sequence = $2;
$sequence =~ s/^0+//;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
organization => $organization,
sequence => $sequence,
}});
if (($organization) && ($anvil->data->{cgi}{organization}{value} eq ""))
{
$anvil->data->{cgi}{organization}{value} = $organization;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::organization::value' => $anvil->data->{cgi}{organization}{value},
}});
}
if (($sequence =~ /^\d+$/) && ($anvil->data->{cgi}{sequence}{value} eq ""))
{
$anvil->data->{cgi}{sequence}{value} = $sequence;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::sequence::value' => $anvil->data->{cgi}{sequence}{value},
}});
}
}
if ($traditional_hostname =~ /^(.*?)-striker\d+\.(.*)$/)
{
my $prefix = $1;
my $domain = $2;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
prefix => $prefix,
domain => $domain,
}});
if (($prefix) && ($anvil->data->{cgi}{prefix}{value} eq ""))
{
$anvil->data->{cgi}{prefix}{value} = $prefix;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::prefix::value' => $anvil->data->{cgi}{prefix}{value},
}});
}
if (($domain) && ($anvil->data->{cgi}{domain}{value} eq ""))
{
$anvil->data->{cgi}{domain}{value} = $domain;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::domain::value' => $anvil->data->{cgi}{domain}{value},
}});
}
}
# If I still don't have a sequence number, set '1'.
if ($anvil->data->{cgi}{sequence}{value} eq "")
{
$anvil->data->{cgi}{sequence}{value} = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'cgi::sequence::value' => $anvil->data->{cgi}{sequence}{value},
}});
}
} }
my $organization_class = $anvil->data->{cgi}{organization}{alert} ? "input_alert" : "input_clear"; my $organization_class = $anvil->data->{cgi}{organization}{alert} ? "input_alert" : "input_clear";

@ -6,6 +6,9 @@ DB stuff;
Dump; Dump;
su - postgres -c "pg_dump anvil" > /anvil.out su - postgres -c "pg_dump anvil" > /anvil.out
Drop;
su - postgres -c "dropdb anvil" && su - postgres -c "createdb --owner admin anvil" && su - postgres -c "psql anvil"
Reload the DB; Reload the DB;
su - postgres -c "dropdb anvil" && su - postgres -c "createdb --owner admin anvil" && su - postgres -c "psql anvil < /anvil.out" su - postgres -c "dropdb anvil" && su - postgres -c "createdb --owner admin anvil" && su - postgres -c "psql anvil < /anvil.out"
su - postgres -c "psql anvil" su - postgres -c "psql anvil"

@ -192,7 +192,7 @@ sub reconfigure_network
}}); }});
# Set the hostname # Set the hostname
my $hostname = $anvil->System->hostname({set => $new_hostname, pretty => $pretty_hostname, debug => 3}); my ($hostname, $descriptive_hostname) = = $anvil->System->hostname({set => $new_hostname, pretty => $pretty_hostname, debug => 3});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { hostname => $hostname }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { hostname => $hostname }});
if ($hostname eq $new_hostname) if ($hostname eq $new_hostname)
{ {

Loading…
Cancel
Save