diff --git a/Anvil/Tools/Cluster.pm b/Anvil/Tools/Cluster.pm
index 82381be3..b7424e31 100644
--- a/Anvil/Tools/Cluster.pm
+++ b/Anvil/Tools/Cluster.pm
@@ -310,6 +310,7 @@ sub parse_cib
}
else
{
+ local $@;
my $dom = eval { XML::LibXML->load_xml(string => $cib_data); };
if ($@)
{
diff --git a/Anvil/Tools/DRBD.pm b/Anvil/Tools/DRBD.pm
index 7f427d9e..fe1afc93 100755
--- a/Anvil/Tools/DRBD.pm
+++ b/Anvil/Tools/DRBD.pm
@@ -8,6 +8,7 @@ use warnings;
use Data::Dumper;
use Scalar::Util qw(weaken isweak);
use Text::Diff;
+use JSON;
our $VERSION = "3.0.0";
my $THIS_FILE = "DRBD.pm";
@@ -311,10 +312,11 @@ sub get_devices
delete $anvil->data->{drbd}{config}{$host};
}
+ local $@;
my $xml = XML::Simple->new();
my $dump_xml = "";
- eval { $dump_xml = $xml->XMLin($output, KeyAttr => {}, ForceArray => 1) };
- if ($@)
+ my $test = eval { $dump_xml = $xml->XMLin($output, KeyAttr => {}, ForceArray => 1) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem parsing: [$output]. The error was:\n";
diff --git a/Anvil/Tools/Database.pm b/Anvil/Tools/Database.pm
index 63ae4ecb..e5e711d7 100644
--- a/Anvil/Tools/Database.pm
+++ b/Anvil/Tools/Database.pm
@@ -1027,12 +1027,13 @@ sub connect
db_connect_string => $db_connect_string,
user => $user,
}});
- eval { $dbh = DBI->connect($db_connect_string, $user, $password, {
+ local $@;
+ my $test = eval { $dbh = DBI->connect($db_connect_string, $user, $password, {
RaiseError => 1,
AutoCommit => 1,
pg_enable_utf8 => 1
}); };
- if ($@)
+ if (not $test)
{
# Something went wrong...
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 1, priority => "alert", key => "log_0064", variables => {
diff --git a/Anvil/Tools/Get.pm b/Anvil/Tools/Get.pm
index a5aaf1e0..28244e88 100644
--- a/Anvil/Tools/Get.pm
+++ b/Anvil/Tools/Get.pm
@@ -10,6 +10,7 @@ use Data::Dumper;
use Encode;
use UUID::Tiny qw(:std);
use Net::Netmask;
+use JSON;
our $VERSION = "3.0.0";
my $THIS_FILE = "Get.pm";
@@ -272,10 +273,11 @@ sub bridges
delete $anvil->data->{$host}{network}{bridges};
};
+ local $@;
my $bridge_data = "";
my $json = JSON->new->allow_nonref;
- eval { $bridge_data = $json->decode($output); };
- if ($@)
+ my $test = eval { $bridge_data = $json->decode($output); };
+ if (not $test)
{
# JSON parse failed.
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "error_0140", variables => {
diff --git a/Anvil/Tools/Server.pm b/Anvil/Tools/Server.pm
index 812c134c..d8cf297b 100755
--- a/Anvil/Tools/Server.pm
+++ b/Anvil/Tools/Server.pm
@@ -650,6 +650,8 @@ sub migrate
});
}
+ # This logs the path down to the resources under the servers, helps in the next step to enable dual
+ # primary fails.
foreach my $source (sort {$a cmp $b} keys %{$anvil->data->{server}})
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { source => $source }});
@@ -662,7 +664,6 @@ sub migrate
}
}
}
- die;
# Enable dual-primary for any resources we know about for this server.
foreach my $resource (sort {$a cmp $b} keys %{$anvil->data->{server}{$source}{$server}{resource}})
@@ -996,10 +997,11 @@ sub _parse_definition
return(1);
}
+ local $@;
my $xml = XML::Simple->new();
my $server_xml = "";
- eval { $server_xml = $xml->XMLin($definition, KeyAttr => {}, ForceArray => 1) };
- if ($@)
+ my $test = eval { $server_xml = $xml->XMLin($definition, KeyAttr => {}, ForceArray => 1) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem parsing: [$definition]. The error was:\n";
diff --git a/Anvil/Tools/Striker.pm b/Anvil/Tools/Striker.pm
index 842f2643..86886126 100644
--- a/Anvil/Tools/Striker.pm
+++ b/Anvil/Tools/Striker.pm
@@ -265,6 +265,10 @@ sub get_fence_data
xml_body => $xml_body,
eval_error => $@,
}});
+
+ # Clear the error so it doesn't propogate out to a future 'die' and confuse things.
+ $@ = '';
+
return(1);
}
}
@@ -899,10 +903,11 @@ WHERE
$anvil->Database->get_fences({debug => $debug});
# Parse the XML.
+ local $@;
my $parsed_xml = "";
my $xml = XML::Simple->new();
- eval { $parsed_xml = $xml->XMLin($manifest_xml, KeyAttr => { key => 'name' }, ForceArray => []) };
- if ($@)
+ my $test = eval { $parsed_xml = $xml->XMLin($manifest_xml, KeyAttr => { key => 'name' }, ForceArray => []) };
+ if (not $test)
{
chomp $@;
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "error_0111", variables => {
diff --git a/Anvil/Tools/System.pm b/Anvil/Tools/System.pm
index f942f5d7..877b1159 100644
--- a/Anvil/Tools/System.pm
+++ b/Anvil/Tools/System.pm
@@ -3054,11 +3054,12 @@ sub manage_firewall
# Read the XML to see what services are opened already and translate those into port numbers and
# protocols.
+ local $@;
my $open_services = [];
my $xml = XML::Simple->new();
my $body = "";
- eval { $body = $xml->XMLin($zone_file, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'service' ]) };
- if ($@)
+ my $test = eval { $body = $xml->XMLin($zone_file, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'service' ]) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$zone_file]. The error was:\n";
@@ -3066,6 +3067,9 @@ sub manage_firewall
$error .= $@."\n";
$error .= "===========================================================\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $error});
+
+ # Clear the error so it doesn't propogate out to a future 'die' and confuse things.
+ $@ = '';
}
else
{
@@ -4473,10 +4477,11 @@ sub _load_specific_firewalld_zone
return("!!error!!");
}
+ local $@;
my $xml = XML::Simple->new();
my $body = "";
- eval { $body = $xml->XMLin($full_path, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'port' ]) };
- if ($@)
+ my $test = eval { $body = $xml->XMLin($full_path, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'port' ]) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$full_path]. The error was:\n";
@@ -4484,6 +4489,9 @@ sub _load_specific_firewalld_zone
$error .= $@."\n";
$error .= "===========================================================\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $error});
+
+ # Clear the error so it doesn't propogate out to a future 'die' and confuse things.
+ $@ = '';
}
else
{
diff --git a/Anvil/Tools/Words.pm b/Anvil/Tools/Words.pm
index 841798d1..84707839 100644
--- a/Anvil/Tools/Words.pm
+++ b/Anvil/Tools/Words.pm
@@ -545,6 +545,7 @@ sub read
}
# Read the file with XML::Simple
+ local $@;
my $xml = XML::Simple->new();
eval { $anvil->data->{words}{$file} = $xml->XMLin($file, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'language', 'key' ]) };
if ($@)
@@ -555,8 +556,7 @@ sub read
$error .= $@."\n";
$error .= "===========================================================\n";
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, priority => "err", raw => $error});
- $return_code = 4;
- die;
+ $anvil->nice_exit({exit_code => 4});
}
else
{
diff --git a/cgi-bin/striker b/cgi-bin/striker
index da463ff1..13b47cf3 100755
--- a/cgi-bin/striker
+++ b/cgi-bin/striker
@@ -8073,11 +8073,12 @@ sub get_network_details
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
# Parse...
+ local $@;
my $xml = XML::Simple->new();
my $data = "";
my $network = "";
- eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name', ip => 'address' }, ForceArray => [ 'interface', 'key' ] ) };
- if ($@)
+ my $test = eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name', ip => 'address' }, ForceArray => [ 'interface', 'key' ] ) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$file]. The error was:\n";
@@ -8183,11 +8184,13 @@ sub get_network_details_form
my $file = $anvil->data->{path}{directories}{html}."/status/network.xml";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { file => $file }});
+
+ local $@;
my $xml = XML::Simple->new();
my $data = "";
my $network = "";
- eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name' }, ForceArray => [ 'interface', 'key' ]) };
- if ($@)
+ my $test = eval { $data = $xml->XMLin($file, KeyAttr => { interface => 'name', key => 'name' }, ForceArray => [ 'interface', 'key' ]) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem reading: [$file]. The error was:\n";
diff --git a/ocf/alteeve/server b/ocf/alteeve/server
index 62ad9538..35df820d 100755
--- a/ocf/alteeve/server
+++ b/ocf/alteeve/server
@@ -731,9 +731,10 @@ sub start_drbd_resource
{
my ($anvil) = @_;
- my $server = $anvil->data->{environment}{OCF_RESKEY_name};
- my $host = $anvil->_short_host_name;
- my $peer = $anvil->data->{drbd}{config}{$host}{peer};
+ my $local_host = $anvil->_short_host_name();
+ my $server = $anvil->data->{environment}{OCF_RESKEY_name};
+ my $host = $anvil->_short_host_name;
+ my $peer = $anvil->data->{drbd}{config}{$host}{peer};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
server => $server,
host => $host,
@@ -1177,6 +1178,7 @@ sub migrate_server
# missing.
# If we're given 'migrate_from', we're pulling the server towards us, so we can check both brdiges
# and storage.
+ my $local_host = $anvil->_short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
my $source = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_source};
my $target = $anvil->data->{environment}{OCF_RESKEY_CRM_meta_migrate_target};
@@ -1693,7 +1695,6 @@ sub validate_name
{
my ($anvil) = @_;
- my $local_host = $anvil->_short_host_name();
my $local_host = $anvil->_short_host_name();
my $server = $anvil->data->{environment}{OCF_RESKEY_name};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
diff --git a/share/words.xml b/share/words.xml
index e00404ac..862f606b 100644
--- a/share/words.xml
+++ b/share/words.xml
@@ -348,7 +348,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
Adding NTP (network time protocol) servers, if needed.
Adding the NTP server: [#!variable!server!#].
Restarting the daemon: [#!variable!daemon!#].
- ,manifest_uuid=,anvil_uuid='. Either the parse failed, or the data was somehow invalid.]]>
+ ,manifest_uuid=,anvil_uuid='. Either the parse failed, or the data was somehow invalid.]]>
Updated the password for the: [#!variable!user!#] user.
Enabled and started the daemon: [#!variable!daemon!#].
Disable and stop the daemon: [#!variable!daemon!#].
@@ -386,6 +386,7 @@ Failure! The return code: [#!variable!return_code!#] was received ('0' was expec
Update completed successfully.
Update not required, nothing changed.
Completed joining the #!string!brand_0002!#.
+ No job was found that needs to be run.
Starting: [#!variable!program!#].
diff --git a/tools/anvil-join-anvil b/tools/anvil-join-anvil
index 7863e9ae..556787bd 100755
--- a/tools/anvil-join-anvil
+++ b/tools/anvil-join-anvil
@@ -10,6 +10,7 @@
# 4 = Failed to reconnect to any database after the network was reconfigured
# 5 = Problem parsing job data or loading manifest or anvil data using job data.
# 6 = A pcs call failed.
+# 7 = No job was found to run.
#
# TODO:
# -
@@ -1830,6 +1831,13 @@ sub load_job
"jobs::job_uuid" => $anvil->data->{jobs}{job_uuid},
}});
+ if (not $anvil->data->{jobs}{job_uuid})
+ {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "job_0130"});
+ sleep 1;
+ $anvil->nice_exit({exit_code => 7});
+ }
+
$anvil->data->{job}{progress} = 0;
update_progress($anvil, $anvil->data->{job}{progress}, "clear");
update_progress($anvil, ($anvil->data->{job}{progress} += 1), "job_0074,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!");
@@ -1851,7 +1859,7 @@ sub load_job
{
# Terminate the job entirely, it's likely an unrecoverable problem.
update_progress($anvil, 100, "job_0092,!!job-uuid!".$anvil->data->{switches}{'job-uuid'}."!!,!!raw!".$anvil->data->{jobs}{job_data}."!!");
- $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, key => "job_0092", variables => {
+ $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 0, priority => "err", key => "job_0092", variables => {
'job-uuid' => $anvil->data->{switches}{'job-uuid'},
raw => $anvil->data->{jobs}{job_data},
}});
diff --git a/tools/fence_pacemaker b/tools/fence_pacemaker
index 7e922eb6..1266c960 100755
--- a/tools/fence_pacemaker
+++ b/tools/fence_pacemaker
@@ -412,9 +412,10 @@ sub read_cib
if (($xml_opened) && ($xml_closed))
{
# We're good
- my $xml = XML::Simple->new();
- eval { $body = $xml->XMLin($cib, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'id' ]) };
- if ($@)
+ local $@;
+ my $xml = XML::Simple->new();
+ my $test = eval { $body = $xml->XMLin($cib, KeyAttr => { language => 'name', key => 'name' }, ForceArray => [ 'id' ]) };
+ if (not $test)
{
chomp $@;
my $error = "[ Error ] - The was a problem parsing: [$cib]. The error was:\n";
diff --git a/tools/test.pl b/tools/test.pl
index a6a8f6fa..3d06bae5 100755
--- a/tools/test.pl
+++ b/tools/test.pl
@@ -29,181 +29,7 @@ $anvil->Database->connect();
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, 'print' => 1, level => 2, secure => 0, key => "log_0132"});
$anvil->Get->switches;
-my $xml = '
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-';
+$anvil->Get->bridges({ debug => 2 });
+my $host = $anvil->_short_host_name();
-$anvil->Cluster->parse_cib({
- debug => 2,
- #cib => $xml,
-});
-
-print "Cluster is in maintenance mode? [".$anvil->data->{cib}{parsed}{data}{cluster}{'maintenance-mode'}."]\n";
+die;