Merge pull request #110 from ClusterLabs/anvil-tools-dev

Anvil tools dev
main
digimer-bot 4 years ago committed by GitHub
commit 6710653ac9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      Anvil/Tools.pm
  2. 2
      Anvil/Tools/Account.pm
  3. 6
      Anvil/Tools/Convert.pm
  4. 171
      Anvil/Tools/Database.pm
  5. 91
      Anvil/Tools/Striker.pm
  6. 59
      Anvil/Tools/System.pm
  7. 1
      html/Makefile.am
  8. 8
      html/index.html
  9. 8
      html/skins/alteeve/anvil.html
  10. 339
      ocf/alteeve/server
  11. 15
      scancore-agents/scan-hardware/scan-hardware
  12. 11
      share/words.xml
  13. 6
      tools/anvil-configure-host
  14. 11
      tools/anvil-daemon
  15. 247
      tools/anvil-manage-server
  16. 2
      tools/anvil-provision-server

@ -834,10 +834,10 @@ sub _set_defaults
$anvil->data->{scancore} = {
timing => {
# Delay between DB connection attempts when no databases are available?
agent_runtime => 60,
agent_runtime => 30,
db_retry_interval => 2,
# Delay between scans?
run_interval => 30,
run_interval => 60,
},
database => {
# This is the number of hours, after which, transient data (like temperature and

@ -355,7 +355,7 @@ AND
}
else
{
# User DID NOT passed a valid username/password.
# User DID NOT pass a valid username/password.
$anvil->data->{form}{error_massage} = $anvil->Template->get({file => "main.html", name => "error_message", variables => { error_message => $anvil->Words->string({key => "error_0027"}) }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0184", variables => {
user_agent => $ENV{HTTP_USER_AGENT} ? $ENV{HTTP_USER_AGENT} : "#!string!log_0185!#",

@ -1340,10 +1340,10 @@ sub time
translate => $translate,
}});
# If the 'time' is '--', return silently.
if ($time eq "--")
# If the 'time' is '--' or '-1', return silently.
if (($time eq "--") or ($time eq "-1"))
{
return("--");
return($time);
}
# Remote commas and verify we're left with a number.

@ -1104,6 +1104,10 @@ If set, the connection will be made only to the database server matching the UUI
If set to C<< 1 >>, no attempt to ping a target before connection will happen, even if C<< database::<uuid>::ping = 1 >> is set.
=head3 sensitive (optional, default '0')
If set to C<< 1 >>, the caller is considered time sensitive and most checks are skipped. This is used when a call must respond as quickly as possible.
=head3 source (optional)
The C<< source >> parameter is used to check the special C<< updated >> table on all connected databases to see when that source (program name, usually) last updated a given database. If the date stamp is the same on all connected databases, nothing further happens. If one of the databases differ, however, a resync will be requested.
@ -1162,6 +1166,7 @@ sub connect
my $db_uuid = defined $parameter->{db_uuid} ? $parameter->{db_uuid} : "";
my $no_ping = defined $parameter->{no_ping} ? $parameter->{no_ping} : 0;
my $check_for_resync = defined $parameter->{check_for_resync} ? $parameter->{check_for_resync} : 0;
my $sensitive = defined $parameter->{sensitive} ? $parameter->{sensitive} : 0;
my $source = defined $parameter->{source} ? $parameter->{source} : "core";
my $sql_file = defined $parameter->{sql_file} ? $parameter->{sql_file} : $anvil->data->{path}{sql}{'anvil.sql'};
my $tables = defined $parameter->{tables} ? $parameter->{tables} : "";
@ -1171,6 +1176,7 @@ sub connect
db_uuid => $db_uuid,
no_ping => $no_ping,
check_for_resync => $check_for_resync,
sensitive => $sensitive,
source => $source,
sql_file => $sql_file,
tables => $tables,
@ -1216,6 +1222,12 @@ sub connect
delete $anvil->data->{sys}{database}{identifier};
}
if ($sensitive)
{
$check_for_resync = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { check_for_resync => $check_for_resync }});
}
# Now setup or however-many connections
my $seen_connections = [];
my $failed_connections = [];
@ -1720,7 +1732,16 @@ sub connect
# }
}
# Make sure my host UUID is valud
if ($sensitive)
{
# Return here.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"sys::database::connections" => $anvil->data->{sys}{database}{connections},
}});
return($anvil->data->{sys}{database}{connections});
}
# Make sure my host UUID is valod
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "sys::host_uuid" => $anvil->data->{sys}{host_uuid} }});
if ($anvil->data->{sys}{host_uuid} !~ /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/)
{
@ -6840,10 +6861,50 @@ sub insert_or_update_health
{
if (not $health_uuid)
{
# Throw an error and exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_uuid" }});
return("");
# If we've got an agent and source name, try to find a health UUID.
if (($health_agent_name) && ($health_source_name))
{
# See if we can find an entry. If not, this might be a simple check to clear.
my $query = "
SELECT
health_uuid
FROM
health
WHERE
health_host_uuid = ".$anvil->Database->quote($health_host_uuid)."
AND
health_agent_name = ".$anvil->Database->quote($health_agent_name)."
AND
health_source_name = ".$anvil->Database->quote($health_source_name)."
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
my $results = $anvil->Database->query({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
my $count = @{$results};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
results => $results,
count => $count,
}});
if ($count)
{
$health_uuid = $results->[0]->[0];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { health_uuid => $health_uuid }});
}
else
{
# Silently exit.
return("");
}
}
else
{
# Throw an error and exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_health()", parameter => "health_uuid" }});
return("");
}
}
# Still alive? do a DELETE.
my $query = "
UPDATE
health
@ -6855,7 +6916,7 @@ WHERE
;";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { query => $query }});
$anvil->Database->write({uuid => $uuid, query => $query, source => $file ? $file." -> ".$THIS_FILE : $THIS_FILE, line => $line ? $line." -> ".__LINE__ : __LINE__});
$query = "
DELETE FROM
health
@ -12167,7 +12228,7 @@ sub insert_or_update_temperature
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0020", variables => { method => "Database->insert_or_update_temperature()", parameter => "temperature_is" }});
return("");
}
elsif (($temperature_is ne "nominal") && ($temperature_is ne "warning") && ($temperature_is ne "critical"))
elsif (($temperature_is ne "nominal") && ($temperature_is ne "high") && ($temperature_is ne "low"))
{
# Invalid value.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", key => "log_0547", variables => { temperature_is => $temperature_is }});
@ -13134,6 +13195,12 @@ sub insert_or_update_variables
return("!!error!!");
}
if ($variable_source_uuid eq "")
{
$variable_source_uuid = "NULL";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_source_uuid => $variable_source_uuid }});
}
# If we have a variable UUID but not a name, read the variable name. If we don't have a UUID, see if
# we can find one for the given variable name.
if (($anvil->Validate->uuid({uuid => $variable_uuid})) && (not $variable_name))
@ -13559,9 +13626,13 @@ sub locking
if ($lock_value)
{
my $variable_uuid = $anvil->Database->insert_or_update_variables({
variable_name => $variable_name,
variable_value => "",
update_value_only => 1,
variable_name => $variable_name,
variable_value => "",
variable_default => "",
variable_description => "striker_0289",
variable_section => "database",
variable_source_uuid => "NULL",
variable_source_table => "",
});
$anvil->data->{sys}{database}{local_lock_active} = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -13582,9 +13653,13 @@ sub locking
{
# Yup, do it.
my $variable_uuid = $anvil->Database->insert_or_update_variables({
variable_name => $variable_name,
variable_value => $variable_value,
update_value_only => 1,
variable_name => $variable_name,
variable_value => $variable_value,
variable_default => "",
variable_description => "striker_0289",
variable_section => "database",
variable_source_uuid => "NULL",
variable_source_table => "",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_uuid => $variable_uuid }});
@ -13644,9 +13719,13 @@ sub locking
{
# The lock is stale.
my $variable_uuid = $anvil->Database->insert_or_update_variables({
variable_name => $variable_name,
variable_value => "",
update_value_only => 1,
variable_name => $variable_name,
variable_value => "",
variable_default => "",
variable_description => "striker_0289",
variable_section => "database",
variable_source_uuid => "",
variable_source_table => "",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_uuid => $variable_uuid }});
}
@ -13672,9 +13751,13 @@ sub locking
{
# Yup, do it.
my $variable_uuid = $anvil->Database->insert_or_update_variables({
variable_name => $variable_name,
variable_value => $variable_value,
update_value_only => 1,
variable_name => $variable_name,
variable_value => $variable_value,
variable_default => "",
variable_description => "striker_0289",
variable_section => "database",
variable_source_uuid => "NULL",
variable_source_table => "",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { variable_uuid => $variable_uuid }});
@ -14615,7 +14698,12 @@ sub read_variable
variable_source_table => $variable_source_table,
}});
# Do we have either the
if (not $variable_source_uuid)
{
$variable_source_uuid = "NULL";
}
# Do we have either the variable name or UUID?
if ((not $variable_name) && (not $variable_uuid))
{
# Throw an error and exit.
@ -14653,6 +14741,7 @@ AND
}
}
$query .= ";";
$query =~ s/'NULL'/NULL/g;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0124", variables => { query => $query }});
my $variable_value = "";
@ -16426,28 +16515,28 @@ ORDER BY
"sys::database::table::${table}::uuid::${uuid}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated},
"sys::database::table::${table}::uuid::${uuid}::row_count" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count},
}});
if ($anvil->data->{sys}{database}{table}{$table}{last_updated} > $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated})
{
# Resync needed.
my $difference = $anvil->data->{sys}{database}{table}{$table}{last_updated} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"s1:difference" => $anvil->Convert->add_commas({number => $difference }),
"s2:sys::database::table::${table}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{last_updated},
"s3:sys::database::table::${table}::uuid::${uuid}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated},
}});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0106", variables => {
seconds => $difference,
table => $table,
uuid => $uuid,
host => $anvil->Get->host_name_from_uuid({host_uuid => $uuid}),
}});
# Mark it as behind.
$anvil->Database->_mark_database_as_behind({debug => $debug, uuid => $uuid});
last;
}
elsif ($anvil->data->{sys}{database}{table}{$table}{row_count} > $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count})
# if ($anvil->data->{sys}{database}{table}{$table}{last_updated} > $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated})
# {
# # Resync needed.
# my $difference = $anvil->data->{sys}{database}{table}{$table}{last_updated} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated};
# $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
# "s1:difference" => $anvil->Convert->add_commas({number => $difference }),
# "s2:sys::database::table::${table}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{last_updated},
# "s3:sys::database::table::${table}::uuid::${uuid}::last_updated" => $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{last_updated},
# }});
#
# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0106", variables => {
# seconds => $difference,
# table => $table,
# uuid => $uuid,
# host => $anvil->Get->host_name_from_uuid({host_uuid => $uuid}),
# }});
#
# # Mark it as behind.
# $anvil->Database->_mark_database_as_behind({debug => $debug, uuid => $uuid});
# last;
# }
if ($anvil->data->{sys}{database}{table}{$table}{row_count} > $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count})
{
# Resync needed.
my $difference = ($anvil->data->{sys}{database}{table}{$table}{row_count} - $anvil->data->{sys}{database}{table}{$table}{uuid}{$uuid}{row_count});

@ -6,13 +6,15 @@ package Anvil::Tools::Striker;
use strict;
use warnings;
use Data::Dumper;
use Scalar::Util qw(weaken isweak);
use JSON;
use Scalar::Util qw(weaken isweak);
use Text::Diff;
our $VERSION = "3.0.0";
my $THIS_FILE = "Striker.pm";
### Methods;
# check_httpd_conf
# generate_manifest
# get_fence_data
# get_local_repo
@ -81,6 +83,93 @@ sub parent
# Public methods #
#############################################################################################################
=head2 check_httpd_conf
This checks the apache configuration file to ensure it's setup for the Striker dashboard and RPM repository. This method does nothing if called on non-striker dashboard.
This method takes no parameters.
=cut
sub check_httpd_conf
{
my $self = shift;
my $parameter = shift;
my $anvil = $self->parent;
my $debug = defined $parameter->{debug} ? $parameter->{debug} : 3;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->check_httpd_conf()" }});
my $update_file = 0;
my $in_dir_module = 0;
my $old_httpd_conf = $anvil->Storage->read_file({file => $anvil->data->{path}{data}{httpd_conf}});
my $new_httpd_conf = "";
foreach my $line (split/\n/, $old_httpd_conf)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { line => $line }});
if ($line =~ /^<IfModule dir_module>/)
{
$in_dir_module = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_dir_module => $in_dir_module }});
}
if ($in_dir_module)
{
if ($line =~ /^<\/IfModule>/)
{
$in_dir_module = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { in_dir_module => $in_dir_module }});
}
elsif ($line =~ /^\s+DirectoryIndex (.*)/)
{
my $directory_index = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { directory_index => $directory_index }});
if ($directory_index ne "cgi-bin/striker")
{
$line =~ s/$directory_index/cgi-bin\/striker/;
$update_file = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
line => $line,
update_file => $update_file,
}});
}
}
}
$new_httpd_conf .= $line."\n";
}
if ($update_file)
{
# Write the new file out.
my $db_difference = diff \$old_httpd_conf, \$new_httpd_conf, { STYLE => 'Unified' };
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0625", variables => {
file => $anvil->data->{path}{data}{httpd_conf},
difference => $db_difference,
}});
my $error = $anvil->Storage->write_file({
debug => $debug,
body => $new_httpd_conf,
file => $anvil->data->{path}{data}{httpd_conf},
group => "root",
user => "root",
mode => "0644",
overwrite => 1,
backup => 1,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, secure => 0, list => { error => $error }});
if (not $error)
{
# Restart apache.
$anvil->System->restart_daemon({
debug => $debug,
daemon => "httpd.service",
});
}
}
return(0);
}
=head2 generate_manifest
This reads the CGI data coming from the manifest form to generate the manifest XML.

