Updated anvil-parse-fence-agents to validate each fence agent's metadata is valid before adding it to the unified XML.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 3 years ago
parent 8abb5b46e0
commit 04cb116c1b
  1. 5
      Anvil/Tools/Striker.pm
  2. 11
      share/words.xml
  3. 6
      tools/anvil-join-anvil
  4. 14
      tools/anvil-parse-fence-agents
  5. 1
      tools/anvil-update-definition

@ -440,7 +440,10 @@ sub get_fence_data
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => $debug, key => "log_0125", variables => { method => "Striker->get_fence_data()" }});
my $parsed_xml = "";
my $xml_body = $anvil->Storage->read_file({file => $anvil->data->{path}{data}{fences_unified_metadata}});
my $xml_body = $anvil->Storage->read_file({
debug => $debug,
file => $anvil->data->{path}{data}{fences_unified_metadata},
});
# Globally replace \fI (opening underline) with '[' and \fP (closing underline) with ']'.
$xml_body =~ s/\\fI/[/gs;

@ -2889,6 +2889,17 @@ Read UUID: .... [#!variable!read_uuid!#]
<key name="warning_0125">[ Warning ] - Asked to check server location constraints, but this is not a node.</key>
<key name="warning_0126">[ Warning ] - Asked to check server location constraints, but this node is not in a cluster.</key>
<key name="warning_0127">[ Warning ] - Asked to check server location constraints, but this node is not fully in the cluster yet.</key>
<key name="warning_0128">[ Warning ] - Failed to parse the fence agent: [#!variable!agent!#]'s XML metadata:
========
#!variable!metadata!#
========
The error was:
========
#!variable!error!#
========
</key>
<!-- The entries below here are not sequential, but use a key to find the entry. -->
<!-- Run 'striker-parse-os-list to find new entries. -->

@ -538,7 +538,7 @@ sub configure_pacemaker
}});
$pcs_add_command = $anvil->data->{path}{exe}{pcs}." stonith create ".$ipmi_stonith_name." ".$fence_agent." pcmk_host_list=\"".$node_name."\" ";
my $switches = $anvil->System->parse_arguments({arguments => $arguments});
my $switches = $anvil->System->parse_arguments({debug => 2, arguments => $arguments});
foreach my $switch (sort {$a cmp $b} keys %{$switches})
{
# Ignore 'delay', we handle that in Cluster->set_delay(); Also,
@ -546,7 +546,7 @@ sub configure_pacemaker
my $value = $switches->{$switch};
$value =~ s/"/\\"/g;
$value =~ s/#!SET!#/true/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
switch => $switch,
value => $value,
}});
@ -556,7 +556,7 @@ sub configure_pacemaker
# Find the argument=value version.
my $argument = $anvil->data->{fence_data}{$fence_agent}{switch}{$switch}{name};
$pcs_add_command .= $argument."=\"".$value."\" ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
argument => $argument,
value => $argument =~ /passw/ ? $anvil->Log->is_secure($value) : $value,
pcs_add_command => $pcs_add_command =~ /passw/ ? $anvil->Log->is_secure($pcs_add_command) : $pcs_add_command,

@ -147,6 +147,20 @@ sub unify_metadata
metadata => $metadata,
return_code => $return_code,
}});
# Test that the metadata is valid XML.
local $@;
my $dom = eval { XML::LibXML->load_xml(string => $metadata); };
if ($@)
{
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 0, key => "warning_0128", variables => {
agent => $fence_agent_file,
metadata => $metadata,
error => $@,
}});
return(1);
}
if ($metadata =~ /<\?xml version="1.0" \?>/gs)
{
$metadata =~ s/<\?xml version="1.0" \?>/<agent name="$fence_agent_file">/gs;

@ -162,7 +162,6 @@ sub validate_and_update
if ($memory != $configured_ram)
{
# Update the configured RAM value.
my $query = "
UPDATE
servers

Loading…
Cancel
Save