mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-31 03:12:30 +00:00 
			
		
		
		
	git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2336 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
		
			
				
	
	
		
			85 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			Perl
		
	
	
		
			Executable File
		
	
	
	
	
| #!/usr/bin/perl
 | |
| # IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
 | |
| BEGIN
 | |
| {
 | |
|     $::XCATROOT = $ENV{'XCATROOT'} ? $ENV{'XCATROOT'} : -d '/opt/xcat' ? '/opt/xcat' : '/usr';
 | |
| }
 | |
| use lib "$::XCATROOT/lib/perl";
 | |
| 
 | |
| use File::Basename;
 | |
| use xCAT::MsgUtils;
 | |
| use xCAT::Client;
 | |
| 
 | |
| use Getopt::Std;
 | |
| 
 | |
| my $bname = basename($0);
 | |
| 
 | |
| #########################################
 | |
| # Main
 | |
| #
 | |
| #   xcatDBcmds
 | |
| #
 | |
| #	Build hash and submit request
 | |
| #
 | |
| #	Handles: mkdef, chdef, lsdef, rmdef, mknimimage, rmnimimage,
 | |
| #		nimnodeset, mkdsklsnode, rmdsklsnode, and xcat2nim commands
 | |
| #
 | |
| #	Note: The subroutines that implement these commands
 | |
| #		are, for the most part, in:
 | |
| #			/opt/xcat/lib/perl/xCAT_plugin/DBobjectdefs.pm
 | |
| #			/opt/xcat/lib/perl/xCAT_plugin/xcat2nim.pm
 | |
| #			/opt/xcat/lib/perl/xCAT_plugin/aixinstall.pm
 | |
| #			/opt/xcat/lib/perl/xCAT/DBobjUtils.pm
 | |
| #
 | |
| #########################################
 | |
| 
 | |
| my $cmdref;
 | |
| 
 | |
| # set the command name to pass to the plugin
 | |
| if ($bname =~ /xcatDBcmds/)
 | |
| {
 | |
|     $cmdref->{command}->[0] = shift @ARGV;
 | |
| }
 | |
| elsif ($bname =~ /^(.*$)/)
 | |
| {
 | |
|     $cmdref->{command}->[0] = $1;
 | |
| }
 | |
| else
 | |
| {
 | |
|     printf("Bad usage\n");
 | |
|     exit 1;
 | |
| }
 | |
| 
 | |
| # get info from files piped in as stdin
 | |
| if (-p STDIN) {
 | |
|   my $data;
 | |
|   while ( <STDIN> ) {
 | |
|     $data.=$_;
 | |
|   }
 | |
|   $cmdref->{stdin}->[0]=$data;
 | |
| }
 | |
| 
 | |
| # add all the cmd line args to the hash - to pass to the plugin subroutine
 | |
| foreach my $a (@ARGV)
 | |
| {
 | |
|     push(@{$cmdref->{arg}}, $a);
 | |
| }
 | |
| 
 | |
| # For some commands we need to set the noderange value
 | |
| # - don't want to depend on the order of args so need to pick
 | |
| #   the operand that doesn't have an "=" sign ( ie. attr=val format)
 | |
| my @checkcmds = ("nimnodeset", "mkdsklsnode", "rmdsklsnode", "xcat2nim", "nimnodecust");
 | |
| if (grep(/^$bname$/, @checkcmds) ) { 
 | |
| 	# strip off all options
 | |
| 	getopts('ab:d:fh?i:l:urs:m:no:t:vVp:');
 | |
| 	# check the operands for a noderange
 | |
| 	while (my $a = shift(@ARGV)) {
 | |
| 		if (!($a =~ /=/)) {
 | |
| 			$cmdref->{noderange}->[0]=$a;
 | |
| 		}
 | |
| 	}
 | |
| }
 | |
| 
 | |
| xCAT::Client::submit_request($cmdref,\&xCAT::Client::handle_response);
 | |
| exit $xCAT::Client::EXITCODE;
 |