From b3d39468efe1b7cd4fac4fad867b3da4dfebc4a6 Mon Sep 17 00:00:00 2001 From: Lei Ai Date: Mon, 5 Aug 2013 14:45:29 +0800 Subject: [PATCH 1/3] initialize global variables to avoid Cannot re-provision the node which has been removed --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 961f05c11..8fff76131 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -385,6 +385,7 @@ Usage: $allmacs{$macstr} = 0; } } + %allmacsupper = (); foreach (keys %allmacs){ $allmacsupper{uc($_)} = 0; } @@ -1107,6 +1108,7 @@ Usage: $allmacs{$macstr} = 0; } } + %allmacsupper = (); foreach (keys %allmacs){ $allmacsupper{uc($_)} = 0; } @@ -1508,6 +1510,7 @@ sub findme{ $allmacs{$macstr} = 0; } } + %allmacsupper = (); foreach (keys %allmacs){ $allmacsupper{uc($_)} = 0; } From 32d25ec8461fd57db9883193c8f78738ffca3270 Mon Sep 17 00:00:00 2001 From: AsirXing Date: Mon, 5 Aug 2013 17:41:37 +0800 Subject: [PATCH 2/3] support to import CEC-based rack-mount Power nodes by nodeimport command --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 60 +++++++++++++++++-- xCAT-client/pods/man1/nodeimport.1.pod | 11 ++++ xCAT-server/lib/xcat/plugins/profilednodes.pm | 30 ++++++++++ 3 files changed, 95 insertions(+), 6 deletions(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 16fd6ae38..db835cd52 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -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, ""; } diff --git a/xCAT-client/pods/man1/nodeimport.1.pod b/xCAT-client/pods/man1/nodeimport.1.pod index 01f2ddf2d..46a385a0f 100644 --- a/xCAT-client/pods/man1/nodeimport.1.pod +++ b/xCAT-client/pods/man1/nodeimport.1.pod @@ -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> This is a mandatory item while define a PureFlex node. Description: The node position in the PureFlex Chassis. +B> 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> This is an optional item. Description: Specify the IP address used for provisioning a node, where 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. diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 8fff76131..0bee187e5 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -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{$_}; From d5df5374795a23e65857bbb3ebc48088f03327ff Mon Sep 17 00:00:00 2001 From: yinqing Date: Mon, 5 Aug 2013 18:01:09 +0800 Subject: [PATCH 3/3] Fix case #220993 Can not import node by auto discovery switch and switch port --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 27 +++++++++++++++++++ xCAT-server/lib/xcat/plugins/profilednodes.pm | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 16fd6ae38..80f740384 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -550,6 +550,32 @@ sub get_allnode_singleattrib_hash #------------------------------------------------------------------------------- +=head3 get_db_swtiches + Description : Get all records of switch config from a table, then return a string list. + Arguments : $tabname - the table name. + Returns : Reference of the records hash. +=cut + +#------------------------------------------------------------------------------- +sub get_db_switches +{ + my $class = shift; + my $table = xCAT::Table->new("switches"); + my @attribs = ("switch"); + my @entries = $table->getAllAttribs(@attribs); + $table->close(); + my %allrecords; + foreach (@entries) + { + if ($_->{'switch'}){ + $allrecords{$_->{'switch'}} = 0; + } + } + return \%allrecords; +} + +#------------------------------------------------------------------------------- + =head3 get_db_swtichports Description : Get all records of switch config from a table, then return a string list. Arguments : $tabname - the table name. @@ -563,6 +589,7 @@ sub get_db_switchports my $table = xCAT::Table->new("switch"); my @attribs = ("switch", "port"); my @entries = $table->getAllAttribs(@attribs); + $table->close(); my %allrecords; foreach (@entries) { diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 8fff76131..7578f19ac 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -370,7 +370,7 @@ Usage: my %allfspips = %$recordsref; # Get all switches name - $recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('switches', 'switch'); + $recordsref = xCAT::ProfiledNodeUtils->get_db_switches(); %allswitches = %$recordsref; # Get all switches_switchport