2008-05-27 13:53:53 +00:00
|
|
|
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
|
|
|
|
package xCAT::PPCcfg;
|
|
|
|
use strict;
|
|
|
|
use Getopt::Long;
|
|
|
|
use xCAT::PPCcli qw(SUCCESS EXPECT_ERROR RC_ERROR NR_ERROR);
|
|
|
|
use xCAT::Usage;
|
|
|
|
|
|
|
|
|
|
|
|
##########################################
|
|
|
|
# Globals
|
|
|
|
##########################################
|
|
|
|
my %rspconfig = (
|
2009-09-02 16:25:46 +00:00
|
|
|
sshcfg => \&sshcfg,
|
2010-03-04 09:38:44 +00:00
|
|
|
frame => \&frame,
|
|
|
|
hostname => \&hostname
|
2008-05-27 13:53:53 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Parse the command line for options and operands
|
|
|
|
##########################################################################
|
|
|
|
sub parse_args {
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $command = $request->{command};
|
|
|
|
my $args = $request->{arg};
|
|
|
|
my %opt = ();
|
|
|
|
my %cmds = ();
|
|
|
|
my @fsp = (
|
|
|
|
"memdecfg",
|
|
|
|
"decfg",
|
|
|
|
"procdecfg",
|
|
|
|
"iocap",
|
|
|
|
"time",
|
|
|
|
"date",
|
|
|
|
"autopower",
|
|
|
|
"sysdump",
|
2009-01-19 08:58:29 +00:00
|
|
|
"spdump",
|
2009-12-29 11:42:49 +00:00
|
|
|
"network",
|
|
|
|
"HMC_passwd",
|
|
|
|
"admin_passwd",
|
2010-03-04 09:38:44 +00:00
|
|
|
"general_passwd",
|
|
|
|
"*_passwd",
|
2011-05-23 10:09:14 +00:00
|
|
|
"hostname",
|
|
|
|
"resetnet",
|
2011-06-17 07:29:17 +00:00
|
|
|
"dev",
|
|
|
|
"celogin1"
|
2009-01-19 08:58:29 +00:00
|
|
|
);
|
|
|
|
my @bpa = (
|
2010-01-05 06:31:25 +00:00
|
|
|
"frame",
|
2009-12-29 11:42:49 +00:00
|
|
|
"password",
|
|
|
|
"newpassword",
|
|
|
|
"HMC_passwd",
|
|
|
|
"admin_passwd",
|
2010-03-04 09:38:44 +00:00
|
|
|
"general_passwd",
|
|
|
|
"*_passwd",
|
2011-05-23 10:09:14 +00:00
|
|
|
"hostname",
|
|
|
|
"resetnet",
|
2011-07-25 03:40:30 +00:00
|
|
|
"dev",
|
|
|
|
"celogin1"
|
2008-05-27 13:53:53 +00:00
|
|
|
);
|
|
|
|
my @ppc = (
|
|
|
|
"sshcfg"
|
|
|
|
);
|
|
|
|
my %rsp = (
|
2011-05-10 08:11:22 +00:00
|
|
|
cec=> \@fsp,
|
|
|
|
frame=>\@bpa,
|
2008-05-27 13:53:53 +00:00
|
|
|
fsp => \@fsp,
|
2009-01-19 08:58:29 +00:00
|
|
|
bpa => \@bpa,
|
2008-05-27 13:53:53 +00:00
|
|
|
ivm => \@ppc,
|
|
|
|
hmc => \@ppc
|
|
|
|
);
|
|
|
|
#############################################
|
|
|
|
# Get support command list
|
|
|
|
#############################################
|
2011-06-07 06:02:28 +00:00
|
|
|
#my $typetab = xCAT::Table->new( 'nodetype' );
|
|
|
|
#my $nodes = $request->{node};
|
|
|
|
#foreach (@$nodes) {
|
|
|
|
# if ( defined( $typetab )) {
|
|
|
|
# my ($ent) = $typetab->getAttribs({ node=>$_},'nodetype');
|
|
|
|
# if ( defined($ent) ) {
|
|
|
|
# $request->{hwtype} = $ent->{nodetype};
|
|
|
|
# last;
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
# }
|
|
|
|
#
|
|
|
|
#}
|
|
|
|
|
2009-07-01 06:03:26 +00:00
|
|
|
my $nodes = $request->{node};
|
2011-06-07 06:02:28 +00:00
|
|
|
foreach my $nn (@$nodes) {
|
|
|
|
$request->{hwtype} = xCAT::DBobjUtils->getnodetype($nn);
|
|
|
|
last if ($request->{hwtype});
|
2009-07-01 06:03:26 +00:00
|
|
|
}
|
2011-05-10 08:11:22 +00:00
|
|
|
|
2008-05-27 13:53:53 +00:00
|
|
|
my $supported = $rsp{$request->{hwtype}};
|
|
|
|
|
|
|
|
#############################################
|
|
|
|
# Responds with usage statement
|
|
|
|
#############################################
|
|
|
|
local *usage = sub {
|
|
|
|
my $usage_string = xCAT::Usage->getUsage($command);
|
|
|
|
return( [$_[0], $usage_string] );
|
|
|
|
};
|
|
|
|
#############################################
|
|
|
|
# Process command-line arguments
|
|
|
|
#############################################
|
|
|
|
if ( !defined( $args )) {
|
|
|
|
return(usage( "No command specified" ));
|
|
|
|
}
|
|
|
|
#############################################
|
|
|
|
# Checks case in GetOptions, allows opts
|
|
|
|
# to be grouped (e.g. -vx), and terminates
|
|
|
|
# at the first unrecognized option.
|
|
|
|
#############################################
|
|
|
|
@ARGV = @$args;
|
|
|
|
$Getopt::Long::ignorecase = 0;
|
|
|
|
Getopt::Long::Configure( "bundling" );
|
|
|
|
$request->{method} = undef;
|
|
|
|
|
2011-05-23 10:09:14 +00:00
|
|
|
if ( !GetOptions( \%opt, qw(V|Verbose resetnet))) {
|
2008-05-27 13:53:53 +00:00
|
|
|
return( usage() );
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Check for "-" with no option
|
|
|
|
####################################
|
|
|
|
if ( grep(/^-$/, @ARGV )) {
|
|
|
|
return(usage( "Missing option: -" ));
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Check for "=" with no argument
|
|
|
|
####################################
|
|
|
|
if (my ($c) = grep(/=$/, @ARGV )) {
|
|
|
|
return(usage( "Missing argument: $c" ));
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Check for unsupported commands
|
|
|
|
####################################
|
|
|
|
foreach my $arg ( @ARGV ) {
|
|
|
|
my ($command,$value) = split( /=/, $arg );
|
2011-05-23 10:09:14 +00:00
|
|
|
if ( !grep( /^$command$/, @$supported) and !$opt{resetnet}) {
|
2008-05-27 13:53:53 +00:00
|
|
|
return(usage( "Invalid command: $arg" ));
|
|
|
|
}
|
|
|
|
if ( exists( $cmds{$command} )) {
|
|
|
|
return(usage( "Command multiple times: $command" ));
|
|
|
|
}
|
|
|
|
$cmds{$command} = $value;
|
|
|
|
}
|
2009-12-29 11:42:49 +00:00
|
|
|
|
2008-05-27 13:53:53 +00:00
|
|
|
####################################
|
|
|
|
# Check command arguments
|
|
|
|
####################################
|
|
|
|
foreach ( keys %cmds ) {
|
|
|
|
if ( $cmds{$_} ) {
|
|
|
|
my $result = parse_option( $request, $_, $cmds{$_} );
|
|
|
|
if ( $result ) {
|
|
|
|
return( usage($result) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2011-06-17 07:29:17 +00:00
|
|
|
{
|
|
|
|
my $result = parse_dev_option( $request, \%cmds);
|
|
|
|
if ($result) {
|
|
|
|
return ( usage($result));
|
|
|
|
}
|
|
|
|
}
|
2008-05-27 13:53:53 +00:00
|
|
|
####################################
|
|
|
|
# Return method to invoke
|
|
|
|
####################################
|
|
|
|
if ( $request->{hwtype} =~ /(^hmc|ivm)$/ ) {
|
|
|
|
$request->{method} = "cfg";
|
|
|
|
return( \%opt );
|
|
|
|
}
|
2009-09-02 16:25:46 +00:00
|
|
|
####################################
|
|
|
|
# Return method to invoke
|
|
|
|
####################################
|
2010-03-04 09:38:44 +00:00
|
|
|
if ( exists($cmds{frame}) or exists($cmds{hostname}) ) {
|
2009-12-29 08:23:20 +00:00
|
|
|
$request->{hcp} = "hmc";
|
2009-09-02 16:25:46 +00:00
|
|
|
$request->{method} = "cfg";
|
|
|
|
return( \%opt );
|
|
|
|
}
|
2011-05-23 10:09:14 +00:00
|
|
|
####################################
|
|
|
|
# Return method to invoke
|
|
|
|
####################################
|
|
|
|
if ( $opt{resetnet} ) {
|
|
|
|
$request->{hcp} = "hmc";
|
|
|
|
$request->{method} = "resetnet";
|
|
|
|
return( \%opt );
|
|
|
|
}
|
2009-12-29 11:42:49 +00:00
|
|
|
|
|
|
|
####################################
|
|
|
|
# Return method to invoke
|
|
|
|
####################################
|
2010-03-04 09:38:44 +00:00
|
|
|
if ( exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"}) ) {
|
2009-12-29 11:42:49 +00:00
|
|
|
$request->{hcp} = "hmc";
|
|
|
|
$request->{method} = "passwd";
|
|
|
|
return( \%opt );
|
|
|
|
}
|
|
|
|
|
2008-05-27 13:53:53 +00:00
|
|
|
$request->{method} = \%cmds;
|
|
|
|
return( \%opt );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-06-17 07:29:17 +00:00
|
|
|
sub parse_dev_option{
|
|
|
|
my $req = shift;
|
|
|
|
my $cmds = shift;
|
|
|
|
foreach my $cmd (keys %$cmds) {
|
|
|
|
if ( $cmd =~ /^(dev|celogin1)$/ ) {
|
|
|
|
if ($cmds->{$cmd} and ($cmds->{$cmd} !~ /^(enable|disable)$/i) ) {
|
|
|
|
return( "Invalid argument ".$cmds->{$cmd}." for ".$cmd );
|
|
|
|
}
|
|
|
|
$req->{dev} = 1;
|
|
|
|
} else {
|
|
|
|
$req->{other} = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($req->{dev} eq '1' && $req->{other} eq '1') {
|
|
|
|
return ("Invalid command arrays");
|
|
|
|
}
|
|
|
|
return undef;
|
|
|
|
}
|
2008-05-27 13:53:53 +00:00
|
|
|
##########################################################################
|
|
|
|
# Parse the command line optional arguments
|
|
|
|
##########################################################################
|
|
|
|
sub parse_option {
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $command = shift;
|
|
|
|
my $value = shift;
|
|
|
|
|
|
|
|
####################################
|
|
|
|
# Set/get time
|
|
|
|
####################################
|
|
|
|
if ( $command =~ /^time$/ ) {
|
|
|
|
if ( $value !~
|
|
|
|
/^([0-1]?[0-9]|2[0-3]):(0?[0-9]|[1-5][0-9]):(0?[0-9]|[1-5][0-9])$/){
|
|
|
|
return( "Invalid time format '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Set/get date
|
|
|
|
####################################
|
|
|
|
if ( $command =~ /^date$/ ) {
|
|
|
|
if ( $value !~
|
|
|
|
/^(0?[1-9]|1[012])-(0?[1-9]|[12][0-9]|3[01])-(20[0-9]{2})$/){
|
|
|
|
return( "Invalid date format '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Set/get options
|
|
|
|
####################################
|
|
|
|
if ( $command =~ /^(autopower|iocap|sshcfg)$/ ) {
|
|
|
|
if ( $value !~ /^(enable|disable)$/i ) {
|
|
|
|
return( "Invalid argument '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Deconfiguration policy
|
|
|
|
####################################
|
|
|
|
if ( $command =~ /^decfg$/ ) {
|
|
|
|
if ( $value !~ /^(enable|disable):.*$/i ) {
|
|
|
|
return( "Invalid argument '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
####################################
|
|
|
|
# Processor deconfiguration
|
|
|
|
####################################
|
|
|
|
if ( $command =~ /^procdecfg$/ ) {
|
|
|
|
if ( $value !~ /^(configure|deconfigure):\d+:(all|[\d,]+)$/i ) {
|
|
|
|
return( "Invalid argument '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
################################
|
|
|
|
# Memory deconfiguration
|
|
|
|
################################
|
|
|
|
elsif ( $command =~ /^memdecfg$/ ) {
|
|
|
|
if ($value !~/^(configure|deconfigure):\d+:(unit|bank):(all|[\d,]+)$/i){
|
|
|
|
return( "Invalid argument '$value'" );
|
|
|
|
}
|
|
|
|
}
|
2009-01-19 08:58:29 +00:00
|
|
|
if ( $command eq 'network'){
|
|
|
|
my ( $adapter_name, $ip, $host, $gateway, $netmask) =
|
|
|
|
split /,/, $value;
|
|
|
|
return ( "Network interface name is required") if ( ! $adapter_name);
|
|
|
|
return ( "Invalide network interface name $adapter_name") if ( $adapter_name !~ /^eth\d$/);
|
|
|
|
return undef if ( $ip eq '*');
|
|
|
|
return ( "Invalid IP address format") if ( $ip and $ip !~ /\d+\.\d+\.\d+\.\d+/);
|
|
|
|
return ( "Invalid netmask format") if ( $netmask and $netmask !~ /\d+\.\d+\.\d+\.\d+/);
|
|
|
|
}
|
|
|
|
|
2009-09-02 16:25:46 +00:00
|
|
|
if ( $command eq 'frame' ){
|
|
|
|
if ( $value !~ /^\d+$/i && $value ne '*' ) {
|
|
|
|
return( "Invalid frame number '$value'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-04 09:38:44 +00:00
|
|
|
if ( $command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq '*_passwd' ){
|
2009-12-29 11:42:49 +00:00
|
|
|
my ($passwd,$newpasswd) = split /,/, $value;
|
|
|
|
if ( !$passwd or !$newpasswd) {
|
2010-03-04 09:38:44 +00:00
|
|
|
return( "Current password and new password couldn't be empty" );
|
2009-12-29 11:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $command eq 'HMC_passwd' ) {
|
|
|
|
my ($passwd,$newpasswd) = split /,/, $value;
|
|
|
|
if ( !$newpasswd ) {
|
|
|
|
return( "New password couldn't be empty for user 'HMC'" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-27 13:53:53 +00:00
|
|
|
return undef;
|
|
|
|
}
|
|
|
|
|
2009-12-29 11:42:49 +00:00
|
|
|
##########################################################################
|
|
|
|
# Update passwords for different users on FSP/BPA
|
|
|
|
##########################################################################
|
|
|
|
sub passwd {
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my $exp = shift;
|
|
|
|
my $args = $request->{arg};
|
|
|
|
my $result;
|
2010-03-04 09:38:44 +00:00
|
|
|
my $users;
|
2009-12-29 11:42:49 +00:00
|
|
|
|
|
|
|
foreach my $arg ( @$args ) {
|
|
|
|
my ($user,$value) = split /=/, $arg;
|
|
|
|
my ($passwd,$newpasswd) = split /,/, $value;
|
|
|
|
$user =~ s/_passwd$//;
|
2010-03-04 09:38:44 +00:00
|
|
|
$user =~ s/^HMC$/access/g;
|
|
|
|
|
|
|
|
if ( $user eq "*" ) {
|
|
|
|
push @$users, "access";
|
|
|
|
push @$users, "admin";
|
|
|
|
push @$users, "general";
|
|
|
|
} else {
|
|
|
|
push @$users, $user;
|
|
|
|
}
|
2009-12-29 11:42:49 +00:00
|
|
|
|
2010-03-04 09:38:44 +00:00
|
|
|
foreach my $usr ( @$users ) {
|
|
|
|
while ( my ($cec,$h) = each(%$hash) ) {
|
|
|
|
while ( my ($node,$d) = each(%$h) ) {
|
|
|
|
my $type = @$d[4];
|
2010-03-25 06:38:39 +00:00
|
|
|
my $data = xCAT::PPCcli::chsyspwd( $exp, $usr, $type, $cec, $passwd, $newpasswd );
|
2010-03-04 09:38:44 +00:00
|
|
|
my $Rc = shift(@$data);
|
2010-03-25 06:38:39 +00:00
|
|
|
my $usr_back = $usr;
|
|
|
|
$usr_back =~ s/^access$/HMC/g;
|
|
|
|
push @$result, [$node,"$usr_back: @$data[0]",$Rc];
|
2010-03-04 09:38:44 +00:00
|
|
|
|
|
|
|
##################################
|
|
|
|
# Write the new password to table
|
|
|
|
##################################
|
|
|
|
if ( $Rc == SUCCESS ) {
|
2010-03-25 06:38:39 +00:00
|
|
|
xCAT::PPCdb::update_credentials( $node, $type, $usr_back, $newpasswd );
|
2010-03-04 09:38:44 +00:00
|
|
|
}
|
2009-12-29 11:42:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2008-05-27 13:53:53 +00:00
|
|
|
|
2009-12-29 11:42:49 +00:00
|
|
|
return( [@$result] );
|
|
|
|
}
|
2008-05-27 13:53:53 +00:00
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Handles all PPC rspconfig commands
|
|
|
|
##########################################################################
|
|
|
|
sub cfg {
|
|
|
|
|
|
|
|
my $request = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my $exp = shift;
|
|
|
|
my $args = $request->{arg};
|
|
|
|
my $result;
|
|
|
|
|
|
|
|
foreach ( @$args ) {
|
|
|
|
##################################
|
|
|
|
# Ignore switches in command-line
|
|
|
|
##################################
|
|
|
|
unless ( /^-/ ) {
|
|
|
|
my ($cmd,$value) = split /=/;
|
|
|
|
|
|
|
|
no strict 'refs';
|
2009-09-02 16:25:46 +00:00
|
|
|
$result = $rspconfig{$cmd}( $request, $exp, $value, $hash );
|
2008-05-27 13:53:53 +00:00
|
|
|
use strict;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( $result );
|
|
|
|
}
|
|
|
|
|
|
|
|
##########################################################################
|
|
|
|
# Enables/disables/displays SSH access to HMC/IVM
|
|
|
|
##########################################################################
|
|
|
|
sub sshcfg {
|
2009-09-25 03:14:50 +00:00
|
|
|
my $request = shift;
|
2009-09-02 16:25:46 +00:00
|
|
|
my $exp = shift;
|
|
|
|
my $mode = shift;
|
|
|
|
my $server = @$exp[3];
|
|
|
|
my $userid = @$exp[4];
|
|
|
|
my $fname = ((xCAT::Utils::isAIX()) ? "/.ssh/":"/root/.ssh/")."id_rsa.pub";
|
|
|
|
my $auth = "/home/$userid/.ssh/authorized_keys2";
|
2008-05-27 13:53:53 +00:00
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Get SSH key on Management Node
|
|
|
|
#####################################
|
|
|
|
unless ( open(RSAKEY,"<$fname") ) {
|
|
|
|
return( [[$server,"Error opening '$fname'",RC_ERROR]] );
|
|
|
|
}
|
|
|
|
my ($sshkey) = <RSAKEY>;
|
|
|
|
close(RSAKEY);
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# userid@host not found in key file
|
|
|
|
#####################################
|
|
|
|
if ( $sshkey !~ /\s+(\S+\@\S+$)/ ) {
|
|
|
|
return( [[$server,"Cannot find userid\@host in '$fname'",RC_ERROR]] );
|
|
|
|
}
|
|
|
|
my $logon = $1;
|
|
|
|
|
|
|
|
#####################################
|
|
|
|
# Determine if SSH is enabled
|
|
|
|
#####################################
|
|
|
|
if ( !defined( $mode )) {
|
|
|
|
my $result = xCAT::PPCcli::send_cmd( $exp, "cat $auth" );
|
|
|
|
my $Rc = shift(@$result);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
return( [[$server,@$result[0],$Rc]] );
|
|
|
|
}
|
|
|
|
#################################
|
|
|
|
# Find logon in key file
|
|
|
|
#################################
|
|
|
|
foreach ( @$result ) {
|
2011-06-08 06:21:41 +00:00
|
|
|
if ( /$logon$/ ) {
|
2008-05-27 13:53:53 +00:00
|
|
|
return( [[$server,"enabled",SUCCESS]] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return( [[$server,"disabled",SUCCESS]] );
|
|
|
|
}
|
|
|
|
#####################################
|
|
|
|
# Enable/disable SSH
|
|
|
|
#####################################
|
|
|
|
my $result = xCAT::PPCcli::mkauthkeys( $exp, $mode, $logon, $sshkey );
|
|
|
|
my $Rc = shift(@$result);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
return( [[$server,@$result[0],$Rc]] );
|
|
|
|
}
|
|
|
|
return( [[$server,lc($mode."d"),SUCCESS]] );
|
|
|
|
}
|
|
|
|
|
2009-09-02 16:25:46 +00:00
|
|
|
sub frame {
|
|
|
|
my $request = shift;
|
|
|
|
my $exp = shift;
|
|
|
|
my $value = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my $arg = $request->{arg};
|
2008-05-27 13:53:53 +00:00
|
|
|
|
2009-09-02 16:25:46 +00:00
|
|
|
foreach ( @$arg ) {
|
|
|
|
my $result;
|
|
|
|
my $Rc;
|
|
|
|
my $data;
|
|
|
|
|
|
|
|
my ($cmd, $value) = split /=/, $_;
|
|
|
|
if ( $cmd ne "frame" ) {
|
|
|
|
return( [[@$exp[2],"Multiple option $cmd and frame is not accepted",SUCCESS]] );
|
|
|
|
}
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Open xCAT database to sync with
|
|
|
|
# the frame number between hcp
|
|
|
|
# and database
|
|
|
|
#################################
|
|
|
|
my $tab = xCAT::Table->new( "ppc" );
|
|
|
|
|
|
|
|
while ( my ($cec,$h) = each(%$hash) ) {
|
|
|
|
while ( my ($node,$d) = each(%$h) ) {
|
|
|
|
if ( !defined($value) ) {
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Get frame number
|
|
|
|
#################################
|
|
|
|
$data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'frame_num' );
|
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
return( [[$node,@$data[0],$Rc]] );
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Set frame number to database
|
|
|
|
#################################
|
|
|
|
$tab->setNodeAttribs( $node, { id=>@$data[0] } );
|
|
|
|
|
|
|
|
} elsif ( $value eq '*' ) {
|
|
|
|
#################################
|
|
|
|
# Set frame number
|
|
|
|
# Read the settings from database
|
|
|
|
#################################
|
|
|
|
my $ent=$tab->getNodeAttribs( $node,['id'] );
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( !defined($ent) or !defined($ent->{id}) ) {
|
|
|
|
return( [[$node,"Cannot find frame num in database",RC_ERROR]] );
|
|
|
|
}
|
2010-03-04 09:38:44 +00:00
|
|
|
$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} );
|
2009-09-02 16:25:46 +00:00
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
return( [[$node,@$data[0],$Rc]] );
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
|
|
|
|
} else {
|
|
|
|
#################################
|
|
|
|
# Set frame number
|
|
|
|
# Read the frame number from opt
|
|
|
|
#################################
|
2010-03-04 09:38:44 +00:00
|
|
|
$data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" );
|
2009-09-02 16:25:46 +00:00
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
return( [[$node,@$data[0],$Rc]] );
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Set frame number to database
|
|
|
|
#################################
|
|
|
|
$tab->setNodeAttribs( $node, { id=>$value } );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( [@$result] );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-03-04 09:38:44 +00:00
|
|
|
sub hostname {
|
|
|
|
my $request = shift;
|
|
|
|
my $exp = shift;
|
|
|
|
my $value = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my $arg = $request->{arg};
|
|
|
|
my $result;
|
|
|
|
|
|
|
|
foreach ( @$arg ) {
|
|
|
|
my $data;
|
|
|
|
my $Rc;
|
|
|
|
|
|
|
|
my ($cmd, $value) = split /=/, $_;
|
|
|
|
if ( $cmd ne "hostname" ) {
|
|
|
|
return( [[@$exp[2],"Multiple option $cmd and hostname is not accepted",SUCCESS]] );
|
|
|
|
}
|
|
|
|
|
|
|
|
while ( my ($cec,$h) = each(%$hash) ) {
|
|
|
|
while ( my ($node,$d) = each(%$h) ) {
|
|
|
|
if ( !defined($value) ) {
|
|
|
|
#################################
|
|
|
|
# Get system name
|
|
|
|
#################################
|
|
|
|
$data = xCAT::PPCcli::lssyscfg( $exp, @$d[4], @$d[2], 'name' );
|
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
push @$result, [$node,@$data[0],$Rc];
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
} elsif ( $value eq '*' ) {
|
|
|
|
$data = xCAT::PPCcli::chsyscfg( $exp, @$d[4], $d, "new_name=$node" );
|
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
push @$result, [$node,@$data[0],$Rc];
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
} else {
|
|
|
|
$data = xCAT::PPCcli::chsyscfg( $exp, @$d[4], $d, "new_name=$value" );
|
|
|
|
$Rc = shift(@$data);
|
|
|
|
|
|
|
|
#################################
|
|
|
|
# Return error
|
|
|
|
#################################
|
|
|
|
if ( $Rc != SUCCESS ) {
|
|
|
|
push @$result, [$node,@$data[0],$Rc];
|
|
|
|
}
|
|
|
|
|
|
|
|
push @$result, [$node,@$data[0],SUCCESS];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return( [@$result] );
|
|
|
|
}
|
2011-05-23 10:09:14 +00:00
|
|
|
##########################################################################
|
|
|
|
# Do resetnet
|
|
|
|
##########################################################################
|
|
|
|
sub resetnet {
|
|
|
|
my $request = shift;
|
|
|
|
my $hash = shift;
|
|
|
|
my %nodehash;
|
|
|
|
foreach ( @{$request->{noderange}}) {
|
|
|
|
$nodehash{$_} = 1;
|
|
|
|
}
|
|
|
|
# go to use lsslp do_resetnet
|
|
|
|
my $result = xCAT_plugin::lsslp::do_resetnet($request, \%nodehash);
|
|
|
|
return [$result];
|
|
|
|
}
|
2010-03-04 09:38:44 +00:00
|
|
|
|
2009-09-02 16:25:46 +00:00
|
|
|
1;
|
2008-05-27 13:53:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|