From 1f8574c8fcafb86e0e52d0583b7bb558f6e7f46c Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Thu, 29 May 2014 11:02:03 +0800 Subject: [PATCH 1/7] support fuzzy matching mode in cfmsync --- perl-xCAT/xCAT/CFMUtils.pm | 127 ++++++++++++++++++++++++++++++++++++- 1 file changed, 125 insertions(+), 2 deletions(-) diff --git a/perl-xCAT/xCAT/CFMUtils.pm b/perl-xCAT/xCAT/CFMUtils.pm index 987cb0d65..314d3c4b9 100644 --- a/perl-xCAT/xCAT/CFMUtils.pm +++ b/perl-xCAT/xCAT/CFMUtils.pm @@ -500,6 +500,7 @@ sub setCFMPkglistFile { Arguments: $imagename - the specified linuximage name @curospkgs - the currently selected OS packages list + $mode - using Fuzzy Matching or Exact Matching to check packages Returns: 0 - update successfully 1 - update failed @@ -509,13 +510,22 @@ sub setCFMPkglistFile { none Example: my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs); + my $ret = CAT::CFMUtils->updateCFMPkglistFile($imagename, @cur_selected_pkgs, 1); =cut #----------------------------------------------------------------------------- sub updateCFMPkglistFile { - my ($class, $img, $ospkgs) = @_; - + my ($class, $img, $ospkgs, $mode) = @_; + + if(defined($mode)){ + # Exact Matching + $mode = 1; + }else { + # Fuzzy Matching + $mode = 0; + } + my @cur_selected = @$ospkgs; my $cfmpkglist = "/install/osimages/$img/pkglist.cfm"; @@ -549,6 +559,14 @@ sub updateCFMPkglistFile { my @selected = @$selected_ref; @basepkgs = xCAT::CFMUtils->arrayops("U", \@basepkgs, \@selected); } + + # Fuzzy Matching + if (not $mode){ + my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->updateSelectedPkgs(\@pre_selected, \@pre_removed, \@cur_selected); + @pre_selected = @$ref1; + @pre_removed = @$ref2; + @cur_selected = @$ref3; + } # get diff between previous and current selected OS packages lists my @diff = xCAT::CFMUtils->getPkgsDiff(\@pre_selected, \@cur_selected); @@ -661,6 +679,48 @@ sub getPreOSpkgsList { return (\@selected, \@removed); } +#----------------------------------------------------------------------------- + +=head3 getPreBaseOSpkgsList + Get previously selected and removed base OS packages lists from pkglist file. Packages named with "example.xxx" should be the base name "example" + + Arguments: + $ospkglist - the path for ospkglist file + Returns: + refs for selected and removed OS packages arrays + Globals: + none + Error: + none + Example: + my $pre_selected_ref = xCAT::CFMUtils->getPreOSpkgsList($ospkglist); + +=cut + +#----------------------------------------------------------------------------- +sub getPreBaseOSpkgsList { + my ($class, $pkglist) = @_; + + my ($pre_selected_ref, $pre_removed_ref) = xCAT::CFMUtils->getPreOSpkgsList($pkglist); + + my %pre_selected_hash = (); + foreach (@$pre_selected_ref) { + my @names = split(/\./, $_); + my $basename = $names[0]; + + if ($_ =~ /^$basename\.([^\.]+)$/) { + $pre_selected_hash{$basename} = 1; + }else { + $pre_selected_hash{$_} = 1; + } + } + + @pre_selected = keys %pre_selected_hash; + + return \@pre_selected; +} + + #----------------------------------------------------------------------------- =head3 getPkgsDiff @@ -819,3 +879,66 @@ sub arrayops { #return (\@union, \@intersection, \@difference); } + + +#----------------------------------------------------------------------------- + +=head3 updateSelectedPkgs + Update previous selected, previous removed and current selected packages based on fuzzy matching rules. Packages named with "example.i686" should be same with package "example" + + Arguments: + \@pre_selected - reference to previous selected packages + \@pre_removed - reference to previous removed packages + \@cur_selected - reference to current selected packages + Returns: + new previous selected, previous removed, current selected packages + Globals: + none + Error: + none + Example: + my ($ref1, $ref2, $ref3) = xCAT::CFMUtils->arrayops(\@pre_selected, \@pre_removed, \@cur_selected); + +=cut + +#----------------------------------------------------------------------------- +sub updateSelectedPkgs() { + my ($class, $pre_selected_ref, $pre_removed_ref, $cur_selected_ref) = @_; + + my %pre_selected_hash = map{$_ => 1} @$pre_selected_ref; + my %pre_removed_hash = map{$_ => 1} @$pre_removed_ref; + my %cur_selected_hash = map{$_ => 1} @$cur_selected_ref; + + my %new_pre_selected_hash = %pre_selected_hash; + my %new_pre_removed_hash = %pre_removed_hash; + my %new_cur_selected_hash = %cur_selected_hash; + + foreach (keys %cur_selected_hash) { + my $father = $_; + my $flag = 0; + foreach (keys %pre_selected_hash) { + my $child = $_; + if ($child =~ /^$father\.([^\.]+)$/) { + $new_cur_selected_hash{$child} = 1; + $flag = 1; + } + } + if ($flag and not exists $pre_selected_hash{$father}){ + delete $new_cur_selected_hash{$father} if exists $new_cur_selected_hash{$father}; + } + + foreach (keys %pre_removed_hash) { + my $child = $_; + if ($child =~ /^$father\.([^\.]+)$/) { + delete $new_pre_removed_hash{$child} if exists $new_pre_removed_hash{$child}; + } + } + } + + my @new_cur_selected = keys %new_cur_selected_hash; + my @new_pre_selected = keys %new_pre_selected_hash; + my @new_pre_removed = keys %new_pre_removed_hash; + + + return (\@new_pre_selected, \@new_pre_removed, \@new_cur_selected); +} From 37ceb9fc132b72692309d848496e42588efc84c8 Mon Sep 17 00:00:00 2001 From: Jia Zhao Date: Thu, 29 May 2014 14:02:45 +0800 Subject: [PATCH 2/7] not regenerate ips for BMC/FSP NIC in pcm --- xCAT-server/lib/xcat/plugins/profilednodes.pm | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/profilednodes.pm b/xCAT-server/lib/xcat/plugins/profilednodes.pm index ae1a88826..4991a6fd7 100644 --- a/xCAT-server/lib/xcat/plugins/profilednodes.pm +++ b/xCAT-server/lib/xcat/plugins/profilednodes.pm @@ -771,10 +771,30 @@ Usage: } # If network profile specified. Need re-generate IPs for all nodess again. + # As new design, ignore BMC/FSP NIC while reinstall nodes if(exists $args_dict{'networkprofile'}){ + my $newNetProfileName = $args_dict{'networkprofile'}; + my $oldNetProfileName = $nodeoldprofiles{'networkprofile'}; + + my $newNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$newNetProfileName])->{$newNetProfileName}; + my $oldNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$oldNetProfileName])->{$oldNetProfileName}; + + my %updateNicsHash = (); + foreach my $newNic (keys %$newNicsRef) { + if ($newNicsRef->{$newNic}->{'type'} ne 'BMC' and $newNicsRef->{$newNic}->{'type'} ne 'FSP'){ + $updateNicsHash{$newNic} = 1; + } + } + foreach my $oldNic (keys %$oldNicsRef) { + if ($oldNicsRef->{$oldNic}->{'type'} ne 'BMC' and $oldNicsRef->{$oldNic}->{'type'} ne 'FSP'){ + $updateNicsHash{$oldNic} = 1; + } + } + + my $updateNics = join(",", keys %updateNicsHash); setrsp_progress("Regenerate IP addresses for nodes..."); $retref = ""; - $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, sequential=>[1]}, $request_command, 0, 2); + $retref = xCAT::Utils->runxcmd({command=>["noderegenips"], node=>$nodes, arg=>["nics=$updateNics"], sequential=>[1]}, $request_command, 0, 2); $retstrref = parse_runxcmd_ret($retref); if ($::RUNCMD_RC != 0){ setrsp_progress("Warning: failed to generate IPs for nodes."); @@ -843,6 +863,7 @@ Usage: $netProfileNicsRef = xCAT::ProfiledNodeUtils->get_nodes_nic_attrs([$netProfileName]); my $nicsref = $netProfileNicsRef->{$netProfileName}; my @nicslist = keys %$nicsref; + #3. validate specified nics if(exists $args_dict{'nics'}){ @updateNics = split(",", $args_dict{'nics'}); @@ -910,7 +931,9 @@ Usage: unless (grep {$_ eq $nicname} @updateNics){ # if the nic not specified, just keep the old IP&NIC record in nics table. my $oldip = $nodesNicsRef->{$node}->{$nicname}->{"ip"}; - $nicipsAttr{$node}{nicips} .= $nicname."!".$oldip.","; + if ($oldip) { + $nicipsAttr{$node}{nicips} .= $nicname."!".$oldip.","; + } }else{ my $ipsref = $freeIPsHash{$nicname}; my $nextip = shift @$ipsref; @@ -932,7 +955,7 @@ Usage: } } } - + #8. Update database. setrsp_progress("Updating database records..."); my $nicstab = xCAT::Table->new('nics',-create=>1); From b6658bd232abcd354f0bd80db98809acbfa86c7b Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 01:30:42 -0700 Subject: [PATCH 3/7] fix defect #4145 [DEV] /etc/httpd/conf.d/xcat.conf is missing after xcat upgrade --- xCAT/xCAT.spec | 38 ++++++++++++++------------------------ 1 file changed, 14 insertions(+), 24 deletions(-) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 3838d7268..44d60be69 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -116,6 +116,7 @@ fi %install +mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d mkdir -p $RPM_BUILD_ROOT/install/postscripts @@ -152,10 +153,9 @@ chmod 755 $RPM_BUILD_ROOT/install/postscripts/* rm LICENSE.html mkdir -p postscripts/hostkeys cd - -cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach22 -cp %{SOURCE7} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf.apach24 -cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach22 -cp %{SOURCE7} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf.apach24 +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf +cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -168,23 +168,15 @@ cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] then rm -rf /etc/httpd/conf.d/xcat.conf - cp /etc/httpd/conf.d/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf -elif [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] -then - rm -rf /etc/apache2/conf.d/xcat.conf - cp /etc/apache2/conf.d/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf -else - rm -rf /etc/httpd/conf.d/xcat.conf - cp /etc/httpd/conf.d/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf - - rm -rf /etc/apache2/conf.d/xcat.conf - cp /etc/apache2/conf.d/xcat.conf.apach22 /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf +fi + +if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf fi -rm -rf /etc/apache2/conf.d/xcat.conf.apach22 -rm -rf /etc/apache2/conf.d/xcat.conf.apach24 -rm -rf /etc/httpd/conf.d/xcat.conf.apach22 -rm -rf /etc/httpd/conf.d/xcat.conf.apach24 %endif @@ -220,11 +212,9 @@ exit 0 %files %{prefix} # one for sles, one for rhel. yes, it's ugly... -/etc/apache2/conf.d/xcat.conf.apach22 -/etc/apache2/conf.d/xcat.conf.apach24 -/etc/httpd/conf.d/xcat.conf.apach22 -/etc/httpd/conf.d/xcat.conf.apach24 - +/etc/xcat/conf.orig/xcat.conf.apach24 +/etc/httpd/conf.d/xcat.conf +/etc/apache2/conf.d/xcat.conf /etc/xCATMN /install/postscripts /install/prescripts From 92aedad72732821bfba97b6da8407fb2605f3328 Mon Sep 17 00:00:00 2001 From: daniceexi Date: Thu, 29 May 2014 07:29:24 -0400 Subject: [PATCH 4/7] defect 4144: to allow the recursion call for local named that the dns resolve request from other network is also allowed --- xCAT-server/lib/xcat/plugins/ddns.pm | 1 + 1 file changed, 1 insertion(+) diff --git a/xCAT-server/lib/xcat/plugins/ddns.pm b/xCAT-server/lib/xcat/plugins/ddns.pm index 5d7f90473..ddda1a6a8 100755 --- a/xCAT-server/lib/xcat/plugins/ddns.pm +++ b/xCAT-server/lib/xcat/plugins/ddns.pm @@ -1009,6 +1009,7 @@ sub update_namedconf { push @newnamed,"options {\n"; unless ($slave && xCAT::Utils->isLinux()) { push @newnamed,"\tdirectory \"".$ctx->{zonesdir}."\";\n"; + push @newnamed, "\tallow-recursion { any; };\n"; } push @newnamed,"\t\t//listen-on-v6 { any; };\n"; if ($ctx->{forwarders}) { From c976cb43a17b38e630bebfa21424738b9f186bdd Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 02:52:35 -0700 Subject: [PATCH 5/7] correct xCATsn.spec to support apache2/httpd 2.4.x --- xCATsn/xCATsn.spec | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/xCATsn/xCATsn.spec b/xCATsn/xCATsn.spec index 2e514c536..0fd02f9f0 100644 --- a/xCATsn/xCATsn.spec +++ b/xCATsn/xCATsn.spec @@ -15,6 +15,7 @@ Source1: xcat.conf Source2: license.tar.gz Source3: xCATSN Source5: templates.tar.gz +Source6: xcat.conf.apach24 Provides: xCATsn = %{version} Requires: xCAT-server xCAT-client perl-DBD-SQLite @@ -80,6 +81,7 @@ tar -xf license.tar %install %ifos linux +mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d/ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/ @@ -87,6 +89,8 @@ mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/xcat/ cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf cp %{SOURCE3} $RPM_BUILD_ROOT/etc/xCATSN +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22 +cp %{SOURCE6} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT cp LICENSE.html $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -122,6 +126,23 @@ fi %endif %post +%ifos linux +#Apply the correct httpd/apache configuration file according to the httpd/apache version +if [ -n "$(httpd -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/httpd/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/httpd/conf.d/xcat.conf +fi + +if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat.conf + cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf +fi + + +%endif + # create dir for the current pid and move the original ones from /tmp/xcat to /var/run/xcat mkdir -p /var/run/xcat if [ -r "/tmp/xcat/installservice.pid" ]; then @@ -161,7 +182,6 @@ if [ -e "/etc/redhat-release" ]; then else # SuSE apachedaemon='apache2' fi - # start xcatd on linux chkconfig $apachedaemon on if [ -f "/proc/cmdline" ]; then # prevent running it during install into chroot image @@ -199,6 +219,8 @@ fi %{prefix} # one for sles, one for rhel. yes, it's ugly... %ifos linux +/etc/xcat/conf.orig/xcat.conf.apach24 +/etc/xcat/conf.orig/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf /etc/apache2/conf.d/xcat.conf %endif From a292d019d6f87cbdb016193030188c57fc45260a Mon Sep 17 00:00:00 2001 From: immarvin Date: Thu, 29 May 2014 03:41:04 -0700 Subject: [PATCH 6/7] backup xcat.conf.apach22 in /etc/xcat/conf.orig/ --- xCAT/xCAT.spec | 2 ++ 1 file changed, 2 insertions(+) diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index 44d60be69..893f04996 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -156,6 +156,7 @@ cd - cp %{SOURCE1} $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat.conf cp %{SOURCE1} $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat.conf cp %{SOURCE7} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach24 +cp %{SOURCE1} $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat.conf.apach22 cp %{SOURCE5} $RPM_BUILD_ROOT/etc/xCATMN mkdir -p $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT @@ -213,6 +214,7 @@ exit 0 %{prefix} # one for sles, one for rhel. yes, it's ugly... /etc/xcat/conf.orig/xcat.conf.apach24 +/etc/xcat/conf.orig/xcat.conf.apach22 /etc/httpd/conf.d/xcat.conf /etc/apache2/conf.d/xcat.conf /etc/xCATMN From db70dcfaa37067a87fade809e2fdbd30786cd1be Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Thu, 29 May 2014 10:32:02 -0400 Subject: [PATCH 7/7] Fix output that occurs on require xCAT::Client when ip is not in path --- perl-xCAT/xCAT/Client.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/perl-xCAT/xCAT/Client.pm b/perl-xCAT/xCAT/Client.pm index 66b4374c7..e604c45a0 100644 --- a/perl-xCAT/xCAT/Client.pm +++ b/perl-xCAT/xCAT/Client.pm @@ -27,7 +27,7 @@ if ($inet6support) { if ($^O =~ /^linux/i) { # Is IPv6 enabled on the MN or xcat client node at all? - my $ipv6enabled = `ip addr | grep inet6`; + my $ipv6enabled = `ip addr 2> /dev/null | grep inet6`; if (!$ipv6enabled) { $inet6support = 0; }