diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 62c1b5081..601949057 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -655,6 +655,38 @@ 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 Description : Judge whether profiled nodes discovering is running or not. Arguments : NA diff --git a/xCAT-client/pods/man1/nodeimport.1.pod b/xCAT-client/pods/man1/nodeimport.1.pod index 9611246c1..5d443d866 100644 --- a/xCAT-client/pods/man1/nodeimport.1.pod +++ b/xCAT-client/pods/man1/nodeimport.1.pod @@ -128,7 +128,11 @@ To import nodes using a profile, follow the following steps: __hostname__: mac=b8:ac:6f:37:59:28 cec=mycec - lpaid=1 + + __hostname__: + mac=b8:ac:6f:37:59:29 + cec=mycec + lpaid=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> 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 is the ID number. The default value is 1 if it is not defined. B> This is an optional item. diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index c8ab55cec..b259f11e2 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -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); @@ -2435,11 +2440,21 @@ sub validate_node_entry{ }elsif ($_ eq "lparid"){ if (not exists $node_entry{"cec"}){ $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