* Fixed a bug where fence option values with double-quotes where not being stored correctly.

Signed-off-by: Digimer <digimer@alteeve.ca>
main
Digimer 5 years ago
parent 1e8982704e
commit 0dbb07dfb7
  1. 2
      Anvil/Tools/Striker.pm
  2. 30
      cgi-bin/striker
  3. 12
      tools/test.pl

@ -348,7 +348,7 @@ sub get_fence_data
$anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{options} = []; $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{options} = [];
# Read the action # Read the action
print "Agent: [".$fence_agent."]; actions (default: [".$anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'}."]);\n"; #print "Agent: [".$fence_agent."]; actions (default: [".$anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'}."]);\n";
foreach my $array_ref (sort {$a cmp $b} @{$agent_ref->{'resource-agent'}->{actions}->{action}}) foreach my $array_ref (sort {$a cmp $b} @{$agent_ref->{'resource-agent'}->{actions}->{action}})
{ {
# There are several options that don't make sense for us. # There are several options that don't make sense for us.

@ -5,7 +5,15 @@
# 1 == Host UUID not available yet. # 1 == Host UUID not available yet.
# #
# TODO: # TODO:
# * Make the BCN count a thing, remove Striker user and make it statically 'admin'. # * Switch out XML::Simple to XML::Twig or libXML
# - 15:05 < perlbot> XML::Simple commits the fatal flaw of trying to massage complicated and often
# irregular XML into the simple and highly regular world of perl data structures.
# Irregularities cause "not a hashref" sort of errors in your program. Use a real
# parser. see: xml
# - 15:06 < perlbot> Don't parse XML with regex! Use a real parser. Avoid XML::Simple (see the xml::simple
# factoid). Choices are ::Easy, ::TreeBuilder, ::Twig, Mojo::DOM (in XML mode) for
# simple stuff. LibXML is a good general purpose starting point. See also XML::All.
# http://perl-xml.sf.net/faq/
# #
use strict; use strict;
@ -3722,9 +3730,11 @@ sub process_fences
}}); }});
foreach my $i (sort {$a cmp $b} keys %{$anvil->data->{fence}{confirm_table}{data}{$name}}) foreach my $i (sort {$a cmp $b} keys %{$anvil->data->{fence}{confirm_table}{data}{$name}})
{ {
my $is_default = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'}; my $is_default = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'};
my $say_value = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value}; my $say_value = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value};
my $value = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value}; $say_value =~ s/"/&quot;/g;
my $value = $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value};
$value =~ s/"/&quot;/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => {
's1:name' => $name, 's1:name' => $name,
's2:i' => $i, 's2:i' => $i,
@ -3891,6 +3901,10 @@ sub process_fences
'default' => $default, 'default' => $default,
}}); }});
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { ">> default" => $default }});
$default =~ s/"/&quot;/g;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => { "<< default" => $default }});
# Set the cgi variable to the default, if not already set. # Set the cgi variable to the default, if not already set.
$anvil->data->{cgi}{$option_key}{alert} = "" if not defined $anvil->data->{cgi}{$option_key}{alert}; $anvil->data->{cgi}{$option_key}{alert} = "" if not defined $anvil->data->{cgi}{$option_key}{alert};
$anvil->data->{cgi}{$option_key}{value} = $default if not defined $anvil->data->{cgi}{$option_key}{value}; $anvil->data->{cgi}{$option_key}{value} = $default if not defined $anvil->data->{cgi}{$option_key}{value};
@ -4038,7 +4052,7 @@ sub sanity_check_fence_agent_form
my $description = $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{description}; my $description = $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{description};
my $type = $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{content_type}; my $type = $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{content_type};
my $default = exists $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'} ? $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'} : ""; my $default = exists $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'} ? $anvil->data->{fence_data}{$fence_agent}{parameters}{$name}{'default'} : "";
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
's1:name' => $name, 's1:name' => $name,
's2:option_key' => $option_key, 's2:option_key' => $option_key,
's3:unique' => $unique, 's3:unique' => $unique,
@ -4060,7 +4074,7 @@ sub sanity_check_fence_agent_form
my $passed_parameter_key = $name."_".$i; my $passed_parameter_key = $name."_".$i;
my $passed_value = defined $anvil->data->{cgi}{$passed_parameter_key}{value} ? $anvil->data->{cgi}{$passed_parameter_key}{value} : ""; my $passed_value = defined $anvil->data->{cgi}{$passed_parameter_key}{value} ? $anvil->data->{cgi}{$passed_parameter_key}{value} : "";
my $say_value = $passed_value; my $say_value = $passed_value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
passed_parameter_key => $passed_parameter_key, passed_parameter_key => $passed_parameter_key,
passed_value => $passed_value, passed_value => $passed_value,
'default' => $default, 'default' => $default,
@ -4108,14 +4122,14 @@ sub sanity_check_fence_agent_form
# This will be used to assemble the base shell call later # This will be used to assemble the base shell call later
$anvil->data->{fence}{$fence_agent}{set}{$i}{parameter}{$name}{set} = $passed_value; $anvil->data->{fence}{$fence_agent}{set}{$i}{parameter}{$name}{set} = $passed_value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"fence::${fence_agent}::set::${i}::parameter::${name}::set" => $anvil->data->{fence}{$fence_agent}{set}{$i}{parameter}{$name}{set}, "fence::${fence_agent}::set::${i}::parameter::${name}::set" => $anvil->data->{fence}{$fence_agent}{set}{$i}{parameter}{$name}{set},
}}); }});
} }
$anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'} = $is_default; $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'} = $is_default;
$anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value} = $passed_value ? $passed_value : $default; $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value} = $passed_value ? $passed_value : $default;
$anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value} = $say_value; $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value} = $say_value;
$anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 3, list => { $anvil->Log->variables({source => $THIS_FILE, line => __LINE__, level => 2, list => {
"fence::confirm_table::data::${name}::${i}::default" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'}, "fence::confirm_table::data::${name}::${i}::default" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{'default'},
"fence::confirm_table::data::${name}::${i}::value" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value}, "fence::confirm_table::data::${name}::${i}::value" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{value},
"fence::confirm_table::data::${name}::${i}::say_value" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value}, "fence::confirm_table::data::${name}::${i}::say_value" => $anvil->data->{fence}{confirm_table}{data}{$name}{$i}{say_value},

@ -25,10 +25,10 @@ $anvil->Database->connect({debug => 3});
$anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"}); $anvil->Log->entry({source => $THIS_FILE, line => __LINE__, level => 2, secure => 0, key => "log_0132"});
print "DB Connections: [".$anvil->data->{sys}{database}{connections}."]\n"; print "DB Connections: [".$anvil->data->{sys}{database}{connections}."]\n";
my $manifest_uuid = "8b4734e0-df34-4653-966f-73d8f29b6931"; $anvil->Striker->get_fence_data();
$anvil->Striker->load_manifest({
debug => 2,
manifest_uuid => $manifest_uuid,
});
print Dumper $anvil->data->{manifests}{manifest_uuid}{$manifest_uuid}; foreach my $name (sort {$a cmp $b} keys %{$anvil->data->{fence_data}{fence_virsh}{parameters}})
{
#print "Name: [".$name."]: [".sprintf('%vX', $anvil->data->{fence_data}{fence_virsh}{parameters}{$name}{'default'})."]\n";
print "Name: [".$name."]: [".$anvil->data->{fence_data}{fence_virsh}{parameters}{$name}{'default'}."]\n";
}

Loading…
Cancel
Save