diff --git a/perl-xCAT/xCAT/FSPUtils.pm b/perl-xCAT/xCAT/FSPUtils.pm index 75f077ee9..388e09b55 100644 --- a/perl-xCAT/xCAT/FSPUtils.pm +++ b/perl-xCAT/xCAT/FSPUtils.pm @@ -152,7 +152,11 @@ sub fsp_api_action { $cmd = "$fsp_api -a $action -T $tooltype -f $parameter -t $type:$fsp_ip:$id:$node_name:"; } else { if( defined($parameter) ) { - $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:$id:$node_name:$parameter"; + if ($action =~ /^(set_frame_name|set_cec_name)$/) { + $cmd = "$fsp_api -a $action -n $parameter -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; + } else { + $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:$id:$node_name:$parameter"; + } } else { $cmd = "$fsp_api -a $action -T $tooltype -t $type:$fsp_ip:$id:$node_name:"; } diff --git a/perl-xCAT/xCAT/FSPcfg.pm b/perl-xCAT/xCAT/FSPcfg.pm index dcb0bb62e..cc03e0d37 100644 --- a/perl-xCAT/xCAT/FSPcfg.pm +++ b/perl-xCAT/xCAT/FSPcfg.pm @@ -51,7 +51,8 @@ sub parse_args { "general_passwd", "*_passwd", "cec_off_policy", - "resetnet" + "resetnet", + "sysname" ); my @frame = ( "frame", @@ -59,7 +60,8 @@ sub parse_args { "admin_passwd", "general_passwd", "*_passwd", - "resetnet" + "resetnet", + "sysname" ); @@ -190,6 +192,11 @@ sub parse_args { $request->{method} = "resetnet"; return( \%opt ); } + if(exists($cmds{sysname})) { + $request->{hcp} = $request->{hwtype} eq 'frame' ? "bpa":"fsp"; + $request->{method} = "sysname"; + return (\%opt); + } #################################### # Return method to invoke #################################### @@ -242,11 +249,106 @@ sub parse_option { return( "Invalid cec_off_policy '$value'" ); } } - - + if ($command eq 'sysname') { + if ($value ne '*') { + if ($value !~ /^[a-zA-Z0-9-_]+$/) { + return( "Invalid sysname '$value'" ); + } elsif (scalar(@{$request->{node}}) gt '1') { + return( "Invalid sysname '$value'" ); + } + my $len = rindex $value."\$", "\$"; + if ($len > '31') { + return ("Invalid sysname '$value', name is too long, max 31 characters"); + } + } + } return undef; } +sub sysname_check_node_info { + my $hash = shift; + my $invalid_node = undef; + while (my ($mtsm, $h) = each (%$hash)) { + while (my ($name, $d) = each(%$h)) { + if (@$d[4] !~ /^(cec|frame)$/) { + $invalid_node = $name; + last; + } + } + } + return $invalid_node; +} +my %sysname_action = ( + query => { + cec => "get_cec_name", + frame => "get_frame_name" + }, + set => { + cec => "set_cec_name", + frame => "set_frame_name" + } +); +sub do_query_sysname { + my $request = shift; + my $hash = shift; + my @result = (); + while (my ($mtms, $h) = each(%$hash)) { + while (my($name, $d) = each(%$h)) { + my $action = $sysname_action{query}{@$d[4]}; + my $values = xCAT::FSPUtils::fsp_api_action($name, $d, $action); + push @result, $values; + if (@$values[2] != 0) { + last; + } else { + my $len = rindex @$values[1]."\$", "\$"; + if ($len > '31') { + return ([[$name, "Get sysname failed, name is too long, max 31 characters", "1"]]); + } + } + } + } + return (\@result); +} +sub do_set_sysname { + my $request = shift; + my $hash = shift; + my $value = shift; + my @result = (); + while (my ($mtms, $h) = each(%$hash)) { + while (my($name, $d) = each(%$h)) { + my $sysname = ($value eq '*') ? $name : $value; + my $action = $sysname_action{set}{@$d[4]}; + my $values = xCAT::FSPUtils::fsp_api_action($name, $d, $action, 0, $sysname); + push @result, $values; + if (@$values[2] != 0) { + last; + } + } + } + return (\@result); +} +sub sysname { + my $request = shift; + my $hash = shift; + my $exp = shift; + my $args = $request->{arg}; + my $invalid_node = &sysname_check_node_info($hash); + if (defined($invalid_node)) { + retrun ([[$invalid_node, "Node must be CEC or Frame", '1']]); + } + foreach my $arg (@$args) { + my ($cmd, $value) = split /=/, $arg; + if ($cmd !~ /^sysname$/) { + return ([[$cmd, "Can't be exec with sysname", 1]]); + } + if ($value) { + return &do_set_sysname($request, $hash, $value) + } else { + return &do_query_sysname($request, $hash); + } + } + return ([["Error", "Arguments invalid", 1]]); +} ########################################################################## # Update passwords for different users on FSP/BPA ########################################################################## diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index e7aec345d..e44db459f 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -139,6 +139,9 @@ my %usage = ( rspconfig [dev|celogin1] rspconfig [dev=]| rspconfig [celogin1=] + Frame/CEC Specific: + rspconfig [sysname] + rspconfig [sysname=<*|name>] ", "getmacs" => "Usage: diff --git a/xCAT-client/pods/man1/rspconfig.1.pod b/xCAT-client/pods/man1/rspconfig.1.pod index 97249436d..f9498b7d2 100644 --- a/xCAT-client/pods/man1/rspconfig.1.pod +++ b/xCAT-client/pods/man1/rspconfig.1.pod @@ -152,6 +152,13 @@ B I B={B|B} B I B<--resetnet> +=head2 HMC Specific: + +B I {B} + +B I B={B<*>|B} + + =head1 DESCRIPTION B configures various settings in the nodes' service processors. If only a keyword is @@ -306,6 +313,10 @@ Set the Switch network parameters. Performs a system dump. +=item B + +Query or set sysname for CEC or Frame. If no value specified, means to query sysname of the specified nodes. If '*' specified, it means to set sysname for the specified nodes, and the sysname values would get from xCAT datebase. If a string was specified, it means to use the string as sysname value to set for the specified node. + =item B