1. update node's status while replace mac address. 2. set blades rack info while import/discover
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14637 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
		| @@ -457,6 +457,29 @@ sub get_all_rack | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| =head3 get_racks_for_chassises | ||||
|       Description : Get rack info for a chassis list. | ||||
|       Arguments   : $chassislistref - chassis list reference. | ||||
|       Returns     : A dict ref. keys are chassis name, values are rack name for each chassis. | ||||
| =cut | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
| sub get_racks_for_chassises | ||||
| { | ||||
|     my $class = shift; | ||||
|     my $chassislistref = shift; | ||||
|     my %rackinfodict = (); | ||||
|  | ||||
|     my $nodepostab = xCAT::Table->new('nodepos'); | ||||
|     my $racksref = $nodepostab->getNodesAttribs($chassislistref, ['rack']); | ||||
|     foreach (@$chassislistref){ | ||||
|         $rackinfodict{$_} = $racksref->{$_}->[0]->{'rack'}; | ||||
|     } | ||||
|     return \%rackinfodict; | ||||
| } | ||||
|  | ||||
| #------------------------------------------------------------------------------- | ||||
|  | ||||
| =head3 get_allnode_singleattrib_hash | ||||
|       Description : Get all records of a column from a table, then return a hash. | ||||
|                     The return hash's keys are the records of this attribute  | ||||
|   | ||||
| @@ -709,6 +709,20 @@ Usage: | ||||
|         setrsp_progress("Warning: failed to call kit commands."); | ||||
|     } | ||||
|  | ||||
|     # Update node's status. | ||||
|     setrsp_progress("Updating node status..."); | ||||
|     my $nodelisttab = xCAT::Table->new('nodelist',-create=>1); | ||||
|     my ( | ||||
|       $sec,  $min,  $hour, $mday, $mon, | ||||
|       $year, $wday, $yday, $isdst | ||||
|     ) = localtime(time); | ||||
|     my $currtime = sprintf("%02d-%02d-%04d %02d:%02d:%02d", | ||||
|                          $mon + 1, $mday, $year + 1900, | ||||
|                          $hour, $min, $sec); | ||||
|  | ||||
|     $nodelisttab->setNodeAttribs($hostname, {status=>'defined', statustime=>$currtime}); | ||||
|     $nodelisttab->close(); | ||||
|  | ||||
|     setrsp_progress("Updated MAC address."); | ||||
| } | ||||
|  | ||||
| @@ -1370,6 +1384,10 @@ sub parse_hosts_string{ | ||||
|     my @allknownips = keys %allips; | ||||
|     my $freeprovipsref = xCAT::ProfiledNodeUtils->get_allocable_staticips_innet($provnet); | ||||
|   | ||||
|     # get all chassis's rack info. | ||||
|     my @chassislist = keys %allchassis; | ||||
|     my $chassisrackref = xCAT::ProfiledNodeUtils->get_racks_for_chassises(\@chassislist); | ||||
|  | ||||
|     foreach my $attr (keys %::FILEATTRS){ | ||||
|         my $errmsg = validate_node_entry($attr, $::FILEATTRS{$attr}); | ||||
|         # Check whether specified IP is in our prov network, static range. | ||||
| @@ -1378,6 +1396,11 @@ sub parse_hosts_string{ | ||||
|                 $errmsg .= "Specified IP address $::FILEATTRS{$attr}->{'ip'} not in static range of provision network $provnet"; | ||||
|             } | ||||
|         } | ||||
|  | ||||
|         # Set rack info for blades too. | ||||
|         if ($::FILEATTRS{$attr}->{'chassis'}){ | ||||
|             $::FILEATTRS{$attr}->{'rack'} = $chassisrackref->{$::FILEATTRS{$attr}->{'chassis'}}; | ||||
|         } | ||||
|         if ($errmsg) { | ||||
|             if ($attr =~ /^TMPHOSTS/){ | ||||
|                 push @invalid_records, ["__hostname__", $errmsg]; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user