2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-05-30 09:36:41 +00:00

enhance chdef pre-check attribute

This commit is contained in:
bybai 2017-10-26 06:12:26 -04:00
parent 155ba82a13
commit 5dd725e2fc

View File

@ -902,6 +902,19 @@ sub setobjdefs
}
my @attrprovided = ();
#get group objects data
my %DBgroupsattr;
my %tmpghash;
my @tmplgrplist;
my %grpvalidattr;
if (defined($objhash{$objname}{'groups'})){
@tmplgrplist = split(",", $objhash{$objname}{'groups'});
foreach my $tmpgrp (@tmplgrplist) {
$tmpghash{$tmpgrp} = "group";
}
%DBgroupsattr=xCAT::DBobjUtils->getobjdefs(\%tmpghash);
}
# check FINALATTRS to see if all the attrs are valid
foreach my $attr (keys %{ $objhash{$objname} }) {
@ -992,7 +1005,6 @@ sub setobjdefs
}
}
}
xCAT::MsgUtils->message("I", $rsp, $::callback);
$checkedattrs{$attr_name} = 1;
if ($invalidattr->{$attr_name}->{valid} != 1) {
$invalidattr->{$attr_name}->{valid} = 0;
@ -1147,10 +1159,26 @@ sub setobjdefs
my $rsp;
foreach my $att (keys %$invalidattr) {
my $pickvalidattr=0;
if ($invalidattr->{$att}->{valid} != 1) {
my $tt = $invalidattr->{$att}->{valid};
push @{ $rsp->{data} }, "Cannot set the attr=\'$att\' attribute unless $invalidattr->{$att}->{condition}.";
xCAT::MsgUtils->message("E", $rsp, $::callback);
#if attribute is set invalid, check if its pre-check attribute exists in group objects, pick the attribute into valid.
# ex. if I want to set hdwctrlpoint I will have
# to match the right value for mgtmethod, but mgtmethod does exist in node object in chdef command
# if mgtmethod exists in group objects, set hdwctrlpoint valid
my $conditionkv=$invalidattr->{$att}->{condition};
$conditionkv=~s/(^'|'$)//g;
my ($attk, $attv)=split("=", $conditionkv);
foreach my $tmpgrp (@tmplgrplist) {
if ($DBgroupsattr{$tmpgrp}{$attk} eq $attv) {
$pickvalidattr=1;
last;
}
}
if ($pickvalidattr != 1) {
push @{ $rsp->{data} }, "Cannot set the attr=\'$att\' attribute unless $invalidattr->{$att}->{condition}.";
xCAT::MsgUtils->message("E", $rsp, $::callback);
}
}
}