* Updated Cluster->parse_crm_mon() to record the role of stonith resources.

* Fixed a bug in System->parse_arguments() where a quoted password without spaces was returned without being recorded in the hash. Also updated logging to log 'suppressed' for passwords when secure logging is disabled.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 2 years ago
parent d1595faf74
commit d271ffec26
  1. 41
      Anvil/Tools/Cluster.pm
  2. 2
      Anvil/Tools/Log.pm
  3. 97
      Anvil/Tools/System.pm
  4. 1
      share/words.xml

@ -2976,7 +2976,7 @@ sub parse_cib
if ($anvil->Network->is_local({host => $target}))
{
# Local call
($cib_data, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
($cib_data, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
cib_data => $cib_data,
return_code => $return_code,
@ -3151,6 +3151,7 @@ sub parse_cib
foreach my $node_state ($dom->findnodes('/cib/status/node_state'))
{
my $id = $node_state->{id};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { id => $id }});
foreach my $variable (sort {$a cmp $b} keys %{$node_state})
{
next if $variable eq "id";
@ -3162,6 +3163,7 @@ sub parse_cib
foreach my $lrm ($node_state->findnodes('./lrm'))
{
my $lrm_id = $lrm->{id};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { lrm_id => $lrm_id }});
foreach my $lrm_resource ($lrm->findnodes('./lrm_resources/lrm_resource'))
{
my $lrm_resource_id = $lrm_resource->{id};
@ -3643,6 +3645,8 @@ sub parse_cib
}});
}
return($problem);
}
@ -3717,7 +3721,7 @@ sub parse_crm_mon
if ($anvil->Network->is_local({host => $target}))
{
# Local call
($crm_mon_data, $return_code) = $anvil->System->call({debug => $debug, shell_call => $shell_call});
($crm_mon_data, $return_code) = $anvil->System->call({debug => 3, shell_call => $shell_call});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
crm_mon_data => $crm_mon_data,
return_code => $return_code,
@ -3764,7 +3768,8 @@ sub parse_crm_mon
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { problem => $problem }});
foreach my $resource ($dom->findnodes('/pacemaker-result/resources/resource'))
{
next if $resource->{resource_agent} ne "ocf::alteeve:server";
if ($resource->{resource_agent} eq "ocf::alteeve:server")
{
my $id = $resource->{id};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { id => $id }});
foreach my $variable (sort {$a cmp $b} keys %{$resource})
@ -3788,6 +3793,36 @@ sub parse_crm_mon
}});
}
}
if ($resource->{resource_agent} =~ /stonith:(.*)$/)
{
my $fence_agent = $1;
my $id = $resource->{id};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
's1:fence_agent' => $fence_agent,
's2:id' => $id,
}});
foreach my $variable (sort {$a cmp $b} keys %{$resource})
{
next if $variable eq "id";
$anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{variables}{$variable} = $resource->{$variable};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"crm_mon::parsed::pacemaker-result::resources::stonith::${id}::variables::${variable}" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{variables}{$variable},
}});
}
foreach my $node ($resource->findnodes('./node'))
{
my $node_id = $node->{id};
my $node_name = $node->{name};
my $cached = $node->{cached};
$anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_name} = $node->{name};
$anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_id} = $node->{id};
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"crm_mon::parsed::pacemaker-result::resources::stonith::${id}::host::node_name" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_name},
"crm_mon::parsed::pacemaker-result::resources::stonith::${id}::host::node_id" => $anvil->data->{crm_mon}{parsed}{'pacemaker-result'}{resources}{stonith}{$id}{host}{node_id},
}});
}
}
}
}
}

@ -924,7 +924,7 @@ sub variables
# Strip a leading 'sX:' in case the user is sorting the output.
my $say_key = $key;
$say_key =~ s/^s(\d+)://;
$raw .= "$say_key: [".$list->{$key}."], ";
$raw .= $say_key.": [".$list->{$key}."], ";
print $THIS_FILE." ".__LINE__."; raw: [".$raw."]\n" if $test;
}
$raw =~ s/, $//;

