From ebe61dbab5bdd69a92504fe7168146a903920d46 Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Thu, 12 Mar 2015 17:30:02 +0800 Subject: [PATCH] fix nodeimport getting netboot attribute error --- perl-xCAT/xCAT/ProfiledNodeUtils.pm | 35 ++++++++++++------- xCAT-server/lib/xcat/plugins/profilednodes.pm | 16 +++++---- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 778eea607..ce7989c72 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -1351,7 +1351,6 @@ sub get_netboot_attr{ { return 0, "Hardware profile not defined in DB." } - $hardwareprofile =~ s/^__HardwareProfile_//; } else { @@ -1384,16 +1383,28 @@ sub get_netboot_attr{ { $os_arch = 'x86_64'; } + + # Identify whether this node is PowerKVM or PowerNV if os arch is ppc64le + # If hardware profile is defined + my $mgt = '*'; + if ($os_arch eq 'ppc64le' and $hardwareprofile ne '*') { + my $nodehmtab = xCAT::Table->new('nodehm'); + my $nodehmtab_entry = $nodehmtab->getNodeAttribs($hardwareprofile, ['mgt']); + if (defined $nodehmtab_entry->{'mgt'}) { + $mgt = $nodehmtab_entry->{'mgt'}; + } + } + # Rule for netboot attribute.If update the rule,just update %netboot_dict and @condition_array # It's sequence sensitive: os arch -> os name -> os major version -> hardware profile -# Priority | Arch | OS Name | OS Major Version | Hardware Profile | Noderes.netboot | -# 1 | x86_64/x86 | * | * | * | xnba | -# 2 | ppc64 | rhels | 7 | * | grub2 | -# 3 | | * | * | * | yaboot | -# 4 | ppc64le/el | * | * | IBM_PowerNV | petitboot | -# 5 | | * | * | * | grub2 | -# arch osname version hardware netboot +# Priority | Arch | OS Name | OS Major Version | Management method | Noderes.netboot | +# 1 | x86_64/x86 | * | * | * | xnba | +# 2 | ppc64 | rhels | 7 | * | grub2 | +# 3 | | * | * | * | yaboot | +# 4 | ppc64le/el | * | * | * | grub2 +# 4 | ppc64le/el | * | * | ipmi | petitboot +# arch osname version hardware netboot my %netboot_dict = ( 'x86_64' => 'xnba', 'ppc64' => { 'rhels' => { @@ -1405,20 +1416,20 @@ sub get_netboot_attr{ 'ppc64le' => { '*' => { '*' => { - 'IBM_PowerNV' => 'petitboot', - '*' => 'grub2', + '*' => 'grub2', + 'ipmi' => 'petitboot', }, }, }, ); - my $condition_array_ref = [$os_arch, $os_name, $os_major_version, $hardwareprofile]; + my $condition_array_ref = [$os_arch, $os_name, $os_major_version, $mgt]; $netboot = cal_netboot(\%netboot_dict, $condition_array_ref); if($netboot eq '0') { return 0, "Can not get the netboot attribute"; } else - { + { return 1, $netboot; } } diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index d674c4c4a..a4c2f4d84 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -839,6 +839,14 @@ Usage: if(exists $args_dict{'hardwareprofile'}){ $hardwareprofile = $args_dict{'hardwareprofile'}; } + + # Get the netboot attribute for node + my ($retcode, $retval) = xCAT::ProfiledNodeUtils->get_netboot_attr($imageprofile, $hardwareprofile); + if (not $retcode) { + setrsp_errormsg($retval); + return; + } + my $new_netboot = $retval; # After checking, all nodes' profile should be same # Get the new profile with specified ones in args_dict @@ -879,13 +887,7 @@ Usage: setrsp_infostr("Warning: no profile changes detect."); return; } - # Get the netboot attribute for node - my ($retcode, $retval) = xCAT::ProfiledNodeUtils->get_netboot_attr($imageprofile, $hardwareprofile); - if (not $retcode) { - setrsp_errormsg($retval); - return; - } - my $new_netboot = $retval; + # Update nodes' attributes foreach (@$nodes) { $updatenodeshash{$_}{'groups'} .= $profile_groups;