From 1607a1dac64b18ba9ac57360203a0fe4defd759f Mon Sep 17 00:00:00 2001 From: baiyuan Date: Tue, 25 Feb 2014 00:07:34 -0500 Subject: [PATCH] fix:convert array to hash,xcatws.cgi use hash entries --- xCAT-server/xCAT-wsapi/xcatws-test.pl | 6 ++++-- xCAT-server/xCAT-wsapi/xcatws-test.sh | 4 +++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.pl b/xCAT-server/xCAT-wsapi/xcatws-test.pl index 927254f95..2cd22fb86 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.pl +++ b/xCAT-server/xCAT-wsapi/xcatws-test.pl @@ -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)); diff --git a/xCAT-server/xCAT-wsapi/xcatws-test.sh b/xCAT-server/xCAT-wsapi/xcatws-test.sh index b18edf98e..701370a66 100755 --- a/xCAT-server/xCAT-wsapi/xcatws-test.sh +++ b/xCAT-server/xCAT-wsapi/xcatws-test.sh @@ -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 : 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"