mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-30 19:02:27 +00:00 
			
		
		
		
	Merge pull request #961 from chenglch/heirarchicalattrtable
Add configuration in site table to inherit attributes
This commit is contained in:
		| @@ -300,16 +300,16 @@ site Attributes: | ||||
|    xcatconfdir:  Where xCAT config data is (default /etc/xcat). | ||||
|    | ||||
|    xcatdebugmode:  the xCAT debug level. xCAT provides a batch of techniques | ||||
|                  to help user debug problems while using xCAT, especially on OS provision, | ||||
|                  such as collecting logs of the whole installation process and accessing | ||||
|                  the installing system via ssh, etc. These techniques will be enabled | ||||
|                  according to different xCAT debug levels specified by 'xcatdebugmode', | ||||
|                  currently supported values: | ||||
|                    '0':  disable debug mode | ||||
|                    '1':  enable basic debug mode | ||||
|                    '2':  enalbe expert debug mode | ||||
|                  For the details on 'basic debug mode' and 'expert debug mode', | ||||
|                  please refer to xCAT documentation. | ||||
|                    to help user debug problems while using xCAT, especially on OS provision, | ||||
|                    such as collecting logs of the whole installation process and accessing | ||||
|                    the installing system via ssh, etc. These techniques will be enabled | ||||
|                    according to different xCAT debug levels specified by 'xcatdebugmode', | ||||
|                    currently supported values: | ||||
|                      '0':  disable debug mode | ||||
|                      '1':  enable basic debug mode | ||||
|                      '2':  enalbe expert debug mode | ||||
|                    For the details on 'basic debug mode' and 'expert debug mode', | ||||
|                    please refer to xCAT documentation. | ||||
|    | ||||
|    -------------------- | ||||
|   REMOTESHELL ATTRIBUTES | ||||
| @@ -380,6 +380,10 @@ site Attributes: | ||||
|             entries generated by 'makehosts' will put the FQDN before the PQDN(Partially  | ||||
|             Qualified Domain Name). Otherwise, the original behavior will be performed. | ||||
|   | ||||
|  heirarchicalattrs: Table attributes(e.g. postscripts, postbootscripts) that will be | ||||
|                     included hierarchically. Attribute values for all the node's groups | ||||
|                     will be applied to the node in the groups' order except the repeat one. | ||||
|   | ||||
|   | ||||
|  .. code-block:: perl | ||||
|   | ||||
|   | ||||
| @@ -1188,6 +1188,9 @@ use xCAT::ExtTab; | ||||
| "FQDNfirst: Fully Qualified Domain Name first. If set to 1/yes/enable, the /etc/hosts \n" . | ||||
| "           entries generated by 'makehosts' will put the FQDN before the PQDN(Partially \n" . | ||||
| "           Qualified Domain Name). Otherwise, the original behavior will be performed.\n\n" . | ||||
| "heirarchicalattrs: Table attributes(e.g. postscripts, postbootscripts) that will be\n". | ||||
| "                   included hierarchically. Attribute values for all the node's groups\n". | ||||
| "                   will be applied to the node in the groups' order except the repeat one.\n\n". | ||||
| " -----------------------\n" . | ||||
| "VIRTUALIZATION ATTRIBUTES\n" . | ||||
| " -----------------------\n" . | ||||
|   | ||||
| @@ -2554,16 +2554,25 @@ sub getNodeAttribs_nosub_returnany | ||||
|      | ||||
|   my $attrib; | ||||
|   my $result; | ||||
|      | ||||
|   my @hierarchy_attrs; | ||||
|   my $hierarchy_field = xCAT::TableUtils->get_site_attribute("heirarchicalattrs"); | ||||
|   if ($hierarchy_field) { | ||||
|       @hierarchy_attrs = split(/,/, $hierarchy_field); | ||||
|   } | ||||
|  | ||||
|   my $data = $results[0]; | ||||
|   if(defined{$data}) { #if there was some data for the node, loop through and check it  | ||||
|     foreach $result (@results) { | ||||
|       foreach $attrib (keys %attribsToDo) { | ||||
|         if (defined($result) && defined($result->{$attrib}) | ||||
|             && @hierarchy_attrs && grep (/^$attrib$/, @hierarchy_attrs) ) { | ||||
|             $result->{$attrib} .= ',+=NEXTRECORD'; | ||||
|         } | ||||
|         #check each item in the results to see which attributes were satisfied | ||||
|         if(defined($result) && defined($result->{$attrib}) && $result->{$attrib} !~ $nextRecordAtEnd) { | ||||
|           delete $attribsToDo{$attrib}; | ||||
|         }  | ||||
|       }    | ||||
|         } | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
| @@ -2578,7 +2587,7 @@ sub getNodeAttribs_nosub_returnany | ||||
|   unless (defined($nodeghash) && defined($nodeghash->{groups})) { | ||||
|     return @results; | ||||
|   } | ||||
|      | ||||
|  | ||||
|   my @nodegroups = split(/,/, $nodeghash->{groups}); | ||||
|   my $group; | ||||
|   my @groupResults; | ||||
| @@ -2601,8 +2610,10 @@ sub getNodeAttribs_nosub_returnany | ||||
| #print "looking for attrib $attrib\n"; | ||||
|           if(defined($groupResult->{$attrib})){ | ||||
|             $attribsDone{$attrib} = 0; | ||||
| #print "found attArib $attrib = $groupResult->{$attrib}\n"; | ||||
| #print "and results look like this:  \n".Dumper(\@results)."\n\n\n"; | ||||
|             # for hierarchy attribute, append attributes from all the node's group | ||||
|             if (@hierarchy_attrs && grep (/^$attrib$/, @hierarchy_attrs) ) { | ||||
|                 $groupResult->{$attrib} .= ',+=NEXTRECORD'; | ||||
|             } | ||||
|             foreach $result (@results){ #loop through our existing results to add or modify the value for this attribute | ||||
|               if(defined($result)) { | ||||
|                 if(defined($result->{$attrib})) { | ||||
| @@ -2639,7 +2650,6 @@ sub getNodeAttribs_nosub_returnany | ||||
|                 } | ||||
|               } | ||||
|               else {#no results in the array so far | ||||
| #print "pushing for the first time.  attr=$attrib groupResults=$groupResult->{$attrib}\n"; | ||||
|                 $toPush{$attrib} = $groupResult->{$attrib}; | ||||
|                 if($options{withattribution} && $attrib ne $nodekey){ | ||||
|                     $toPush{'!!xcatgroupattribution!!'}->{$attrib} = $group; | ||||
| @@ -2685,6 +2695,13 @@ sub getNodeAttribs_nosub_returnany | ||||
|   for $result (@results) { | ||||
|     for my $key (keys %$result) { | ||||
|       $result->{$key} =~ s/\+=NEXTRECORD//g; | ||||
|       if (@hierarchy_attrs && grep (/^$key$/, @hierarchy_attrs) ) { | ||||
|           my @attribs = split(/,/, $result->{$key}); | ||||
|           my %count; | ||||
|           # remove the repeat value | ||||
|           @attribs = grep { ++$count{ $_ } < 2; } @attribs; | ||||
|           $result->{$key} = join(',', @attribs); | ||||
|       } | ||||
|     } | ||||
|   } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user