diff --git a/buildcore.sh b/buildcore.sh index dcc5147c6..621690849 100755 --- a/buildcore.sh +++ b/buildcore.sh @@ -423,6 +423,10 @@ EOF #!/bin/sh cd `dirname $0` REPOFILE=`basename xCAT-*.repo` +if [[ $REPOFILE == "xCAT-*.repo" ]]; then + echo "ERROR: For xcat-dep, please execute $0 in the correct / subdirectory" + exit 1 +fi sed -e 's|baseurl=.*|baseurl=file://'"`pwd`"'|' $REPOFILE | sed -e 's|gpgkey=.*|gpgkey=file://'"`pwd`"'/repodata/repomd.xml.key|' > /etc/yum.repos.d/$REPOFILE cd - EOF2 diff --git a/perl-xCAT/xCAT/ProfiledNodeUtils.pm b/perl-xCAT/xCAT/ProfiledNodeUtils.pm index 35b53ea37..766f7a63e 100644 --- a/perl-xCAT/xCAT/ProfiledNodeUtils.pm +++ b/perl-xCAT/xCAT/ProfiledNodeUtils.pm @@ -858,6 +858,13 @@ sub check_profile_consistent{ my $arch = $nodetypeentry->{'arch'}; $nodetypetab->close(); + # Get Imageprofile pkgdir + my $osdistroname = $os . "-" . $arch; + my $osdistrotab = xCAT::Table->new('osdistro'); + my $osdistroentry = ($osdistrotab->getAllAttribsWhere("osdistroname = '$osdistroname'", 'ALL' ))[0]; + my $pkgdir = $osdistroentry->{'dirpaths'}; + $osdistrotab->close(); + # Get networkprofile netboot and installnic my $noderestab = xCAT::Table->new('noderes'); my $noderesentry = $noderestab->getNodeAttribs($networkprofile, ['netboot', 'installnic']); @@ -889,6 +896,12 @@ sub check_profile_consistent{ my $nodetype = undef; $nodetype = $ntentry->{'nodetype'} if ($ntentry->{'nodetype'}); $ppctab->close(); + + # Checking whether netboot initrd image for Ubuntu ppc64 + # This image should be downloaded from internet + if ($arch =~ /ppc64/i and $os =~ /ubuntu/i and !(-e "$pkgdir/install/netboot/initrd.gz")){ + return 0, "The netboot initrd is not found in $pkgdir/install/netboot, please download it firstly."; + } # Check if exists provision network if (not ($installnic and exists $netprofile_nicshash{$installnic}{"network"})){ @@ -941,7 +954,7 @@ sub check_profile_consistent{ } return 0, $errmsg; } - + return 1, ""; } @@ -1299,3 +1312,153 @@ sub get_all_vmhosts # Return the ref accordingly return \%vmhostshash; } + +#------------------------------------------------------------------------------- + +=head3 get_netboot_attr + Description : Get netboot attribute for node + Arguments : $imageprofile - image profile name, mandatory. e.g. "__ImageProfile_rhels7.0-x86_64-stateful-mgmtnode" + $hardwareprofile - harware profile name, optional. e.g. "__HardwareProfile_IBM_System_x_M4" + Returns : (returncode, netboot) + returncode=0 - can not get netboot value,netboot is the error message + returncode=1 - can get netboot value,netboot is the right value +=cut + +#------------------------------------------------------------------------------- +sub get_netboot_attr{ + my $class = shift; + my $imageprofile = shift; + my $hardwareprofile = shift; + my $netboot; + + my @nodegrps = xCAT::TableUtils->list_all_node_groups(); + unless(grep{ $_ eq $imageprofile} @nodegrps) + { + return 0, "Image profile not defined in DB." + } + $imageprofile =~ s/^__ImageProfile_//; + + if ($hardwareprofile){ + unless(grep{ $_ eq $hardwareprofile} @nodegrps) + { + return 0, "Hardware profile not defined in DB." + } + $hardwareprofile =~ s/^__HardwareProfile_//; + } + else + { + $hardwareprofile = '*'; + } + + # Get os name, os major version, osarch + my $osimage_tab = xCAT::Table->new('osimage'); + my $osimage_tab_entry = $osimage_tab->getAttribs({'imagename'=> $imageprofile},('osdistroname')); + my $osdistroname = $osimage_tab_entry->{'osdistroname'}; + $osimage_tab->close(); + + my $osdistro_tab = xCAT::Table->new('osdistro'); + my $osdistro_tab_entry = $osdistro_tab->getAttribs({'osdistroname'=> $osdistroname},('basename', 'majorversion', 'arch')); + my $os_name = $osdistro_tab_entry->{'basename'}; + my $os_major_version = $osdistro_tab_entry->{'majorversion'}; + my $os_arch = $osdistro_tab_entry->{'arch'}; + $osdistro_tab->close; + + # Treate os name rhel,centos,rhelhpc same as rhels + if ($os_name eq 'centos' || $os_name eq 'rhelhpc' || $os_name eq 'rhel') + { + $os_name = 'rhels'; + } + # Treate arch ppc64el same as ppc64le,x86 same as x86_64 + if ($os_arch eq 'ppc64el') + { + $os_arch = 'ppc64le'; + }elsif ($os_arch eq 'x86') + { + $os_arch = 'x86_64'; + } + +# 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 | petiboot | +# 5 | | * | * | * | grub2 | +# arch osname version hardware netboot + my %netboot_dict = ( 'x86_64' => 'xnba', + 'ppc64' => { + 'rhels' => { + '7' => 'grub2', + '*' => 'yaboot', + }, + '*' => 'yaboot', + }, + 'ppc64le' => { + '*' => { + '*' => { + 'IBM_PowerNV' => 'petiboot', + '*' => 'grub2', + }, + }, + }, + ); + my $condition_array_ref = [$os_arch, $os_name, $os_major_version, $hardwareprofile]; + $netboot = cal_netboot(\%netboot_dict, $condition_array_ref); + if($netboot eq '0') + { + return 0, "Can not get the netboot attribute"; + } + else + { + return 1, $netboot; + } +} +#------------------------------------------------------------------------------- + +=head3 cal_netboot + Description : Calculate netboot attribute by conditions recursively, internal use. + Arguments : $netboot_dict_ref + $condition_array_ref + Returns : netboot + returncode=0 - can not get netboot value +=cut + +#------------------------------------------------------------------------------- +sub cal_netboot{ + my $netboot_dict_ref = shift; + my $condition_array_ref = shift; + my $condition_array_len = scalar @$condition_array_ref; + + if( $condition_array_len == 0 ){ + return 0; + } + + my $condition = shift $condition_array_ref; + if( (exists($netboot_dict_ref->{$condition})) || (exists($netboot_dict_ref->{'*'})) ) + { + if(!exists($netboot_dict_ref->{$condition})) + { + $condition = '*'; + } + if(ref($netboot_dict_ref->{$condition}) eq 'HASH') + { + if($condition_array_len > 1) + { + return cal_netboot($netboot_dict_ref->{$condition}, $condition_array_ref); + } + else + { + return 0; + } + } + else + { + return $netboot_dict_ref->{$condition}; + } + } + else + { + return 0; + } +} diff --git a/perl-xCAT/xCAT/Schema.pm b/perl-xCAT/xCAT/Schema.pm index 2d5fc97dc..a41d42724 100755 --- a/perl-xCAT/xCAT/Schema.pm +++ b/perl-xCAT/xCAT/Schema.pm @@ -643,7 +643,7 @@ noderes => { descriptions => { node => 'The node name or group name.', servicenode => 'A comma separated list of node names (as known by the management node) that provides most services for this node. The first service node on the list that is accessible will be used. The 2nd node on the list is generally considered to be the backup service node for this node when running commands like snmove.', - netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for POWER architecture, grub2 for RHEL7 on Power. Notice: yaboot is not supported from rhels7 on Power,use grub2 instead', + netboot => 'The type of network booting to use for this node. Valid values: pxe or xnba for x86* architecture, yaboot for POWER architecture, grub2-tftp and grub2-http for RHEL7 on Power and all the os deployment on Power LE. Notice: yaboot is not supported from rhels7 on Power,use grub2-tftp or grub2-http instead, the difference between the 2 is the file transfer protocol(i.e, http or tftp)', tftpserver => 'The TFTP server for this node (as known by this node). If not set, it defaults to networks.tftpserver.', tftpdir => 'The directory that roots this nodes contents from a tftp and related perspective. Used for NAS offload by using different mountpoints.', nfsserver => 'The NFS or HTTP server for this node (as known by this node).', diff --git a/xCAT-server/lib/xcat/plugins/energy.pm b/xCAT-server/lib/xcat/plugins/energy.pm index c17b10371..ab6346b3d 100644 --- a/xCAT-server/lib/xcat/plugins/energy.pm +++ b/xCAT-server/lib/xcat/plugins/energy.pm @@ -630,7 +630,7 @@ sub run_cim my $http_params = shift; my $node = $http_params->{node}; - my @output; + my $output; my $verbose; my $query_list; my $set_pair; @@ -769,37 +769,37 @@ sub run_cim if (defined ($query_pum_value->{PowerUtilizationMode})) { # 2 = None; 3 = Dynamic; 4 = Static; 32768 = Dynamic Favor Performance; 32769 = FFO if ($query_pum_value->{PowerUtilizationMode} eq "2") { - push @output, "$node: $attr: off"; + push @{$output->{$node}}, "$attr: off"; } elsif ($query_pum_value->{PowerUtilizationMode} eq "3") { if ($attr eq "dsavingstatus") { - push @output, "$node: $attr: on-norm"; + push @{$output->{$node}}, "$attr: on-norm"; } else { - push @output, "$node: $attr: off"; + push @{$output->{$node}}, "$attr: off"; } } elsif ($query_pum_value->{PowerUtilizationMode} eq "4") { if ($attr eq "savingstatus") { - push @output, "$node: $attr: on"; + push @{$output->{$node}}, "$attr: on"; } else { - push @output, "$node: $attr: off"; + push @{$output->{$node}}, "$attr: off"; } } elsif ($query_pum_value->{PowerUtilizationMode} eq "32768") { if ($attr eq "dsavingstatus") { - push @output, "$node: $attr: on-maxp"; + push @{$output->{$node}}, "$attr: on-maxp"; } else { - push @output, "$node: $attr: off"; + push @{$output->{$node}}, "$attr: off"; } } elsif ($query_pum_value->{PowerUtilizationMode} eq "32769") { if ($attr eq "fsavingstatus") { - push @output, "$node: $attr: on"; + push @{$output->{$node}}, "$attr: on"; } else { - push @output, "$node: $attr: off"; + push @{$output->{$node}}, "$attr: off"; } } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } @@ -811,20 +811,20 @@ sub run_cim my @ffo_point_value = split (',', $query_pum_value->{FixedFrequencyPointValues}); foreach my $index (0..$#ffo_point) { if ($ffo_point[$index] eq '2' && $attr eq 'ffoNorm') { # Norminal - push @output, "$node: $attr: $ffo_point_value[$index] MHZ"; + push @{$output->{$node}}, "$attr: $ffo_point_value[$index] MHZ"; } elsif ($ffo_point[$index] eq '3' && $attr eq 'ffoTurbo') { # Turbo - push @output, "$node: $attr: $ffo_point_value[$index] MHZ"; + push @{$output->{$node}}, "$attr: $ffo_point_value[$index] MHZ"; } elsif ($ffo_point[$index] eq '4' && $attr eq 'ffoVmin') { # Vmin - push @output, "$node: $attr: $ffo_point_value[$index] MHZ"; + push @{$output->{$node}}, "$attr: $ffo_point_value[$index] MHZ"; } elsif ($ffo_point[$index] eq '5' && $attr eq 'ffoMin') { # Min - push @output, "$node: $attr: $ffo_point_value[$index] MHZ"; + push @{$output->{$node}}, "$attr: $ffo_point_value[$index] MHZ"; } } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } @@ -833,15 +833,15 @@ sub run_cim if ($query_pum_flag) { if (defined ($query_pum_value->{FixedFrequencyOverrideFreq})) { if ($query_pum_value->{FixedFrequencyOverrideFreq} eq '4294967295') { - push @output, "$node: $attr: 0 MHZ"; + push @{$output->{$node}}, "$attr: 0 MHZ"; } else { - push @output, "$node: $attr: $query_pum_value->{FixedFrequencyOverrideFreq} MHZ"; + push @{$output->{$node}}, "$attr: $query_pum_value->{FixedFrequencyOverrideFreq} MHZ"; } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } @@ -850,14 +850,14 @@ sub run_cim if ($attr =~ /^(syssbpower|sysIPLtime)$/) { if ($query_drawer_flag) { if (defined ($query_drawer_value->{AverageTimeToIPL}) && $attr eq "sysIPLtime") { - push @output, "$node: $attr: $query_drawer_value->{AverageTimeToIPL} S"; + push @{$output->{$node}}, "$attr: $query_drawer_value->{AverageTimeToIPL} S"; } elsif (defined ($query_drawer_value->{StandbyPowerUtilization}) && $attr eq "syssbpower") { - push @output, "$node: $attr: $query_drawer_value->{StandbyPowerUtilization} W"; + push @{$output->{$node}}, "$attr: $query_drawer_value->{StandbyPowerUtilization} W"; } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } else { - push @output, "$node: $attr: na"; + push @{$output->{$node}}, "$attr: na"; } } @@ -867,12 +867,12 @@ sub run_cim if ($ins =~ /InletAirTemp/) { my @times = sort keys %{$tmphash->{$ins}->{MetricValue}}; if ($attr eq "ambienttemp") { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} C"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} C"; } else { foreach my $time (@times) { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$time} C: $time"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$time} C: $time"; } } } @@ -883,12 +883,12 @@ sub run_cim if ($ins =~ /ExhaustAirTemp/) { my @times = sort keys %{$tmphash->{$ins}->{MetricValue}}; if ($attr eq "exhausttemp") { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} C"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} C"; } else { foreach my $time (@times) { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$time} C: $time"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$time} C: $time"; } } } @@ -899,12 +899,12 @@ sub run_cim if ($ins =~ /AvgCPUUsage/) { my @times = sort keys %{$tmphash->{$ins}->{MetricValue}}; if ($attr eq "CPUspeed") { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} MHZ"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]}"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$times[-1]} MHZ"; } else { foreach my $time (@times) { - #push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; - push @output, "$node: $attr: $tmphash->{$ins}->{MetricValue}->{$time} MHZ: $time"; + #push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time}: $time"; + push @{$output->{$node}}, "$attr: $tmphash->{$ins}->{MetricValue}->{$time} MHZ: $time"; } } } @@ -915,10 +915,10 @@ sub run_cim if ($ins =~ /FansSpeed/) { my @times = sort keys %{$tmphash->{$ins}->{MetricValue}}; if ($attr eq "fanspeed") { - push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]} RPM"; + push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$times[-1]} RPM"; } else { foreach my $time (@times) { - push @output, "$node: $attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time} RPM: $time"; + push @{$output->{$node}}, "$attr ($tmphash->{$ins}->{MeasuredElementName}): $tmphash->{$ins}->{MetricValue}->{$time} RPM: $time"; } } } @@ -930,10 +930,10 @@ sub run_cim my @times = sort keys %{$tmphash->{$tmpattr}->{MetricValue}}; if ($attr =~ /history$/) { foreach my $time (@times) { - push @output, "$node: $attr: $tmphash->{$tmpattr}->{MetricValue}->{$time} W: $time"; + push @{$output->{$node}}, "$attr: $tmphash->{$tmpattr}->{MetricValue}->{$time} W: $time"; } } else { - push @output, "$node: $attr: $tmphash->{$attr}->{MetricValue}->{$times[-1]} W"; + push @{$output->{$node}}, "$attr: $tmphash->{$attr}->{MetricValue}->{$times[-1]} W"; } } } @@ -979,14 +979,14 @@ sub run_cim }; $ret = xCAT::CIMUtils->set_property($http_params, $cimargs); if ($ret->{rc}) { - push @output, "$node: Set $set_name failed. [$ret->{msg}]"; + push @{$output->{$node}}, "Set $set_name failed. [$ret->{msg}]"; } else { - push @output, "$node: Set $set_name succeeded"; + push @{$output->{$node}}, "Set $set_name succeeded"; } } else { # set the power saving if ($ps_value eq $query_pum_value->{PowerUtilizationMode}) { # do nothing if it already was the correct status - push @output, "$node: Set $set_name succeeded"; + push @{$output->{$node}}, "Set $set_name succeeded"; } else { # perform the setting $cimargs = { @@ -996,29 +996,37 @@ sub run_cim }; $ret = xCAT::CIMUtils->set_property($http_params, $cimargs); if ($ret->{rc}) { - push @output, "$node: Set $set_name failed. [$ret->{msg}]"; + push @{$output->{$node}}, "Set $set_name failed. [$ret->{msg}]"; } else { - push @output, "$node: Set $set_name succeeded"; + push @{$output->{$node}}, "Set $set_name succeeded"; } } } } else { - push @output, "$node: Set $set_name failed"; + push @{$output->{$node}}, "Set $set_name failed"; } } else { - push @output, "$node: Set $set_name failed"; + push @{$output->{$node}}, "Set $set_name failed"; } } } # Display the output - my $rsp; - if ($query_list && $query_list !~ /history/) { - push @{$rsp->{data}}, sort (@output); - } else { - push @{$rsp->{data}}, @output; + foreach my $node (keys (%{$output})) { + my @newoutput; + if ($query_list && $query_list !~ /history/) { + @newoutput = sort (@{$output->{$node}}); + } else { + @newoutput = @{$output->{$node}}; + } + foreach (@newoutput) { + my $rsp; + $rsp->{node}->[0]->{name} = $node; + push @{$rsp->{node}->[0]->{data}->[0]->{contents}}, $_; + + xCAT::MsgUtils->message("N", $rsp, $callback); + } } - xCAT::MsgUtils->message("I", $rsp, $callback); return 0; } diff --git a/xCAT-server/lib/xcat/plugins/grub2.pm b/xCAT-server/lib/xcat/plugins/grub2.pm index dfe5d3cfa..57f91500e 100644 --- a/xCAT-server/lib/xcat/plugins/grub2.pm +++ b/xCAT-server/lib/xcat/plugins/grub2.pm @@ -26,8 +26,10 @@ my %usage = ( "nodeset" => "Usage: nodeset [install|shell|boot|runcmd=bmcsetup|netboot|iscsiboot|osimage[=]|offline]", ); sub handled_commands { + # process noderes:netboot like "grub2-" + # such as grub2-http and grub2-tftp return { - nodeset => "noderes:netboot" + nodeset => "noderes:netboot=(grub2[-]?.*)" } } @@ -189,20 +191,47 @@ sub setstate { } $tftpserverip{$tftpserver} = $serverip; } + + my $grub2protocol="tftp"; + if (defined ($nrhash{$node}->[0]) && $nrhash{$node}->[0]->{'netboot'} + && ($nrhash{$node}->[0]->{'netboot'} =~ /grub2-(.*)/)) { + $grub2protocol = $1; + } + + unless($grub2protocol =~ /^http|tftp$/ ){ + $::callback->( + { + error => [ + "Invalid netboot method, please check noderes.netboot for $node" + ], + errorcode => [1] + } + ); + return; + } + + print $pcfg "set default=\"xCAT OS Deployment\"\n"; print $pcfg "menuentry \"xCAT OS Deployment\" {\n"; print $pcfg " insmod http\n"; print $pcfg " insmod tftp\n"; - print $pcfg " set root=http,$serverip\n"; + print $pcfg " set root=$grub2protocol,$serverip\n"; print $pcfg " echo Loading Install kernel ...\n"; + + my $protocolrootdir=""; + if($grub2protocol =~ /^http$/) + { + $protocolrootdir=$tftpdir; + } + if ($kern and $kern->{kcmdline}) { - print $pcfg " linux $tftpdir/$kern->{kernel} $kern->{kcmdline}\n"; + print $pcfg " linux $protocolrootdir/$kern->{kernel} $kern->{kcmdline}\n"; } else { - print $pcfg " linux $tftpdir/$kern->{kernel}\n"; + print $pcfg " linux $protocolrootdir/$kern->{kernel}\n"; } print $pcfg " echo Loading initial ramdisk ...\n"; if ($kern and $kern->{initrd}) { - print $pcfg " initrd $tftpdir/$kern->{initrd}\n"; + print $pcfg " initrd $protocolrootdir/$kern->{initrd}\n"; } print $pcfg "}"; @@ -457,7 +486,7 @@ sub process_request { my $mactab=xCAT::Table->new('mac',-create=>1); my $machash=$mactab->getNodesAttribs(\@nodes,['mac']); my $nrtab=xCAT::Table->new('noderes',-create=>1); - my $nrhash=$nrtab->getNodesAttribs(\@nodes,['servicenode','tftpserver','xcatmaster']); + my $nrhash=$nrtab->getNodesAttribs(\@nodes,['servicenode','tftpserver','xcatmaster','netboot']); my $typetab=xCAT::Table->new('nodetype',-create=>1); my $typehash=$typetab->getNodesAttribs(\@nodes,['os','provmethod','arch','profile']); my $linuximgtab=xCAT::Table->new('linuximage',-create=>1); diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index 33544a373..d674c4c4a 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -45,6 +45,7 @@ my %all_switchports; my %allvmhosts; my @switch_records; +my $netboot; # The array of all chassis which is special CMM my %allcmmchassis; @@ -381,6 +382,13 @@ Usage: setrsp_errormsg($errmsg); return; } + # Get the netboot attribute for node + my ($retcode, $retval) = xCAT::ProfiledNodeUtils->get_netboot_attr($imageprofile, $hardwareprofile); + if (not $retcode) { + setrsp_errormsg($retval); + return; + } + $netboot = $retval; # Get database records: all hostnames, all ips, all racks... xCAT::MsgUtils->message('S', "Getting database records."); @@ -767,6 +775,7 @@ Usage: my $nodelstab = xCAT::Table->new('nodelist'); my $nodeshashref = $nodelstab->getNodesAttribs($nodes, ['groups']); my %updatenodeshash; + my %updatenodereshash; my %nodeoldprofiles = (); foreach (@$nodes){ @@ -870,18 +879,27 @@ 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; - } + $updatenodereshash{$_}{'netboot'} = $new_netboot; + } #update DataBase. setrsp_progress("Updating database records..."); my $nodetab = xCAT::Table->new('nodelist',-create=>1); $nodetab->setNodesAttribs(\%updatenodeshash); $nodetab->close(); - + my $noderestab = xCAT::Table->new('noderes',-create=>1); + $noderestab->setNodesAttribs(\%updatenodereshash); + $noderestab->close(); #update node's status: if($profile_status eq "defined"){ xCAT::Utils->runxcmd({command=>["updatenodestat"], node=>$nodes, arg=>['defined']}, $request_command, -1, 2); @@ -1778,6 +1796,16 @@ sub findme{ } } } + my $imageprofile = $args_dict{'imageprofile'}; + my $networkprofile = $args_dict{'networkprofile'}; + my $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; + } + $netboot = $retval; # Get database records: all hostnames, all ips, all racks... # To improve performance, we should initalize a daemon later?? @@ -2108,11 +2136,8 @@ 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'; - } + # Set netboot attribute for node + $hostinfo_dict{$item}{"netboot"} = $netboot; # get the chain attribute from hardwareprofile and insert it to node. my $chaintab = xCAT::Table->new('chain'); diff --git a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle index e69cdebbf..271cbda5a 100644 --- a/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle +++ b/xCAT-test/autotest/bundle/x_ubuntu_cmd.bundle @@ -199,3 +199,57 @@ copycds_a copycds_n_a copycds_a_err copycds_n_err +addkit_v +addkit_h +addkit_kit +addkit_i +addkit_multikit +addkit_p +addkitcomp_v +addkitcomp_h +addkitcomp_i +addkitcomp_f +addkitcomp_a +addkitcomp_noscripts +buildkit_v +buildkit_h +buildkit_create +buildkit_create_l +buildkit_buildrepo_all +buildkit_buildrepo_ubuntu +buildkit_cleanrepo_all +buildkit_cleanrepo_ubuntu +buildkit_listrepo +buildkit_buildtar +buildkit_cleantar +buildkit_partialkit_ubuntu +buildkit_partialkit_completekit +chkkitcomp_v +chkkitcomp_h +chkkitcomp_V +lskit_v +lskit_h +lskit_F +lskit_K +lskit_R +lskit_C +lskitcomp_v +lskitcomp_h +lskitcomp_C +lskitcomp_C +lskitcomp_S +lskitdeployparam_v +lskitdeployparam_h +lskitdeployparam_no_param +lskitdeployparam_k_1 +lskitdeployparam_c_1 +rmkit_v +rmkit_h +rmkit_t_no +rmkit_t_yes +rmkit_f +rmkit_V +rmkitcomp_v +rmkitcomp_h +rmkitcomp_noscripts +rmkitcomp_f