From 038a7f43dd044e5ca344613d43a4ccf5340d259e Mon Sep 17 00:00:00 2001 From: daniceexi Date: Tue, 20 Oct 2009 14:39:13 +0000 Subject: [PATCH] Defect 2879279: supports the -d for blade node and restrict the invalid flags git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4423 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/Usage.pm | 2 +- xCAT-server/lib/xcat/plugins/blade.pm | 34 +++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/perl-xCAT/xCAT/Usage.pm b/perl-xCAT/xCAT/Usage.pm index 9584e56af..033178217 100644 --- a/perl-xCAT/xCAT/Usage.pm +++ b/perl-xCAT/xCAT/Usage.pm @@ -110,7 +110,7 @@ my %usage = ( "getmacs" => "Usage: Common: - getmacs [-V|--verbose] + getmacs [-d] [-V|--verbose] getmacs [-h|--help|-v|--version] PPC specific: getmacs [-F filter] diff --git a/xCAT-server/lib/xcat/plugins/blade.pm b/xCAT-server/lib/xcat/plugins/blade.pm index df84ce8ac..c5d01b968 100644 --- a/xCAT-server/lib/xcat/plugins/blade.pm +++ b/xCAT-server/lib/xcat/plugins/blade.pm @@ -1351,6 +1351,15 @@ sub rscan_stanza { } sub getmacs { + my (@args) = @_; + + my $display = (); + foreach my $arg (@args) { + if ($arg eq "-d") { + $display = "yes"; + } + } + (my $code,my @macs)=inv('mac'); foreach (@macs) { if (/(.*) ->/) { #Convert JS style mac ranges to pretend to be simple @@ -1423,10 +1432,14 @@ sub getmacs { } my $macstring = join("|",@allmacs); - my $mactab = xCAT::Table->new('mac',-create=>1); - $mactab->setNodeAttribs($curn,{mac=>$macstring}); - $mactab->close; - return 0,":mac.mac set to $macstring"; + if ($display =~ /yes/) { + return 0,":The mac address is $macstring"; + } else { + my $mactab = xCAT::Table->new('mac',-create=>1); + $mactab->setNodeAttribs($curn,{mac=>$macstring}); + $mactab->close; + return 0,":mac.mac set to $macstring"; + } } else { return $code,$macs[0]; } @@ -1976,6 +1989,19 @@ sub preprocess_request { return; } + #parse the arguments for commands + if ($command eq "getmacs") { + foreach my $arg (@exargs) { + if (defined($arg) && $arg !~ /^-V|--verbose|-d$/) { + $usage_string="Error arguments\n"; + $usage_string .=xCAT::Usage->getUsage($command); + $callback->({data=>$usage_string}); + $request = {}; + return; + } + } + } + if (!$noderange) { $usage_string="Missing Noderange\n"; $usage_string .=xCAT::Usage->getUsage($command);