diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index d400a5072..891bde510 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -873,21 +873,26 @@ Usage: my $oldNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$oldNetProfileName])->{$oldNetProfileName}; my %updateNicsHash = (); + my %reserveNicsHash = (); foreach my $newNic (keys %$newNicsRef) { if ($newNicsRef->{$newNic}->{'type'} ne 'BMC' and $newNicsRef->{$newNic}->{'type'} ne 'FSP'){ $updateNicsHash{$newNic} = 1; } } + # Add BMC/FSP as reserve NICs and not remove it form nics table foreach my $oldNic (keys %$oldNicsRef) { if ($oldNicsRef->{$oldNic}->{'type'} ne 'BMC' and $oldNicsRef->{$oldNic}->{'type'} ne 'FSP'){ $updateNicsHash{$oldNic} = 1; + } else { + $reserveNicsHash{$oldNic} = 1; } } my $updateNics = join(",", keys %updateNicsHash); + my $reserveNics = join(",", keys %reserveNicsHash); setrsp_progress("Regenerate IP addresses for nodes..."); $retref = ""; - $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, arg=>["nics=$updateNics"], sequential=>[1]}, $request_command, 0, 2); + $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, arg=>["nics=$updateNics", "reservenics=$reserveNics"], sequential=>[1]}, $request_command, 0, 2); $retstrref = parse_runxcmd_ret($retref); if ($::RUNCMD_RC != 0){ setrsp_progress("Warning: failed to generate IPs for nodes."); @@ -986,7 +991,7 @@ Usage: setrsp_infostr($helpmsg); return; } - my @enabledparams = ('nics'); + my @enabledparams = ('nics', 'reservenics'); my $ret = validate_args($helpmsg, \@enabledparams); if (! $ret){ return; @@ -994,6 +999,7 @@ Usage: my @updateNics = (); my @removedNics = (); + my @reserveNics = (); my $netProfileName = ''; my $netProfileNicsRef; my %freeIPsHash = (); @@ -1027,6 +1033,9 @@ Usage: if(exists $args_dict{'nics'}){ @updateNics = split(",", $args_dict{'nics'}); } + if (exists $args_dict{'reservenics'}){ + @reserveNics = split(",", $args_dict{'reservenics'}); + } foreach (@updateNics){ unless ($netProfileNicsRef->{$netProfileName}->{$_}){ # We want to remove this nic from these nodes. @@ -1117,6 +1126,13 @@ Usage: } } } + # Add reserve nics + foreach my $nicname (@reserveNics){ + my $oldip = $nodesNicsRef->{$node}->{$nicname}->{"ip"}; + if ($oldip) { + $nicipsAttr{$node}{nicips} .= $nicname."!".$oldip.","; + } + } } #8. Update database.