* Continues work on migrating ocf:alteeve:server to use Anvil::Tools.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 6 years ago
parent 9c0f6b8f79
commit c0220c9635
  1. 170
      ocf/alteeve/server
  2. 121
      share/words.xml

@ -98,32 +98,30 @@ my $anvil = Anvil::Tools->new();
$anvil->Log->level({set => 2}); $anvil->Log->level({set => 2});
$anvil->Log->secure({set => 1}); $anvil->Log->secure({set => 1});
# Read or Set the environment variables ### Read or Set the environment variables
$anvil->data->{environment} => { # This is the name of the server we're managing. # Example values:
# 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} : ""; # srv01-c7
OCF_RESKEY_name => defined $ENV{OCF_RESKEY_name} ? $ENV{OCF_RESKEY_name} : "", # srv01-c7 # This is our node name
# This is our node name $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node} = defined $ENV{OCF_RESKEY_CRM_meta_on_node} ? $ENV{OCF_RESKEY_CRM_meta_on_node} : ""; # el8-a01n01.digimer.ca
OCF_RESKEY_CRM_meta_on_node => defined $ENV{OCF_RESKEY_CRM_meta_on_node} ? $ENV{OCF_RESKEY_CRM_meta_on_node} : "", # el8-a01n01.digimer.ca # This says "UUID", but it's the node ID.
# This says "UUID", but it's the node ID. $anvil->data->{environment}{OCF_RESKEY_CRM_meta_on_node_uuid} = defined $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} ? $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} : ""; # 1
OCF_RESKEY_CRM_meta_on_node_uuid => defined $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} ? $ENV{OCF_RESKEY_CRM_meta_on_node_uuid} : "", # 1 # This is the timeout for the called action in millisecond.
# 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
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.
# 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
PCMK_debug => defined $ENV{PCMK_debug} ? $ENV{PCMK_debug} : "", # 0 # These are other variables that are set, but we don't currently care about them
# 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:
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
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
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
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
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
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
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
OCF_ROOT => defined $ENV{OCF_ROOT} ? $ENV{OCF_ROOT} : "", # /usr/lib/ocf # These are set during a migration
# 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} : ""; # el8-a01n01.digimer.ca
OCF_RESKEY_CRM_meta_migrate_source => defined $ENV{OCF_RESKEY_CRM_meta_migrate_source} ? $ENV{OCF_RESKEY_CRM_meta_migrate_source} : "", # el8-a01n01.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} : ""; # el8-a01n02.digimer.ca
OCF_RESKEY_CRM_meta_migrate_target => defined $ENV{OCF_RESKEY_CRM_meta_migrate_target} ? $ENV{OCF_RESKEY_CRM_meta_migrate_target} : "", # el8-a01n02.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
OCF_RESKEY_CRM_meta_record_pending => defined $ENV{OCF_RESKEY_CRM_meta_record_pending} ? $ENV{OCF_RESKEY_CRM_meta_record_pending} : "", # true
};
# If pacemaker is in debug, so are we, # If pacemaker is in debug, so are we,
if ($anvil->data->{environment}{PCMK_debug}) if ($anvil->data->{environment}{PCMK_debug})
@ -347,7 +345,7 @@ sub start_server
validate_all($anvil); validate_all($anvil);
# If we're still alive, we're ready to boot. # If we're still alive, we're ready to boot.
to_log($anvil, {message => "Sanity checks passed, ready to start: [$server].", 'line' => __LINE__, level => 2}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0305", variables => { server => $server }});
my $definition_file = $anvil->data->{path}{directories}{shared}{definitions}."/".$server.".xml"; my $definition_file = $anvil->data->{path}{directories}{shared}{definitions}."/".$server.".xml";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { definition_file => $definition_file }}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { definition_file => $definition_file }});
@ -359,7 +357,11 @@ sub start_server
{ {
# If this fails, we want to exit with OCF_ERR_CONFIGURED (6) so that pacemaker doesn't try to # If this fails, we want to exit with OCF_ERR_CONFIGURED (6) so that pacemaker doesn't try to
# also start the server on another node, because we don't know the state of it here. # also start the server on another node, because we don't know the state of it here.
to_log($anvil, {message => "All tests passed, yet the attempt to boot the server: [$server] exited with a non-zero return code: [$return_code]. The server is in an unknown state, so exiting with a fatal error. Human intervention is now required. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0307", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 6}); $anvil->nice_exit({exit_code => 6});
} }
@ -372,7 +374,11 @@ sub start_server
{ {
# If this fails, we want to exit with OCF_ERR_CONFIGURED (6) so that pacemaker doesn't try to # If this fails, we want to exit with OCF_ERR_CONFIGURED (6) so that pacemaker doesn't try to
# also start the server on another node, because we don't know the state of it here. # also start the server on another node, because we don't know the state of it here.
to_log($anvil, {message => "It appears that the call to boot the server: [$server] worked, but the call to list running servers exited with a non-zero return code: [$return_code]. The server is in an unknown state, so exiting with a fatal error. Human intervention is now required. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0308", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 6}); $anvil->nice_exit({exit_code => 6});
} }
foreach my $line (split/\n/, $output) foreach my $line (split/\n/, $output)
@ -392,13 +398,13 @@ sub start_server
if ($state eq "running") if ($state eq "running")
{ {
# Success! # Success!
to_log($anvil, {message => "The server: [$server] has started successfully.", 'line' => __LINE__, level => 2}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0309", variables => { server => $server }});
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }
else else
{ {
# WTF? # WTF?
to_log($anvil, {message => "The server: [$server] should have been started, but it's state is: [$state]. Human intervention is required!", 'line' => __LINE__, level => 1, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0310", variables => { server => $server, 'state' => $state }});
$anvil->nice_exit({exit_code => 6}); $anvil->nice_exit({exit_code => 6});
} }
@ -407,7 +413,7 @@ sub start_server
} }
# If we're still alive, then we didn't see the server in the list of running servers, which is really weird. # If we're still alive, then we didn't see the server in the list of running servers, which is really weird.
to_log($anvil, {message => "The server: [$server] should have been started, but it wasn't found in the list of running servers.", 'line' => __LINE__, level => 1, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0311", variables => { server => $server }});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -422,7 +428,7 @@ sub stop_server
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to list the running servers returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0312", variables => { return_code => $return_code, output => $output }});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -446,17 +452,21 @@ sub stop_server
if ($state eq "running") if ($state eq "running")
{ {
# The server is running, shut it down. # The server is running, shut it down.
to_log($anvil, {message => "The server: [$server] is running. We will ask it to shut down now.", 'line' => __LINE__, level => 2}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0313", variables => { server => $server }});
} }
elsif ($state eq "paused") elsif ($state eq "paused")
{ {
# The server is paused. Resume it, wait a few, then proceed with the shutdown. # The server is paused. Resume it, wait a few, then proceed with the shutdown.
to_log($anvil, {message => "The server: [$server] is paused. Resuming it now so that it can react to the shutdown request.", 'line' => __LINE__, level => 2}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "log_0314", variables => { server => $server }});
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." resume $server"}); my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." resume $server"});
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to resume the server: [$server] returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0315", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
to_log($anvil, {message => "Pausing for a moment to give the server time to resume.", 'line' => __LINE__, level => 2}); to_log($anvil, {message => "Pausing for a moment to give the server time to resume.", 'line' => __LINE__, level => 2});
@ -470,7 +480,11 @@ sub stop_server
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to wake the server: [$server] returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0318", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
to_log($anvil, {message => "Pausing for half a minute to give the server time to wake up.", 'line' => __LINE__, level => 2}); to_log($anvil, {message => "Pausing for half a minute to give the server time to wake up.", 'line' => __LINE__, level => 2});
@ -496,7 +510,11 @@ sub stop_server
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to force-off the server: [$server] returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0323", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -506,7 +524,10 @@ sub stop_server
else else
{ {
# WTF? # WTF?
to_log($anvil, {message => "The server: [$server] is running, but it is in an unexpected state: [$state]. Human intervention is required!", 'line' => __LINE__, level => 1, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0325", variables => {
server => $server,
'state' => $state,
}});
$anvil->nice_exit({exit_code => 6}); $anvil->nice_exit({exit_code => 6});
} }
@ -529,7 +550,11 @@ sub stop_server
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to shut down the server: [$server] returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0328", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
} }
@ -543,7 +568,11 @@ sub stop_server
if ($return_code) if ($return_code)
{ {
# Looks like virsh isn't running. # Looks like virsh isn't running.
to_log($anvil, {message => "The attempt to list the running servers returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0312", variables => {
server => $server,
return_code => $return_code,
output => $output,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
foreach my $line (split/\n/, $output) foreach my $line (split/\n/, $output)
@ -643,11 +672,13 @@ sub server_status
# If I got a non-zero return code, something went wrong with the virsh call. # If I got a non-zero return code, something went wrong with the virsh call.
if ($return_code) if ($return_code)
{ {
to_log($anvil, {message => "It would appear that libvirtd is not operating (or not operating correctly). Expected the return code '0' but got: [$return_code].", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0334", variables => { return_code => $return_code }});
if ($output) if ($output)
{ {
to_log($anvil, {message => "Output of: [".$anvil->data->{path}{exe}{virsh}." list] follows;", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0335", variables => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", list => { output => $output }}); command => $anvil->data->{path}{exe}{virsh},
output => $output,
}});
} }
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -683,17 +714,23 @@ sub server_status
elsif ($state eq "shut off") elsif ($state eq "shut off")
{ {
to_log($anvil, {message => "The server: [$server] is: [$state].", 'line' => __LINE__, level => 1}); to_log($anvil, {message => "The server: [$server] is: [$state].", 'line' => __LINE__, level => 1});
$anvil->nice_exit({exit_code => 7}); $anvil->nice_exit({exit_code => $7});
} }
elsif (($state eq "idle") or ($state eq "crashed")) elsif (($state eq "idle") or ($state eq "crashed"))
{ {
to_log($anvil, {message => "The server: [$server] is in a bad state: [$state]!", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0338", variables => {
server => $server,
'state' => $state,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
else else
{ {
# WTF? # WTF?
to_log($anvil, {message => "The server: [$server] is in an unexpected state: [$state]!", 'line' => __LINE__, level => 0, priority => "err"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0339", variables => {
server => $server,
'state' => $state,
}});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
} }
@ -741,6 +778,11 @@ sub migrate_server
my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." list"}); my ($output, $return_code) = $anvil->System->call({shell_call => $anvil->data->{path}{exe}{virsh}." list"});
if ($return_code) if ($return_code)
{ {
### TODO: Left off here, was changing the to_log() calles with priority => "err"/"warn"
# $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "log_0339", variables => {
# server => $server,
# 'state' => $state,
# }});
to_log($anvil, {message => "It appears that the call to check if the server: [$server] is on this node returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"}); to_log($anvil, {message => "It appears that the call to check if the server: [$server] is on this node returned a non-zero return code: [$return_code]. The output, if any, was: [$output].", 'line' => __LINE__, level => 0, priority => "err"});
$anvil->nice_exit({exit_code => 1}); $anvil->nice_exit({exit_code => 1});
} }
@ -1521,7 +1563,7 @@ sub validate_emulator
# What emulator is this using? # What emulator is this using?
my $emulator = $anvil->data->{server}{definition_xml}->{devices}->[0]->{emulator}->[0]; my $emulator = $anvil->data->{server}{definition_xml}->{devices}->[0]->{emulator}->[0];
to_log($anvil, {message => "emulator: [$emulator]", 'line' => __LINE__, level => 2}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { emulator => $emulator }});
if (not -e $emulator) if (not -e $emulator)
{ {
# It doesn't exist. Exit with OCF_ERR_INSTALLED (5). # It doesn't exist. Exit with OCF_ERR_INSTALLED (5).
@ -1708,17 +1750,17 @@ sub show_environment
{ {
next if $key eq "raw"; next if $key eq "raw";
next if $anvil->data->{switches}{$key} eq ""; next if $anvil->data->{switches}{$key} eq "";
to_log($anvil, {message => "Command line switch: [$key] -> [".$anvil->data->{switches}{$key}."]", 'line' => __LINE__, level => $level}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $level, list => { "switches::${key}" => $anvil->data->{switches}{$key} }});
} }
foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{environment}}) foreach my $key (sort {$a cmp $b} keys %{$anvil->data->{environment}})
{ {
next if $anvil->data->{environment}{$key} eq ""; next if $anvil->data->{environment}{$key} eq "";
to_log($anvil, {message => "OCF Environment variable: [$key] -> [".$anvil->data->{environment}{$key}."]", 'line' => __LINE__, level => $level}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $level, list => { "environment::${key}" => $anvil->data->{environment}{$key} }});
} }
foreach my $key (sort {$a cmp $b} keys %ENV) foreach my $key (sort {$a cmp $b} keys %ENV)
{ {
next if exists $anvil->data->{environment}{$key}; next if exists $anvil->data->{environment}{$key};
to_log($anvil, {message => "System Environment variable: [$key] -> [".$ENV{$key}."]", 'line' => __LINE__, level => $level}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $level, list => { "ENV::${key}" => $ENV{$key} }});
} }
return(0); return(0);
@ -1729,7 +1771,7 @@ sub show_usage
{ {
my ($anvil) = @_; my ($anvil) = @_;
print "TODO: How to use this...\n"; ### TODO: How to use this...
$anvil->nice_exit({exit_code => 0}); $anvil->nice_exit({exit_code => 0});
} }
@ -1783,37 +1825,37 @@ sub get_switches
$anvil->data->{switches}{raw} = ""; $anvil->data->{switches}{raw} = "";
foreach my $argument (@ARGV) foreach my $argument (@ARGV)
{ {
to_log($anvil, {message => "argument: [$argument]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { argument => $argument }});
if ($last_argument eq "raw") if ($last_argument eq "raw")
{ {
# Don't process anything. # Don't process anything.
$anvil->data->{switches}{raw} .= " ".$argument; $anvil->data->{switches}{raw} .= " ".$argument;
to_log($anvil, {message => "switches::raw: [".$anvil->data->{switches}{raw}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::raw" => $anvil->data->{switches}{raw} }});
} }
elsif ($argument =~ /^-/) elsif ($argument =~ /^-/)
{ {
# If the argument is just '--', appeand everything after it to 'raw'. # If the argument is just '--', appeand everything after it to 'raw'.
if ($argument eq "--") if ($argument eq "--")
{ {
$last_argument = "raw"; $last_argument = "raw";
$anvil->data->{switches}{raw} = ""; $anvil->data->{switches}{raw} = "";
to_log($anvil, {message => "switches::raw: [".$anvil->data->{switches}{raw}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::raw" => $anvil->data->{switches}{raw} }});
} }
else else
{ {
($last_argument) = ($argument =~ /^-{1,2}(.*)/)[0]; ($last_argument) = ($argument =~ /^-{1,2}(.*)/)[0];
to_log($anvil, {message => "last_argument: [$last_argument]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { last_argument => $last_argument }});
if ($last_argument =~ /=/) if ($last_argument =~ /=/)
{ {
# Break up the variable/value. # Break up the variable/value.
($last_argument, my $value) = (split /=/, $last_argument, 2); ($last_argument, my $value) = (split /=/, $last_argument, 2);
$anvil->data->{switches}{$last_argument} = $value; $anvil->data->{switches}{$last_argument} = $value;
to_log($anvil, {message => "switches::${last_argument}: [".$anvil->data->{switches}{$last_argument}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::${last_argument}" => $anvil->data->{switches}{$last_argument} }});
} }
else else
{ {
$anvil->data->{switches}{$last_argument} = "#!SET!#"; $anvil->data->{switches}{$last_argument} = "#!SET!#";
to_log($anvil, {message => "switches::${last_argument}: [".$anvil->data->{switches}{$last_argument}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::${last_argument}" => $anvil->data->{switches}{$last_argument} }});
} }
} }
} }
@ -1822,26 +1864,26 @@ sub get_switches
if ($last_argument) if ($last_argument)
{ {
$anvil->data->{switches}{$last_argument} = $argument; $anvil->data->{switches}{$last_argument} = $argument;
to_log($anvil, {message => "switches::${last_argument}: [".$anvil->data->{switches}{$last_argument}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::${last_argument}" => $anvil->data->{switches}{$last_argument} }});
$last_argument = ""; $last_argument = "";
to_log($anvil, {message => "last_argument: [$last_argument]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { last_argument => $last_argument }});
} }
else else
{ {
# Got a value without an argument. That's OK. # Got a value without an argument. That's OK.
$anvil->data->{switches}{$argument} = "#!SET!#"; $anvil->data->{switches}{$argument} = "#!SET!#";
to_log($anvil, {message => "switches::${argument}: [".$anvil->data->{switches}{$argument}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::${last_argument}" => $anvil->data->{switches}{$argument} }});
} }
} }
} }
# Clean up the initial space added to 'raw'. # Clean up the initial space added to 'raw'.
to_log($anvil, {message => "switches::raw: [".$anvil->data->{switches}{raw}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::raw:" => $anvil->data->{switches}{raw} }});
if ($anvil->data->{switches}{raw}) if ($anvil->data->{switches}{raw})
{ {
$anvil->data->{switches}{raw} =~ s/^ //; $anvil->data->{switches}{raw} =~ s/^ //;
to_log($anvil, {message => "switches::raw: [".$anvil->data->{switches}{raw}."]", 'line' => __LINE__, level => 3}); $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { "switches::raw:" => $anvil->data->{switches}{raw} }});
} }
return(0); return(0);

@ -612,22 +612,113 @@ We will keep looking.</key>
<key name="log_0302">We were invoked with an unexpected (or no) command. Environment variables and arguments below.</key> <key name="log_0302">We were invoked with an unexpected (or no) command. Environment variables and arguments below.</key>
<key name="log_0303">We've been asked to start the server: [#!variable!server!#].</key> <key name="log_0303">We've been asked to start the server: [#!variable!server!#].</key>
<key name="log_0304">It appears that the list the currently running servers returned a non-zero return code: [#!variable!return_code!#]. We will proceed as we may be able to fix this. The output, if any, was: [#!variable!output!#].</key> <key name="log_0304">It appears that the list the currently running servers returned a non-zero return code: [#!variable!return_code!#]. We will proceed as we may be able to fix this. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0305">#!free!#</key> <key name="log_0305">Sanity checks passed, ready to start: [#!variable!server!#].</key>
<key name="log_0306">The server: [#!variable!server!#] is already on this node in the state: [#!variable!state!#], aborting the start request.</key> <key name="log_0306">The server: [#!variable!server!#] is already on this node in the state: [#!variable!state!#], aborting the start request.</key>
<key name="log_0307"></key> <key name="log_0307">All tests passed, yet the attempt to boot the server: [#!variable!server!#] exited with a non-zero return code: [#!variable!return_code!#]. The server is in an unknown state, so exiting with a fatal error. Human intervention is now required. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0308"></key> <key name="log_0308">It appears that the call to boot the server: [#!variable!server!#] worked, but the call to list running servers exited with a non-zero return code: [#!variable!return_code!#]. The server is in an unknown state, so exiting with a fatal error. Human intervention is now required. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0309"></key> <key name="log_0309">The server: [#!variable!server!#] has started successfully.</key>
<key name="log_0310"></key> <key name="log_0310">The server: [#!variable!server!#] should have been started, but it's state is: [#!variable!state!#]. Human intervention is required!</key>
<key name="log_0311"></key> <key name="log_0311">The server: [#!variable!server!#] should have been started, but it wasn't found in the list of running servers.</key>
<key name="log_0312"></key> <key name="log_0312">The attempt to list the running servers returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0313"></key> <key name="log_0313">The server: [#!variable!server!#] is running. We will ask it to shut down now.</key>
<key name="log_0314"></key> <key name="log_0314">The server: [#!variable!server!#] is paused. Resuming it now so that it can react to the shutdown request.</key>
<key name="log_0315"></key> <key name="log_0315">The attempt to resume the server: [#!variable!server!#] returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0316"></key> <key name="log_0316">Pausing for a moment to give the server time to resume.</key>
<key name="log_0317"></key> <key name="log_0317">The server: [#!variable!server!#] is asleep. Waking it now so that it can react to the shutdown request.</key>
<key name="log_0318"></key> <key name="log_0318">The attempt to wake the server: [#!variable!server!#] returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0319"></key> <key name="log_0319">Pausing for half a minute to give the server time to wake up.</key>
<key name="log_0320"></key> <key name="log_0320">The server: [#!variable!server!#] is already shutting down. We'll monitor it until it actually shuts off.</key>
<key name="log_0321">The server: [#!variable!server!#] is already off.</key>
<key name="log_0322">The server: [#!variable!server!#] is hung. Its state is: [#!variable!state!#]. We will force it off now.</key>
<key name="log_0323">The attempt to force-off the server: [#!variable!server!#] returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0324">The server: [#!variable!server!#] is now off.</key>
<key name="log_0325">The server: [#!variable!server!#] is running, but it is in an unexpected state: [#!variable!state!#]. Human intervention is required!</key>
<key name="log_0326">The server: [#!variable!server!#] was not listed on this node, so it is not running here.</key>
<key name="log_0327">Asking the server: [#!variable!server!#] to shut down now. Please be patient.</key>
<key name="log_0328">The attempt to shut down the server: [#!variable!server!#] returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0329">The server: [#!variable!server!#] is no longer listed. It is now off.</key>
<key name="log_0330">The server: [#!variable!server!#] is not off yet, waiting a few seconds and then we'll check again.</key>
<key name="log_0331">The environment variable 'OCF_RESKEY_CRM_meta_timeout' was not set, so setting it to: [#!variable!timeout!#].</key>
<key name="log_0332">The 'virsh' call exited with the return code: [#!variable!return_code!#]. The 'libvirtd' may have failed to start. We won't wait any longer.</key>
<key name="log_0333">The 'virsh' call exited with the return code: [#!variable!return_code!#]. The 'libvirtd' service might be starting, so we will check again shortly.</key>
<key name="log_0334">It would appear that libvirtd is not operating (or not operating correctly). Expected the return code '0' but got: [#!variable!return_code!#].</key>
<key name="log_0335">
Output of: [#!variable!command!#] was;
==========
#!variable!output!#
==========
</key>
<key name="log_0336">The server: [#!variable!server!#] is: [#!variable!state!#], which is OK.</key>
<key name="log_0337">The server: [#!variable!server!#] is: [#!variable!state!#].</key>
<key name="log_0338">The server: [#!variable!server!#] is in a bad state: [#!variable!state!#]!</key>
<key name="log_0339">The server: [#!variable!server!#] is in an unexpected state: [#!variable!state!#]!</key>
<key name="log_0340">The server: [#!variable!server!#] is not running on this node.</key>
<key name="log_0341">We're pushing the: [#!variable!server!#] to: [#!variable!target!#].</key>
<key name="log_0342">It appears that the call to check if the server: [#!variable!server!#] is on this node returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0343">The server: [#!variable!server!#] state is: [#!variable!state!#]. A server must be 'running' in order to migrate it.</key>
<key name="log_0344">The server: [#!variable!server!#] wasn't found on this machine.</key>
<key name="log_0345">Verifying that the server: [#!variable!server!#] was successfully migrated here.</key>
<key name="log_0346">While verifying that the server: [#!variable!server!#] migrated here, the attempt to list servers running here returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0347">The migration of the server: [#!variable!server!#] to here was successful!</key>
<key name="log_0348">It looks like we were called to verify that the: [#!variable!server!#] migrated here, but it isn't here yet. We'll proceed with an attempt to pull the server over.</key>
<key name="log_0349">We're pulling the: [#!variable!server!#] from: [#!variable!target!#].</key>
<key name="log_0350">Temporarily enabling dual primary for the resource: [#!variable!resource!#] to the node: [#!variable!target_name!# (#!variable!target_node_id!#].</key>
<key name="log_0351">The attempt to enable dual-primary for the resource: [#!variable!resource!#] to the node: [#!variable!target_name!# (#!variable!target_node_id!#)] returned a non-zero return code [#!variable!return_code!#]. The returned output (if any) was: [#!variable!output!#].</key>
<key name="log_0352">The migration of: [#!variable!server!#] to the node: [#!variable!target!#] will now begin.</key>
<key name="log_0353">The attempt to migrate the server: [#!variable!server!#] to the node: [#!variable!target!#] returned a non-zero return code [#!variable!return_code!#]. The returned output (if any) was: [#!variable!output!#].</key>
<key name="log_0354">It looks like the migration was successful. Will verify in a moment.</key>
<key name="log_0355">Re-disabling dual primary by restoring config file settings.</key>
<key name="log_0356">The attempt to reset DRBD to config file settings returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0357">Failure, exiting with '1'.</key>
<key name="log_0358">It appears that the list the running servers on the migration target: [#!variable!target!#] returned a non-zero return code: [#!variable!return_code!#]. The output, if any, was: [#!variable!output!#].</key>
<key name="log_0359">The migration of the server: [#!variable!server!#] to: [#!variable!target!#] was a success!</key>
<key name="log_0360">Success, exiting with '0'.</key>
<key name="log_0361">Running validation tests...</key>
<key name="log_0362">- Server definition was read.</key>
<key name="log_0363">- Server name is valid.</key>
<key name="log_0364">- Eumlator is valid.</key>
<key name="log_0365">- Sufficient RAM is available.</key>
<key name="log_0366">- Network bridge(s) are available.</key>
<key name="log_0367">- Storage is valid and ready.</key>
<key name="log_0368">The bridge: [#!variable!bridge!#] is available for this server.</key>
<key name="log_0369">The server wants to connect to the bridge: [#!variable!bridge!#] which we do not have on this node.</key>
<key name="log_0370">The attempt to read the DRBD configuration returned a non-zero code: [#!variable!return_code!#]. The returned output (if any) was: [#!variable!drbd_body!#].</key>
<key name="log_0371">Recording the local connection details for the resource: [#!variable!resource!#] -> [#!variable!address!#:#!variable!port!#].</key>
<key name="log_0372">Recording the peer's connection details for the resource: [#!variable!resource!#] -> [#!variable!address!#:#!variable!port!#].</key>
<key name="log_0373">Checking that the DRBD device: [#!variable!device_path!#] is ready.</key>
<key name="log_0374">The server wants to use: [#!variable!device_path!#] as a hard drive, but we couldn't find the backing logical volume on this node.</key>
<key name="log_0375">The server wants to use: [#!variable!device_path!#] as a hard drive, but the backing logical volume: [#!variable!lv!#] doesn't exist on this node.</key>
<key name="log_0376">The server wants to use: [#!variable!device_path!#] as a hard drive, which is backed by the logical volume: [#!variable!lv!#]. Checking that these are ready.</key>
<key name="log_0377">The attempt to read the DRBD status returned a non-zero code: [#!variable!return_code!#]. The returned output (if any) was: [#!variable!status_json!#].</key>
<key name="log_0378">DRBD is not loaded. Bringing it up now.</key>
<key name="log_0379">Bringing up the resource: [#!variable!resource!#] for the server's: [".#!variable!device_path!#."] disk.</key>
<key name="log_0380">The attempt to start the DRBD resource: [#!variable!resource!#] returned a non-zero code: [#!variable!return_code!#]. The returned output (if any) was: [#!variable!output!#].</key>
<key name="log_0381">Pausing briefly to give the resources time to start.</key>
<key name="log_0382">The attempt to read the DRBD status after bringing up the resource(s) for this server returned a non-zero code: [#!variable!return_code!#]. The returned output (if any) was: [#!variable!status_json!#].</key>
<key name="log_0383">The attempt to read the DRBD status after bringing up the resource(s) appears to have failed.</key>
<key name="log_0384">The DRBD resource: [#!variable!resource!#] backing the device: [#!variable!device_path!#] was not seen in the 'drbdsetup' status data. Attempting to bringing it up now.</key>
<key name="log_0385">Checking the DRBD status again.</key>
<key name="log_0386">The DRBD resource: [#!variable!resource!#] backing the device: [#!variable!device_path!#] was not able to start.</key>
<key name="log_0387">Checking that the peer's DRBD resources are Connected and UpToDate prior to migration.</key>
<key name="log_0388">The local replicated disk: [#!variable!device_path!#] is used by this server. Checking it out now.</key>
<key name="log_0389">The DRBD resource: [#!variable!resource!#] volume: [#!variable!volume!#] locat disk state is: [#!variable!disk_state!#]. Unsafe to boot the server unless the disk state is UpToDate.</key>
<key name="log_0390">The DRBD resource: [#!variable!resource!#] volume: [#!variable!volume!#] locat disk state is: [#!variable!disk_state!#], good.</key>
<key name="log_0391">Checking connection to: [#!variable!name!#].</key>
<key name="log_0392">The DRBD resource: [#!variable!resource!#] on the peer: [#!variable!name!#] is 'Primary'. Refusing to boot.</key>
<key name="log_0393">peer_short_name: [#!variable!peer_short_name!#], migration_target: [#!variable!migration_target!#].</key>
<key name="log_0394">Ignoring the connection to: [#!variable!peer_short_name!#], it isn't the migration target.</key>
<key name="log_0395">The DRBD resource: [#!variable!resource!#] on the peer: [#!variable!name!#] is not UpToDate (or SyncSource). Refusing to migrate.</key>
<key name="log_0396">Ignoring the local replicated disk: [#!variable!device_path!#], it is not used by this server.</key>
<key name="log_0397">Checking that the optical disc image: [#!variable!file!#] exists.</key>
<key name="log_0398">The server has the ISO: [#!variable!file!#] mounted in its optical drive, but that file doesn't exist on this system.</key>
<key name="log_0399">The server has the ISO: [#!variable!file!#] mounted in its optical drive, which we have, but we can't read it. Check permissions and for SELinux denials.</key>
<key name="log_0400">The server has the ISO: [#!variable!file!#] mounted in its optical drive, which we have.</key>
<key name="log_0401">The server wants to use the emulator: [#!variable!emulator!#] which doesn't exist on this node. Was this server migrated from a different generation Anvil! system? Please update '<emulator>...</emulator>' in the server's definition file: [#!variable!definition_file!#].</key>
<key name="log_0402">The server wants to use the emulator: [#!variable!emulator!#] which exists, but we can't run. Please check permissions and for SELinux denials.</key>
<key name="log_0403">The configured server name: [#!variable!server!#] does not match the name of the server in the definition file: [#!variable!name!#]!</key>
<key name="log_0404">The configured server name: [#!variable!name!#] needs: [#!variable!ram!# (#!variable!ram_bytes!# bytes)] of RAM, but only: #!variable!available_ram!# (#!variable!available_ram_bytes!# bytes)] are available!</key>
<key name="log_0405">The definition file: [#!variable!definition_file!#] for the server: [#!variable!server!#] does not exist here!</key>
<key name="log_0406">The definition file: [#!variable!definition_file!#] for the server: [#!variable!server!#] can not be read!</key>
<!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. --> <!-- Test words. Do NOT change unless you update 't/Words.t' or tests will needlessly fail. -->
<key name="t_0000">Test</key> <key name="t_0000">Test</key>

Loading…
Cancel
Save