diff --git a/perl-xCAT/xCAT/PPCcfg.pm b/perl-xCAT/xCAT/PPCcfg.pm index 58494e476..02cb1da15 100644 --- a/perl-xCAT/xCAT/PPCcfg.pm +++ b/perl-xCAT/xCAT/PPCcfg.pm @@ -12,7 +12,8 @@ use xCAT::Usage; ########################################## my %rspconfig = ( sshcfg => \&sshcfg, - frame => \&frame + frame => \&frame, + hostname => \&hostname ); @@ -40,7 +41,9 @@ sub parse_args { "network", "HMC_passwd", "admin_passwd", - "general_passwd" + "general_passwd", + "*_passwd", + "hostname" ); my @bpa = ( "frame", @@ -48,7 +51,9 @@ sub parse_args { "newpassword", "HMC_passwd", "admin_passwd", - "general_passwd" + "general_passwd", + "*_passwd", + "hostname" ); my @ppc = ( "sshcfg" @@ -151,7 +156,7 @@ sub parse_args { #################################### # Return method to invoke #################################### - if ( exists($cmds{frame}) ) { + if ( exists($cmds{frame}) or exists($cmds{hostname}) ) { $request->{hcp} = "hmc"; $request->{method} = "cfg"; return( \%opt ); @@ -160,7 +165,7 @@ sub parse_args { #################################### # Return method to invoke #################################### - if ( exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) ) { + if ( exists($cmds{HMC_passwd}) or exists($cmds{general_passwd}) or exists($cmds{admin_passwd}) or exists($cmds{"*_passwd"}) ) { $request->{hcp} = "hmc"; $request->{method} = "passwd"; return( \%opt ); @@ -246,10 +251,10 @@ sub parse_option { } } - if ( $command eq 'admin_passwd' or $command eq 'general_passwd' ){ + if ( $command eq 'admin_passwd' or $command eq 'general_passwd' or $command eq '*_passwd' ){ my ($passwd,$newpasswd) = split /,/, $value; if ( !$passwd or !$newpasswd) { - return( "Current password and new password couldn't be empty for user 'admin' and 'general'" ); + return( "Current password and new password couldn't be empty" ); } } @@ -273,24 +278,37 @@ sub passwd { my $exp = shift; my $args = $request->{arg}; my $result; + my $users; foreach my $arg ( @$args ) { my ($user,$value) = split /=/, $arg; my ($passwd,$newpasswd) = split /,/, $value; $user =~ s/_passwd$//; + $user =~ s/^HMC$/access/g; - while ( my ($cec,$h) = each(%$hash) ) { - while ( my ($node,$d) = each(%$h) ) { - my $type = @$d[4]; - my $data = xCAT::PPCcli::chsyspwd( $exp, $user, $type, $cec, $newpasswd, $passwd ); - my $Rc = shift(@$data); - push @$result, [$node,@$data[0],$Rc]; + if ( $user eq "*" ) { + push @$users, "access"; + push @$users, "admin"; + push @$users, "general"; + } else { + push @$users, $user; + } - ################################## - # Write the new password to table - ################################## - if ( $Rc == SUCCESS ) { - xCAT::PPCdb::update_credentials( $node, $type, $user, $newpasswd ); + foreach my $usr ( @$users ) { + while ( my ($cec,$h) = each(%$hash) ) { + while ( my ($node,$d) = each(%$h) ) { + my $type = @$d[4]; + my $data = xCAT::PPCcli::chsyspwd( $exp, $usr, $type, $cec, $newpasswd, $passwd ); + my $Rc = shift(@$data); + $usr =~ s/^access$/HMC/g; + push @$result, [$node,"$usr: @$data[0]",$Rc]; + + ################################## + # Write the new password to table + ################################## + if ( $Rc == SUCCESS ) { + xCAT::PPCdb::update_credentials( $node, $type, $usr, $newpasswd ); + } } } } @@ -453,7 +471,7 @@ sub frame { if ( !defined($ent) or !defined($ent->{id}) ) { return( [[$node,"Cannot find frame num in database",RC_ERROR]] ); } - $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, $ent->{id} ); + $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=".$ent->{id} ); $Rc = shift(@$data); ################################# @@ -470,7 +488,7 @@ sub frame { # Set frame number # Read the frame number from opt ################################# - $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, $value ); + $data = xCAT::PPCcli::chsyscfg( $exp, "bpa", $d, "frame_num=$value" ); $Rc = shift(@$data); ################################# @@ -494,6 +512,72 @@ sub frame { } } +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] ); +} + 1; diff --git a/perl-xCAT/xCAT/PPCcli.pm b/perl-xCAT/xCAT/PPCcli.pm index bf123ad11..69bb6e00f 100644 --- a/perl-xCAT/xCAT/PPCcli.pm +++ b/perl-xCAT/xCAT/PPCcli.pm @@ -41,8 +41,8 @@ my %lssyscfg = ( my %chsyscfg = ( prof =>"chsyscfg -r prof -m %s -i %s", - bpa =>"chsyscfg -r frame -e %s -i frame_num=%s", - sys =>"chsyscfg -r sys -m %s -i %s" + bpa =>"chsyscfg -r frame -e %s -i %s", + fsp =>"chsyscfg -r sys -m %s -i %s" ); ############################################## diff --git a/perl-xCAT/xCAT/PPCvm.pm b/perl-xCAT/xCAT/PPCvm.pm index 917e7a0ac..14081e6c4 100644 --- a/perl-xCAT/xCAT/PPCvm.pm +++ b/perl-xCAT/xCAT/PPCvm.pm @@ -689,7 +689,7 @@ sub remove { my $cfgdata = @$service_lparid[0]; if ( ($id == $cfgdata) && ($cfgdata !~ /none/) ) { $cfgdata = "service_lpar_id=none"; - my $result = xCAT::PPCcli::chsyscfg( $exp, "sys", $d, $cfgdata ); + my $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); $Rc = shift(@$result); if ( $Rc != SUCCESS ) { return( [[$lpar, @$service_lparid[0], $Rc]] ); @@ -1918,7 +1918,7 @@ my $ppctab = xCAT::Table->new('ppc'); ########################################### if ( $Rc == SUCCESS) { $cfgdata = "service_lpar_id=$lpar_id"; - $result = xCAT::PPCcli::chsyscfg( $exp, "sys", $d, $cfgdata ); + $result = xCAT::PPCcli::chsyscfg( $exp, "fsp", $d, $cfgdata ); $Rc = shift(@$result); if ( $Rc != SUCCESS ) { $ppctab->close; diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index eb7419ffd..2d1dfebd9 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -97,18 +97,27 @@ my %usage = ( textid=<*>| frame=<*>| ntp=<[ntp],[ip],[frequency],[v3]> - FSP specific: - rspconfig [autopower|iocap|decfg|memdecfg|procdecfg|time|date|spdump|sysdump] + FSP/BPA Common: + rspconfig [autopower|iocap|decfg|memdecfg|procdecfg|time|date|spdump|sysdump|network|hostname] rspconfig autopower=| iocap=| decfg=:,...| memdecfg=::::id,...| procdecfg=::id,...| date=| - time= + time=| + network=<*|[ip],[host],[gateway],[netmask]>| + HMC_passwd=| + admin_passwd=| + general_passwd=| + *_passwd=| + hostname=<*|hostname> + BPA specific: + rspconfig [frame] + rspconfig frame=<*|frame> HMC specific: - rspconfig [sshcfg] - rspconfig [sshcfg=]", + rspconfig [sshcfg] + rspconfig [sshcfg=]", "getmacs" => "Usage: Common: