diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index 1937e9eb0..8c153b661 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -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; diff --git a/xCAT-server/lib/xcat/plugins/updatenode.pm b/xCAT-server/lib/xcat/plugins/updatenode.pm index a43280ba8..fdd503bc5 100644 --- a/xCAT-server/lib/xcat/plugins/updatenode.pm +++ b/xCAT-server/lib/xcat/plugins/updatenode.pm @@ -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);