2009-12-02 09:41:06 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
package xCAT::FSPinv;
|
2009-12-02 09:41:06 +00:00
|
|
|
use strict;
|
|
|
|
use Getopt::Long;
|
|
|
|
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
|
|
|
use xCAT::Usage;
|
2009-12-10 02:19:40 +00:00
|
|
|
use xCAT::PPCinv;
|
2009-12-02 09:41:06 +00:00
|
|
|
use Data::Dumper;
|
|
|
|
|
|
|
|
##########################################
|
|
|
|
# Maps fsp-api attributes to text
|
|
|
|
##########################################
|
|
|
|
my @licmap = (
|
|
|
|
["ecnumber", "Release Level "],
|
|
|
|
["activated_level", "Active Level "],
|
|
|
|
["installed_level", "Installed Level"],
|
|
|
|
["accepted_level", "Accepted Level "],
|
|
|
|
["curr_ecnumber_a", "Release Level A"],
|
|
|
|
["curr_level_a", "Level A "],
|
|
|
|
["curr_ecnumber_b", "Release Level B"],
|
|
|
|
["curr_level_b", "Level B "],
|
|
|
|
["curr_ecnumber_primary", "Release Level Primary"],
|
|
|
|
["curr_level_primary", "Level Primary "],
|
|
|
|
["curr_ecnumber_secondary","Release Level Secondary"],
|
|
|
|
["curr_level_secondary", "Level Secondary"]
|
|
|
|
);
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
##########################################################################
|
|
|
|
# Parse the command line for options and operands
|
|
|
|
##########################################################################
|
|
|
|
sub parse_args {
|
|
|
|
xCAT::PPCinv::parse_args(@_);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2009-12-02 09:41:06 +00:00
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Returns FSP/BPA firmware information
|
|
|
|
##########################################################################
|
|
|
|
sub firmware {
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my @result;
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
# print "in FSPinv \n";
|
2009-12-02 09:41:06 +00:00
|
|
|
#print Dumper($request);
|
|
|
|
#print Dumper($hash);
|
|
|
|
|
|
|
|
####################################
|
2009-12-10 02:19:40 +00:00
|
|
|
# FSPinv with firm command is grouped by hardware control point
|
|
|
|
# In FSPinv, the hcp is the related fsp.
|
2009-12-02 09:41:06 +00:00
|
|
|
####################################
|
|
|
|
|
|
|
|
# Example of $hash.
|
|
|
|
#VAR1 = {
|
|
|
|
# '9110-51A*1075ECF' => {
|
|
|
|
# 'Server-9110-51A-SN1075ECF' => [
|
|
|
|
# 0,
|
|
|
|
# 0,
|
2009-12-10 02:19:40 +00:00
|
|
|
# '9110-51A*1075ECF',
|
|
|
|
# 'fsp1_name',
|
|
|
|
# 'fsp',
|
|
|
|
# 0
|
|
|
|
# ]
|
|
|
|
# }
|
2009-12-02 09:41:06 +00:00
|
|
|
# };
|
|
|
|
|
|
|
|
while (my ($mtms,$h) = each(%$hash) ) {
|
|
|
|
while (my ($name,$d) = each(%$h) ) {
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Command only supported on FSP/BPA/LPARs
|
|
|
|
#####################################
|
|
|
|
if ( @$d[4] !~ /^(fsp|bpa|lpar)$/ ) {
|
|
|
|
push @result,
|
|
|
|
[$name,"Information only available for CEC/BPA/LPAR",RC_ERROR];
|
|
|
|
next;
|
|
|
|
}
|
|
|
|
#################
|
|
|
|
#For support on Lpars, the flag need to be changed.
|
|
|
|
##########
|
|
|
|
if(@$d[4] eq "lpar") {
|
|
|
|
@$d[4] = "fsp";
|
|
|
|
}
|
|
|
|
my $values = action( $name, $d, "list_firmware_level");
|
|
|
|
my $Rc = shift(@$values);
|
|
|
|
my $data = @$values[0];
|
|
|
|
#print "values";
|
|
|
|
#print Dumper($values);
|
|
|
|
#####################################
|
|
|
|
# Return error
|
|
|
|
#####################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
2009-12-23 02:10:00 +00:00
|
|
|
push @result, [$name,$data->{$name},$Rc];
|
2009-12-02 09:41:06 +00:00
|
|
|
next;
|
|
|
|
}
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Format fsp-api results
|
|
|
|
#####################################
|
2009-12-10 02:19:40 +00:00
|
|
|
my $val;
|
|
|
|
foreach $val ( @licmap ) {
|
|
|
|
if ( $data->{$name} =~ /@$val[0]=(\w+)/ ) {
|
|
|
|
push @result, [$name,"@$val[1]: $1",$Rc];
|
2009-12-02 09:41:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( \@result );
|
|
|
|
}
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
##########################################################################
|
|
|
|
# invoke the fsp-api command
|
|
|
|
##########################################################################
|
2009-12-02 09:41:06 +00:00
|
|
|
sub action {
|
|
|
|
my $node_name = shift;
|
2009-12-10 02:19:40 +00:00
|
|
|
my $attrs = shift;
|
2009-12-02 09:41:06 +00:00
|
|
|
my $action = shift;
|
2009-12-10 02:19:40 +00:00
|
|
|
# my $fsp_api ="/opt/xcat/sbin/fsp-api";
|
|
|
|
my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api";
|
2009-12-02 09:41:06 +00:00
|
|
|
my $id = 1;
|
|
|
|
my $fsp_name = ();
|
|
|
|
my $fsp_ip = ();
|
|
|
|
my $target_list=();
|
|
|
|
my $type = (); # fsp|lpar -- 0. BPA -- 1
|
|
|
|
my @result;
|
|
|
|
my $Rc = 0 ;
|
|
|
|
my %outhash = ();
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
$id = $$attrs[0];
|
|
|
|
$fsp_name = $$attrs[3];
|
2009-12-02 09:41:06 +00:00
|
|
|
|
|
|
|
my %objhash = ();
|
|
|
|
$objhash{$fsp_name} = "node";
|
|
|
|
my %myhash = xCAT::DBobjUtils->getobjdefs(\%objhash);
|
2009-12-10 02:19:40 +00:00
|
|
|
my $password = $myhash{$fsp_name}{"passwd.hscroot"};
|
2009-12-02 09:41:06 +00:00
|
|
|
#print "fspname:$fsp_name password:$password\n";
|
|
|
|
#print Dumper(%myhash);
|
|
|
|
if(!$password ) {
|
2009-12-10 02:19:40 +00:00
|
|
|
$outhash{$node_name} = "The password.hscroot of $fsp_name in ppcdirect table is empty";
|
2009-12-02 09:41:06 +00:00
|
|
|
return ([-1, \%outhash]);
|
|
|
|
}
|
|
|
|
# my $user = "HMC";
|
|
|
|
my $user = "hscroot";
|
|
|
|
# my $cred = $request->{$fsp_name}{cred};
|
|
|
|
# my $user = @$cred[0];
|
|
|
|
# my $password = @$cred[1];
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
if($$attrs[4] =~ /^lpar$/) {
|
2009-12-02 09:41:06 +00:00
|
|
|
$type = 0;
|
|
|
|
$id = 1;
|
2009-12-10 02:19:40 +00:00
|
|
|
} elsif($$attrs[4] =~ /^fsp$/) {
|
2009-12-02 09:41:06 +00:00
|
|
|
$type = 0;
|
|
|
|
} else {
|
|
|
|
$type = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
############################
|
|
|
|
# Get IP address
|
|
|
|
############################
|
2009-12-10 02:19:40 +00:00
|
|
|
$fsp_ip = xCAT::Utils::get_hdwr_ip($fsp_name);
|
|
|
|
if($fsp_ip == -1) {
|
|
|
|
$outhash{$node_name} = "Failed to get the $fsp_name\'s ip";
|
|
|
|
return ([-1, \%outhash]);
|
2009-12-02 09:41:06 +00:00
|
|
|
}
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
|
2009-12-02 09:41:06 +00:00
|
|
|
print "fsp name: $fsp_name\n";
|
|
|
|
print "fsp ip: $fsp_ip\n";
|
|
|
|
|
|
|
|
my $cmd = "$fsp_api -a $action -u $user -p $password -t $type:$fsp_ip:$id:$node_name:";
|
|
|
|
|
|
|
|
print "cmd: $cmd\n";
|
|
|
|
$SIG{CHLD} = ();
|
2009-12-10 02:19:40 +00:00
|
|
|
my $res = xCAT::Utils->runcmd($cmd, -1);
|
2009-12-02 09:41:06 +00:00
|
|
|
if($::RUNCMD_RC != 0){
|
|
|
|
$Rc = -1;
|
|
|
|
} else {
|
|
|
|
$Rc = SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-12-10 02:19:40 +00:00
|
|
|
$outhash{ $node_name } = $res;
|
2009-12-02 09:41:06 +00:00
|
|
|
|
|
|
|
return( [$Rc,\%outhash] );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Returns firmware version
|
|
|
|
##########################################################################
|
|
|
|
sub firm {
|
|
|
|
return( firmware(@_) );
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Returns serial-number
|
|
|
|
##########################################################################
|
|
|
|
sub serial {
|
|
|
|
}
|
|
|
|
|
|
|
|
sub vpd {
|
|
|
|
}
|
|
|
|
|
|
|
|
sub bus {
|
|
|
|
}
|
|
|
|
|
|
|
|
sub config {
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Returns machine-type-model
|
|
|
|
##########################################################################
|
|
|
|
sub model {
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Returns all inventory information
|
|
|
|
##########################################################################
|
|
|
|
sub all {
|
|
|
|
|
|
|
|
my @result = (
|
|
|
|
@{vpd(@_)},
|
|
|
|
@{bus(@_)},
|
|
|
|
@{config(@_)},
|
|
|
|
@{firmware(@_)}
|
|
|
|
);
|
|
|
|
return( \@result );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
1;
|
|
|
|
|
|
|
|
|