From a7a5218b5b8f8f7da236370c636e1a1ca3238e55 Mon Sep 17 00:00:00 2001 From: lissav Date: Mon, 16 Apr 2012 12:52:08 +0000 Subject: [PATCH] Add support for XML in git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12245 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Client.pm | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index dceb2e141..6d5200ac7 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -115,13 +115,17 @@ sub submit_request { unless ($certfile) { $certfile = $homedir."/.xcat/client-cred.pem"; } unless ($cafile) { $cafile = $homedir."/.xcat/ca.pem"; } $xCAT::Client::EXITCODE = 0; # clear out exit code before invoking the plugin -$request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog +if (ref($request) eq 'HASH') { # the request is an array, not pure XML + $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog +} # If XCATBYPASS is set, invoke the plugin process_request method directly # without going through the socket connection to the xcatd daemon if ($ENV{XCATBYPASS}) { #add current userid to the request - if (!(defined($request->{username}))) { - $request->{username}->[0] = getpwuid($>); + if (ref($request) eq 'HASH') { # the request is an array, not pure XML + if (!(defined($request->{username}))) { + $request->{username}->[0] = getpwuid($>); + } } # Load plugins from either specified or default dir require xCAT::Table; @@ -183,7 +187,12 @@ $request->{clienttype}->[0] = "cli"; # setup clienttype for auditlog die "Connection failure: $@" } } - my $msg=XMLout($request,RootName=>'xcatrequest',NoAttr=>1,KeyAttr=>[]); + my $msg; + if (ref($request) eq 'HASH') { # the request is an array, not pure XML + $msg=XMLout($request,RootName=>'xcatrequest',NoAttr=>1,KeyAttr=>[]); + } else { #XML + $msg=$request; + } if ($ENV{XCATXMLTRACE}) { print $msg; } if($ENV{XCATXMLWARNING}) { validateXML($msg); @@ -315,7 +324,6 @@ sub plugin_command { my $callback = shift; my %handler_hash; my $usesiteglobal = 0; - # We require these only in bypass mode to reduce start up time for the normal case #use lib "$::XCATROOT/lib/perl"; #use xCAT::NodeRange; @@ -325,6 +333,12 @@ sub plugin_command { require xCAT::Table; $Main::resps={}; + my $xmlreq; + if (ref($req) ne 'HASH') { # the request XML, get an array + $xmlreq=$req; # save the original XML + $req = XMLin($xmlreq,SuppressEmpty=>undef,ForceArray=>1) ; + + } my @nodes; if ($req->{node}) { @nodes = @{$req->{node}};