2008-08-08 13:22:06 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head1
|
|
|
|
xCAT plugin package to handle sinv
|
|
|
|
|
|
|
|
Supported command:
|
2008-10-24 18:39:43 +00:00
|
|
|
sinv - software/firmware inventory program
|
|
|
|
run xdsh or rinv. See man sinv.
|
2008-08-08 13:22:06 +00:00
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
package xCAT_plugin::sinv;
|
|
|
|
use strict;
|
|
|
|
|
|
|
|
require xCAT::Utils;
|
2012-08-09 04:07:40 +00:00
|
|
|
require xCAT::TableUtils;
|
|
|
|
require xCAT::ServiceNodeUtils;
|
2008-08-08 13:22:06 +00:00
|
|
|
require xCAT::MsgUtils;
|
2008-09-16 12:53:11 +00:00
|
|
|
require xCAT::SINV;
|
2008-08-08 13:22:06 +00:00
|
|
|
use Getopt::Long;
|
2008-09-19 17:29:08 +00:00
|
|
|
|
2008-08-08 13:22:06 +00:00
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 handled_commands
|
|
|
|
|
|
|
|
Return list of commands handled by this plugin
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
sub handled_commands
|
|
|
|
{
|
|
|
|
return {sinv => "sinv",};
|
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
2008-09-19 17:29:08 +00:00
|
|
|
=head3 preprocess_request ( handles hierachy, TBD)
|
2008-08-08 13:22:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
2008-09-19 17:29:08 +00:00
|
|
|
#sub preprocess_request
|
|
|
|
#{
|
|
|
|
# my $req = shift;
|
|
|
|
# my $cb = shift;
|
|
|
|
# $::CALLBACK = $cb;
|
|
|
|
# my %sn;
|
|
|
|
# my $sn;
|
2009-07-15 15:15:40 +00:00
|
|
|
# if ($req->{_xcatpreprocessed}->[0] == 1) { return [$req]; }
|
2008-09-19 17:29:08 +00:00
|
|
|
# my $nodes = $req->{node};
|
|
|
|
# my $service = "xcat";
|
|
|
|
# my @requests;
|
|
|
|
# #display usage statement if -h and version if -v
|
|
|
|
# my $extrargs = $req->{arg};
|
|
|
|
# my @exargs=($req->{arg});
|
|
|
|
# if (ref($extrargs)) {
|
|
|
|
# @exargs=@$extrargs;
|
|
|
|
# }
|
|
|
|
# @ARGV=@exargs;
|
|
|
|
# $Getopt::Long::ignorecase=0;
|
|
|
|
# if(!GetOptions(
|
|
|
|
# 'h|help' => \$::HELP,
|
|
|
|
# 'v|version' => \$::VERSION)) {
|
|
|
|
# $req= {};
|
|
|
|
# #return;
|
|
|
|
# }
|
|
|
|
# if ($::HELP) {
|
|
|
|
# xCAT::SINV->usage();
|
|
|
|
# $req = {};
|
|
|
|
# return;
|
|
|
|
# }
|
|
|
|
# if ($::VERSION) {
|
|
|
|
# my $version = xCAT::Utils->Version();
|
|
|
|
# $version .= "\n";
|
|
|
|
# my $rsp = {};
|
|
|
|
# $rsp->{data}->[0] = $version;
|
|
|
|
# xCAT::MsgUtils->message("I", $rsp, $cb);
|
|
|
|
# $req= {};
|
|
|
|
# return;
|
|
|
|
# }
|
|
|
|
# if ($nodes) {
|
|
|
|
# # find service nodes for requested nodes
|
|
|
|
# # build an individual request for each service node
|
2012-08-09 04:07:40 +00:00
|
|
|
# $sn = xCAT::ServiceNodeUtils->get_ServiceNode($nodes, $service, "MN");
|
2008-09-19 17:29:08 +00:00
|
|
|
#
|
|
|
|
# # build each request for each service node
|
|
|
|
#
|
|
|
|
# foreach my $snkey (keys %$sn)
|
|
|
|
# {
|
|
|
|
# my $reqcopy = {%$req};
|
|
|
|
# $reqcopy->{node} = $sn->{$snkey};
|
|
|
|
# $reqcopy->{'_xcatdest'} = $snkey;
|
2009-07-15 15:15:40 +00:00
|
|
|
# $reqcopy->{_xcatpreprocessed}->[0] = 1
|
2008-09-19 17:29:08 +00:00
|
|
|
# push @requests, $reqcopy;
|
|
|
|
#
|
|
|
|
# }
|
|
|
|
# } else { # no nodes
|
|
|
|
# my $rsp = {};
|
|
|
|
# $rsp->{data}->[0] = "No noderange specified on the command.\n";
|
|
|
|
# xCAT::MsgUtils->message("E", $rsp, $cb);
|
|
|
|
# $req= {};
|
|
|
|
# return;
|
|
|
|
#
|
|
|
|
# }
|
|
|
|
# return \@requests;
|
|
|
|
# }
|
|
|
|
#
|
2008-08-08 13:22:06 +00:00
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 process_request
|
|
|
|
|
|
|
|
Process the command
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub process_request
|
|
|
|
{
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $callback = shift;
|
2008-09-19 17:29:08 +00:00
|
|
|
my $sub_req = shift;
|
2008-08-08 13:22:06 +00:00
|
|
|
|
2008-10-20 17:13:32 +00:00
|
|
|
sinv($request, $callback,$sub_req);
|
2008-08-08 13:22:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
|
|
|
|
=head3 sinv
|
|
|
|
|
|
|
|
Parses Builds and runs the sinv
|
|
|
|
|
|
|
|
|
|
|
|
=cut
|
|
|
|
|
|
|
|
#-------------------------------------------------------
|
|
|
|
sub sinv
|
|
|
|
{
|
2008-10-20 17:13:32 +00:00
|
|
|
my ($request, $callback, $sub_req) = @_;
|
2008-08-08 13:22:06 +00:00
|
|
|
|
|
|
|
|
2008-09-19 17:29:08 +00:00
|
|
|
# parse input and run dsh
|
2008-08-08 13:22:06 +00:00
|
|
|
my @local_results =
|
2008-10-20 17:13:32 +00:00
|
|
|
xCAT::SINV->parse_and_run_sinv($request, $callback,
|
|
|
|
$sub_req);
|
|
|
|
my $rsp = {};
|
2008-08-08 13:22:06 +00:00
|
|
|
push @{$rsp->{data}}, @local_results;
|
|
|
|
|
|
|
|
xCAT::MsgUtils->message("I", $rsp, $callback);
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2008-09-19 17:29:08 +00:00
|
|
|
1;
|