@ -4863,10 +4863,12 @@ sub update_hosts
}
# Read in the existing hosts file
my $add_header = 1;
my $changes = 0;
my $new_body = "";
my $old_body = $anvil->Storage->read_file({
my $add_header = 1;
my $changes = 0;
my $added_lo_ipv4 = 0;
my $added_lo_ipv6 = 0;
my $new_body = "";
my $old_body = $anvil->Storage->read_file({
debug => $debug,
file => $anvil->data->{path}{configs}{hosts},
});
@ -4909,6 +4911,53 @@ sub update_hosts
next;
}
# If this line is localhost, set it statically. This is needed because cloud-init sets the
# real host name to point to 127.0.0.1 / ::1. (WHY?!)
if ($line =~ /^127.0.0.1\s/)
{
if ($line ne "127.0.0.1\tlocalhost localhost.localdomain localhost4 localhost4.localdomain4")
{
$changes = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { changes => $changes }});
if (not $added_lo_ipv4)
{
$new_body .= "127.0.0.1\tlocalhost localhost.localdomain localhost4 localhost4.localdomain4\n";
$added_lo_ipv4 = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { added_lo_ipv4 => $added_lo_ipv4 }});
}
}
else
{
# Line is as expected.
$added_lo_ipv4 = 1;
$new_body .= $line."\n";
}
next;
}
if ($line =~ /^::1\s/)
{
if ($line ne "::1\t\tlocalhost localhost.localdomain localhost6 localhost6.localdomain6")
{
$changes = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { changes => $changes }});
if (not $added_lo_ipv6)
{
$new_body .= "::1\t\tlocalhost localhost.localdomain localhost6 localhost6.localdomain6\n";
$added_lo_ipv6 = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { added_lo_ipv6 => $added_lo_ipv6 }});
}
}
else
{
# Line is as expected.
$added_lo_ipv6 = 1;
$new_body .= $line."\n";
}
next;
}
# Now pull apart the line and store the entries.
my ($ip_address, $names) = ($line =~ /^(.*?)\s+(.*)$/);
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
@ -4954,7 +5003,7 @@ sub update_hosts
# Matches, we don't need to deal with this name.
delete $anvil->data->{hosts}{needed}{$name};
}
elsif ($ip_address ne "127.0.0.1")
else
{
# The IP has changed. Skip this name (which removes it from the list).
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0481", variables => {

@ -7,7 +7,6 @@ jqueryuiver = 1.12.1
dist_html_DATA = \
favicon.ico \
index.html \
jquery-$(jqueryver).js
# empty dir for now

@ -1,8 +0,0 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Striker</title>
<META HTTP-EQUIV="Refresh" CONTENT="0; URL=cgi-bin/striker">
</head>
<body>
Hi, I'll be right with you...
</body>

@ -2245,6 +2245,14 @@
&nbsp;
</td>
</tr>
<tr>
<td class="main_option_icon">
<a href="/index.html"><img src="#!data!skin::url!#/images/anvil_icon_on.png" class="top_icon" ></a>
</td>
<td class="main_option">
<a href="/index.html">#!string!striker_0288!#</a>
</td>
</tr>
<tr>
<td class="main_option_icon">
<a href="?anvil=true&task=prep-host"><img src="#!data!skin::url!#/images/prep-host_icon.png" class="top_icon" ></a>

@ -97,16 +97,6 @@ $| = 1;
# in the loop as well to override defaults in code.
my $anvil = Anvil::Tools->new();
# If we can connect to a database, we'll set/clear the 'migrating' flag during migrations. For timing reasons
# we don't let the RA do resyncs.
$anvil->Database->connect({no_resync => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, we're only going to be able to do status checks..
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "warning_0073"});
}
### Read or Set the environment variables
# This is the name of the server we're managing. # Example values:
$anvil->data->{environment}{OCF_RESKEY_name} = defined $ENV{OCF_RESKEY_name} ? $ENV{OCF_RESKEY_name} : "";
@ -117,20 +107,20 @@ $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node_uuid} = defined $ENV{O
# This is the timeout for the called action in millisecond.
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_timeout} = defined $ENV{OCF_RESKEY_CRM_meta_timeout} ? $ENV{OCF_RESKEY_CRM_meta_timeout} : ""; # 20000
# If this is set, we'll bump our log level as well.
$anvil->data->{environment}{PCMK_debug} = defined $ENV{PCMK_debug} ? $ENV{PCMK_debug} : ""; # 0
$anvil->data->{environment}{PCMK_debug} = defined $ENV{PCMK_debug} ? $ENV{PCMK_debug} : "0"; # Disable debug by default
# These are other variables that are set, but we don't currently care about them
$anvil->data->{environment}{OCF_EXIT_REASON_PREFIX} = defined $ENV{OCF_EXIT_REASON_PREFIX} ? $ENV{OCF_EXIT_REASON_PREFIX} : ""; # ocf-exit-reason:
$anvil->data->{environment}{OCF_EXIT_REASON_PREFIX} = defined $ENV{OCF_EXIT_REASON_PREFIX} ? $ENV{OCF_EXIT_REASON_PREFIX} : "ocf-exit-reason:";
$anvil->data->{environment}{OCF_RA_VERSION_MAJOR} = defined $ENV{OCF_RA_VERSION_MAJOR} ? $ENV{OCF_RA_VERSION_MAJOR} : ""; # 1
$anvil->data->{environment}{OCF_RA_VERSION_MINOR} = defined $ENV{OCF_RA_VERSION_MINOR} ? $ENV{OCF_RA_VERSION_MINOR} : ""; # 0
$anvil->data->{environment}{OCF_RESKEY_crm_feature_set} = defined $ENV{OCF_RESKEY_crm_feature_set} ? $ENV{OCF_RESKEY_crm_feature_set} : ""; # 3.0.12
$anvil->data->{environment}{OCF_RESOURCE_INSTANCE} = defined $ENV{OCF_RESOURCE_INSTANCE} ? $ENV{OCF_RESOURCE_INSTANCE} : ""; # srv01-c7
$anvil->data->{environment}{OCF_RESOURCE_PROVIDER} = defined $ENV{OCF_RESOURCE_PROVIDER} ? $ENV{OCF_RESOURCE_PROVIDER} : ""; # alteeve
$anvil->data->{environment}{OCF_RESOURCE_TYPE} = defined $ENV{OCF_RESOURCE_TYPE} ? $ENV{OCF_RESOURCE_TYPE} : ""; # server
$anvil->data->{environment}{OCF_ROOT} = defined $ENV{OCF_ROOT} ? $ENV{OCF_ROOT} : ""; # /usr/lib/ocf
$anvil->data->{environment}{OCF_RESKEY_crm_feature_set} = defined $ENV{OCF_RESKEY_crm_feature_set} ? $ENV{OCF_RESKEY_crm_feature_set} : ""; # Pacemaker OCF version - 3.7.1
$anvil->data->{environment}{OCF_RESOURCE_INSTANCE} = defined $ENV{OCF_RESOURCE_INSTANCE} ? $ENV{OCF_RESOURCE_INSTANCE} : ""; # Name of server / resource being acted on.
$anvil->data->{environment}{OCF_RESOURCE_PROVIDER} = defined $ENV{OCF_RESOURCE_PROVIDER} ? $ENV{OCF_RESOURCE_PROVIDER} : "alteeve";
$anvil->data->{environment}{OCF_RESOURCE_TYPE} = defined $ENV{OCF_RESOURCE_TYPE} ? $ENV{OCF_RESOURCE_TYPE} : "server";
$anvil->data->{environment}{OCF_ROOT} = defined $ENV{OCF_ROOT} ? $ENV{OCF_ROOT} : "/usr/lib/ocf";
# These are set during a migration
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_source} ? $ENV{OCF_RESKEY_CRM_meta_migrate_source} : ""; # mk-a02n01.digimer.ca
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_target} ? $ENV{OCF_RESKEY_CRM_meta_migrate_target} : ""; # mk-a02n02.digimer.ca
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_record_pending} = defined $ENV{OCF_RESKEY_CRM_meta_record_pending} ? $ENV{OCF_RESKEY_CRM_meta_record_pending} : ""; # true
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_source} ? $ENV{OCF_RESKEY_CRM_meta_migrate_source} : "";
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target} = defined $ENV{OCF_RESKEY_CRM_meta_migrate_target} ? $ENV{OCF_RESKEY_CRM_meta_migrate_target} : "";
$anvil->data->{environment}{OCF_RESKEY_CRM_meta_record_pending} = defined $ENV{OCF_RESKEY_CRM_meta_record_pending} ? $ENV{OCF_RESKEY_CRM_meta_record_pending} : "";
# Any variable=value arguments in the resource are set under 'OCF_RESKEY_CRM_meta_'
foreach my $key (sort {$a cmp $b} keys %ENV)
{
@ -156,7 +146,28 @@ $anvil->data->{environment}{OCF_RESKEY_CRM_meta_stop_drbd_resources} = 0;
$anvil->data->{switches}{migrate_to} = ""; # Sets 'meta_migrate_target'
$anvil->data->{switches}{migrate_from} = ""; # Sets 'meta_migrate_source' When set without 'migrate_to', does a status check after migration
$anvil->data->{switches}{server} = ""; # Sets 'name'.
$anvil->data->{switches}{start} = "";
$anvil->data->{switches}{stop} = "";
$anvil->data->{switches}{monitor} = "";
$anvil->Get->switches();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"switches::migrate_to" => $anvil->data->{switches}{migrate_to},
"switches::migrate_from" => $anvil->data->{switches}{migrate_from},
"switches::server" => $anvil->data->{switches}{server},
"switches::start" => $anvil->data->{switches}{start},
"switches::stop" => $anvil->data->{switches}{stop},
"switches::monitor" => $anvil->data->{switches}{monitor},
}});
# If we can connect to a database, we'll set/clear the 'migrating' flag during migrations. For timing reasons
# we don't let the RA do resyncs.
$anvil->Database->connect({sensitive => 1});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases,
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "warning_0073"});
}
if ($anvil->data->{switches}{stop_drbd_resources})
{
@ -164,36 +175,187 @@ if ($anvil->data->{switches}{stop_drbd_resources})
}
# Something for the logs
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 3, key => "log_0298"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 0, level => 2, key => "log_0298"});
=cut
Start:
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [start]
environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [300000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Monitor after start:
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Monitor one minute later:
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Migrate from an-a02n01 to an-a02n02
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
<2 seconds later>
environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_name: [migrate_to]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: [true]
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_ROOT: [/usr/lib/ocf]
Post migration on an-a02n01
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [stop]
environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [1]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::PCMK_debug: [0]
Post migration on an-a02n02
environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a02n01]
environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_name: [migrate_from]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [600000]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
Checking server state after: [srv02-c8s-fujitsu] was migrated to this host.
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
server --server
-=] Boot (on an-a01n01)
2021/04/17 18:41:30:ocf:alteeve:server:236; environment::OCF_RESKEY_CRM_meta_name: [start]
2021/04/17 18:41:30:ocf:alteeve:server:236; environment::OCF_RESKEY_CRM_meta_on_node: [an-a01n01]
Monitor on an-a02n02 after a minute
-=] Stop (on an-a01n01)
2021/04/17 18:33:50:ocf:alteeve:server:236; environment::OCF_RESKEY_CRM_meta_name: [stop]
2021/04/17 18:33:50:ocf:alteeve:server:236; environment::OCF_RESKEY_CRM_meta_on_node: [an-a01n01]
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_interval: [60000]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [monitor]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [20000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
-=] Migration - source (before - from an-a01n01)
2021/04/17 19:33:12:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a01n01]
2021/04/17 19:33:12:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a01n02]
2021/04/17 19:33:12:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_name: [migrate_to]
2021/04/17 19:33:12:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_on_node: [an-a01n01]
-=] Migration - target (after - to an-a01n02)
2021/04/17 19:33:19:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_migrate_source: [an-a01n01]
2021/04/17 19:33:19:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_migrate_target: [an-a01n02]
2021/04/17 19:33:19:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_name: [migrate_from]
2021/04/17 19:33:19:ocf:alteeve:server:196; environment::OCF_RESKEY_CRM_meta_on_node: [an-a01n02]
Stop server:
environment::OCF_EXIT_REASON_PREFIX: [ocf-exit-reason:]
environment::OCF_RA_VERSION_MAJOR: [1]
environment::OCF_RA_VERSION_MINOR: [0]
environment::OCF_RESKEY_CRM_meta_migrate_source: []
environment::OCF_RESKEY_CRM_meta_migrate_target: []
environment::OCF_RESKEY_CRM_meta_name: [stop]
environment::OCF_RESKEY_CRM_meta_on_fail: [block]
environment::OCF_RESKEY_CRM_meta_on_node: [an-a02n02]
environment::OCF_RESKEY_CRM_meta_on_node_uuid: [2]
environment::OCF_RESKEY_CRM_meta_record_pending: []
environment::OCF_RESKEY_CRM_meta_stop_drbd_resources: [0]
environment::OCF_RESKEY_CRM_meta_timeout: [86400000]
environment::OCF_RESKEY_crm_feature_set: [3.7.1]
environment::OCF_RESKEY_name: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_INSTANCE: [srv02-c8s-fujitsu]
environment::OCF_RESOURCE_PROVIDER: [alteeve]
environment::OCF_RESOURCE_TYPE: [server]
environment::OCF_ROOT: [/usr/lib/ocf]
environment::PCMK_debug: [0]
=cut
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{environment}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"environment::${key}" => $anvil->data->{environment}{$key},
}});
}
@ -336,7 +498,7 @@ sub check_daemons
# Is the peer running? We'll use this to know whether to try and start daemons on the peer.
my $peer_name = $anvil->data->{cib}{parsed}{peer}{name};
my $peer_ready = $anvil->data->{cib}{parsed}{peer}{ready};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
peer_name => $peer_name,
peer_ready => $peer_ready,
}});
@ -351,7 +513,7 @@ sub check_daemons
my $running_peer = 0;
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
@ -360,7 +522,7 @@ sub check_daemons
# It is stopped, start it..
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0482", variables => { daemon => $daemon }});
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
@ -370,7 +532,7 @@ sub check_daemons
until ($running)
{
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
@ -410,7 +572,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
@ -426,7 +588,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." start ".$daemon,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
@ -440,7 +602,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
@ -503,7 +665,7 @@ sub check_daemons
# Call virsh list --all
my ($local_output, $local_return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." list --all"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
local_output => $local_output,
local_return_code => $local_return_code,
}});
@ -513,12 +675,12 @@ sub check_daemons
foreach my $line (split/\n/, $local_output)
{
$line = $anvil->Words->clean_spaces({ string => $line });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /(\d+)\s+(.*?)\s+running/)
{
$local_vm_count++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { local_vm_count => $local_vm_count }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { local_vm_count => $local_vm_count }});
}
}
}
@ -527,7 +689,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{virsh}." list --all",
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
remote_output => $remote_output,
remote_error => $remote_error,
remote_return_code => $remote_return_code,
@ -538,17 +700,17 @@ sub check_daemons
foreach my $line (split/\n/, $remote_output)
{
$line = $anvil->Words->clean_spaces({ string => $line });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /(\d+)\s+(.*?)\s+running/)
{
$remote_vm_count++;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { remote_vm_count => $remote_vm_count }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { remote_vm_count => $remote_vm_count }});
}
}
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
local_vm_count => $local_vm_count,
remote_vm_count => $remote_vm_count,
}});
@ -570,7 +732,7 @@ sub check_daemons
my $running_peer = 0;
my ($local_output, $local_return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
local_output => $local_output,
local_return_code => $local_return_code,
}});
@ -584,7 +746,7 @@ sub check_daemons
# Running, stop it.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, key => "log_0493", variables => { daemon => $daemon }});
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{systemctl}." stop ".$daemon});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
@ -594,7 +756,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." status ".$daemon,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
remote_output => $remote_output,
remote_error => $remote_error,
remote_return_code => $remote_return_code,
@ -618,7 +780,7 @@ sub check_daemons
target => $peer_name,
shell_call => $anvil->data->{path}{exe}{systemctl}." stop ".$daemon,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
error => $error,
return_code => $return_code,
@ -994,7 +1156,7 @@ sub stop_server
}
# Now stop the DRBD resource(s).
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'environment::OCF_RESKEY_CRM_meta_stop_drbd_resources' => $anvil->data->{environment}{OCF_RESKEY_CRM_meta_stop_drbd_resources},
}});
if ($anvil->data->{environment}{OCF_RESKEY_CRM_meta_stop_drbd_resources})
@ -1011,8 +1173,6 @@ sub server_status
{
my ($anvil) = @_;
### NOTE: This method MUST always work, even without access to databases!
# If the named server is running, return OCF_SUCCESS (rc: 0), otherwise OCF_NOT_RUNNING (rc: 7). If
# the server is failed, return OCF_ERR_GENERIC (1).
my $state = "";
@ -1035,11 +1195,11 @@ sub server_status
while($libvirtd_wait)
{
my $running = $anvil->System->check_daemon({daemon => "libvirtd.service"});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { running => $running }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { running => $running }});
if ($running)
{
$libvirtd_wait = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { libvirtd_wait => $libvirtd_wait }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { libvirtd_wait => $libvirtd_wait }});
}
else
{
@ -1056,7 +1216,7 @@ sub server_status
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "warning_0057"});
$look_for_pid = 1;
$libvirtd_wait = 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
look_for_pid => $look_for_pid,
libvirtd_wait => $libvirtd_wait,
}});
@ -1069,10 +1229,10 @@ sub server_status
{
my $server_up = 0;
my $shell_call = $anvil->data->{path}{exe}{ps}." aux";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { shell_call => $shell_call }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
@ -1081,18 +1241,18 @@ sub server_status
next if $line !~ /qemu-kvm/;
$line = $anvil->Words->clean_spaces({ string => $line });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /guest=(.*?),/)
{
my $this_server = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { this_server => $this_server }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { this_server => $this_server }});
if ($this_server eq $server)
{
# Found it.
$server_up = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { server_up => $server_up }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { server_up => $server_up }});
last;
}
}
@ -1122,23 +1282,23 @@ sub server_status
$loop = 0;
my $found = 0;
my $shell_call = $anvil->data->{path}{exe}{virsh}." list --all";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { shell_call => $shell_call }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { shell_call => $shell_call }});
my ($output, $return_code) = $anvil->System->call({shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
output => $output,
return_code => $return_code,
}});
foreach my $line (split/\n/, $output)
{
$line = $anvil->Words->clean_spaces({ string => $line });
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { line => $line }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { line => $line }});
if ($line =~ /\s\Q$server\E\s+(.*)/)
{
my $state = $1;
$found = 1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
found => $found,
'state' => $state,
}});
@ -1202,18 +1362,23 @@ pmsuspended - The domain has been suspended by guest power management, e.g. ente
$anvil->nice_exit({exit_code => 1});
}
### TODO: Write the migration duration to /tmp/anvil.migration.<server>.data and have 'anvil-migrate-server' read that in to update the DB.
# Migrate the server
sub migrate_server
{
my ($anvil) = @_;
# This requires a database
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "error_0003"});
return(1);
}
### This requires a database
# If we can connect to a database, we'll set/clear the 'migrating' flag during migrations. For timing
# reasons we don't let the RA do resyncs.
# $anvil->Database->connect({sensitive => 1});
# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
# if (not $anvil->data->{sys}{database}{connections})
# {
# # No databases, exit.
# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, secure => 0, key => "error_0003"});
# return(1);
# }
### NOTE: For now, we're not going to block if the target is not UpToDate. There are times when a
### user might want to do this (ie: sync will be done soon and the need to evacuate the node
@ -1309,7 +1474,7 @@ sub migrate_server
$anvil->nice_exit({exit_code => 1});
}
# Get a view of the servers locally and our peer.
# Get a view of the servers locally and on our peer.
validate_all($anvil);
# Get the DRBD status.
@ -1558,7 +1723,7 @@ sub validate_bridges
if ($found)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, key => "log_0368", variables => { bridge => $bridge }});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, key => "log_0368", variables => { bridge => $bridge }});
}
else
{
@ -1590,7 +1755,7 @@ sub validate_storage
{
$xml_source = "from_virsh";
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
xml_source => $xml_source,
}});
@ -1729,7 +1894,7 @@ sub validate_emulator
my $local_host = $anvil->Get->short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $emulator = $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{emulator};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
emulator => $emulator,
"server::${local_host}::${server}::from_disk::info::emulator" => $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{emulator}
}});
@ -1760,7 +1925,7 @@ sub validate_name
my $local_host = $anvil->Get->short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
"server::${local_host}::${server}::from_disk::info::name" => $anvil->data->{server}{$local_host}{$server}{from_disk}{info}{name},
}});
@ -1799,7 +1964,7 @@ sub validate_ram
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $server_ram_bytes = $anvil->data->{server}{$local_host}{$server}{from_disk}{memory};
my $available = $anvil->Get->free_memory({debug => 3});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server_ram_bytes => $anvil->Convert->add_commas({number => $server_ram_bytes})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $server_ram_bytes}).")",
available => $anvil->Convert->add_commas({number => $available})." (".$anvil->Convert->bytes_to_human_readable({'bytes' => $available}).")",
}});
@ -1838,7 +2003,7 @@ sub read_server_definition
my ($anvil) = @_;
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
}});

