NGP Power support enhance

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14636 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
creativezj 2012-12-13 02:00:48 +00:00
parent ef9d529f87
commit dd8fc76f6f
3 changed files with 233 additions and 9 deletions

View File

@ -383,10 +383,14 @@ sub get_output_filename
Description : Get all chassis in system.
Arguments : hashref: if not set, return a array ref.
if set, return a hash ref.
type : "all", get all chassis,
"cmm", get all chassis whose type is cmm
if type not specify, it is 'all'
Returns : ref for chassis list.
Example :
my $arrayref = xCAT::ProfiledNodeUtils->get_all_chassis();
my $hashref = xCAT::ProfiledNodeUtils->get_all_chassis(1);
my $hashref = xCAT::ProfiledNodeUtils->get_all_chassis(1, 'cmm');
=cut
#-------------------------------------------------------------------------------
@ -394,9 +398,14 @@ sub get_all_chassis
{
my $class = shift;
my $hashref = shift;
my $type = shift;
my %chassishash;
my %chassistype = ('all' => '__Chassis', 'cmm' => '__Chassis_IBM_Flex_chassis');
my @chassis = xCAT::NodeRange::noderange('__Chassis');
if (not $type) {
$type = 'all';
}
my @chassis = xCAT::NodeRange::noderange($chassistype{$type});
if ($hashref){
foreach (@chassis){
$chassishash{$_} = 1;
@ -567,3 +576,153 @@ sub get_imageprofile_prov_method
#return $osimgentry->{'provmethod'};
}
#-------------------------------------------------------------------------------
=head3 check_profile_consistent
Description : Check if three profile consistent
Arguments : $imageprofile - image profile name
$networkprofile - network profile name
$hardwareprofile - harware profile name
Returns : returncode, errmsg - consistent
returncode=1 - consistent
returncode=0 - not consistent
=cut
#-------------------------------------------------------------------------------
sub check_profile_consistent{
my $class = shift;
my $imageprofile = shift;
my $networkprofile = shift;
my $hardwareprofile = shift;
# Profile consistent keys, arch=>netboot, mgt=>nictype
my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => 'yaboot',
'fsp' => 'FSP', 'ipmi' => 'BMC');
# Get Imageprofile arch
my $nodetypetab = xCAT::Table->new('nodetype');
my $nodetypeentry = $nodetypetab->getNodeAttribs($imageprofile, ['arch']);
my $arch = $nodetypeentry->{'arch'};
$nodetypetab->close();
# Get networkprofile netboot and installnic
my $noderestab = xCAT::Table->new('noderes');
my $noderesentry = $noderestab->getNodeAttribs($networkprofile, ['netboot', 'installnic']);
my $netboot = $noderesentry->{'netboot'};
my $installnic = $noderesentry->{'installnic'};
$noderestab->close();
# Get networkprofile nictypes
my $netprofile_nicshash_ref = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$networkprofile])->{$networkprofile};
my %netprofile_nicshash = %$netprofile_nicshash_ref;
my $nictype = undef;
foreach (keys %netprofile_nicshash) {
my $value = $netprofile_nicshash{$_}{'type'};
if (($value eq 'FSP') or ($value eq 'BMC')) {
$nictype = $value;
}
}
#Get hardwareprofile mgt
my $nodehmtab = xCAT::Table->new('nodehm');
my $mgtentry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']);
my $mgt = undef;
$mgt = $mgtentry->{'mgt'} if ($mgtentry->{'mgt'});
$nodehmtab->close();
# Check if exists provision network
if (not ($installnic and exists $netprofile_nicshash{$installnic}{"network"})){
return 0, "Provisioning network not defined for network profile."
}
# Check if imageprofile is consistent with networkprofile
if ($profile_dict{$arch} ne $netboot) {
return 0, "Imageprofile's arch is not consistent with networkprofile's netboot."
}
# Check if networkprofile is consistent with hardwareprofile
if (not $hardwareprofile) { # Not define hardwareprofile
if (not $nictype) { # Networkprofile is not fsp or bmc
return 1, "";
}elsif ($nictype eq 'FSP' or $nictype eq 'BMC') {
return 0, "$nictype networkprofile must use with hardwareprofile.";
}
}
if (not $nictype and $mgt) {
# define hardwareprofile, not define fsp or bmc networkprofile
return 0, "$profile_dict{$mgt} hardwareprofile must use with $profile_dict{$mgt} networkprofile.";
}
if ($profile_dict{$mgt} ne $nictype) {
# Networkprofile's nictype is not consistent with hadrwareprofile's mgt
return 0, "Networkprofile's nictype is not consistent with hardwareprofile's mgt.";
}
return 1, "";
}
#-------------------------------------------------------------------------------
=head3 is_fsp_node
Description : Judge whether nodes use fsp.
Arguments : $node - node name
Returns : 1 - Use fsp
0 - Not use fsp
=cut
#-------------------------------------------------------------------------------
sub is_fsp_node
{
my $class = shift;
my $node = shift;
my $nicstab = xCAT::Table->new('nics');
my $entry = $nicstab->getNodeAttribs($node, ['nictypes']);
$nicstab->close();
if ($entry->{'nictypes'}){
my @nicattrslist = split(",", $entry->{'nictypes'});
foreach (@nicattrslist){
my @nicattrs = split(":", $_);
if ($nicattrs[1] eq 'FSP'){
return 1;
}
}
}
return 0;
}
#-------------------------------------------------------------------------------
=head3 get_nodes_cmm
Description : Get the CMM of nodelist
Arguments : $nodelist - the ref of node list array
Returns : $cmm - the ref of hash like
{
"cmm1" => 1,
"cmm2" => 1
}
=cut
#-------------------------------------------------------------------------------
sub get_nodes_cmm
{
my $class = shift;
my $nodelistref = shift;
my @nodes = @$nodelistref;
my %returncmm;
my $mptab = xCAT::Table->new('mp');
my $entry = $mptab->getNodesAttribs($nodelistref, ['mpa']);
$mptab->close();
foreach (@nodes) {
my $mpa = $entry->{$_}->[0]->{'mpa'};
if ($mpa and not exists $returncmm{$mpa}){
$returncmm{$mpa} = 1;
}
}
return \%returncmm
}

