diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index e3e96804b..72a9a2c83 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2776,7 +2776,9 @@ sub rmkitcomp if ( !$match ) { if ( $debianflag ) { - system("umount -f $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}"); + #Now we do not use moun --bind for kitrepo dir to otherpkgdir + #leave this line is support old way when using mount + system("umount -f $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame} > /dev/null"); } system("rm -rf $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}"); } @@ -3249,6 +3251,60 @@ sub rmkitcomp # Write osimage table with all the above udpates. $tabs{osimage}->setAttribs({imagename => $osimage }, \%{$osimagetable} ); + #After all the data updated in osimage and linuximage table + #check if these kitcomponents are assigned to other osimage + #if these kitcomponents are not used by other osimage, find their kitrepo and kitrepo directory under otherpkg dir + #delete these kitrepo + my @allosikitcomps = $tabs{osimage}->getAllAttribs( 'imagename', 'kitcomponents' ); + + (my $linuximagetable) = $tabs{linuximage}->getAttribs({imagename=> $osimage}, 'postinstall', 'exlist', 'otherpkglist', 'otherpkgdir', 'driverupdatesrc'); + if ( $linuximagetable and $linuximagetable->{otherpkgdir} ) { + + my $otherpkgdir = $linuximagetable->{otherpkgdir}; + foreach my $kitcomponent (keys %kitcomps) { + + my %newosikitcomponents; + foreach my $allosikitcomp (@allosikitcomps) { + if ( $allosikitcomp->{kitcomponents} and $allosikitcomp->{imagename} ) { + my @allkitcomps = split /,/, $allosikitcomp->{kitcomponents}; + foreach my $allkitcomp ( @allkitcomps ) { + if ( $allosikitcomp->{imagename} ne $osimage or $allkitcomp ne $kitcomponent ) { + $newosikitcomponents{$allkitcomp} = 1; + } + } + } + } + + if ( $kitcomps{$kitcomponent}{kitreponame} ) { + if ( -d "$otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}" ) { + + # Check if this repo is used by other kitcomponent before removing the link + my $match = 0; + foreach my $osikitcomp ( keys %newosikitcomponents ) { + + my $depkitrepodir; + (my $kitcomptable) = $tabs{kitcomponent}->getAttribs({kitcompname => $osikitcomp}, 'kitreponame'); + if ( $kitcomptable and $kitcomptable->{kitreponame} ) { + $depkitrepodir = "$otherpkgdir/$kitcomptable->{kitreponame}"; + } + if ( $depkitrepodir =~ /^$otherpkgdir\/$kitcomps{$kitcomponent}{kitreponame}$/) { + $match = 1; + } + } + if ( !$match ) { + if ( $debianflag ) + { + system("umount -f $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame} > /dev/null"); + } + system("rm -rf $otherpkgdir/$kitcomps{$kitcomponent}{kitreponame}"); + } + } + } + } + } + + + return; } @@ -4200,6 +4256,8 @@ sub lskit { my $kitrepo_hash = get_kitrepo_hash($::kitnames, $::kitrepoattrs); my $kitcomp_hash = get_kitcomp_hash($::kitnames, $::kitcompattrs); + + # Now display the output my @kitnames = keys(%$kit_hash); if (scalar @kitnames == 0) { @@ -4209,15 +4267,204 @@ sub lskit { return 0; } - if (defined($::opt_x)) { - create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); - } else { - create_lskit_stanza_response($kit_hash, $kitrepo_hash, $kitcomp_hash); + #lskit use options + if ( defined($::opt_K) || defined($::opt_R) || defined($::opt_C) ) { + + if ( ! defined($::opt_x)) { + if ( defined($::opt_K) ){ + lskit_K($kit_hash); + } + + # Option -R for kit repo attributes + if ( defined($::opt_R) ) { + my @kitrepos = keys(%$kitrepo_hash); + if (scalar @kitrepos == 0) { + my $rsp = {}; + push @{ $rsp->{data} }, "No kit repos were found."; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + return 0; + } + lskit_R($kit_hash,$kitrepo_hash); + } + + if ( defined($::opt_C) ) { + my @kitcomplist = keys(%$kitcomp_hash); + if (scalar @kitcomplist == 0) { + my $rsp = {}; + push @{ $rsp->{data} }, "No kit components were found."; + xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); + return 0; + } + lskit_C($kit_hash,$kitcomp_hash); + } + }else + { + #To support xml format + if (defined($::opt_K)) { + create_lskit_K_xml_response($kit_hash); + } + if (defined($::opt_R)) { + create_lskit_R_xml_response($kit_hash,$kitrepo_hash); + } + if (defined($::opt_C)) { + create_lskit_C_xml_response($kit_hash,$kitcomp_hash); + } + } + } + else + { + #lskit use no options + if (defined($::opt_x)) { + create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); + } else { + create_lskit_stanza_response($kit_hash, $kitrepo_hash, $kitcomp_hash); + } } return 0; } +#---------------------------------------------------------------------------- + +=head3 lskit_R + + Support for listing kit repo + + Arguments: + Returns: + 0 - OK + 1 - help + 2 - error +=cut + +#----------------------------------------------------------------------------- + +sub lskit_R { + + my $kit_hash = shift; + my $kitrepo_hash = shift; + my $rsp = {}; + my $count = 0; + + + for my $kitname (sort(keys(%$kit_hash))) { + + my $output .= "\nkit : $kitname\n----------------------------------------------------\n"; + + + # Kit repository info + if (defined($kitrepo_hash->{$kitname})) { + for my $kitrepo (@{$kitrepo_hash->{$kitname}}) { + $output .= "kitrepo:\n"; + for my $kitrepo_attr (sort(keys(%$kitrepo))) { + $output .= sprintf(" %s=%s\n", $kitrepo_attr, $kitrepo->{$kitrepo_attr}); + } + $output .= "\n"; + } + } + + push @{ $rsp->{data} }, $output; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); + + +} + + +#---------------------------------------------------------------------------- + +=head3 lskit_K + + Support for listing kit + + Arguments: + Returns: + 0 - OK + 1 - help + 2 - error +=cut + +#----------------------------------------------------------------------------- + +sub lskit_K { + + my $kit_hash = shift; + my $rsp = {}; + my $count = 0; + + + for my $kitname (sort(keys(%$kit_hash))) { + + my $output .= "\nkit : $kitname\n----------------------------------------------------\n"; + # Kit info + if (defined($kit_hash->{$kitname})) { + my $kit = $kit_hash->{$kitname}->[0]; + $output .= "kit:\n"; + for my $kit_attr (sort(keys(%$kit))) { + $output .= sprintf(" %s=%s\n", $kit_attr, $kit->{$kit_attr}); + } + $output .= "\n"; + } + + + push @{ $rsp->{data} }, $output; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); + + +} + +#---------------------------------------------------------------------------- + +=head3 lskit_C + + Support for listing kitcomponent + + Arguments: + Returns: + 0 - OK + 1 - help + 2 - error +=cut + +#----------------------------------------------------------------------------- + +sub lskit_C { + + my $kit_hash = shift; + my $kitcomp_hash = shift; + my $rsp = {}; + my $count = 0; + + + for my $kitname (sort(keys(%$kit_hash))) { + + my $output .= "\nkit : $kitname\n----------------------------------------------------\n"; + + + # Kit component info + if (defined($kitcomp_hash->{$kitname})) { + for my $kitcomp (@{$kitcomp_hash->{$kitname}}) { + $output .= "kitcomponent:\n"; + for my $kitcomp_attr (sort(keys(%$kitcomp))) { + $output .= sprintf(" %s=%s\n", $kitcomp_attr, $kitcomp->{$kitcomp_attr}); + } + $output .= "\n"; + } + } + + + push @{ $rsp->{data} }, $output; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); + + +} + + #---------------------------------------------------------------------------- =head3 lskitcomp @@ -4880,6 +5127,122 @@ sub create_lskit_xml_response { } +#---------------------------------------------------------------------------- + +=head3 create_lskit_K_xml_response + + Prepare a response that returns the kit info in XML format. + + Arguments: + kit hash table + + Note: Hash tables are created by create_hash_from_table_rows() +=cut + +#----------------------------------------------------------------------------- + +sub create_lskit_K_xml_response { + + my $kit_hash = shift; + + my $rsp = {}; + + for my $kitname (sort(keys(%$kit_hash))) { + my $output_hash = {"kitinfo" => {"kit" => [], "kitrepo" => [], "kitcomponent" => [] } }; + + # Kit info + if (defined($kit_hash->{$kitname})) { + my $kit = $kit_hash->{$kitname}->[0]; + push(@{$output_hash->{kitinfo}->{kit}}, $kit); + } + + push @{ $rsp->{data} }, $output_hash; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); +} + +#---------------------------------------------------------------------------- + +=head3 create_lskit_R_xml_response + + Prepare a response that returns the kit repository + info in XML format. + + Arguments: + kit repo hash table + + Note: Hash tables are created by create_hash_from_table_rows() +=cut + +#----------------------------------------------------------------------------- + +sub create_lskit_R_xml_response { + + my $kit_hash = shift; + my $kitrepo_hash = shift; + + my $rsp = {}; + + for my $kitname (sort(keys(%$kit_hash))) { + my $output_hash = {"kitinfo" => {"kit" => [], "kitrepo" => [], "kitcomponent" => [] } }; + + # Kit repository info + if (defined($kitrepo_hash->{$kitname})) { + for my $kitrepo (@{$kitrepo_hash->{$kitname}}) { + push(@{$output_hash->{kitinfo}->{kitrepo}}, $kitrepo); + } + } + + push @{ $rsp->{data} }, $output_hash; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); +} + + +#---------------------------------------------------------------------------- + +=head3 create_lskit_C_xml_response + + Prepare a response that returns the + kit component info in XML format. + + Arguments: + kit hash table + kit component hash table + + Note: Hash tables are created by create_hash_from_table_rows() +=cut + +#----------------------------------------------------------------------------- + +sub create_lskit_C_xml_response { + + my $kit_hash = shift; + my $kitcomp_hash = shift; + + my $rsp = {}; + + for my $kitname (sort(keys(%$kit_hash))) { + my $output_hash = {"kitinfo" => {"kit" => [], "kitrepo" => [], "kitcomponent" => [] } }; + + + # Kit component info + if (defined($kitcomp_hash->{$kitname})) { + for my $kitcomp (@{$kitcomp_hash->{$kitname}}) { + push(@{$output_hash->{kitinfo}->{kitcomp}}, $kitcomp); + } + } + + push @{ $rsp->{data} }, $output_hash; + } + + xCAT::MsgUtils->message("D", $rsp, $::CALLBACK); +} + + + #---------------------------------------------------------------------------- =head3 create_lskit_stanza_response diff --git a/xCAT-server/xCAT-server.spec b/xCAT-server/xCAT-server.spec index 810109b66..7320448a2 100644 --- a/xCAT-server/xCAT-server.spec +++ b/xCAT-server/xCAT-server.spec @@ -328,6 +328,8 @@ chmod 644 $RPM_BUILD_ROOT/%{prefix}/share/doc/packages/xCAT-server/* mkdir -p $RPM_BUILD_ROOT/%{prefix}/ws mkdir -p $RPM_BUILD_ROOT/etc/apache2/conf.d mkdir -p $RPM_BUILD_ROOT/etc/httpd/conf.d +mkdir -p $RPM_BUILD_ROOT/etc/xcat/conf.orig + cp xCAT-wsapi/* $RPM_BUILD_ROOT/%{prefix}/ws # PCM does not need xcatws.cgi @@ -338,20 +340,24 @@ rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcatws.cgi %if %fsm %else -echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf +echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 +echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24 %if %notpcm -echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf +echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 +echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24 %endif -cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache2 >> $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf -echo "ScriptAlias /xcatrhevh %{prefix}/ws/xcatrhevh.cgi" > $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf -%if %notpcm -echo "ScriptAlias /xcatws %{prefix}/ws/xcatws.cgi" >> $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf +cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache22 >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 +cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache24 >> $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache24 +#install lower version(<2.4) apache/httpd conf files by default +cp $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/apache2/conf.d/xcat-ws.conf +cp $RPM_BUILD_ROOT/etc/xcat/conf.orig/xcat-ws.conf.apache22 $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf %endif -cat $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.httpd >> $RPM_BUILD_ROOT/etc/httpd/conf.d/xcat-ws.conf -%endif -rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache2 -rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.httpd + + + +rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache22 +rm -f $RPM_BUILD_ROOT/%{prefix}/ws/xcat-ws.conf.apache24 %clean rm -rf $RPM_BUILD_ROOT @@ -364,6 +370,8 @@ rm -rf $RPM_BUILD_ROOT %if %fsm %else /etc/init.d/xcatd +#/etc/xcat/conf.orig/xcat-ws.conf.apache24 +#/etc/xcat/conf.orig/xcat-ws.conf.apache22 /etc/apache2/conf.d/xcat-ws.conf /etc/httpd/conf.d/xcat-ws.conf %endif @@ -409,8 +417,8 @@ fi if [ "$1" -gt "1" ]; then #only on upgrade... #migration issue for monitoring XCATROOT=$RPM_INSTALL_PREFIX0 $RPM_INSTALL_PREFIX0/sbin/chtab filename=monitorctrl.pm notification -d - fi + %else if [ "$1" -gt "1" ]; then #only on upgrade for AIX... #migration issue for monitoring @@ -420,6 +428,26 @@ fi %endif +#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-ws.conf + cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/httpd/conf.d/xcat-ws.conf +fi + +if [ -n "$(apachectl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat-ws.conf + cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf +fi + +if [ -n "$(apache2ctl -v 2>&1 |grep -e '^Server version\s*:.*\/2.4')" ] +then + rm -rf /etc/apache2/conf.d/xcat-ws.conf + cp /etc/xcat/conf.orig/xcat-ws.conf.apache24 /etc/apache2/conf.d/xcat-ws.conf +fi + + exit 0 %preun @@ -435,8 +463,6 @@ if [ $1 == 0 ]; then #This means only on -e fi rm -f /usr/sbin/xcatd #remove the symbolic - rm -f /etc/httpd/conf.d/xcat-ws.conf - rm -f /etc/httpd/conf.d/xcat-ws.conf fi %endif diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2 b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 similarity index 100% rename from xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2 rename to xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 similarity index 52% rename from xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd rename to xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 index 921735e12..b10ccf224 100644 --- a/xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd +++ b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 @@ -1,4 +1,10 @@ +LoadModule rewrite_module /usr/lib64/apache2-prefork/mod_rewrite.so RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteCond %{REQUEST_URI} xcatws RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L] + + +Require all granted + + diff --git a/xCAT/postscripts/xcatdsklspost b/xCAT/postscripts/xcatdsklspost index c9ac442bc..e279b9b89 100755 --- a/xCAT/postscripts/xcatdsklspost +++ b/xCAT/postscripts/xcatdsklspost @@ -29,7 +29,7 @@ update_VPD() # Run updatevpd only when necessary if [ -f /usr/sbin/lsvpd ]; then - /usr/sbin/lsvpd | grep -i cpu 2>&1 1>/dev/null + /usr/sbin/lsvpd | grep -i -E 'cpu|processor' 2>&1 1>/dev/null if [ "$?" = "1" ]; then update_VPD fi diff --git a/xCAT/xCAT.spec b/xCAT/xCAT.spec index e418e8b92..4593a7bd4 100644 --- a/xCAT/xCAT.spec +++ b/xCAT/xCAT.spec @@ -184,6 +184,11 @@ then cp /etc/xcat/conf.orig/xcat.conf.apach24 /etc/apache2/conf.d/xcat.conf fi +if [ -n "$(apache2ctl -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