@ -925,8 +925,8 @@ sub find_changes
my $new_swap_bytes_used = $new_scan_hardware_swap_total - $new_scan_hardware_swap_free;
my $old_swap_bytes_used = $old_scan_hardware_swap_total - $old_scan_hardware_swap_free;
my $new_swap_percent_used = $anvil->Math->round({number => (($new_swap_bytes_used / $new_scan_hardware_swap_total) * 100)});
my $old_swap_percent_used = $anvil->Math->round({number => (($old_swap_bytes_used / $old_scan_hardware_swap_total) * 100)});
my $new_swap_percent_used = $anvil->Convert->round({number => (($new_swap_bytes_used / $new_scan_hardware_swap_total) * 100)});
my $old_swap_percent_used = $anvil->Convert->round({number => (($old_swap_bytes_used / $old_scan_hardware_swap_total) * 100)});
my $swap_percent_high = $anvil->data->{scancore}{'scan-hardware'}{swap}{high_threshold} =~ /^\d+/ ? $anvil->data->{scancore}{'scan-hardware'}{swap}{high_threshold} : 75;
my $swap_percent_low = $anvil->data->{scancore}{'scan-hardware'}{swap}{clear_threshold} =~ /^\d+/ ? $anvil->data->{scancore}{'scan-hardware'}{swap}{clear_threshold} : 25;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
@ -1356,7 +1356,7 @@ sub process_health
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { health_uuid => $health_uuid }});
}
elsif (($peer_ram_total == $hardware_ram_total) or ($difference < $anvil->data->{scancore}{'scan-hardware'}{ram}{clear_threshold}))
elsif ((not $difference) or ($difference < $anvil->data->{scancore}{'scan-hardware'}{ram}{clear_threshold}))
{
my $age = $anvil->Alert->check_condition_age({
debug => 2,
@ -1364,6 +1364,7 @@ sub process_health
name => "scan-hardware::less_ram_than_peer",
host_uuid => $anvil->Get->host_uuid,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { age => $age }});
my $changed = $anvil->Alert->check_alert_sent({
debug => 3,
record_locator => "scan_hardware::less_ram_than_peer",
@ -1381,10 +1382,10 @@ sub process_health
$anvil->Alert->register({alert_level => "warning", message => "scan_hardware_alert_0028", variables => $variables, set_by => $THIS_FILE});
}
my ($health_uuid) = $anvil->Database->insert_or_update_health({
debug => 2,
health_agent_name => $THIS_FILE,
health_source_name => "less_ram_than_peer",
health_source_weight => 0,
debug => 2,
health_agent_name => $THIS_FILE,
health_source_name => "less_ram_than_peer",
'delete' => 1,
});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { health_uuid => $health_uuid }});
}

