check valid attributes for mkdsklsnode.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@11638 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
fce8747ca4
commit
f05851ee6b
@ -7555,6 +7555,9 @@ sub prenimnodeset
|
||||
my %objhash;
|
||||
my %attrs;
|
||||
my %nimhash;
|
||||
# currently supported valid attributes, may append later..
|
||||
my @validattr = ("duplex", "speed", "psize", "sparse_paging", "dump_iscsi_port", "configdump");
|
||||
my @badattr;
|
||||
|
||||
# the first arg should be a noderange - the other should be attr=val
|
||||
# - put attr=val operands in %attrs hash
|
||||
@ -7579,9 +7582,43 @@ sub prenimnodeset
|
||||
|
||||
# put attr=val in hash
|
||||
$attrs{$attr} = $value;
|
||||
|
||||
if ($command eq 'mkdsklsnode')
|
||||
{
|
||||
|
||||
# if it has an "=" sign its an attr=val - we hope
|
||||
my ($attr, $value) = $a =~ /^\s*(\S+?)\s*=\s*(\S*.*)$/;
|
||||
if (!$attr || !$value)
|
||||
{
|
||||
my $rsp;
|
||||
push @{$rsp->{data}}, "Incorrect \'attr=val\' pair - $a\n";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# check the valid attributes.
|
||||
if (grep(/$attr/, @validattr))
|
||||
{
|
||||
$attrs{$attr} = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
push @badattr, $attr;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scalar(@badattr))
|
||||
{
|
||||
my $rsp;
|
||||
my $bad = join(', ', @badattr);
|
||||
my $valid = join(', ', @validattr);
|
||||
push @{$rsp->{data}}, "Bad attributes '$bad'. The valid attributes are '$valid'.\n";
|
||||
xCAT::MsgUtils->message("E", $rsp, $callback);
|
||||
return 1;
|
||||
}
|
||||
|
||||
my $Sname = xCAT::InstUtils->myxCATname();
|
||||
chomp $Sname;
|
||||
|
||||
@ -9112,15 +9149,8 @@ sub mkdsklsnode
|
||||
|
||||
# if it has an "=" sign its an attr=val - we hope
|
||||
my ($attr, $value) = $a =~ /^\s*(\S+?)\s*=\s*(\S*.*)$/;
|
||||
if (!defined($attr) || !defined($value))
|
||||
{
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] =
|
||||
"$Sname: Incorrect \'attr=val\' pair - $a\n";
|
||||
xCAT::MsgUtils->message("E", $rsp, $::callback);
|
||||
return 1;
|
||||
}
|
||||
|
||||
# attributes already checked in prenimnodeset
|
||||
# put attr=val in hash
|
||||
$attrs{$attr} = $value;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user