From 0ac6b30f4d3fff044f6d771e3a0f3946785f933f Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Tue, 29 Apr 2008 18:41:24 +0000 Subject: [PATCH] -Create 'getpostscript' command to enable nodes to retrieve their own current postscript git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1225 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- .../lib/xcat/plugins/getpostscript.pm | 75 +++++++++++++++++++ xCAT/xCAT.spec | 1 + 2 files changed, 76 insertions(+) create mode 100644 xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm diff --git a/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm b/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm new file mode 100644 index 000000000..dbc4afdc5 --- /dev/null +++ b/xCAT-server-2.0/lib/xcat/plugins/getpostscript.pm @@ -0,0 +1,75 @@ +# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html +#------------------------------------------------------- + +=head1 + xCAT plugin package to handle getpostscript command + +=cut + +#------------------------------------------------------- +package xCAT_plugin::getpostscript; +use xCAT::Postage; +use xCAT::Utils; +use xCAT::NodeRange; + +1; + +#------------------------------------------------------- + +=head3 handled_commands + +Return list of commands handled by this plugin + +=cut + +#------------------------------------------------------- + +sub handled_commands +{ + return {'getpostscript' => "getpostscript"}; +} + + +#------------------------------------------------------- + +=head3 process_request + + Process the command + +=cut + +#------------------------------------------------------- +sub process_request +{ + + my $request = shift; + my $callback = shift; + my $nodes = $request->{node}; + my $command = $request->{command}->[0]; + my $args = $request->{arg}; + my $envs = $request->{env}; + my $rsp; + my $i = 1; + my @nodes=@$nodes; + # do your processing here + # return info + my $client; + if ($request->{'_xcat_clienthost'}) { + $client = $request->{'_xcat_clienthost'}->[0]; + } + if ($client) { ($client) = noderange($client) }; + unless ($client) { #Not able to do identify the host in question + return; + } + my $state = $request->{scripttype}->[0]; + unless ($state) { + return; + } + + my @scriptcontents = xCAT::Postage::makescript($client,$state,$callback); + if (scalar(@scriptcontents)) { + $rsp->{data} = \@scriptcontents; + } + $callback->($rsp); +} + diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 56d0e6ca6..d6680476b 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -132,6 +132,7 @@ if [ "$1" = "1" ]; then #Only if installing for the fist time.. XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab priority=2 policy.commands=getbmcconfig policy.rule=allow XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab priority=3 policy.commands=nextdestiny policy.rule=allow XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab priority=4 policy.commands=getdestiny policy.rule=allow + XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab priority=4.4 policy.commands=getpostscript policy.rule=allow XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab priority=4.5 policy.commands=getcredentials policy.rule=allow fi