@ -416,6 +416,8 @@ The attempt to start the servers appears to have failed. The return code '0' was
<key name="error_0302">The passed in Anvil! UUID: [#!variable!anvil_uuid!#] was not found in the database.</key>
<key name="error_0303">The passed in host UUID: [#!variable!host_uuid!#] was not found in the database.</key>
<key name="error_0304">Failed to parse the request body: [#!variable!request_body_string!#]. Reason: [#!variable!json_decode_error!#]</key>
<key name="error_0305">Unable to connect to the database, unable to manage a server at this time.</key>
<key name="error_0306">Unable to connect to the database, unable to provision a server at this time.</key>
<!-- Files templates -->
<!-- NOTE: Translating these files requires an understanding of which lines are translatable -->
@ -1807,6 +1809,11 @@ The file: [#!variable!file!#] needs to be updated. The difference is:
<key name="log_0622">Aging out one or more records that are more than: [#!variable!age!#] hours old from the table: [#!variable!table!#] on the database host: [#!variable!database!#].</key>
<key name="log_0623">Starting the process of aging out old data. This can take about a minute, please be patient.</key>
<key name="log_0624">Aging out old data completed after: [#!variable!runtime!#] seconds.</key>
<key name="log_0625">Updating the apache configuration file: [#!variable!file!#]. The changes are:
====
#!variable!difference!#
====
</key>
<!-- Messages for users (less technical than log entries), though sometimes used for logs, too. -->
<key name="message_0001">The host name: [#!variable!target!#] does not resolve to an IP address.</key>
@ -2153,6 +2160,8 @@ Are you sure that you want to delete the server: [#!variable!server_name!#]? [Ty
<key name="message_0248">Created the journald directory: [#!variable!directory!#].</key>
<key name="message_0249">Checking that the daemon: [#!variable!daemon!#] is running.</key>
<key name="message_0250">The daemon: [#!variable!daemon!#] was not running, starting it now.</key>
<key name="message_0251">Preparing to manage a server.</key>
<key name="message_0252">Found the server: [#!variable!server_name!#] in the database, loading details now.</key>
<!-- Success messages shown to the user -->
<key name="ok_0001">Saved the mail server information successfully!</key>
@ -2474,6 +2483,8 @@ If you are comfortable that the target has changed for a known reason, you can s
<key name="striker_0285">Close</key>
<key name="striker_0286">This controls if 'anvil-safe-start' is enabled on a node.</key>
<key name="striker_0287">The virtio NAT bridge: [#!variable!bridge!#] exists. Removing it...</key>
<key name="striker_0288">Manage existing Anvil! systems.</key>
<key name="striker_0289">Control when the database is locked for use by any system except the lock holder.</key>
<!-- These are generally units and appended to numbers -->
<key name="suffix_0001">#!variable!number!#/sec</key>

@ -263,6 +263,12 @@ sub reconfigure_network
# Get the current list of IPs and MAC addresses.
$anvil->Network->get_ips({debug => 3});
# If we're a striker, check apache's config.
if ($type eq "striker")
{
$anvil->Striker->check_httpd_conf({debug => 2});
}
# Now configure the network.
my $dns = defined $anvil->data->{variables}{form}{config_step2}{dns}{value} ? [split/,/, $anvil->data->{variables}{form}{config_step2}{dns}{value}] : [];
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { dns => $dns }});

@ -943,12 +943,23 @@ AND
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { variable_uuid => $variable_uuid }});
}
# Make sure /etc/hosts is updated.
$anvil->System->update_hosts();
# Now look for jobs that have a job status of 'scancore_startup'
run_jobs($anvil, 1);
# Check the firewall needs to be updated.
check_firewall($anvil);
# If we're a striker, check apache
my $host_type = $anvil->Get->host_type;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { host_type => $host_type }});
if ($host_type eq "striker")
{
$anvil->Striker->check_httpd_conf({debug => 2});
}
return(0);
}

@ -13,6 +13,8 @@
use strict;
use warnings;
use Anvil::Tools;
require POSIX;
use Term::Cap;
my $THIS_FILE = ($0 =~ /^.*\/(.*)$/)[0];
my $running_directory = ($0 =~ /^(.*?)\/$THIS_FILE$/)[0];
@ -26,35 +28,106 @@ $| = 1;
my $anvil = Anvil::Tools->new();
$anvil->data->{switches}{'boot'} = ""; # This is a comma-separated list of ordered boot devices
$anvil->data->{switches}{'cores'} = ""; # This sets the server to use this number of CPU cores.
$anvil->data->{switches}{'drive'} = ""; # drive being modified (insert/eject ISO, growing drive)
$anvil->data->{switches}{'eject'} = ""; # This will eject whatever ISO (if any) in the '--drive'.
$anvil->data->{switches}{anvil} = ""; # This is the Anvil! Name or UUID being worked on.
$anvil->data->{switches}{boot} = ""; # This is a comma-separated list of ordered boot devices
$anvil->data->{switches}{cores} = ""; # This sets the server to use this number of CPU cores.
$anvil->data->{switches}{drive} = ""; # drive being modified (insert/eject ISO, growing drive)
$anvil->data->{switches}{eject} = ""; # This will eject whatever ISO (if any) in the '--drive'.
$anvil->data->{switches}{'expand-to'} = ""; # When the drive is a disk (backed by a DRBD resource), this is the new desired size to grow to.
$anvil->data->{switches}{'insert'} = ""; # This is the ISO to insert into the --drive
$anvil->data->{switches}{insert} = ""; # This is the ISO to insert into the --drive
$anvil->data->{switches}{'job-uuid'} = "";
$anvil->data->{switches}{'ram'} = ""; # This is the amount of RAM to set the server to use.
$anvil->data->{switches}{'server'} = ""; # server name or uuid
$anvil->data->{switches}{'y'} = ""; # Don't prompt for confirmation. Only useful when there isn't a job UUID.
$anvil->data->{switches}{ram} = ""; # This is the amount of RAM to set the server to use.
$anvil->data->{switches}{server} = ""; # server name or uuid
$anvil->data->{switches}{y} = ""; # Don't prompt for confirmation. Only useful when there isn't a job UUID.
$anvil->Get->switches;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 1, secure => 0, key => "log_0115", variables => { program => $THIS_FILE }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
'switches::boot' => $anvil->data->{switches}{'boot'},
'switches::cores' => $anvil->data->{switches}{'cores'},
'switches::drive' => $anvil->data->{switches}{'drive'},
'switches::eject' => $anvil->data->{switches}{'eject'},
'switches::boot' => $anvil->data->{switches}{boot},
'switches::cores' => $anvil->data->{switches}{cores},
'switches::drive' => $anvil->data->{switches}{drive},
'switches::eject' => $anvil->data->{switches}{eject},
'switches::expand-to' => $anvil->data->{switches}{'expand-to'},
'switches::insert' => $anvil->data->{switches}{'insert'},
'switches::insert' => $anvil->data->{switches}{insert},
'switches::job-uuid' => $anvil->data->{switches}{'job-uuid'},
'switches::ram' => $anvil->data->{switches}{'ram'},
'switches::server' => $anvil->data->{switches}{'server'},
'switches::y' => $anvil->data->{switches}{'y'},
'switches::ram' => $anvil->data->{switches}{ram},
'switches::server' => $anvil->data->{switches}{server},
'switches::y' => $anvil->data->{switches}{y},
}});
# Connect to the database(s). If we have no connections, we'll proceed anyway as one of the 'run_once' tasks
# is to setup the database server.
$anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 3, secure => 0, key => "log_0132"});
if (not $anvil->data->{sys}{database}{connections})
{
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try
# again after we exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0305"});
sleep 10;
$anvil->nice_exit({exit_code => 1});
}
# If we don't have a job UUID, try to find one.
if (not $anvil->data->{switches}{'job-uuid'})
{
# Load the job data.
$anvil->data->{switches}{'job-uuid'} = $anvil->Job->get_job_uuid({program => $THIS_FILE});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "switches::job-uuid" => $anvil->data->{switches}{'job-uuid'} }});
}
# If we still don't have a job-uuit, go into interactive mode.
if ($anvil->data->{switches}{'job-uuid'})
{
# Load the job data.
$anvil->Job->clear();
$anvil->Job->get_job_details();
$anvil->Job->update_progress({
progress => 1,
job_picked_up_by => $$,
job_picked_up_at => time,
message => "message_0251",
});
# Job data will be in $anvil->data->{jobs}{job_data}
run_jobs($anvil);
}
else
{
# Interactive!
interactive_question($anvil);
}
$anvil->nice_exit({exit_code => 0});
# Make sure we're in an Anvil!
$anvil->data->{sys}{anvil_uuid} = $anvil->Cluster->get_anvil_uuid();
@ -137,6 +210,146 @@ $anvil->nice_exit({exit_code => 0});
# Functions #
#############################################################################################################
sub run_jobs
{
my ($anvil) = @_;
return(0);
}
sub interactive_question
{
my ($anvil) = @_;
$anvil->Database->get_anvils();
$anvil->Database->get_servers();
### Server
# First, has the user specified a server? If so, and if it's by name, make sure it's unique. If the
# name exists on two or more Anvil! systems, we'll need an Anvil! name as well. If it's unique, we
# can devine the Anvil! UUID.
if ($anvil->data->{switches}{server})
{
if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{server}}))
{
$anvil->data->{target_server}{server_uuid} = $anvil->data->{switches}{server};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::server_uuid" => $anvil->data->{target_server}{server_uuid},
}});
}
else
{
$anvil->data->{target_server}{server_name} = $anvil->data->{switches}{server};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::server_name" => $anvil->data->{target_server}{server_name},
}});
}
}
# Do we know or can we find the Anvil! UUID?
$anvil->data->{target_server}{server_uuid} = $anvil->data->{switches}{'server-uuid'} ? $anvil->data->{switches}{'server-uuid'} : "";
$anvil->data->{target_server}{server_name} = $anvil->data->{switches}{'server-name'} ? $anvil->data->{switches}{'server-name'} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::server_uuid" => $anvil->data->{target_server}{server_uuid},
"target_server::server_name" => $anvil->data->{target_server}{server_name},
}});
# If we have a server UUID, make sure it's valid.
if $anvil->data->{target_server}{server_uuid})
{
# Pull up the server data.
my $server_uuid = $anvil->data->{target_server}{server_uuid};
if (exists $anvil->data->{servers}{server_uuid}{$server_uuid})
{
# We can divine everthing from this.
$anvil->data->{target_server}{server_name} = $anvil->data->{servers}{server_uuid}{$server_uuid}{server_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::server_name" => $anvil->data->{target_server}{server_name},
}});
}
}
if (not $anvil->data->{target_server}{server_name})
{
$anvil->data->{target_server}{server_name} = $anvil->Cluster->get_server_name({server_uuid => $anvil->data->{target_server}{server_uuid}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "target_server::server_name" => $anvil->data->{target_server}{server_name} }});
}
elsif (not $anvil->data->{target_server}{server_uuid})
{
$anvil->data->{target_server}{server_uuid} = $anvil->Cluster->get_server_uuid({server_name => $anvil->data->{target_server}{server_name}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "target_server::server_uuid" => $anvil->data->{target_server}{server_uuid} }});
}
### Anvil
# If 'switches::anvil' is set, see if it's a UUID and then set either 'anvil-uuid' or 'anvil-name'.
if ($anvil->data->{switches}{anvil})
{
if ($anvil->Validate->uuid({uuid => $anvil->data->{switches}{anvil}}))
{
$anvil->data->{target_server}{anvil_uuid} = $anvil->data->{switches}{anvil};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::anvil_uuid" => $anvil->data->{target_server}{anvil_uuid},
}});
}
else
{
$anvil->data->{target_server}{anvil_name} = $anvil->data->{switches}{anvil};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::anvil_name" => $anvil->data->{target_server}{anvil_name},
}});
}
}
# Do we know or can we find the Anvil! UUID?
$anvil->data->{target_server}{anvil_uuid} = $anvil->data->{switches}{'anvil-uuid'} ? $anvil->data->{switches}{'anvil-uuid'} : "";
$anvil->data->{target_server}{anvil_name} = $anvil->data->{switches}{'anvil-name'} ? $anvil->data->{switches}{'anvil-name'} : "";
if ((not $anvil->data->{target_server}{anvil_uuid}) && (not $anvil->data->{target_server}{anvil_name}))
{
# Nothing given. Is this host a node, perhaps?
my $anvil_uuid = $anvil->Cluster->get_anvil_uuid();
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { anvil_uuid => $anvil_uuid }});
if ($anvil_uuid)
{
$anvil->data->{target_server}{anvil_uuid} = $anvil_uuid;
$anvil->data->{target_server}{anvil_name} = $anvil->data->{anvils}{anvil_uuid}{$anvil_uuid}{anvil_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"target_server::anvil_name" => $anvil->data->{target_server}{anvil_name},
"target_server::anvil_uuid" => $anvil->data->{target_server}{anvil_uuid},
}});
}
}
elsif (not $anvil->data->{target_server}{anvil_uuid})
{
$anvil->data->{target_server}{anvil_uuid} = $anvil->Cluster->get_anvil_uuid({anvil_name => $anvil->data->{target_server}{anvil_name}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "target_server::anvil_uuid" => $anvil->data->{target_server}{anvil_uuid} }});
}
elsif (not $anvil->data->{target_server}{anvil_name})
{
$anvil->data->{target_server}{anvil_name} = $anvil->Cluster->get_anvil_name({anvil_uuid => $anvil->data->{target_server}{anvil_uuid}});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "target_server::anvil_name" => $anvil->data->{target_server}{anvil_name} }});
}
# If this is a node, load the anvil_uuid automatically.
my $termios = new POSIX::Termios;
$termios->getattr;
my $ospeed = $termios->getospeed;
my $terminal = Tgetent Term::Cap { TERM => undef, OSPEED => $ospeed };
$terminal->Trequire(qw/ce ku kd/);
return(0);
}
sub show_stats
{
my ($anvil) = @_;

@ -65,7 +65,7 @@ if (not $anvil->data->{sys}{database}{connections})
{
# No databases, update the job, sleep for a bit and then exit. The daemon will pick it up and try
# again after we exit.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0077"});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0306"});
sleep 10;
$anvil->nice_exit({exit_code => 1});
}

Loading…
Cancel
Save