validate cec and lparid during nodeimport
This commit is contained in:
		@@ -653,6 +653,39 @@ sub get_all_cecs
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------------
 | 
			
		||||
 
 | 
			
		||||
=head3 get_all_lparids
 | 
			
		||||
      Description : Get all LPAR ids  in system.
 | 
			
		||||
      Arguments   : ref of all cecs
 | 
			
		||||
      Returns     : ref for LPAR ids hash.
 | 
			
		||||
      Example     : 
 | 
			
		||||
                    my $arrayref = xCAT::ProfiledNodeUtils->get_all_lparids(\%allcecs);
 | 
			
		||||
=cut
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------------
 | 
			
		||||
sub get_all_lparids
 | 
			
		||||
{
 | 
			
		||||
    my $class= shift;
 | 
			
		||||
    my $cecsref = shift;
 | 
			
		||||
    my %allcecs = %$cecsref;
 | 
			
		||||
    my %lparids;
 | 
			
		||||
 | 
			
		||||
    my $ppctab = xCAT::Table->new('ppc');
 | 
			
		||||
    foreach my $cec (keys  %allcecs) {
 | 
			
		||||
        my @ids = $ppctab->getAllAttribsWhere("hcp = '$cec'", 'id');
 | 
			
		||||
        foreach (@ids) {
 | 
			
		||||
            if ( $_->{'id'} ){
 | 
			
		||||
                $lparids{$cec}{$_->{'id'}} = 0;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
    $ppctab->close();
 | 
			
		||||
    
 | 
			
		||||
    return \%lparids;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#-------------------------------------------------------------------------------
 | 
			
		||||
 | 
			
		||||
=head3 is_discover_started
 | 
			
		||||
 
 | 
			
		||||
@@ -128,7 +128,11 @@ To import nodes using a profile, follow the following steps:
 | 
			
		||||
  __hostname__:
 | 
			
		||||
     mac=b8:ac:6f:37:59:28
 | 
			
		||||
     cec=mycec
 | 
			
		||||
     lparid=1
 | 
			
		||||
  
 | 
			
		||||
  __hostname__:
 | 
			
		||||
     mac=b8:ac:6f:37:59:28
 | 
			
		||||
     cec=mycec
 | 
			
		||||
     lparid=2
 | 
			
		||||
  # Node information file ends.
 | 
			
		||||
 | 
			
		||||
The node information file includes the following items:
 | 
			
		||||
@@ -155,7 +159,7 @@ Description: Specifies the name of a Power rack-mount central electronic complex
 | 
			
		||||
 | 
			
		||||
B<lparid=<lpar-id>>  This is a optional option for defining Power rack-mounted nodes.
 | 
			
		||||
 | 
			
		||||
Description: Specifies the LPAR id of Power rack-mounted node.
 | 
			
		||||
Description: Specifies the LPAR ID of a Power rack-mounted node, where <lpar-id> is the ID number. The default value is 1 if it is not defined.
 | 
			
		||||
 | 
			
		||||
B<ip=<ip-address>> This is an optional item.
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,7 @@ my %allhostnames;
 | 
			
		||||
my %allbmcips;
 | 
			
		||||
my %allmacs;
 | 
			
		||||
my %allcecs;
 | 
			
		||||
my %alllparids;
 | 
			
		||||
my %allmacsupper;
 | 
			
		||||
my %allips;
 | 
			
		||||
my %allinstallips;
 | 
			
		||||
@@ -425,6 +426,10 @@ Usage:
 | 
			
		||||
    # Get all CEC names
 | 
			
		||||
    $recordsref =  xCAT::ProfiledNodeUtils->get_all_cecs(1);
 | 
			
		||||
    %allcecs = %$recordsref;
 | 
			
		||||
    
 | 
			
		||||
    # Get all LPAR ids
 | 
			
		||||
    $recordsref = xCAT::ProfiledNodeUtils->get_all_lparids(\%allcecs);
 | 
			
		||||
    %alllparids = %$recordsref;
 | 
			
		||||
 | 
			
		||||
    #TODO: can not use getallnode to get rack infos.
 | 
			
		||||
    $recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1);
 | 
			
		||||
@@ -2437,10 +2442,20 @@ sub validate_node_entry{
 | 
			
		||||
                $errmsg .= "The lparid option must be used with the cec option.\n";
 | 
			
		||||
            }
 | 
			
		||||
        }elsif ($_ eq "cec"){
 | 
			
		||||
            my $cec_name = $node_entry{"cec"};
 | 
			
		||||
            my $lpar_id = 1;
 | 
			
		||||
            # Check the specified CEC is existing
 | 
			
		||||
            if (! exists $allcecs{$node_entry{$_}}){
 | 
			
		||||
                $errmsg .= "The CEC name $node_entry{$_} that is specified in the node information file is not defined in the system.\n";
 | 
			
		||||
            }elsif (exists $node_entry{"lparid"}){
 | 
			
		||||
                $lpar_id = $node_entry{"lparid"};
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
            if (exists $alllparids{$cec_name}{$lpar_id}){
 | 
			
		||||
                $errmsg .= "The CEC name $cec_name and LPAR id $lpar_id already exist in the database or in the nodeinfo file. You must use a new CEC name and LPAR id.\n";
 | 
			
		||||
            }else{
 | 
			
		||||
                $alllparids{$cec_name}{$lpar_id} = 0;
 | 
			
		||||
            }    
 | 
			
		||||
        }elsif ($_ eq "nicips"){
 | 
			
		||||
            # Check Multi-Nic's ip
 | 
			
		||||
            my $othernics = $node_entry{$_};
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user