From 3b86d90a7c26e0d41bb9a3cd866e2913f5ae28a0 Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Tue, 20 Jan 2015 14:15:07 +0800 Subject: [PATCH] merge from 2.9 about supporting powerkvm in nodeimport --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 86 +++++++++++++------ xCAT-client/pods/man1/nodeimport.1.pod | 16 +++- xCAT-server/lib/xcat/plugins/profilednodes.pm | 17 ++++ 3 files changed, 91 insertions(+), 28 deletions(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index f0ab430c2..35b53ea37 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -895,18 +895,21 @@ sub check_profile_consistent{ return 0, "Provisioning network not defined for network profile." } + # Remove check mechanism about arch and netboot attribute + # Attribute 'neboot' will be generated based on arch, management method, os + # Profile consistent keys, arch=>netboot, mgt=>nictype - my $ppc_netboot = 'yaboot'; - if( $os =~ /rhels7/ ){ - $ppc_netboot = 'grub2'; - } - my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => $ppc_netboot, - 'ppc64el' => $ppc_netboot, - 'fsp' => 'FSP', 'ipmi' => 'BMC'); + #my $ppc_netboot = 'yaboot'; + #if( $os =~ /rhels7/ ){ + # $ppc_netboot = 'grub2'; + #} + #my %profile_dict = ('x86' => 'xnba','x86_64' => 'xnba', 'ppc64' => $ppc_netboot, + # 'ppc64el' => $ppc_netboot, + # 'fsp' => 'FSP', 'ipmi' => 'BMC'); # 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." - } + #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 @@ -916,27 +919,27 @@ sub check_profile_consistent{ return 0, "$nictype networkprofile must use with hardwareprofile."; } } - - if ($mgt eq 'vm') - { - return 1, ""; - } + + my %mgt_dict = ('fsp' => 'FSP', 'ipmi' => 'BMC', 'kvm' => ''); - # 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 ($mgt eq 'vm') { + return 1, ""; } - if ($profile_dict{$mgt} ne $nictype and $nodetype ne 'lpar') { - # Networkprofile's nictype is not consistent with hadrwareprofile's mgt, and the node type is not lpar - return 0, "Networkprofile's nictype is not consistent with hardwareprofile's mgt."; + if ($nodetype eq 'lpar') { + if ($nictype) { + # Can not associate FSP/BMC network if the node type is lpar + return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile."; + } + return 1, "" } - - if ($nodetype eq 'lpar' and $nictype eq 'FSP') - { - # can not associate FSP network if the node type is lpar - return 0, "The node with hardware type $nodetype can not use with $nictype networkprofile."; + + if ($mgt and $mgt_dict{$mgt} ne $nictype) { + my $errmsg = "$mgt hardwareprofile must use with $mgt_dict{$mgt} networkprofile."; + if ( $mgt eq 'kvm' ) { + $errmsg = "$mgt hardwareprofile must use with non-BMC and non-FSP networkprofile." + } + return 0, $errmsg; } return 1, ""; @@ -1267,3 +1270,32 @@ sub gen_chain_for_profiles{ } return (0, $final_chain); } + +#------------------------------------------------------------------------------- + +=head3 get_all_vmhosts + Description : Get all vm hosts/hypervisor from DB. + Arguments : N/A + Returns : ref for vm hosts/hypervisor hash. + Example : + my $hashref = xCAT::ProfiledNodeUtils->get_all_vmhosts(); +=cut + +#------------------------------------------------------------------------------- +sub get_all_vmhosts +{ + my %vmhostshash; + + my $nodelisttab = xCAT::Table->new('nodelist'); + # groups like '__Hypervisor_pkvm' means this node is Power KVM hypervisor + my @vmhosts = $nodelisttab->getAllAttribsWhere("groups like '%__Hypervisor_kvm%'", 'node'); + foreach (@vmhosts) { + if($_->{'node'}) { + $vmhostshash{$_->{'node'}} = 1; + } + } + $nodelisttab->close(); + + # Return the ref accordingly + return \%vmhostshash; +} diff --git a/xCAT-client/pods/man1/nodeimport.1.pod b/xCAT-client/pods/man1/nodeimport.1.pod index 41e962a52..e23dfbb3c 100644 --- a/xCAT-client/pods/man1/nodeimport.1.pod +++ b/xCAT-client/pods/man1/nodeimport.1.pod @@ -134,12 +134,22 @@ To import nodes using a profile, follow the following steps: cec=mycec lparid=2 # Node information file ends. + + Example of a node information file that specifies a PowerKVM Guest node that uses KVM management: + + # Node information file begins + # This entry defines a PowerKVM Guest node. + # Make sure the node 'vm01' is already created on Hypervisor + vm01: + mac=b8:ef:3f:28:31:15 + vmhost=pkvm1 + # Node information file ends. The node information file includes the following items: B<__hostname__:> This is a mandatory item. -Description: The name of the node, where __hostname__ is automatically generated by the node name format. You can also input a fixed node name, for example “compute-node”. +Description: The name of the node, where __hostname__ is automatically generated by the node name format. You can also input a fixed node name, for example "compute-node". B> This is a mandatory item. @@ -185,6 +195,10 @@ B> This is an optional item. Description: node location info, for rack server only. Specify the node's start unit number in rack, in U. this item must be specified together with rack and height. +B> This is a mandatory option for defining PowerKVM Guest nodes. + +Description: Specifies the vmhost of a Power KVM Guest node, where is the host name of PowerKVM Hypervisior. + 3. Import the nodes, by using the following commands. Note: If we want to import PureFlex X/P nodes, hardware profile must be set to a PureFlex hardware type. nodeimport file=/root/hostinfo.txt networkprofile=default_cn imageprofile=rhels6.3_packaged hostnameformat=compute-#NNN diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 2f0cc335f..33544a373 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -42,6 +42,7 @@ my %allracks; my %allchassis; my %allswitches; my %all_switchports; +my %allvmhosts; my @switch_records; @@ -430,6 +431,10 @@ Usage: # Get all LPAR ids $recordsref = xCAT::ProfiledNodeUtils->get_all_lparids(\%allcecs); %alllparids = %$recordsref; + + # Get all vm hosts/hypervisiors + $recordsref = xCAT::ProfiledNodeUtils->get_all_vmhosts(); + %allvmhosts = %$recordsref; #TODO: can not use getallnode to get rack infos. $recordsref = xCAT::ProfiledNodeUtils->get_all_rack(1); @@ -2103,6 +2108,12 @@ sub gen_new_hostinfo_dict{ $hostinfo_dict{$item}{"mgt"} = "fsp"; } + # Generate VM host nodes' attribute + # Update netboot attribute if this is powerKVM node + if (exists $hostinfo_dict{$item}{"vmhost"}){ + $hostinfo_dict{$item}{"netboot"} = 'grub2'; + } + # get the chain attribute from hardwareprofile and insert it to node. my $chaintab = xCAT::Table->new('chain'); my $hardwareprofile = $args_dict{'hardwareprofile'}; @@ -2538,6 +2549,12 @@ sub validate_node_entry{ } } } + }elsif ($_ eq "vmhost") { + # Support PowerKVM vms + my $vm_host= $node_entry{"vmhost"}; + if (! exists $allvmhosts{$node_entry{$_}}){ + $errmsg .= "The VM host name $node_entry{$_} that is specified in the node information file is not defined in the system.\n"; + } }else{ $errmsg .= "Invalid attribute $_ specified\n"; }