From 95d5f9db58c52440d66ddbdcca064fce49a35bcc Mon Sep 17 00:00:00 2001 From: xq2005 Date: Tue, 20 Mar 2012 07:54:21 +0000 Subject: [PATCH] add REST API for capture image git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11906 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/xCAT-wsapi/xcatws.cgi | 47 ++++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index b0d31acfc..f4d091017 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -14,7 +14,7 @@ use Data::Dumper; #all data input will be done from the common structure #turn on or off the debugging output -my $DEBUGGING = 0; +my $DEBUGGING = 1; my $VERSION = "2.7"; my $q = CGI->new; @@ -352,6 +352,51 @@ sub imagesHandler { } } elsif (isPost()) { + my $operationname = $image; + my $entries; + my %entryhash; + + #check the post data + unless (defined($q->param('POSTDATA'))) { + addPageContent("Invalid Parameters"); + sendResponseMsg($STATUS_BAD_REQUEST); + } + $entries = decode_json $q->param('POSTDATA'); + if (scalar(@$entries) < 1) { + addPageContent("No set attribute was supplied."); + sendResponseMsg($STATUS_BAD_REQUEST); + } + + extractData(\%entryhash, $entries); + + #for image capture + if ($operationname eq 'capture') { + $request->{command} = 'imgcapture'; + if (defined($entryhash{'nodename'})) { + $request->{noderange} = $entryhash{'nodename'}; + } + else { + addPageContent('No node range.'); + sendResponseMsg($STATUS_BAD_REQUEST); + } + + if (defined($entryhash{'profile'})) { + push @args, '-p'; + push @args, $entryhash{'profile'}; + } + if (defined($entryhash{'osimage'})) { + push @args, '-o'; + push @args, $entryhash{'osimage'}; + } + if (defined($entryhash{'bootinterface'})) { + push @args, '-i'; + push @args, $entryhash{'bootinterface'}; + } + if (defined($entryhash{'netdriver'})) { + push @args, '-n'; + push @args, $entryhash{'netdriver'}; + } + } } elsif (isPut()) {