View File

@ -99,10 +99,26 @@ sub process_request {
log_cmd_return($retref);
}
my $isfsp = xCAT::ProfiledNodeUtils->is_fsp_node([$firstnode]);
if ($isfsp) {
setrsp_progress("Updating FSP's IP address");
$retref = xCAT::Utils->runxcmd({command=>["rspconfig"], node=>$nodelist, arg=>['network=*']}, $request_command, 0, 2);
log_cmd_return($retref);
my $cmmref = xCAT::ProfiledNodeUtils->get_nodes_cmm($nodelist);
my @cmmchassis = keys %$cmmref;
setrsp_progress("Update node's some attributes through 'rscan -u'");
$retref = xCAT::Utils->runxcmd({command=>["rscan"], node=>\@cmmchassis, arg=>['-u']}, $request_command, 0, 2);
log_cmd_return($retref);
setrsp_progress("Sets up connections for nodes to FSP");
$retref = xCAT::Utils->runxcmd({command=>["mkhwconn"], node=>$nodelist, arg=>['-t']}, $request_command, 0, 2);
log_cmd_return($retref);
}
setrsp_progress("Updating conserver configuration files");
$retref = xCAT::Utils->runxcmd({command=>["makeconservercf"], node=>$nodelist}, $request_command, 0, 2);
log_cmd_return($retref);
}
elsif ($command eq 'kitnoderemove'){
setrsp_progress("Updating conserver configuration files");

View File

@ -37,6 +37,8 @@ my %allinstallips;
my %allnicips;
my %allracks;
my %allchassis;
# The array of all chassis which is special CMM
my %allcmmchassis;
# Define parameters for xcat requests.
my $request;
@ -289,6 +291,16 @@ Usage:
setrsp_errormsg("Invalid node name format: $args_dict{'hostnameformat'}");
return;
}
# Validate if profile consistent
my $imageprofile = $args_dict{'imageprofile'};
my $networkprofile = $args_dict{'networkprofile'};
my $hardwareprofile = $args_dict{'hardwareprofile'};
my ($returncode, $errmsg) = xCAT::ProfiledNodeUtils->check_profile_consistent($imageprofile, $networkprofile, $hardwareprofile);
if (not $returncode) {
setrsp_errormsg($errmsg);
return;
}
# Get database records: all hostnames, all ips, all racks...
xCAT::MsgUtils->message('S', "Getting database records.");
@ -298,6 +310,11 @@ Usage:
%allbmcips = %$recordsref;
$recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('mac', 'mac');
%allmacs = %$recordsref;
# Get all FSP ip address
$recordsref = xCAT::ProfiledNodeUtils->get_allnode_singleattrib_hash('ppc', 'hcp');
my %allfspips = %$recordsref;
# MAC records looks like: "01:02:03:04:05:0E!node5│01:02:03:05:0F!node6-eth1". We want to get the real mac addres.
foreach (keys %allmacs){
my @hostentries = split(/\|/, $_);
@ -312,13 +329,15 @@ Usage:
%allips = %$recordsref;
# Merge all BMC IPs and install IPs into allips.
%allips = (%allips, %allbmcips, %allinstallips);
%allips = (%allips, %allbmcips, %allinstallips, %allfspips);
#TODO: can not use getallnode to get rack infos.
$recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1);
%allracks = %$recordsref;
$recordsref = xCAT::ProfiledNodeUtils->get_all_chassis(1);
%allchassis = %$recordsref;
$recordsref = xCAT::ProfiledNodeUtils->get_all_chassis(1,'cmm');
%allcmmchassis = %$recordsref;
# Generate temporary hostnames for hosts entries in hostfile.
xCAT::MsgUtils->message('S', "Generate temporary hostnames.");
@ -1188,10 +1207,10 @@ sub gen_new_hostinfo_string{
# Get node's provisioning method
my $provmethod = xCAT::ProfiledNodeUtils->get_imageprofile_prov_method($args_dict{'imageprofile'});
# compose the stanza string for hostinfo file.
my $hostsinfostr = "";
foreach my $item (keys %hostinfo_dict){
foreach my $item (keys %hostinfo_dict){
# Generate IPs for all interfaces.
my %ipshash;
foreach (keys %netprofileattr){
@ -1229,8 +1248,8 @@ sub gen_new_hostinfo_string{
if (exists $args_dict{'hardwareprofile'}){$hostinfo_dict{$item}{"groups"} .= ",".$args_dict{'hardwareprofile'}}
if (exists $args_dict{'groups'}){$hostinfo_dict{$item}{"groups"} .= ",".$args_dict{'groups'}}
# Update BMC records.
if (exists $netprofileattr{"bmc"}){
$hostinfo_dict{$item}{"chain"} = 'osimage='.$provmethod;
if (exists $netprofileattr{"bmc"}){ # Update BMC records.
$hostinfo_dict{$item}{"mgt"} = "ipmi";
$hostinfo_dict{$item}{"chain"} = 'runcmd=bmcsetup,osimage='.$provmethod;
@ -1239,8 +1258,15 @@ sub gen_new_hostinfo_string{
} else{
return 0, "There are no more IP addresses available in the static network range for the BMC network.";
}
} else{
$hostinfo_dict{$item}{"chain"} = 'osimage='.$provmethod;
} elsif (exists $netprofileattr{"fsp"}){ # Update FSP records
$hostinfo_dict{$item}{"mgt"} = "fsp";
$hostinfo_dict{$item}{"mpa"}= $hostinfo_dict{$item}{"chassis"};
if (exists $ipshash{"fsp"}){
$hostinfo_dict{$item}{"hcp"} = $ipshash{"fsp"};
} else{
return 0, "No sufficient IP addresses for FSP";
}
}
# Generate the hostinfo string.
@ -1449,6 +1475,10 @@ sub validate_node_entry{
if (! xCAT::NetworkUtils->isValidHostname($node_name)){
$errmsg .= "Node name: $node_name is invalid. You must use a valid node name.\n";
}
# validate if node use FSP network
my $is_fsp = xCAT::ProfiledNodeUtils->is_fsp_node($args_dict{'networkprofile'});
# validate each single value.
foreach (keys %node_entry){
if ($_ eq "mac"){
@ -1492,6 +1522,17 @@ sub validate_node_entry{
if (exists $node_entry{"height"} or exists $node_entry{"unit"}){
$errmsg .= "Specified chassis cannot be used with height or unit.\n";
}
# Check if this chassis is CMM. If it is, must specify slotid
if (exists $allcmmchassis{$node_entry{$_}}){
if (not exists $node_entry{"slotid"}){
$errmsg .= "Specified CMM Chassis must be used with sloid";
}
}else {
# If the specific chassis is not CMM chassis, but network is fsp
if ($is_fsp) {
$errmsg .= "Specified FSP network must be used with CMM chassis."
}
}
}elsif ($_ eq "unit"){
if (! exists $node_entry{"rack"}){
$errmsg .= "Specified unit must be used with rack.\n";
@ -1508,6 +1549,14 @@ sub validate_node_entry{
if (!($node_entry{$_} =~ /^\d+$/)){
$errmsg .= "Specified height $node_entry{$_} is invalid\n";
}
}elsif ($_ eq "slotid"){
if (not exists $node_entry{"chassis"}){
$errmsg .= "Specified slotid must be used with chassis";
}
# Not a valid number.
if (!($node_entry{$_} =~ /^[1-9]\d*$/)){
$errmsg .= "Specified slotid $node_entry{$_} is invalid";
}
}else{
$errmsg .= "Invalid attribute $_ specified\n";
}