From f9d339c3bad2d004039f30bf1139400e9bb00ff2 Mon Sep 17 00:00:00 2001 From: chenglch Date: Wed, 17 Aug 2016 04:24:39 -0400 Subject: [PATCH] Update rest api for rinstall and console - Refactor console api, console will be looked as a service resource - Add rest api to support rinstall --- xCAT-server/xCAT-wsapi/xcatws.cgi | 52 ++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/xCAT-server/xCAT-wsapi/xcatws.cgi b/xCAT-server/xCAT-wsapi/xcatws.cgi index 20306c00d..3b9fde3c5 100755 --- a/xCAT-server/xCAT-wsapi/xcatws.cgi +++ b/xCAT-server/xCAT-wsapi/xcatws.cgi @@ -217,17 +217,17 @@ my %URIdef = ( outhdler => \&noout, } }, - console => { - desc => "[URI:/nodes/{noderange}/console] - The console configuration for the node {noderange}", - matcher => '^/nodes/[^/]*/console$', - PUT => { - desc => "Update conserver configuration for the node {noderange}.", - usage => "|Json Formatted DataBody: {action:on/off}.|$usagemsg{non_getreturn}|", - example => "|Enable the console capability for node1|PUT|/nodes/node1/console {\"action\":\"on\", \"trust_host\": \"host\"}||", - cmd => "makeconservercf", + provision => { + desc => "[URI:/nodes/{noderange}/provision] - The deployment resource for the node {noderange}", + matcher => '^/nodes/[^/]*/provision$', + PUT => { + desc => "OS provision for the node {noderange}.", + usage => "|Json Formatted DataBody: {osimage: ubuntu16.04.1-x86_64-install-compute, action: boot}.|$usagemsg{non_getreturn}|", + example => "|Provision the node|PUT|/nodes/node1/provision {\"osimage\":\"ubuntu16.04.1-x86_64-install-compute\"}||", + cmd => "rinstall", fhandler => \&actionhdl, outhdler => \&noout, - } + } }, energy => { desc => "[URI:/nodes/{noderange}/energy] - The energy resource for the node {noderange}", @@ -773,7 +773,7 @@ my %URIdef = ( }, #### definition for mknb [-c] nbimage => { - desc => "[URI:/nbimage] - Create netboot root image for specified arch.", + desc => "[URI:/services/nbimage] - Create netboot root image for specified arch.", matcher => '^/services/nbimage/arch/[ppc64|x86_64]', POST => { desc => "creates a network boot root image", @@ -783,6 +783,18 @@ my %URIdef = ( fhandler => \&actionhdl, }, }, + console => { + desc => "[URI:/services/console] - Conserver configuration on management node.", + matcher => '^/services/console$', + PUT => { + desc => "Update conserver configuration", + usage => "|Json Formatted DataBody: {nodes: [node1, node2], action: on/off trust_host: }.|$usagemsg{non_getreturn}|", + example => "|Enable the console capability for node1|PUT|/services/console {\"nodes\":\n[\"node1\", \"node2\"]\"\n, \"action\": \"on\", \n\"trust_host\": \"host\"}||", + cmd => "makeconservercf", + fhandler => \&actionhdl, + outhdler => \&noout, + } + }, }, #### definition for network resources @@ -2194,15 +2206,25 @@ sub actionhdl { } } elsif ($params->{'resourcename'} eq "console") { + delete $request->{noderange}; if ($paramhash->{'action'}) { my %action = ('on' => '', 'off' => '-d'); push @args, $action{$paramhash->{'action'}}; - if ($paramhash->{'trust_host'}) { - push @args, '-t'; - push @args, $paramhash->{'trust_host'}; + if ($paramhash->{'nodes'}) { + $request->{noderange} = join(',', @{$paramhash->{'nodes'}}); + } else { + error("Missed node.") } - } else { - error("Missed Action.", $STATUS_NOT_FOUND); + } + if ($paramhash->{'trust_host'}) { + push @args, '-t'; + push @args, $paramhash->{'trust_host'}; + } + } elsif ($params->{'resourcename'} eq "provision") { + if ($paramhash->{'osimage'}) { + push @args, 'osimage='.$paramhash->{'osimage'}; + } elsif ($paramhash->{'action'}) { + push @args, $paramhash->{'action'}; } }