2
0
mirror of https://github.com/xcat2/xcat-core.git synced 2025-07-29 15:51:18 +00:00

Updatenode to skip processing nodes which have some attributes missing

This commit is contained in:
Mark Gurevich
2016-03-11 09:10:55 -05:00
parent 485ee6f764
commit b186c2ed0f
2 changed files with 28 additions and 10 deletions

View File

@@ -47,6 +47,8 @@ This program module file is a set of utilities to support xCAT post scripts.
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq);
Return: list of nodes that have some attributes missing from node definition
=cut
@@ -102,7 +104,8 @@ sub create_mypostscript_or_not {
}
}
# Return the list of nodes that had missing attributes
return @::exclude_nodes;
}
@@ -270,10 +273,9 @@ sub makescript {
#
#
#%::GLOBAL_TAB_HASH = ();
my $rc = collect_all_attribs_for_tables_in_template(\%table, $nodes, $callback);
if($rc == -1) {
#return;
}
# Collect all node attributes and save a list of nodes which have some missing node definition attributes
@::exclude_nodes = collect_all_attribs_for_tables_in_template(\%table, $nodes, $callback);
#print Dumper(\%::GLOBAL_TAB_HASH);
@@ -1395,6 +1397,7 @@ sub collect_all_attribs_for_tables_in_template
my $nodes = shift;
my $callback = shift;
my $blankok;
my @exclude_nodes = ();
if(defined($table) ) {
foreach my $tabname (keys %$table) {
my $key_hash = $table->{$tabname};
@@ -1445,7 +1448,9 @@ sub collect_all_attribs_for_tables_in_template
push @{$rsp->{data}},
"No os or arch setting in nodetype table for $node.\n";
xCAT::MsgUtils->message("E", $rsp, $callback);
return -1;
# Save this node in the list of nodes that have missing attributes
push(@exclude_nodes, $node);
last; # Continue to the next node
}
}
@@ -1481,7 +1486,7 @@ sub collect_all_attribs_for_tables_in_template
}
}
return @exclude_nodes;
}
@@ -2131,6 +2136,4 @@ sub includetmpl
return join(',', @text);
}
1;

View File

@@ -1230,7 +1230,22 @@ sub updatenode
my $notmpfiles=1;
my $nofiles=0;
#my $nofiles=1;
xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
my @exclude_nodes = xCAT::Postage::create_mypostscript_or_not($request, $callback, $subreq,$notmpfiles,$nofiles);
# exclude_nodes list contains nodes which have some attributes missing from node definition, like arch or os.
# remove those nodes from the request node list so that updatenode will not be executes on those nodes
foreach my $exclude_node (@exclude_nodes) {
my $index = 0;
$index++ until @{$request->{node}}[$index] eq $exclude_node;
splice(@{$request->{node}}, $index, 1);
}
if (@exclude_nodes > 0) {
my $rsp = {};
$rsp->{error}->[0] =
"Following nodes will be ignored bacause they are missing some attribute definitions: @exclude_nodes";
$rsp->{errorcode}->[0] =1;
$callback->($rsp);
}
# convert the hashes back to the way they were passed in
my $flatreq = xCAT::InstUtils->restore_request($request, $callback);