From f05851ee6b0210b24fae4c829107f62c2b739e6b Mon Sep 17 00:00:00 2001 From: sjing Date: Mon, 20 Feb 2012 10:01:58 +0000 Subject: [PATCH] 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 --- xCAT-server/lib/xcat/plugins/aixinstall.pm | 46 ++++++++++++++++++---- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/aixinstall.pm b/xCAT-server/lib/xcat/plugins/aixinstall.pm index 20940517c..36a8678e7 100644 --- a/xCAT-server/lib/xcat/plugins/aixinstall.pm +++ b/xCAT-server/lib/xcat/plugins/aixinstall.pm @@ -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; }