diff --git a/perl-xCAT/xCAT/FSPbootseq.pm b/perl-xCAT/xCAT/FSPbootseq.pm index 4f7db174d..c26ba6aad 100644 --- a/perl-xCAT/xCAT/FSPbootseq.pm +++ b/perl-xCAT/xCAT/FSPbootseq.pm @@ -131,11 +131,26 @@ sub rbootseq { #print Dumper($d); - if (!($$d[4] =~ /^lpar$/)) { + if (!($$d[4] =~ /^(lpar|blade)$/)) { push @output, [$node_name, "\'boot\' command not supported for CEC or BPA", -1 ]; return (\@output); } - + # add checking the power state of the cec + my $power_state = xCAT::FSPUtils::fsp_api_action ($node_name, $d, "cec_state", $tooltype); + unless (@$power_state and @$power_state =~ /operating|standby/) { + my $machine; + my $state; + if ($$d[4] eq 'blade') { + $machine = "blade"; + $state = "on"; + } else { + $machine = "CEC"; + $state = "power on"; + } + + push @output, [$node_name, "\'boot\' command can only support while the $machine is in the \'$state\' state, -1"]; + return (\@output); + } if( $opt->{net} ) { my $mactab = xCAT::Table->new( 'mac'); unless($mactab) { diff --git a/perl-xCAT/xCAT/FSPconn.pm b/perl-xCAT/xCAT/FSPconn.pm index 65fbe9aea..194046ac5 100644 --- a/perl-xCAT/xCAT/FSPconn.pm +++ b/perl-xCAT/xCAT/FSPconn.pm @@ -157,7 +157,7 @@ sub mkhwconn_parse_args next; } else { - unless ( $nodetype =~ /^(fsp|bpa|frame|cec|hmc)$/) + unless ( $nodetype =~ /^(fsp|bpa|frame|cec|hmc|blade)$/) { return ( usage("Node type is incorrect. \n")); } @@ -369,7 +369,7 @@ sub lshwconn_parse_args return( ["Failed to get nodehm.mgt value for node $node.\n"]); } if ( $ttype ne 'fsp' and $ttype ne 'cec' - and $ttype ne 'bpa' and $ttype ne 'frame') + and $ttype ne 'bpa' and $ttype ne 'frame' and $ttype ne 'blade') { return( ["Node type $ttype is not supported for this command in FSPAPI\n"]); } diff --git a/perl-xCAT/xCAT/FSPinv.pm b/perl-xCAT/xCAT/FSPinv.pm index 30124b601..4dcfed1df 100644 --- a/perl-xCAT/xCAT/FSPinv.pm +++ b/perl-xCAT/xCAT/FSPinv.pm @@ -142,7 +142,7 @@ sub firmware { ##################################### # Command only supported on FSP/BPA/LPARs ##################################### - if ( @$d[4] !~ /^(cec|frame|fsp|bpa|lpar)$/ ) { + if ( @$d[4] !~ /^(cec|frame|fsp|bpa|lpar|blade)$/ ) { push @result, [$name,"Information only available for CEC/FSP/Frame/BPA/LPAR",RC_ERROR]; next; diff --git a/perl-xCAT/xCAT/FSPpower.pm b/perl-xCAT/xCAT/FSPpower.pm index 1b409b029..bc408074b 100644 --- a/perl-xCAT/xCAT/FSPpower.pm +++ b/perl-xCAT/xCAT/FSPpower.pm @@ -209,13 +209,14 @@ sub powercmd { $newnames .="$node_name,"; $newd = $d; $lpar_flag = 1; - } elsif ($$d[4] =~ /^(fsp|cec)$/) { + } elsif ($$d[4] =~ /^(fsp|cec|blade)$/) { if($action =~ /^on$/) { $action = "cec_on_autostart"; } if($action =~ /^off$/) { $action = "cec_off"; } if($action =~ /^resetsp$/) { $action = "reboot_service_processor"; } if($action =~ /^lowpower$/) { $action = "cec_on_low_power"; } + if($action =~ /^reboot$/) {$action = "cec_reboot";} if($action !~ /^cec_on_autostart$/ && $action !~ /^cec_off$/ && $action !~ /^cec_on_low_power$/ && $action !~ /^onstandby$/ && $action !~ /^reboot_service_processor$/ ) { - push @output, [$node_name, "\'$action\' command not supported for CEC", -1 ]; + push @output, [$node_name, "\'$action\' command not supported for $$d[4]", -1 ]; next; } $newids = $$d[0]; @@ -409,9 +410,18 @@ sub state { ############################## # Convert state to on/off ############################## + if ($type eq 'blade') { + if ($value =~ /^(power-on-transition|power off|off)$/) { + $value = "off"; + } else { + $value = "on"; + } + } if ( defined( $convert )) { $value = power_status( $value ); } + + push @result, [$name,"$prefix$value",$Rc]; } } diff --git a/perl-xCAT/xCAT/PPCdb.pm b/perl-xCAT/xCAT/PPCdb.pm index 37bcf6139..db06d7ce7 100644 --- a/perl-xCAT/xCAT/PPCdb.pm +++ b/perl-xCAT/xCAT/PPCdb.pm @@ -28,7 +28,7 @@ my %hcptab = ( bpa => "ppcdirect", frame => "ppcdirect", cec => "ppcdirect", - + blade => "mpa", ); ########################################### @@ -41,7 +41,7 @@ my %defaultgrp = ( bpa => "bpa", frame => "frame", cec => "cec", - + blade => "blade", ); my %globlehwtype = ( fsp => $::NODETYPE_FSP, @@ -848,7 +848,8 @@ my %default_passwd_accounts = ( bpa => \%power_accounts, frame => \%power_accounts, cec => \%power_accounts, - blade => { USERID => 'PASSW0RD',}, + blade => { USERID => 'PASSW0RD', + HMC => 'PASSW0RD'}, ipmi => { USERID => 'PASSW0RD',}, ivm => { padmin => 'padmin',}, vmware => { root => '',}, diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index b7f7c7ae4..0a88d61d9 100644 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -421,7 +421,7 @@ mp => { }, mpa => { cols => [qw(mpa username password comments disable)], - keys => [qw(mpa)], + keys => [qw(mpa username)], nodecol => "mpa", table_desc => 'Contains info about each Management Module and how to access it.', descriptions => { diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index bd55a09e1..bfcaaf780 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -2346,9 +2346,9 @@ sub getNodeSpecAttribs { my %options = (); my @attribs = (); my @keys = (); - if (ref $_[0]) { + if (ref $_[0] eq 'HASH') { %options = %{shift()}; - @attribs = @_; + @attribs = @{shift()}; foreach my $key (keys %options) { if (!grep(/^$key$/, @attribs)) { push @attribs, $key; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 5234ba8c6..6ae4dfa8a 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -111,6 +111,8 @@ my %usage = ( rspconfig [sshcfg|snmpcfg|pd1|pd2|network|swnet|ntp|textid|frame] rspconfig [textid=name] rspconfig [frame=number] + rspconfig [USERID=passwd] + rspconfig [HMC=passwd] rspconfig [sshcfg=| snmpcfg=| pd1=| diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index 30698b0f8..44a2daf2f 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -3897,7 +3897,7 @@ sub process_request { my $pass=$bladepass; my $ent; if (defined($mpatab)) { - ($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>"USERID"},['username','password']);#zet modify here + ($ent)=$mpatab->getNodeSpecAttribs($mpa, {username=>"USERID"},qw(username password)); if (defined($ent->{password})) { $pass = $ent->{password}; } if (defined($ent->{username})) { $user = $ent->{username}; } } @@ -3952,12 +3952,12 @@ sub telnetcmds { my @unhandled; my %handled = (); my $result; - my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg); + my @tcmds = qw(snmpcfg sshcfg network swnet pd1 pd2 textid network_reset rscanfsp initnetwork solcfg USERID HMC); # most of these commands should be able to be done # through SNMP, but they produce various errors. foreach my $cmd (@_) { - if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|=/) { + if ($cmd =~ /^swnet|pd1|pd2|sshcfg|rscanfsp|USERID|HMC|=/) { if (($cmd =~ /^textid/) and ($nodeid > 0)) { push @unhandled,$cmd; next; @@ -4031,6 +4031,7 @@ sub telnetcmds { elsif (/^rscanfsp$/) { $result = rscanfsp($t,$mpa,$handled{$_},$mm); } elsif (/^solcfg$/) { $result = solcfg($t,$handled{$_},$mm); } elsif (/^network_reset$/) { $result = network($t,$handled{$_},$mpa,$mm,$node,$nodeid,1); } + elsif (/^(USERID|HMC)$/) {$result = passwd($t, $mpa, $1, $handled{$_}, $mm);} push @data, "$_: @$result"; $Rc |= shift(@$result); push @cfgtext,@$result; @@ -4165,6 +4166,31 @@ sub mmtextid { return([0,"textid: $value"]); } +sub passwd { + my $t = shift; + my $mpa = shift; + my $user = shift; + my $pass = shift; + my $mm = shift; + my $cmd = "users -n $user -p $pass -T system:$mm"; + print "===>$cmd\n"; + if (!$pass) { + return ([1, "No param specified"]); + } + my @data = $t->cmd($cmd); + if (!grep(/OK/i, @data)) { + return ([1, @data]); + } + my $mpatab = xCAT::Table->new('mpa'); + if ($mpatab) { + $mpatab->setAttribs({mpa=>$mpa,username=>$user},{password=>$pass}); + } else { + return ([1, "Update password for $user in 'mpa' table failed"]); + } + return ([0, "Success"]); +} + + sub pd { diff --git a/xCAT-server/lib/xcat/plugins/fsp.pm b/xCAT-server/lib/xcat/plugins/fsp.pm index dcdf7262c..dc2a5dc12 100644 --- a/xCAT-server/lib/xcat/plugins/fsp.pm +++ b/xCAT-server/lib/xcat/plugins/fsp.pm @@ -259,7 +259,7 @@ sub getfspcon { $rsp = {node=>[{name=>[$node]}]}; $rsp->{node}->[0]->{fsp_ip}->[0]=$fsp_ip; $rsp->{node}->[0]->{id}->[0]=$id; - $rsp->{node}->[0]->{type}->[0]=$type; #zet + $rsp->{node}->[0]->{type}->[0]=$type; $callback->($rsp); return $rsp } diff --git a/xCAT-server/share/xcat/cons/fsp b/xCAT-server/share/xcat/cons/fsp index b8ff6e016..806b40e1e 100755 --- a/xCAT-server/share/xcat/cons/fsp +++ b/xCAT-server/share/xcat/cons/fsp @@ -38,6 +38,7 @@ BEGIN my $sleepint=int(rand(10)); use lib "$::XCATROOT/lib/perl"; require xCAT::Client; +require xCAT::Utils; use strict; #use Getopt::Long; #use xCAT::Table; @@ -56,6 +57,7 @@ my $verbose = 0; my $node; my $ips; my $id; +my $hwtype; ########################################## # Database errors @@ -166,6 +168,17 @@ sub invoke_cmd { my $node = shift; my $fsp_ip = shift; my $id = shift; + my $hwtype = shift; + my $machine; + my $state; + if ($hwtype eq 'blade') { + $machine = "blade"; + $state = "on"; + } else { + $machine = "CEC"; + $state = "power on"; + } + #my @attribs = qw(id parent hcp); #my %tabs = (); @@ -240,7 +253,12 @@ sub invoke_cmd { #if(!defined($fsp_ip)) { # return "Failed to get the $fsp_name\'s ip"; #} - + my $power_state_cmd = "$fsp_api -a cec_state -t $type:$fsp_ip:$id:$node: 2>&1"; + my $res = xCAT::Utils->runcmd($power_state_cmd, -1); + unless ($res and $res =~ /operating|standby/) { + return("The command 'rcons' is only support while the $machine is in the '$state' state"); + } + my $cmd = "$fsp_api -a $action -t $type:$fsp_ip:$id:$node:\r"; #print "cmd: $cmd\n"; my $running_failed_code = "Reason code: 0x1000000"; @@ -294,6 +312,7 @@ sub getans { if ($rsp->{node}) { $ips = $rsp->{node}->[0]->{fsp_ip}->[0]; $id = $rsp->{node}->[0]->{id}->[0]; + $hwtype = $rsp->{node}->[0]->{type}->[0]; } } @@ -315,7 +334,7 @@ release_lock(); #done with xcatd, can run with near impunity $node = $ARGV[0]; -my $result = invoke_cmd($node, $ips, $id); +my $result = invoke_cmd($node, $ips, $id, $hwtype); if ( $result ne "0" ) { print STDERR "$node: $result\n"; exit(1);