@ -3864,18 +3864,62 @@ sub parse_arguments
arguments => $arguments,
}});
# Convert escaped quotes, we'll convert them back at the end
my $secure = $arguments =~ /-passw/ ? 1 : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
">> arguments" => $secure ? $anvil->Log->is_secure($arguments) : $arguments,
}});
$arguments =~ s/\\\"/&quot;/g;
$arguments =~ s/\\\'/&apos;/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"<< arguments" => $secure ? $anvil->Log->is_secure($arguments) : $arguments,
}});
my $hash = {};
my $quoted = "";
my $switch = "";
my $value = "";
foreach my $arg (split/ /, $arguments)
{
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { arg => $arg }});
# We're likely processing a password, so we need to decide if we're logging securely or not
# right away.
my $secure = 0;
if (($switch) && ($switch =~ /passw/))
{
$secure = 1;
}
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { secure => $secure }});
# Now we can start logging.
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
arg => $secure ? $anvil->Log->is_secure($arg) : $arg,
}});
if (($arg =~ /^'/) or ($arg =~ /^"/))
{
# If the quoted value has no spaces, store it now.
if (($arg =~ /^'(.*?)'$/) or ($arg =~ /^"(.*?)"$/))
{
$hash->{$switch} = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
}
elsif (($arg =~ /'$/) or ($arg =~ /"$/))
{
$hash->{$switch} = $quoted.$arg;
$quoted = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
}
else
{
# Store a quoted value.
$quoted .= $arg." ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { quoted => $quoted }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
quoted => $secure ? $anvil->Log->is_secure($quoted) : $quoted,
}});
}
}
elsif ($quoted)
{
@ -3883,33 +3927,43 @@ sub parse_arguments
{
# Done
$quoted .= $arg;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { quoted => $quoted }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
quoted => $secure ? $anvil->Log->is_secure($quoted) : $quoted,
}});
if ($quoted =~ /^'(.*)'$/)
{
$value = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { value => $value }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
value => $secure ? $anvil->Log->is_secure($value) : $value,
}});
}
elsif ($quoted =~ /^"(.*)"$/)
{
$value = $1;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { value => $value }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
value => $secure ? $anvil->Log->is_secure($value) : $value,
}});
}
$hash->{$switch} = $value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "hash->{$switch}" => $hash->{$switch} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
$quoted = "";
$switch = "";
$value = "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
quoted => $quoted,
quoted => $secure ? $anvil->Log->is_secure($quoted) : $quoted,
switch => $switch,
value => $value,
value => $secure ? $anvil->Log->is_secure($value) : $value,
}});
}
else
{
$quoted .= $arg." ";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { quoted => $quoted }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
quoted => $secure ? $anvil->Log->is_secure($quoted) : $quoted,
}});
}
}
elsif ($arg =~ /^-/)
@ -3918,7 +3972,9 @@ sub parse_arguments
{
$value = "#!SET!#";
$hash->{$switch} = $value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "hash->{$switch}" => $hash->{$switch} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
$switch = "";
$value = "";
@ -3942,7 +3998,9 @@ sub parse_arguments
else
{
$hash->{$switch} = $value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "hash->{$switch}" => $hash->{$switch} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
$switch = "";
$value = "";
@ -3962,7 +4020,9 @@ sub parse_arguments
else
{
$hash->{$switch} = $arg;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => { "hash->{$switch}" => $hash->{$switch} }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
$switch = "";
$value = "";
@ -3973,6 +4033,19 @@ sub parse_arguments
}
}
foreach my $switch (sort {$a cmp $b} keys %{$hash})
{
my $secure = $switch =~ /^passw/ ? 1 : 0;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
">> hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
$hash->{$switch} =~ s/&quot;/\\"/g;
$hash->{$switch} =~ s/&apos;/\\'/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => $debug, list => {
"<< hash->{$switch}" => $secure ? $anvil->Log->is_secure($hash->{$switch}) : $hash->{$switch},
}});
}
return($hash);
}

@ -3315,6 +3315,7 @@ The error was:
========
</key>
<key name="warning_0147">[ Warning ] - The interface: [#!variable!interface!#] is in a bond, but it is down. The system uptime is: [#!variable!uptime!#], so it might be a problem where the interface didn't start on boot as it should have. So we're going to bring the interface up.</key>
<key name="warning_0148">[ Warning ] - The IPMI stonith resource: [#!variable!resource!#] is in the role: [#!variable!role!#] (should be 'Started'). Will check the IPMI config now.</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. -->

Loading…
Cancel
Save