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
This commit is contained in:
daniceexi 2009-10-20 14:39:13 +00:00
parent 7b40214de1
commit 038a7f43dd
2 changed files with 31 additions and 5 deletions

View File

@ -110,7 +110,7 @@ my %usage = (
"getmacs" =>
"Usage:
Common:
getmacs <noderange> [-V|--verbose]
getmacs <noderange> [-d] [-V|--verbose]
getmacs [-h|--help|-v|--version]
PPC specific:
getmacs <noderange> [-F filter]

View File

@ -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);