performance enhancement for getIPaddress() in FSPxx.pm

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12389 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jjhua 2012-04-28 09:26:49 +00:00
parent 794f22057a
commit d55a7c6d5a
11 changed files with 272 additions and 110 deletions

View File

@ -30,6 +30,186 @@ require xCAT::Utils;
require xCAT::NodeRange;
#-------------------------------------------------------------------------------
=head3 getHcpAttribs - Build 2 Hashes from ppc/vpd table
on hash is : CEC/Frame is the Key, FSPs/BPAs are the value.
the other is: fsp/bpa is the key, the side is the value.
Arguments:
Returns:
Globals:
none
Error:
none
Example: xCAT::FSPUtils::getPPCAttribs($request, \%tabs);
=cut
#-------------------------------------------------------------------------------
sub getHcpAttribs
{
my $request = shift;
my $tabs = shift;
my %ppchash ;
my %vpd ;
my $t = `date`;
print $t."\n";
my @vs = $tabs->{vpd}->getAllNodeAttribs(['node', 'side']);
for my $entry ( @vs ) {
my $tmp_node = $entry->{node};
my $tmp_side = $entry->{side};
if(defined($tmp_node) && defined($tmp_side)) {
$vpd{$tmp_node} = $tmp_side ;
}
}
my $t = `date`;
print $t."\n";
my @ps = $tabs->{ppc}->getAllNodeAttribs(['node','parent','nodetype']);
for my $entry ( @ps ) {
my $tmp_parent = $entry->{parent};
my $tmp_node = $entry->{node};
my $tmp_type = $entry->{nodetype};
if(defined($tmp_node) && defined($tmp_type) && ($tmp_type =~ /^(fsp|bpa)$/ && $tmp_parent) ) {
push @{$ppchash{$tmp_parent}{children}}, $tmp_node;
#push @{$ppchash{$tmp_parent}}, $tmp_node;
}
#if(exists($ppchash{$tmp_node})) {
# if( defined($tmp_type) ) {
# #push @{$ppchash{$tmp_node}{type}}, $tmp_type;
# } else {
# my %output;
# my $msg = "no type for $tmp_type in the ppc table.";
# $output{errorcode} = 1;
# $output{data} = $msg;
# $request->{callback}->( \%output );
# }
#}
}
$request->{ppc}=\%ppchash ;
$request->{vpd}=\%vpd ;
}
#-------------------------------------------------------------------------------
=head3 getIPaddress - Used by DFM related functions to support service vlan redundancy.
Arguments:
Node name only one at a time
Returns: ip address(s)
Globals:
none
Error:
none
Example: my $c1 = xCAT::Utils::getIPaddress($nodetocheck);
=cut
#-------------------------------------------------------------------------------
sub getIPaddress
{
# require xCAT::Table;
my $request = shift;
my $type = shift;
my $nodetocheck = shift;
my $port = shift;
if (xCAT::Utils::isIpaddr($nodetocheck)) {
return $nodetocheck;
}
my $side = "[A|B]";
if (!defined($port)) {
$port = "[0|1]";
}
my $ppc = $request->{ppc};
my $vpd = $request->{vpd};
# only need to parse IP addresses for Frame/CEC/BPA/FSP
#my $type = xCAT::DBobjUtils->getnodetype($nodetocheck);
#my $type = $$attrs[4];
if ($type) {
my @children;
my %node_side_pairs = ();
my $children_num = 0;
my $parent;
if ($type eq "bpa" or $type eq "fsp") {
push @children, $nodetocheck;
#my $tmp_s = $vpdtab->getNodeAttribs($nodetocheck, ['side']);
my $tmp_s = $vpd->{$nodetocheck};
if ($tmp_s and $tmp_s =~ /(A|B)-\d/i) {
$side = $1; # get side for the fsp, in order to get its brothers
} else {
return -3;
}
} elsif ($type eq "frame" or $type eq "cec") {
$parent = $nodetocheck;
} else {
return undef;
}
if( @children == 0 ) {
if( exists($ppc->{$parent} ) ) {
@children = @{$ppc->{$parent}->{children}};
} else {
return undef;
}
}
foreach my $tmp_n( @children) {
my $tmp_s = $vpd->{$tmp_n};
if ($tmp_s and $tmp_s =~ /^$side-$port$/i) {
$tmp_s =~ s/a/A/;
$tmp_s =~ s/b/B/;
if (xCAT::Utils::isIpaddr($tmp_n)) {
$node_side_pairs{$tmp_s} = $tmp_n;
$children_num++;
} else {
my $tmpip = xCAT::NetworkUtils->getipaddr($tmp_n);
if (!$tmpip) {
#my $hoststab = xCAT::Table->new( 'hosts' );
#my $tmp = $hoststab->getNodeAttribs($tmp_n, ['ip']);
#if ($tmp->{ip}) {
# $tmpip = $tmp->{ip};
#}
}
if ($tmpip) {
$node_side_pairs{$tmp_s} = $tmpip;
$children_num++;
}
} # end of parse IP address for a fsp/bpa
} # end of parse a child's side
} #end of loop for children
if ($children_num == 0) {
return undef; #no children or brothers for this node.
}
my @keys = qw(A-0 A-1 B-0 B-1);
my $out_strings = undef;
foreach my $tmp (@keys) {
if (!$node_side_pairs{$tmp}) {
$node_side_pairs{$tmp} = '';
}
}
$out_strings = $node_side_pairs{"A-0"}.','.$node_side_pairs{"A-1"}.','.$node_side_pairs{"B-0"}.','.$node_side_pairs{"B-1"};
return $out_strings;
} else {
return undef;
}
}
#-------------------------------------------------------------------------------
@ -56,6 +236,7 @@ require xCAT::NodeRange;
#-------------------------------------------------------------------------------
sub fsp_api_action {
my $request = shift;
my $node_name = shift;
my $attrs = shift;
my $action = shift;
@ -99,12 +280,10 @@ sub fsp_api_action {
############################
# Get IP address
############################
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name, $parameter );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name, $parameter );
undef($parameter);
$fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name, $parameter );
undef($parameter);
} else {
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
$fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name );
}
if(!defined($fsp_ip)) {
@ -126,25 +305,23 @@ sub fsp_api_action {
#get the HMC/password from passwd table or ppcdirect table.
if( $action =~ /^add_connection$/) {
my $tmp_node;
if( $$attrs[4] =~ /^cec$/ || $$attrs[4] =~ /^frame$/ ) {
#for redundant FSPs/BPAs, we only need to get the one node's HMC/passwd
my $children = xCAT::DBobjUtils->getchildren($fsp_name);
if( !defined($children) ) {
$res = "Failed to get the $fsp_name\'s FSPs/BPAs";
return ([$fsp_name, $res, -1]);
}
$tmp_node = $$children[0];
} elsif ($$attrs[4] =~ /^blade$/) {
$tmp_node = $$attrs[5];
} else {
if( $$attrs[4] =~ /^cec$/ || $$attrs[4] =~ /^frame$/ ) {
$tmp_node = $node_name;
} elsif ($$attrs[4] =~ /^blade$/) {
$tmp_node = $$attrs[5];
} else {
$tmp_node = $fsp_name;
}
($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,'HMC');
if ( !$password) {
$res = "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'.";
return ([$node_name, $res, -1]);
}
}
my $cred = $request->{$tmp_node}{cred};
($user, $password) = @$cred ;
#($user, $password) = xCAT::PPCdb::credentials( $tmp_node, $fsp_bpa_type,'HMC');
if ( !$password) {
$res = "Cannot get password of userid 'HMC'. Please check table 'passwd' or 'ppcdirect'.";
return ([$node_name, $res, -1]);
}
$user = 'HMC';
}
my $cmd;
@ -219,8 +396,9 @@ sub fsp_api_action {
#-------------------------------------------------------------------------------
sub fsp_state_action {
my $request = shift;
my $node_name = shift;
my $type_name = shift;
my $attrs = shift;
my $action = shift;
my $tooltype = shift;
my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api";
@ -241,7 +419,7 @@ sub fsp_state_action {
$fsp_name = $node_name;
if($type_name =~ /^fsp$/ || $type_name =~ /^lpar$/ || $type_name =~ /^(cec|blade)$/) {
if( $$attrs[4] =~ /^(fsp|lpar|cec|blade)$/) {
$type = 0;
} else {
$type = 1;
@ -250,8 +428,7 @@ sub fsp_state_action {
############################
# Get IP address
############################
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
$fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name );
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res[0] = ["Failed to get IP address for $fsp_name."];
return ([$node_name, @res, -1]);
@ -278,37 +455,10 @@ sub fsp_state_action {
return( [$Rc,@res] );
}
sub getTypeOfNode
{
my $class = shift;
my $node = shift;
my $callback = shift;
my $nodetypetab = xCAT::Table->new( 'nodetype');
if (!$nodetypetab) {
my $rsp;
$rsp->{errorcode}->[0] = [1];
$rsp->{data}->[0]= "Failed to open table 'nodetype'";
xCAT::MsgUtils->message('E', $rsp, $callback);
}
my $nodetype_hash = $nodetypetab->getNodeAttribs( $node,[qw(nodetype)]);
my $nodetype = $nodetype_hash->{nodetype};
if ( !$nodetype) {
my $rsp;
$rsp->{errorcode}->[0] = [1];
$rsp->{data}->[0]= "Not found the $node\'s nodetype";
xCAT::MsgUtils->message('E', $rsp, $callback);
return undef;
}
return $nodetype;
}
#-------------------------------------------------------------------------------
=head3 fsp_api_partition_action
=head3 fsp_api_create_partition
Description:
invoke the fsp_api to perform the functions
@ -324,13 +474,14 @@ sub getTypeOfNode
Error:
none
Example:
my $res = xCAT::FSPUtils::fsp_api_action( $node_name, $d, "add_connection", $tooltype );
my $res = xCAT::FSPUtils::fsp_api_create_partition($request, ... );
Comments:
=cut
#-------------------------------------------------------------------------------
sub fsp_api_create_parttion {
sub fsp_api_create_partition {
my $request = shift;
my $starting_lpar_id = shift;
my $octant_cfg = shift;
my $node_number = shift;
@ -368,8 +519,7 @@ sub fsp_api_create_parttion {
############################
# Get IP address
############################
#$fsp_ip = xCAT::Utils::getNodeIPaddress( $fsp_name );
$fsp_ip = xCAT::Utils::getIPaddress( $fsp_name );
$fsp_ip = getIPaddress($request, $$attrs[4], $fsp_name );
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res = "Failed to get IP address for $fsp_name.";
return ([$fsp_name, $res, -1]);

View File

@ -136,7 +136,7 @@ sub rbootseq {
return (\@output);
}
# add checking the power state of the cec
my $power_state = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "cec_state", $tooltype);
my $power_state = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "cec_state", $tooltype);
if ( @$power_state[2] != 0 ) {
push @output, [$node_name, @$power_state[1], -1 ];
return (\@output);
@ -208,7 +208,7 @@ sub rbootseq {
}
my $res = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "set_lpar_bootstring", $tooltype, $parameter);
my $res = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "set_lpar_bootstring", $tooltype, $parameter);
#print "In boot, state\n";
#print Dumper($res);
my $Rc = @$res[2];

View File

@ -465,7 +465,7 @@ sub do_query {
while (my ($mtms, $h) = each(%$hash)) {
while (my($name, $d) = each(%$h)) {
my $action = $fspapi_action{$cmd}{query}{@$d[4]};
my $values = xCAT::FSPUtils::fsp_api_action($name, $d, $action);
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action);
&do_process_query_res($name, $cmd, \@result, $values);
#my $res = &do_process_query_res($name, $cmd, \@result, $values);
#if (defined($res)) {
@ -512,7 +512,7 @@ sub do_set {
while (my($name, $d) = each(%$h)) {
my $action = $fspapi_action{$cmd}{set}{@$d[4]};
my $para = &do_set_get_para($name, $cmd, $value);
my $values = xCAT::FSPUtils::fsp_api_action($name, $d, $action, 0, $para);
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $para);
# print Dumper($values);
&do_process_set_res($name, $cmd, \@result, $values);
#my $res = &do_process_set_res($name, $cmd, \@result, $values);
@ -594,7 +594,7 @@ sub passwd {
while ( my ($node,$d) = each(%$h) ) {
my $type = @$d[4];
my $fsp_api = ($::XCATROOT) ? "$::XCATROOT/sbin/fsp-api" : "/opt/xcat/sbin/fsp-api";
my $cmd = xCAT::FSPcfg::fsp_api_passwd ($node, $d, $usr, $passwd, $newpasswd);
my $cmd = xCAT::FSPcfg::fsp_api_passwd ($request, $node, $d, $usr, $passwd, $newpasswd);
my $Rc = @$cmd[2];
my $data = @$cmd[1];
my $usr_back = $usr;
@ -676,7 +676,7 @@ sub frame {
# Get frame number
#################################
#$data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'frame_num' );
$data = xCAT::FSPUtils::fsp_api_action( $node, $d, "get_frame_number");
$data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "get_frame_number");
$Rc = pop(@$data);
#################################
@ -707,7 +707,7 @@ sub frame {
return( [[$node,"Cannot find frame num in database", -1]] );
}
#$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} );
$data = xCAT::FSPUtils::fsp_api_action( $node, $d, "set_frame_number", 0, $ent->{id});
$data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "set_frame_number", 0, $ent->{id});
$Rc = pop(@$data);
#################################
@ -726,7 +726,7 @@ sub frame {
# Read the frame number from opt
#################################
#$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" );
$data = xCAT::FSPUtils::fsp_api_action( $node, $d, "set_frame_number", 0, $value);
$data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "set_frame_number", 0, $value);
$Rc = pop(@$data);
#################################
@ -774,7 +774,7 @@ sub cec_off_policy {
#################################
# Get platform IPL parameters
#################################
$data = xCAT::FSPUtils::fsp_api_action( $node, $d, "get_phyp_cfg_power_off_policy");
$data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, "get_phyp_cfg_power_off_policy");
$Rc = pop(@$data);
#################################
@ -798,7 +798,7 @@ sub cec_off_policy {
} else {
$value = "cec_off_policy_stayon";
}
$data = xCAT::FSPUtils::fsp_api_action( $node, $d, $value);
$data = xCAT::FSPUtils::fsp_api_action( $request, $node, $d, $value);
$Rc = pop(@$data);
#################################
@ -830,6 +830,7 @@ sub cec_off_policy {
# Invoke fsp_api to change the passwords and store updated passwd in db
##########################################################################
sub fsp_api_passwd {
my $request = shift;
my $node_name = shift;
my $attrs = shift;
my $user = shift;
@ -862,7 +863,8 @@ sub fsp_api_passwd {
############################
#$fsp_ip = xCAT::Utils::get_hdwr_ip($fsp_name);
#$fsp_ip = xCAT::Utils::getNodeIPaddress($fsp_name);
$fsp_ip = xCAT::Utils::getIPaddress($fsp_name);
#$fsp_ip = xCAT::Utils::getIPaddress($fsp_name);
$fsp_ip = getIPaddress($request, $attrs, $fsp_name );
if(!defined($fsp_ip) or ($fsp_ip == -3)) {
$res = "Failed to get IP address for $fsp_name.";
return ([$node_name, $res, -1]);

View File

@ -596,7 +596,7 @@ sub mkhwconn
#}
my $res = xCAT::FSPUtils::fsp_api_action( $node_name, $d, "add_connection", $tooltype, $opt->{port} );
my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "add_connection", $tooltype, $opt->{port} );
$Rc = @$res[2];
if( @$res[1] ne "") {
push @value, [$node_name, @$res[1], $Rc];
@ -628,7 +628,7 @@ sub lshwconn
{
my $d = $node_hash->{$node_name};
my $action = "query_connection";
my $res = xCAT::FSPUtils::fsp_api_action ($node_name, $d, $action, $tooltype);
my $res = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, $action, $tooltype);
#print "in lshwconn:\n";
#print Dumper($res);
my $Rc = @$res[2];
@ -697,7 +697,7 @@ sub rmhwconn
my ( undef,undef,undef,undef,$type) = @$d;
my $res = xCAT::FSPUtils::fsp_api_action( $node_name, $d, "rm_connection", $tooltype );
my $res = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "rm_connection", $tooltype );
$Rc = @$res[2];
if( @$res[1] ne "") {
push @value, [$node_name, @$res[1], $Rc];

View File

@ -248,7 +248,7 @@ sub rflash {
if( !defined($housekeeping) && ($$d[4] =~ /^fsp$/ || $$d[4] =~ /^lpar$/ || $$d[4] =~ /^cec$/)) {
$action = "get_compatible_version_from_rpm";
my $values = xCAT::FSPUtils::fsp_api_action( $name, $d, $action, 0, $request->{opt}->{d} );
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d} );
my $Rc = @$values[2];
my $v = @$values[1];
if ($Rc != 0) {
@ -265,7 +265,7 @@ sub rflash {
my @frame_d = (0, 0, 0, $frame, "frame", 0);
$action = "list_firmware_level";
$values = xCAT::FSPUtils::fsp_api_action( $frame, \@frame_d, $action );
$values = xCAT::FSPUtils::fsp_api_action($request, $frame, \@frame_d, $action );
$Rc = @$values[2];
my $frame_firmware_level = @$values[1];
if ($Rc != 0) {
@ -300,7 +300,7 @@ sub rflash {
}
if(!defined($housekeeping)) {
my $values = xCAT::FSPUtils::fsp_api_action( $name, $d, "list_firmware_level");
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level");
my $Rc = @$values[2];
my $level = @$values[1];
#####################################
@ -348,7 +348,7 @@ sub rflash {
dpush ( \@value, [$name, $msg]);
}
my $res = xCAT::FSPUtils::fsp_api_action( $name, $d, $action, 0, $request->{opt}->{d} );
my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $request->{opt}->{d} );
push(@value,[$name, @$res[1], @$res[2]]);
return (\@value);

View File

@ -154,7 +154,7 @@ sub firmware {
@$d[4] = "fsp";
@$d[0] = 0;
}
my $values = xCAT::FSPUtils::fsp_api_action( $name, $d, "list_firmware_level");
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "list_firmware_level");
my $Rc = @$values[2];
my $data = @$values[1];
#print "values";
@ -248,7 +248,7 @@ sub deconfig {
# @$d[4] = "fsp";
# @$d[0] = 0;
#}
my $values = xCAT::FSPUtils::fsp_api_action( $name, $d, "get_cec_deconfigured");
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "get_cec_deconfigured");
my $Rc = @$values[2];
my $data = @$values[1];
#print "values";

View File

@ -257,7 +257,7 @@ sub getmacs {
#########################################
for ( my $stat = 0; $stat < 3; $stat++ ) {
#my $output = xCAT::PPCcli::lshwres( $exp, @$cmd[$stat], $hcp);
my $output = xCAT::FSPUtils::fsp_api_action($name, $d, $cmd[$stat]);
my $output = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $cmd[$stat]);
my $macs;
my $res = $$output[1];
chomp($res);

View File

@ -21,6 +21,7 @@ sub parse_args {
##########################################################################
sub enumerate {
my $request = shift;
my $h = shift;
my $mtms = shift;
my $tooltype = shift;
@ -28,12 +29,15 @@ sub enumerate {
my %cmds = ();
my $type = ();
my $cec_bpa = ();
my $tmp_d;
######################################
# Check for CEC/LPAR/BPAs in list
######################################
while (my ($name,$d) = each(%$h) ) {
$cec_bpa = @$d[3];
$type = @$d[4];
$tmp_d = $d;
#$cmds{$type} = ($type=~/^lpar$/) ? "all_lpars_state" : "cec_state";
if( $type=~/^lpar$/ ) {
$cmds{$type} = "all_lpars_state";
@ -45,7 +49,8 @@ sub enumerate {
}
foreach my $type ( keys %cmds ) {
my $action = $cmds{$type};
my $values = xCAT::FSPUtils::fsp_state_action ($cec_bpa, $type, $action, $tooltype);
#my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $type, $action, $tooltype);
my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_bpa, $tmp_d, $action, $tooltype);
my $Rc = shift(@$values);
##################################
# Return error
@ -117,7 +122,7 @@ sub powercmd_boot {
next;
}
my $res = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "state");
my $res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, "state");
#print "In boot, state\n";
#print Dumper($res);
my $Rc = @$res[2];
@ -147,7 +152,7 @@ sub powercmd_boot {
}
$res = xCAT::FSPUtils::fsp_api_action ($node_name, $d, $op);
$res = xCAT::FSPUtils::fsp_api_action ($request,$node_name, $d, $op);
# @output ...
$Rc = @$res[2];
@ -272,7 +277,7 @@ sub powercmd {
#print Dumper($newd);
my $res = xCAT::FSPUtils::fsp_api_action($newnames, $newd, $action, $tooltype, $request->{'powerinterval'} );
my $res = xCAT::FSPUtils::fsp_api_action($request, $newnames, $newd, $action, $tooltype, $request->{'powerinterval'} );
# print "In boot, state\n";
# print Dumper($res);
my $Rc = @$res[2];
@ -299,7 +304,7 @@ sub powercmd {
#my $msg = "success";
if ($action eq 'cec_reboot') {
sleep 0.1;
xCAT::FSPUtils::fsp_state_action (@$d[3], @$d[4], "cec_state");
xCAT::FSPUtils::fsp_state_action ($request, @$d[3], $d, "cec_state");
#my $state_res = xCAT::FSPUtils::fsp_state_action (@$d[3], @$d[4], "cec_state");
#my @state_state = @$state_res[1];
#$msg = @state_state[0];
@ -377,7 +382,7 @@ sub state {
######################################
# Build CEC/LPAR information hash
######################################
my $stat = enumerate( $h, $mtms, $tooltype);
my $stat = enumerate($request, $h, $mtms, $tooltype);
my $Rc = shift(@$stat);
my $data = @$stat[0];
#if($Rc != 0) {
@ -407,7 +412,7 @@ sub state {
# Node not found
##################################
if ($type !~ /^blade$/ and !exists( $data->{$id} )) {
my $res = xCAT::FSPUtils::fsp_api_action($name, $d, "state", $tooltype);
my $res = xCAT::FSPUtils::fsp_api_action($request, $name, $d, "state", $tooltype);
my $rc = @$res[2];
my $val = @$res[1];
if( $rc != 0) {
@ -495,7 +500,7 @@ sub state1 {
if($$d[4] =~ /^fsp$/ || $$d[4] =~ /^bpa$/) {
$action = "cec_state";
}
my $stat = xCAT::FSPUtils::fsp_api_action ($node_name, $d, $action);
my $stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, $action);
my $Rc = @$stat[2];
my $data = @$stat[1];
my $type = @$d[4];

View File

@ -82,6 +82,7 @@ sub getshorthost {
##########################################################################
sub enumerate {
my $request = shift;
my $hash = shift;
my $exp = shift;
my $hwtype = ();
@ -118,7 +119,7 @@ sub enumerate {
push @values, $data;
next;
}
my $stat = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "query_connection");
my $stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "query_connection");
my $Rc = @$stat[2];
my $data = @$stat[1];
@ -183,7 +184,7 @@ sub enumerate {
#####################################
# Enumerate LPARs
#####################################
$stat = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "get_lpar_info");
$stat = xCAT::FSPUtils::fsp_api_action ($request, $node_name, $d, "get_lpar_info");
$Rc = @$stat[2];
$data = @$stat[1];
@ -524,7 +525,7 @@ sub rscan {
###################################
# Enumerate all the hardware
###################################
my $values = enumerate( $hash );
my $values = enumerate($request, $hash );
#print "In rscan:\n";
#print Dumper($values);
if ( ref($values) ne 'ARRAY' ) {

View File

@ -60,6 +60,7 @@ sub enumerate_temp {
##########################################################################
sub enumerate_lcds {
my $request= shift;
my $name= shift;
my $d = shift;
my $mtms = @$d[2];
@ -78,7 +79,7 @@ sub enumerate_lcds {
$action = "cec_query_lcds";
}
my $values = xCAT::FSPUtils::fsp_api_action ($name, $d, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action);
$Rc = @$values[2];
my $data = @$values[1];
$data =~ /\|(\w*)/ ;
@ -97,6 +98,7 @@ sub enumerate_lcds {
##########################################################################
sub enumerate_rackenv {
my $request= shift;
my $name= shift;
my $d = shift;
#my $mtms = @$d[2];
@ -106,7 +108,7 @@ sub enumerate_rackenv {
my %outhash = ();
my $action = "get_rack_env";
my $values = xCAT::FSPUtils::fsp_api_action ($name, $d, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action);
$Rc = @$values[2];
my $data = @$values[1];
if ( $Rc != 0 ) {
@ -303,7 +305,7 @@ sub rackenv {
}
my $action = "get_rack_env";
my $values = xCAT::FSPUtils::fsp_api_action ($name, $d, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $name, $d, $action);
my $Rc = @$values[2];
my $data = @$values[1];
if ( $Rc != 0 ) {
@ -370,7 +372,7 @@ sub lcds {
# push @result, [$name, "$text Not available(NO HMC)", 1];
# next;
#}
$refcodes = enumerate_lcds($name, $d);
$refcodes = enumerate_lcds($request, $name, $d);
$num = 1;
foreach $rcode (@$refcodes){
$Rc = shift(@$rcode);

View File

@ -644,7 +644,7 @@ sub do_op_extra_cmds {
while (my ($mtms, $h) = each(%$hash)) {
while (my($name, $d) = each(%$h)) {
my $tmp_value = ($param eq '*') ? $name : $param;
my $value = xCAT::FSPUtils::fsp_api_action($name, $d, $action, 0, $tmp_value);
my $value = xCAT::FSPUtils::fsp_api_action($request, $name, $d, $action, 0, $tmp_value);
if (@$value[1] && ((@$value[1] =~ /Error/i) && (@$value[2] ne '0'))) {
return ([[$name, @$value[1], '1']]) ;
} else {
@ -721,7 +721,7 @@ sub modify_by_prof {
}
#get the current I/O slot information
my $action = "get_io_slot_info";
my $values = xCAT::FSPUtils::fsp_api_action ($cec_name, $td, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec_name, $td, $action);
my $Rc = $$values[2];
if ( $Rc != 0 ) {
push @result, [$cec_name, $$values[1], $Rc];
@ -738,7 +738,7 @@ sub modify_by_prof {
#get all the nodes state in the same cec
$action = "all_lpars_state";
undef($values);
my $values = xCAT::FSPUtils::fsp_state_action ($cec_name, "fsp", $action);
my $values = xCAT::FSPUtils::fsp_state_action ($request, $cec_name, $td, $action);
$Rc = shift(@$values);
if ( $Rc != 0 ) {
push @result, [$cec_name, $$values[0], $Rc];
@ -770,7 +770,7 @@ sub modify_by_prof {
return ( \@result );
}
my $values = xCAT::FSPUtils::fsp_api_action ($lpar, $d, $action, $tooltype, $drc_index);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $lpar, $d, $action, $tooltype, $drc_index);
#my $Rc = shift(@$values);
my $Rc = pop(@$values);
if ( $Rc != 0 ) {
@ -787,6 +787,7 @@ sub modify_by_prof {
sub enumerate {
my $request = shift;
my $h = shift;
my $mtms = shift;
my %outhash = ();
@ -802,7 +803,7 @@ sub enumerate {
$td[4]="fsp";
my $action = "get_io_slot_info";
my $values = xCAT::FSPUtils::fsp_api_action ($cec, \@td, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec, \@td, $action);
#my $Rc = shift(@$values);
my $Rc = $$values[2];
if ( $Rc != 0 ) {
@ -818,7 +819,7 @@ sub enumerate {
if( $type =~ /^(fsp|cec)$/ ) {
$action = "query_octant_cfg";
my $values = xCAT::FSPUtils::fsp_api_action ($cec, \@td, $action);
my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec, \@td, $action);
my $Rc = pop(@$values);
if ( $Rc != 0 ) {
return( [$Rc,$$values[1]] );
@ -841,6 +842,7 @@ sub enumerate {
}
sub get_cec_attr_info {
my $request = shift;
my $name = shift;
my $attr = shift;
my $op = shift;
@ -850,7 +852,7 @@ sub get_cec_attr_info {
huge_page => "get_huge_page"
);
my $action = $op_hash{$op};
my $values = xCAT::FSPUtils::fsp_api_action($name, $attr, $action);
my $values = xCAT::FSPUtils::fsp_api_action($request, $name, $attr, $action);
if (@$values[1] && ((@$values[1] =~ /Error/i) && @$values[2] ne '0')) {
return ([[$name, @$values[1], '1']]);
}
@ -985,7 +987,7 @@ sub list {
my $l_string = "\n";
#print Dumper($hash);
while (my ($mtms,$h) = each(%$hash) ) {
my $info = enumerate( $h, $mtms );
my $info = enumerate($request, $h, $mtms );
my $Rc = shift(@$info);
my $data = @$info[0];
@ -1013,16 +1015,16 @@ sub list {
# get the I/O slot information
if($request->{opt}->{l}) {
if ($type =~ /^(fsp|cec)$/) {
$bsr_infos = get_cec_attr_info($node_name, $d, "bsr");
$bsr_infos = get_cec_attr_info($request, $node_name, $d, "bsr");
if (ref($bsr_infos) eq 'ARRAY') {
return $bsr_infos;
}
$huge_infos = get_cec_attr_info($node_name, $d, "huge_page");
$huge_infos = get_cec_attr_info($request,$node_name, $d, "huge_page");
if (ref($huge_infos) eq 'ARRAY') {
return $huge_infos;
}
}
$lpar_infos = get_cec_attr_info($node_name, $d, "lpar_info");
$lpar_infos = get_cec_attr_info($request, $node_name, $d, "lpar_info");
if (ref($lpar_infos) eq 'ARRAY') {
return $lpar_infos;
}
@ -1053,7 +1055,7 @@ sub list {
if (defined($lpar_huges{$lparid})) {
$hugepage = $lpar_huges{$lparid};
} else {
$hugepage = get_cec_attr_info($node_name, $d, "huge_page");
$hugepage = get_cec_attr_info($request, $node_name, $d, "huge_page");
if (ref($hugepage) eq 'ARRAY') {
return $hugepage;
}
@ -1144,7 +1146,7 @@ sub list_orig {
# This is a CEC
####################################
else {
my $values = xCAT::FSPUtils::fsp_api_action( $node_name, $d, "query_octant_cfg");
my $values = xCAT::FSPUtils::fsp_api_action($request, $node_name, $d, "query_octant_cfg");
my $Rc = @$values[2];
my $data = @$values[1];
if ( $Rc != SUCCESS ) {
@ -1210,7 +1212,7 @@ sub create {
}
}
my $values = xCAT::FSPUtils::fsp_api_action ($cec_name, $d, "query_octant_cfg");
my $values = xCAT::FSPUtils::fsp_api_action ($request, $cec_name, $d, "query_octant_cfg");
my $Rc = shift(@$values);
if ( $Rc != 0 ) {
return( [[$cec_name,$$values[0],$Rc]] );
@ -1287,7 +1289,7 @@ sub create {
#$values = xCAT::FSPUtils::fsp_api_create_parttion( $starting_lpar_id, $octant_cfg, $node_number, $d, "set_octant_cfg");
$values = xCAT::FSPUtils::fsp_api_action ($cec_name, $d, "set_octant_cfg", 0, $parameters);
$values = xCAT::FSPUtils::fsp_api_action ($request,$cec_name, $d, "set_octant_cfg", 0, $parameters);
my $Rc = $$values[2];
my $data = $$values[1];
if ( $Rc != SUCCESS ) {