support to import CEC-based rack-mount Power nodes by nodeimport command

This commit is contained in:
AsirXing
2013-08-05 17:41:37 +08:00
parent b3d39468ef
commit 32d25ec846
3 changed files with 95 additions and 6 deletions
+54 -6
View File
@@ -573,6 +573,46 @@ sub get_db_switchports
#-------------------------------------------------------------------------------
=head3 get_all_cecs
Description : Get all CEC objects name in system.
Arguments : hashref: if not set, return a array ref.
if set, return a hash ref.
Returns : ref for CECs list.
Example :
my $arrayref = xCAT::ProfiledNodeUtils->get_all_cecs();
my $hashref = xCAT::ProfiledNodeUtils->get_all_cecs(1);
=cut
#-------------------------------------------------------------------------------
sub get_all_cecs
{
my $hashref = shift;
my %cecshash;
my @cecslist;
my $ppctab = xCAT::Table->new('ppc');
my @cecs = $ppctab->getAllAttribsWhere("nodetype = 'cec'", 'node');
foreach (@cecs) {
if($_->{'node'}) {
if ($hashref) {
$cecshash{$_->{'node'}} = 1;
} else {
push @cecslist, $_->{'node'};
}
}
}
$ppctab->close();
# Return the ref accordingly
if ($hashref) {
return \%cecshash;
} else {
return \@cecslist;
}
}
#-------------------------------------------------------------------------------
=head3 is_discover_started
Description : Judge whether profiled nodes discovering is running or not.
Arguments : NA
@@ -731,7 +771,14 @@ sub check_profile_consistent{
my $mgt = undef;
$mgt = $mgtentry->{'mgt'} if ($mgtentry->{'mgt'});
$nodehmtab->close();
#Get hardwareprofile nodetype
my $ppctab = xCAT::Table->new('ppc');
my $ntentry = $ppctab->getNodeAttribs($hardwareprofile, ['nodetype']);
my $nodetype = undef;
$nodetype = $ntentry->{'nodetype'} if ($ntentry->{'nodetype'});
$ppctab->close();
# Check if exists provision network
if (not ($installnic and exists $netprofile_nicshash{$installnic}{"network"})){
return 0, "Provisioning network not defined for network profile."
@@ -750,17 +797,18 @@ sub check_profile_consistent{
return 0, "$nictype networkprofile must use with hardwareprofile.";
}
}
if (not $nictype and $mgt) {
# define hardwareprofile, not define fsp or bmc networkprofile
# For nodetype is lpar node, not need to check the nictype as it is not required for lpar node
if (not $nictype and $mgt and $nodetype ne 'lpar' ) {
# define hardwareprofile, not define fsp or bmc networkprofile, and the node type is not lpar
return 0, "$profile_dict{$mgt} hardwareprofile must use with $profile_dict{$mgt} networkprofile.";
}
if ($profile_dict{$mgt} ne $nictype) {
if ($profile_dict{$mgt} ne $nictype and $nodetype ne 'lpar') {
# Networkprofile's nictype is not consistent with hadrwareprofile's mgt
return 0, "Networkprofile's nictype is not consistent with hardwareprofile's mgt.";
}
return 1, "";
}
+11
View File
@@ -123,6 +123,13 @@ To import nodes using a profile, follow the following steps:
switch=myswitch
switchport=9
Example of a node information file that specifies a CEC-based rack-mounted Power node that uses direct FSP management:
# Node information file begins
# This entry defines a Power rack-mount node.
__hostname__:
cec=mycec
# Node information file ends.
The node information file includes the following items:
B<__hostname__:> This is a mandatory item.
@@ -145,6 +152,10 @@ B<slotid=<slot-id>> This is a mandatory item while define a PureFlex node.
Description: The node position in the PureFlex Chassis.
B<cec=<cec-name>> This is a mandatory option for defining Power rack-mounted nodes.
Description: Specifies the name of a Power rack-mount central electronic complex (CEC).
B<ip=<ip-address>> This is an optional item.
Description: Specify the IP address used for provisioning a node, where <ip-address> is in the form xxx.xxx.xxx.xxx. If this item is not included, the IP address used to provision the node is generated automatically according to the Network Profile used by the node.
@@ -31,6 +31,7 @@ require xCAT::ProfiledNodeUtils;
my %allhostnames;
my %allbmcips;
my %allmacs;
my %allcecs;
my %allmacsupper;
my %allips;
my %allinstallips;
@@ -398,6 +399,10 @@ Usage:
# Merge all BMC IPs and install IPs into allips.
%allips = (%allips, %allbmcips, %allinstallips, %allfspips);
# Get all CEC names
$recordsref = xCAT::ProfiledNodeUtils->get_all_cecs(1);
%allcecs = %$recordsref;
#TODO: can not use getallnode to get rack infos.
$recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1);
%allracks = %$recordsref;
@@ -1750,6 +1755,22 @@ sub gen_new_hostinfo_string{
$hostinfo_dict{$item}{"mpa"} = $chassisname;
}
}
# generate CEC-based rack-mount Power nodes' attributes
# lparid is optional, if not set, set it to 1
if ((exists $hostinfo_dict{$item}{"cec"}) && (! $is_fsp) ){
$hostinfo_dict{$item}{"hcp"} = $hostinfo_dict{$item}{"cec"};
$hostinfo_dict{$item}{"parent"} = $hostinfo_dict{$item}{"cec"};
delete($hostinfo_dict{$item}{"cec"});
if (exists $hostinfo_dict{$item}{"lparid"}) {
$hostinfo_dict{$item}{"id"} = $hostinfo_dict{$item}{"lparid"};
delete($hostinfo_dict{$item}{"lparid"});
} else {
$hostinfo_dict{$item}{"id"} = 1;
}
$hostinfo_dict{$item}{"mgt"} = "fsp";
}
# get the chain attribute from hardwareprofile and insert it to node.
my $chaintab = xCAT::Table->new('chain');
@@ -2140,6 +2161,15 @@ sub validate_node_entry{
if (!($node_entry{$_} =~ /^[1-9]\d*$/)){
$errmsg .= "Specified slotid $node_entry{$_} is invalid";
}
}elsif ($_ eq "lparid"){
if (not exists $node_entry{"cec"}){
$errmsg .= "The lparid option must be used with the cec option.\n";
}
}elsif ($_ eq "cec"){
# 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 ($_ eq "nicips"){
# Check Multi-Nic's ip
my $othernics = $node_entry{$_};