mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 11:22:27 +00:00 
			
		
		
		
	Cleaned up node cmds and man pages and fixed Tracker bug 1908147
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@733 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -1,65 +1,83 @@ | ||||
| =head1 NAME | ||||
|   | ||||
| B<nodeadd> -Adds nodes to the cluster. | ||||
|   | ||||
|  | ||||
| B<nodeadd> - Adds nodes to the xCAT cluster database. | ||||
|  | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|   | ||||
| I<nodeadd [-h| --help]> | ||||
|  | ||||
| I<nodeadd  [noderange] nodelist.groups= [groupname] > | ||||
| B<nodeadd> I<noderange> B<groups>=I<groupnames> [I<table.column=value>] [I<...>] | ||||
|  | ||||
| I<nodeadd  [noderange] [table.column=value, table.column=value] >  | ||||
| B<nodeadd> {B<-v> | B<--version>} | ||||
|  | ||||
| B<nodeadd> [B<-?> | B<-h> | B<--help>] | ||||
|  | ||||
|  | ||||
| =head1 DESCRIPTION | ||||
|  | ||||
|  The nodeadd command adds the node from the input node range. At least one groupname must be supplied | ||||
| The nodeadd command adds the nodes specified in noderange to the xCAT database.  It also stores | ||||
| the any additional attributes specified for these nodes.  At least one groupname must be supplied. | ||||
| You should also consider specifying attributes in at least the following tables:  B<nodehm>, B<noderes>, | ||||
| B<nodetype>.  See the man page for each of these for details.  Also see the B<xcatdb> man page for an | ||||
| overview of each table. | ||||
|  | ||||
|  nodeadd also supports  some short cut tags: | ||||
| 	  groups  is equivalent to table.column = nodelist.groups | ||||
| 	 	for example:nodeadd blade1-blade8  groups=all,compuTe | ||||
|  | ||||
|       mgt is equivalent to table.column = nodehm.mgt | ||||
| 		for example:nodeadd blade7  mgt=blade | ||||
| 	  switch is equivalent to table.colum=  switch.switch | ||||
| 		for example:nodeadd blade8  switch=switch1 | ||||
| The nodeadd command also supports some short cut names as aliases to common attributes.  See the | ||||
| B<nodels> man page for details. | ||||
|  | ||||
|  | ||||
| =head1 OPTIONS | ||||
|  | ||||
| =over 10 | ||||
|  | ||||
| B<-h>          Display usage message. | ||||
| =item B<-v|--version> | ||||
|  | ||||
| B<-v>          Command Version.  | ||||
| Command Version. | ||||
|  | ||||
| B<-V>          Verbose output.  | ||||
| =item B<-?|-h|--help> | ||||
|  | ||||
| Display usage message. | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 RETURN VALUE | ||||
|  | ||||
| 0 The command completed successfully. | ||||
| =over 3 | ||||
|  | ||||
| =item 0 | ||||
|  | ||||
| The command completed successfully. | ||||
|  | ||||
| =item 1 | ||||
|  | ||||
| An error has occurred. | ||||
|  | ||||
| =back | ||||
|  | ||||
| 1 An error has occurred. | ||||
|  | ||||
| =head1 EXAMPLES | ||||
|  | ||||
| 1. To add nodes in noderange  node1-node4 with group all:  | ||||
| =over 2 | ||||
|  | ||||
| I<nodeadd  node1-node4 groups=all >  | ||||
| 	 | ||||
| 2. To add nodes in noderange  node1-node4 to the nodetype table with os=rhel5:  | ||||
| =item * | ||||
|  | ||||
| I<nodeadd  node1-node4 nodetype.os=rhel5>  | ||||
| To add nodes in noderange  node1-node4 with group all: | ||||
|  | ||||
| B<nodeadd> I<node1-node4 groups=all> | ||||
|  | ||||
| =item * | ||||
|  | ||||
| To add nodes in noderange  node1-node4 to the nodetype table with os=rhel5: | ||||
|  | ||||
| B<nodeadd> I<node1-node4 groups=all,rhel5 nodetype.os=rhel5> | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 FILES | ||||
|   | ||||
|  | ||||
| /opt/xcat/bin/nodeadd | ||||
|  | ||||
|  | ||||
| =head1 NOTES | ||||
| =head1 SEE ALSO | ||||
|  | ||||
| This command is part of the xCAT software product. | ||||
| See nodels,nodech,noderange | ||||
|  | ||||
|   | ||||
| nodels(1), nodech(1), noderange(5) | ||||
| @@ -1,54 +1,104 @@ | ||||
| =head1 NAME | ||||
|   | ||||
| B<nodech> -Changes node attributes in the database. | ||||
|   | ||||
|  | ||||
| B<nodech> - Changes nodes' attributes in the xCAT cluster database. | ||||
|  | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|   | ||||
| I<nodech [-h| --help]> | ||||
|  | ||||
| B<nodech> I<noderange> I<table.column=value> [I<...>] | ||||
|  | ||||
| I<nodech  [noderange] [table.column=value, table.column=value] >  | ||||
| B<nodech> {B<-d> | B<--delete>} I<noderange> I<table> [I<...>] | ||||
|  | ||||
| B<nodech> {B<-v> | B<--version>} | ||||
|  | ||||
| B<nodech> [B<-?> | B<-h> | B<--help>] | ||||
|  | ||||
|  | ||||
| =head1 DESCRIPTION | ||||
|  | ||||
|  The nodech command changes the attribute value in the input table.column for the input node range. | ||||
| The nodech command changes the specified attributes for the given nodes.  Normally, the given | ||||
| value will completely replace the current attribute value.  But if ",=" is used instead of "=", | ||||
| the specified value will be added to the attribute's comma separated list, if it is not already | ||||
| there.  If "^=" is used, the specified value will be removed from the attribute's comma separated list, | ||||
| if it is there.  You can also use "^=" and ",=" in the same command to essentially replace one item | ||||
| in the list with another.  (See the Examples section.) | ||||
|  | ||||
| See the B<xcatdb> man page for an overview of each table. | ||||
|  | ||||
| The nodech command also supports some short cut names as aliases to common attributes.  See the | ||||
| B<nodels> man page for details. | ||||
|  | ||||
|  | ||||
| =head1 OPTIONS | ||||
|  | ||||
| =over 10 | ||||
|  | ||||
| B<-h>          Display usage message. | ||||
| =item B<-d|--delete> | ||||
|  | ||||
| B<-v>          Command Version.  | ||||
| Delete the nodes' row in the specified tables. | ||||
|  | ||||
| =item B<-v|--version> | ||||
|  | ||||
| Command Version. | ||||
|  | ||||
| =item B<-?|-h|--help> | ||||
|  | ||||
| Display usage message. | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 RETURN VALUE | ||||
|  | ||||
| 0 The command completed successfully. | ||||
| =over 3 | ||||
|  | ||||
| =item 0 | ||||
|  | ||||
| The command completed successfully. | ||||
|  | ||||
| =item 1 | ||||
|  | ||||
| An error has occurred. | ||||
|  | ||||
| =back | ||||
|  | ||||
| 1 An error has occurred. | ||||
|  | ||||
| =head1 EXAMPLES | ||||
|  | ||||
| 1. To change the group name nodes in noderange node1-node4:  | ||||
| =over 2 | ||||
|  | ||||
| I<nodech  node1-node4 nodelist.groups=compute >  | ||||
| 	 | ||||
| 2. To change nodes in noderange  node1-node4 to os=rhel5 in nodetype table:  | ||||
| =item * | ||||
|  | ||||
| I<nodech  node1-node4 nodetype.os=rhel5>  | ||||
| To add nodes in noderange  node1-node4 with group all: | ||||
|  | ||||
| B<  nodech> I<node1-node4 groups=all> | ||||
|  | ||||
| =item * | ||||
|  | ||||
| To add nodes in noderange  node1-node4 to the nodetype table with os=rhel5: | ||||
|  | ||||
| B<  nodech> I<node1-node4 groups=all,rhel5 nodetype.os=rhel5> | ||||
|  | ||||
| =item * | ||||
|  | ||||
| To add node1-node4 to group1: | ||||
|  | ||||
| B<  nodech> I<node1-node4 groups,=group1> | ||||
|  | ||||
| =item * | ||||
|  | ||||
| To put node1-node4 in group2, instead of group1: | ||||
|  | ||||
| B<  nodech> I<node1-node4 groups^=group1 groups,=group2> | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 FILES | ||||
|   | ||||
|  | ||||
| /opt/xcat/bin/nodech | ||||
|  | ||||
|  | ||||
| =head1 NOTES | ||||
| =head1 SEE ALSO | ||||
|  | ||||
| This command is part of the xCAT software product. | ||||
| See nodels,nodeadd,noderange | ||||
|  | ||||
|   | ||||
| nodels(1), nodeadd(1), noderange(5) | ||||
| @@ -2,21 +2,22 @@ | ||||
|  | ||||
| B<nodels> - lists the nodes in the noderange. | ||||
|  | ||||
|  | ||||
| =head1 SYNOPSIS | ||||
|  | ||||
| B<nodels> [I<noderange>] [I<table.attribute> | I<shortname>] I<...> | ||||
| B<nodels> [I<noderange>] [I<table.column> | I<shortname>] [I<...>] | ||||
|  | ||||
| B<nodels> {B<-v> | B<--version>} | ||||
|  | ||||
| B<nodels> [B<-?> | B<-h> | B<--help>] | ||||
|  | ||||
| B<nodels> [B<-v> | B<--version>] | ||||
|  | ||||
|  | ||||
| =head1 DESCRIPTION | ||||
|  | ||||
| The nodels command lists the nodes specified in the node range. If no noderange is provided, then all nodes are listed. | ||||
|  | ||||
| Additional attributes of the nodes will also be displayed if the table names and attribute names | ||||
| are specified after the noderange in the form:  I<table.attribute> .  A few shortcut names can | ||||
| are specified after the noderange in the form:  I<table.column> .  A few shortcut names can | ||||
| also be used as aliases to common attributes: | ||||
|  | ||||
| =over 10 | ||||
| @@ -44,20 +45,22 @@ for grep'ing through the tab files, like was done in xCAT 1.x.  This is because | ||||
| any regular expression rows in the tables into their meaning for the specified node.  The tab* commands | ||||
| will not do this, instead they will just display the single regular expression row. | ||||
|  | ||||
|  | ||||
| =head1 OPTIONS | ||||
|  | ||||
| =over 10 | ||||
|  | ||||
| =item B<-v|--version> | ||||
|  | ||||
| Command Version. | ||||
|  | ||||
| =item B<-?|-h|--help> | ||||
|  | ||||
| Display usage message. | ||||
|  | ||||
| =item B<-v> | ||||
|  | ||||
| Command Version. | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 RETURN VALUE | ||||
|  | ||||
| =over 3 | ||||
| @@ -72,6 +75,7 @@ An error has occurred. | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 EXAMPLES | ||||
|  | ||||
| =over 2 | ||||
| @@ -131,10 +135,12 @@ Output is similar to: | ||||
|  | ||||
| =back | ||||
|  | ||||
|  | ||||
| =head1 FILES | ||||
|  | ||||
| /opt/xcat/bin/nodels | ||||
|  | ||||
|  | ||||
| =head1 SEE ALSO | ||||
|  | ||||
| noderange(5) | ||||
|   | ||||
| @@ -336,7 +336,7 @@ Displays usage information. | ||||
| \fR | ||||
| .RE | ||||
| .RS +9 | ||||
| Set up the SSH keys for the specified node list.  Currently, this must be run on the management node in bypass mode (export XCATBYPASS=1). | ||||
| Set up the SSH keys for the specified node list.  Currently, this must be run on the management node in bypass mode.  Run: XCATBYPASS=1 xdsh <noderange> -K | ||||
| .RE | ||||
| .RS +3 | ||||
| \fB-l | --user \fIuser_ID\fR | ||||
|   | ||||
| @@ -12,7 +12,7 @@ use Data::Dumper; | ||||
| use xCAT::NodeRange; | ||||
| use xCAT::Schema; | ||||
|  | ||||
| #use Getopt::Long qw(GetOptionsFromArray); | ||||
| use Getopt::Long; | ||||
|  | ||||
| 1; | ||||
|  | ||||
| @@ -48,40 +48,40 @@ sub handled_commands | ||||
|             }; | ||||
| } | ||||
|  | ||||
| my %usage = ( | ||||
|     nodech => | ||||
|       "Usage: nodech <noderange> [table.column=value] [table.column=value] ...", | ||||
|     nodeadd => | ||||
|       "Usage: nodeadd <noderange> [table.column=value] [table.column=value] ...", | ||||
|     noderm  => "Usage: noderm <noderange>", | ||||
| # Each cmd now returns its own usage inside its function | ||||
| #my %usage = ( | ||||
|     #nodech => "Usage: nodech <noderange> [table.column=value] [table.column=value] ...", | ||||
|     #nodeadd => "Usage: nodeadd <noderange> [table.column=value] [table.column=value] ...", | ||||
|     #noderm  => "Usage: noderm <noderange>", | ||||
|     # the usage for tabdump is in the tabdump function | ||||
|     #tabdump => "Usage: tabdump <tablename>\n   where <tablename> is one of the following:\n     " . join("\n     ", keys %xCAT::Schema::tabspec), | ||||
|     # the usage for tabrestore is in the tabrestore client cmd | ||||
|     #tabrestore => "Usage: tabrestore <tablename>.csv", | ||||
|     ); | ||||
|     #); | ||||
|  | ||||
| ##################################################### | ||||
| # Process the command | ||||
| ##################################################### | ||||
| sub process_request | ||||
| { | ||||
|     use Getopt::Long; | ||||
|     #use Getopt::Long; | ||||
|     Getopt::Long::Configure("bundling"); | ||||
|     Getopt::Long::Configure("pass_through"); | ||||
|     #Getopt::Long::Configure("pass_through"); | ||||
|     Getopt::Long::Configure("no_pass_through"); | ||||
|  | ||||
|     my $request  = shift; | ||||
|     my $callback = shift; | ||||
|     my $nodes    = $request->{node}; | ||||
|     my $command  = $request->{command}->[0]; | ||||
|     my $args     = $request->{arg}; | ||||
|     unless ($args or $nodes or $request->{data}) | ||||
|     { | ||||
|         if ($usage{$command}) | ||||
|         { | ||||
|             $callback->({data => [$usage{$command}]}); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
|     #unless ($args or $nodes or $request->{data}) | ||||
|     #{ | ||||
|         #if ($usage{$command}) | ||||
|         #{ | ||||
|             #$callback->({data => [$usage{$command}]}); | ||||
|             #return; | ||||
|         #} | ||||
|     #} | ||||
|  | ||||
|     if ($command eq "nodels") | ||||
|     { | ||||
| @@ -185,38 +185,32 @@ sub noderm | ||||
|     my $VERSION; | ||||
|     my $HELP; | ||||
|  | ||||
|     sub noderm_usage | ||||
|     { | ||||
|     sub noderm_usage { | ||||
|     	my $exitcode = shift @_; | ||||
|         my %rsp; | ||||
|         $rsp->{data}->[0] = "Usage:"; | ||||
|         $rsp->{data}->[1] = "  noderm [noderange] "; | ||||
|         $cb->($rsp); | ||||
|         push @{$rsp{data}}, "Usage:"; | ||||
|         push @{$rsp{data}}, "  noderm noderange"; | ||||
|         push @{$rsp{data}}, "  noderm {-v|--version}"; | ||||
|         push @{$rsp{data}}, "  noderm [-?|-h|--help]"; | ||||
|         if ($exitcode) { $rsp{errorcode} = $exitcode; } | ||||
|         $cb->(\%rsp); | ||||
|     } | ||||
|  | ||||
|     @ARGV = @{$args}; | ||||
|     if ( | ||||
|         !GetOptions('h|?|help'  => \$HELP, | ||||
|                     'v|version' => \$VERSION,) | ||||
|       ) | ||||
|     { | ||||
|         &noderm_usage; | ||||
|     } | ||||
|     if (!GetOptions('h|?|help'  => \$HELP, 'v|version' => \$VERSION) ) { noderm_usage(1); return; } | ||||
|  | ||||
|     # Help | ||||
|     if ($HELP) | ||||
|     { | ||||
|         &noderm_usage; | ||||
|         return; | ||||
|     } | ||||
|     if ($HELP) { noderm_usage(0); return; } | ||||
|  | ||||
|     # Version | ||||
|     if ($VERSION) | ||||
|     { | ||||
|     if ($VERSION) { | ||||
|         my %rsp; | ||||
|         $rsp->{data}->[0] = "2.0"; | ||||
|         $cb->($rsp); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     if (!$nodes) { noderm_usage(1); return; } | ||||
|  | ||||
|     # Build the argument list for using the -d option of nodech to do our work for us | ||||
|     my @tablist = ("-d"); | ||||
|     foreach (keys %{xCAT::Schema::tabspec}) | ||||
|     { | ||||
| @@ -485,55 +479,60 @@ sub nodech | ||||
|     my $addmode  = shift; | ||||
|     my $VERSION; | ||||
|     my $HELP; | ||||
|     my $deletemode; | ||||
|  | ||||
|     sub nodech_usage | ||||
|     { | ||||
|     	my $exitcode = shift @_; | ||||
|     	my $addmode = shift @_; | ||||
|     	my $cmdname = $addmode ? 'nodeadd' : 'nodech'; | ||||
|         my %rsp; | ||||
|         $rsp->{data}->[0] = "Usage:"; | ||||
|         $rsp->{data}->[1] = " nodech <noderange> [table.column=value] [table.column=value] ...\n "; | ||||
|         $callback->($rsp); | ||||
|         if ($addmode) { | ||||
|         	push @{$rsp{data}}, "Usage: $cmdname <noderange> groups=<groupnames> [table.column=value] [...]"; | ||||
|         } else { | ||||
|         	push @{$rsp{data}}, "Usage: $cmdname <noderange> table.column=value [...]"; | ||||
|         	push @{$rsp{data}}, "       $cmdname {-d | --delete} <noderange> <table> [...]"; | ||||
|         } | ||||
|         push @{$rsp{data}}, "       $cmdname {-v | --version}"; | ||||
|         push @{$rsp{data}}, "       $cmdname [-? | -h | --help]"; | ||||
|         if ($exitcode) { $rsp{errorcode} = $exitcode; } | ||||
|         $callback->(\%rsp); | ||||
|     } | ||||
|  | ||||
|     @ARGV = @{$args}; | ||||
|     if ( | ||||
|         !GetOptions('h|?|help'  => \$HELP, | ||||
|                     'v|version' => \$VERSION,) | ||||
|       ) | ||||
|     { | ||||
|         &nodech_usage; | ||||
|     my %options = ('h|?|help'  => \$HELP, 'v|version' => \$VERSION); | ||||
|     if (!$addmode) { $options{'d|delete'} = \$deletemode; } | ||||
|     if (!GetOptions(%options)) { | ||||
|         nodech_usage(1, $addmode); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     # Help | ||||
|     if ($HELP) | ||||
|     { | ||||
|         &nodech_usage; | ||||
|     if ($HELP) { | ||||
|         nodech_usage(0, $addmode); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     # Version | ||||
|     if ($VERSION) | ||||
|     { | ||||
|     if ($VERSION) { | ||||
|         my %rsp; | ||||
|         $rsp->{data}->[0] = "2.0"; | ||||
|         $callback->($rsp); | ||||
|         return; | ||||
|     } | ||||
|  | ||||
|     # Note: the noderange comes through in $arg (and therefore @ARGV) for nodeadd, | ||||
|     # because it is linked to xcatclientnnr, since the nodes specified in the noderange | ||||
|     # do not exist yet.  The nodech cmd is linked to xcatclient, so its noderange is | ||||
|     # put in $nodes instead of $args. | ||||
|     if (scalar(@ARGV) < (1+$addmode)) { nodech_usage(1, $addmode);  return; } | ||||
|  | ||||
|     if ($addmode) | ||||
|     { | ||||
|         my $idx = 0; | ||||
|         foreach my $arg (@$args) | ||||
|         { | ||||
|             unless ($arg =~ /^-/) | ||||
|             { | ||||
|                 $nodes = [noderange($arg, 0)]; | ||||
|                 splice(@$args, $idx, 1); | ||||
|                 last; | ||||
|             } | ||||
|             $idx++; | ||||
|         } | ||||
|         unless ($nodes) | ||||
|         { | ||||
|             $callback->({error => "No range to add detected\n"}); | ||||
|     	my $nr = shift @ARGV; | ||||
|     	$nodes = [noderange($nr, 0)]; | ||||
|         unless ($nodes) { | ||||
|             $callback->({error => "No noderange to add.\n",errorcode=>1}); | ||||
|             return; | ||||
|         } | ||||
|     } | ||||
| @@ -542,51 +541,15 @@ sub nodech | ||||
|     my $temp; | ||||
|     my %tables; | ||||
|     my $tab; | ||||
|     my $deletemode; | ||||
|  | ||||
|     #No GetOptionsFromArray... | ||||
|     #GetOptionsFromArray($args,"d|delete" => \$deletemode); | ||||
|     #print Dumper($deletemode); | ||||
|     foreach (@$args) | ||||
|     foreach (@ARGV) | ||||
|     { | ||||
|         if (m/^-/) | ||||
|         {    #A quick and dirty option parser in lieu of lacking Getoptinos | ||||
|             if (m/^--/) | ||||
|             { | ||||
|                 if (m/--delete/) | ||||
|                 { | ||||
|                     $deletemode = 1; | ||||
|                     next; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     $callback->( | ||||
|                             {data => ["ERROR: Malformed argument $_ ignored"]}); | ||||
|                     next; | ||||
|                 } | ||||
|             } | ||||
|             else | ||||
|             { | ||||
|                 if (m/^-d$/) | ||||
|                 { | ||||
|                     $deletemode = 1; | ||||
|                     next; | ||||
|                 } | ||||
|                 else | ||||
|                 { | ||||
|                     $callback->( | ||||
|                             {data => ["ERROR: Malformed argument $_ ignored"]}); | ||||
|                     next; | ||||
|                 } | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         if ($deletemode) | ||||
|         { | ||||
|             if (m/[=\.]/) | ||||
|             if (m/[=\.]/)   # in delete mode they can only specify tables names | ||||
|             { | ||||
|                 $callback->( | ||||
|                          {data => ["ERROR: . and = not valid in delete mode"]}); | ||||
|                 $callback->({error => [". and = not valid in delete mode."],errorcode=>1}); | ||||
|                 next; | ||||
|             } | ||||
|             $tables{$_} = 1; | ||||
| @@ -594,7 +557,7 @@ sub nodech | ||||
|         } | ||||
|         unless (m/=/) | ||||
|         { | ||||
|             $callback->({data => ["ERROR: Malformed argument $_ ignored"]}); | ||||
|             $callback->({error => ["Malformed argument $_ ignored."],errorcode=>1}); | ||||
|             next; | ||||
|         } | ||||
|         ($temp, $value) = split('=', $_, 2); | ||||
| @@ -622,7 +585,10 @@ sub nodech | ||||
|              $callback->({error=>"$table.$column not a valid table.column description",errorcode=>[1]}); | ||||
|              return; | ||||
|         } | ||||
|         $tables{$table}->{$column} = [$value, $op]; | ||||
|  | ||||
|         # Keep a list of the value/op pairs, in case there is more than 1 per table.column | ||||
|         #$tables{$table}->{$column} = [$value, $op]; | ||||
|         push @{$tables{$table}->{$column}}, ($value, $op); | ||||
|     } | ||||
|     foreach $tab (keys %tables) | ||||
|     { | ||||
| @@ -641,60 +607,60 @@ sub nodech | ||||
|                     #$tabhdl->setNodeAttribs($_,$tables{$tab}); | ||||
|                     my %uhsh; | ||||
|                     my $node = $_; | ||||
|                     foreach (keys %{$tables{$tab}}) | ||||
|                     foreach (keys %{$tables{$tab}})		# for each column specified for this table | ||||
|                     { | ||||
|                         my $op  = $tables{$tab}->{$_}->[1]; | ||||
|                         my $val = $tables{$tab}->{$_}->[0]; | ||||
|                         my $key = $_; | ||||
|                         if ($op eq '=') | ||||
|                         { | ||||
|                             $uhsh{$key} = $val; | ||||
|                         } | ||||
|                         elsif ($op eq ',=') | ||||
|                         {    #splice assignment | ||||
|                             my $cent = $tabhdl->getNodeAttribs($node, [$key]); | ||||
|                             my $curval; | ||||
|                             if ($cent) { $curval = $cent->{$key}; } | ||||
|                             if ($curval) | ||||
|                             { | ||||
|                                 my @vals = split(/,/, $curval); | ||||
|                                 unless (grep /^$val$/, @vals) | ||||
|                                 { | ||||
|                                     @vals = (@vals, $val); | ||||
|                                     my $newval = join(',', @vals); | ||||
|                                     $uhsh{$key} = $newval; | ||||
|                                 } | ||||
|                             } | ||||
|                             else | ||||
|                             { | ||||
|                                 $uhsh{$key} = $val; | ||||
|                             } | ||||
|                         } | ||||
|                         elsif ($op eq '^=') | ||||
|                         { | ||||
|                             my $cent = $tabhdl->getNodeAttribs($node, [$key]); | ||||
|                             my $curval; | ||||
|                             if ($cent) { $curval = $cent->{$key}; } | ||||
|                             if ($curval) | ||||
|                             { | ||||
|                                 my @vals = split(/,/, $curval); | ||||
|                                 if (grep /^$val$/, @vals) | ||||
|                                 {    #only bother if there | ||||
|                                     @vals = grep(!/^$val$/, @vals); | ||||
|                                     my $newval = join(',', @vals); | ||||
|                                     $uhsh{$key} = $newval; | ||||
|                                 } | ||||
|                             }    #else, what they asked for is the case alredy | ||||
|                         #my $op  = $tables{$tab}->{$_}->[1]; | ||||
|                         #my $val = $tables{$tab}->{$_}->[0]; | ||||
|                         my $valoppairs = $tables{$tab}->{$_}; | ||||
|                         while (scalar(@$valoppairs)) {			# alternating list of value and op for this table.column | ||||
|                         	my $val = shift @$valoppairs; | ||||
|                         	my $op  = shift @$valoppairs; | ||||
|                         	my $key = $_; | ||||
|                         	if ($op eq '=') { | ||||
|                             	$uhsh{$key} = $val; | ||||
|                         	} | ||||
|                         	elsif ($op eq ',=') {    #splice assignment | ||||
|                         		my $curval = $uhsh{$key};    # in case it was already set | ||||
|                         		if (!defined($curval)) { | ||||
|                             		my $cent = $tabhdl->getNodeAttribs($node, [$key]); | ||||
|                             		if ($cent) { $curval = $cent->{$key}; } | ||||
|                         		} | ||||
|                             	if ($curval) { | ||||
|                                 	my @vals = split(/,/, $curval); | ||||
|                                 	unless (grep /^$val$/, @vals) { | ||||
|                                     	@vals = (@vals, $val); | ||||
|                                     	my $newval = join(',', @vals); | ||||
|                                     	$uhsh{$key} = $newval; | ||||
|                                 	} | ||||
|                             	} else { | ||||
|                                 	$uhsh{$key} = $val; | ||||
|                             	} | ||||
|                         	} | ||||
|                         	elsif ($op eq '^=') { | ||||
|                         		my $curval = $uhsh{$key};    # in case it was already set | ||||
|                         		if (!defined($curval)) { | ||||
|                             		my $cent = $tabhdl->getNodeAttribs($node, [$key]); | ||||
|                             		if ($cent) { $curval = $cent->{$key}; } | ||||
|                         		} | ||||
|                             	if ($curval) { | ||||
|                                 	my @vals = split(/,/, $curval); | ||||
|                                 	if (grep /^$val$/, @vals) {    #only bother if there | ||||
|                                     	@vals = grep(!/^$val$/, @vals); | ||||
|                                     	my $newval = join(',', @vals); | ||||
|                                     	$uhsh{$key} = $newval; | ||||
|                                 	} | ||||
|                             	}    #else, what they asked for is the case alredy | ||||
|                         	} | ||||
|                         }		# end of while $valoppairs | ||||
|                     }		# end of foreach column specified for this table | ||||
|  | ||||
|                         } | ||||
|                     } | ||||
|                     if (keys %uhsh) | ||||
|                     { | ||||
|  | ||||
|                         my @rc = $tabhdl->setNodeAttribs($node, \%uhsh); | ||||
|                         if (not defined($rc[0])) | ||||
|                         { | ||||
|                             $callback->({error => "DB error " . $rc[1]}); | ||||
|                             $callback->({error => "DB error " . $rc[1],errorcode=>1}); | ||||
|                         } | ||||
|                     } | ||||
|                 } | ||||
| @@ -704,7 +670,7 @@ sub nodech | ||||
|         else | ||||
|         { | ||||
|             $callback->( | ||||
|                  {data => ["ERROR: Unable to open table $tab in configuration"]} | ||||
|                  {error => ["ERROR: Unable to open table $tab in configuration"],errorcode=>1} | ||||
|                  ); | ||||
|         } | ||||
|     } | ||||
| @@ -751,11 +717,12 @@ sub nodels | ||||
|  | ||||
|     sub nodels_usage | ||||
|     { | ||||
|     	my $exitcode = shift @_; | ||||
|         my %rsp; | ||||
|         $rsp->{data}->[0] = "Usage:"; | ||||
|         $rsp->{data}->[1] = "  nodels [-?|-h|--help] "; | ||||
|         $rsp->{data}->[2] = "  nodels [-v|--version] "; | ||||
|         $rsp->{data}->[3] = "  nodels [noderange] [table.attribute | shortname] ..."; | ||||
|         push @{$rsp{data}}, "Usage:"; | ||||
|         push @{$rsp{data}}, "  nodels [noderange] [table.attribute | shortname] [...]"; | ||||
|         push @{$rsp{data}}, "  nodels {-v|--version}"; | ||||
|         push @{$rsp{data}}, "  nodels [-?|-h|--help]"; | ||||
| #####  xcat 1.2 nodels usage: | ||||
|         #     $rsp->{data}->[1]= "  nodels [noderange] [group|pos|type|rg|install|hm|all]"; | ||||
|         #     $rsp->{data}->[2]= " "; | ||||
| @@ -767,24 +734,15 @@ sub nodels | ||||
|         #     $rsp->{data}->[8]= "  nodels [noderange] rg.{tftp|nfs_install|install_dir|serial}"; | ||||
|         #     $rsp->{data}->[9]= "                     rg.{usenis|install_roll|acct|gm|pbs}"; | ||||
|         #     $rsp->{data}->[10]="                     rg.{access|gpfs|netdevice|prinic|all}"; | ||||
|         $callback->($rsp); | ||||
|         if ($exitcode) { $rsp{errorcode} = $exitcode; } | ||||
|         $callback->(\%rsp); | ||||
|     } | ||||
|  | ||||
|     @ARGV = @{$args}; | ||||
|     if ( | ||||
|         !GetOptions('h|?|help'  => \$HELP, | ||||
|                     'v|version' => \$VERSION,) | ||||
|       ) | ||||
|     { | ||||
|         &nodels_usage; | ||||
|     } | ||||
|     if (!GetOptions('h|?|help'  => \$HELP, 'v|version' => \$VERSION,) ) { nodels_usage(1); return; } | ||||
|  | ||||
|     # Help | ||||
|     if ($HELP) | ||||
|     { | ||||
|         &nodels_usage; | ||||
|         return; | ||||
|     } | ||||
|     if ($HELP) { nodels_usage(0); return; } | ||||
|  | ||||
|     # Version | ||||
|     if ($VERSION) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user