fix:convert array to hash,xcatws.cgi use hash entries

This commit is contained in:
baiyuan 2014-02-25 00:07:34 -05:00
parent d5695f5727
commit 1607a1dac6
2 changed files with 7 additions and 3 deletions

View File

@ -78,18 +78,20 @@ if (!$::URL) {
my @updatearray;
my $fieldname;
my $fieldvalue;
my %entryhash;
if (scalar(@ARGV) > 0){
foreach my $tempstr (@ARGV){
push @updatearray, $tempstr;
push @updatearray, split(/=/,$tempstr);
}
}
%entryhash=@updatearray;
my $request;
my $ua = LWP::UserAgent->new();
my $response;
if (($::METHOD eq 'PUT') || ($::METHOD eq 'POST')){
my $tempstr = encode_json \@updatearray;
my $tempstr = encode_json \%entryhash;
$request = HTTP::Request->new($::METHOD => $::URL);
$request->header('content-type' => 'text/plain');
$request->header('content-length' => length($tempstr));

View File

@ -10,7 +10,9 @@ pw=$2
format='format=json&pretty=1'
#todo: add a test case for every api call that is documented
#todo: figure out why i currently have to specify -k
#curl [options] [URL...]:
# -X/--request <command> : commands include PUT,POST,GET and DELETE.
# -k/--insecure : This option explicitly allows curl to perform "insecure" SSL connections and transfers.
curl -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&format=xml"
curl -X GET -k "https://127.0.0.1/xcatws/nodes?userName=$user&password=$pw&format=xml&field=mac"