From 2170c7196f1521de62d7ac30706e7ebfbf417858 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Mon, 3 Nov 2014 07:13:53 -0800 Subject: [PATCH 01/12] defect 4303 arrange lskit options --- xCAT-server/lib/xcat/plugins/kit.pm | 113 +++++++++++++++++++++------- 1 file changed, 84 insertions(+), 29 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 18b094f61..149c498af 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -4256,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) { @@ -4264,43 +4266,51 @@ sub lskit { xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); return 0; } + 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) ) { + # 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); + } - 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; + 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 + { + create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); } - lskit_R($kit_hash,$kitrepo_hash); - return 0; } - - 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); - 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); + else + { + 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 @@ -4346,6 +4356,51 @@ sub lskit_R { 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); + + } #---------------------------------------------------------------------------- From da874a91f2a1dd49939f5b26ace6746431ce98a2 Mon Sep 17 00:00:00 2001 From: ligc Date: Mon, 4 Nov 2013 15:42:23 +0800 Subject: [PATCH 02/12] fix for bug 4347: lsvpd does not output the word 'cpu' on Ubuntu LE, it outputs 'processor' instead --- xCAT/postscripts/xcatdsklspost | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From ec1ef81ea8f44807c07118872aabb43372907972 Mon Sep 17 00:00:00 2001 From: baiyuan Date: Fri, 31 Oct 2014 04:40:09 -0400 Subject: [PATCH 03/12] fix defect 4349 [dev]after rmkit/rmkitcomp -i kitcomp list, kitrepo dir in otherpkgdir is not deleted --- xCAT-server/lib/xcat/plugins/kit.pm | 58 ++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index e3e96804b..c8f08846e 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; } From 9ba2726f83ff7fb388cba0f2f8157fdf00fbac0c Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 31 Oct 2014 02:43:22 -0700 Subject: [PATCH 04/12] add conf support for apache2.4 --- xCAT-server/xCAT-server.spec | 52 ++++++++++++++----- ...-ws.conf.apache2 => xcat-ws.conf.apache24} | 3 +- xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd | 4 -- 3 files changed, 40 insertions(+), 19 deletions(-) rename xCAT-server/xCAT-wsapi/{xcat-ws.conf.apache2 => xcat-ws.conf.apache24} (85%) delete mode 100644 xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd 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.apache24 similarity index 85% rename from xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2 rename to xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 index 8e7326c59..b10ccf224 100644 --- a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache2 +++ b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache24 @@ -5,7 +5,6 @@ RewriteCond %{REQUEST_URI} xcatws RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L] - Order allow,deny - Allow from all +Require all granted diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd b/xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd deleted file mode 100644 index 921735e12..000000000 --- a/xCAT-server/xCAT-wsapi/xcat-ws.conf.httpd +++ /dev/null @@ -1,4 +0,0 @@ -RewriteEngine On -RewriteCond %{SERVER_PORT} 80 -RewriteCond %{REQUEST_URI} xcatws -RewriteRule ^(.*)$ https://%{SERVER_NAME}$1 [R,L] From b6c35465dc7b10911c8a90eb96e73c0aa590cf97 Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 31 Oct 2014 02:48:33 -0700 Subject: [PATCH 05/12] update configuration file for apache2.4 on sles12 --- xCAT/xCAT.spec | 5 +++++ 1 file changed, 5 insertions(+) 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 From dd63773ee8048d3decaa39d0be8fb686d1d24c8e Mon Sep 17 00:00:00 2001 From: immarvin Date: Fri, 31 Oct 2014 03:12:25 -0700 Subject: [PATCH 06/12] dd conf support for apache2.4:create a new file xcat-ws.conf.apache22 --- xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 diff --git a/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 new file mode 100644 index 000000000..8e7326c59 --- /dev/null +++ b/xCAT-server/xCAT-wsapi/xcat-ws.conf.apache22 @@ -0,0 +1,11 @@ +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] + + + Order allow,deny + Allow from all + + From 5c9bd40b1fa53ef139f22eadb488d40a10b90078 Mon Sep 17 00:00:00 2001 From: baiyuan Date: Mon, 3 Nov 2014 00:08:49 -0500 Subject: [PATCH 07/12] defect4303 --- add -R support for lskit --- xCAT-server/lib/xcat/plugins/kit.pm | 62 +++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index c8f08846e..14a88d625 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -4265,6 +4265,20 @@ sub lskit { return 0; } + # 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); + return 0; + } + if (defined($::opt_x)) { create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); } else { @@ -4273,6 +4287,54 @@ sub lskit { 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); + + +} + + #---------------------------------------------------------------------------- From 943b31d0ffd2baef5bcf0c1c08fda463005d18dc Mon Sep 17 00:00:00 2001 From: baiyuan Date: Mon, 3 Nov 2014 00:40:30 -0500 Subject: [PATCH 08/12] defect4303 --- add -C support for lskit --- xCAT-server/lib/xcat/plugins/kit.pm | 61 +++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 14a88d625..18b094f61 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -4279,6 +4279,20 @@ sub lskit { return 0; } + 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); + return 0; + } + + if (defined($::opt_x)) { create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); } else { @@ -4334,6 +4348,53 @@ sub lskit_R { } +#---------------------------------------------------------------------------- + +=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); + + +} #---------------------------------------------------------------------------- From c8426f9f432f925de5ae76f15b0ba44942e321ab Mon Sep 17 00:00:00 2001 From: baiyuan Date: Mon, 3 Nov 2014 03:34:33 -0500 Subject: [PATCH 09/12] pick up ligc fix for bug 4347: lsvpd does not output the word 'cpu' on Ubuntu LE --- xCAT/postscripts/xcatdsklspost | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 From 47c91ef186e918cb6cbbe5724b35e05a49683fb9 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Mon, 3 Nov 2014 07:48:57 -0800 Subject: [PATCH 10/12] defect lskit to support seperate -R -C as xml format --- xCAT-server/lib/xcat/plugins/kit.pm | 177 ++++++++++++++++++++++++---- 1 file changed, 151 insertions(+), 26 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 149c498af..a3cead27e 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -4267,36 +4267,45 @@ sub lskit { return 0; } 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; + if ( ! defined($::opt_x)) { + if ( defined($::opt_K) ){ + lskit_K($kit_hash); } - lskit_C($kit_hash,$kitcomp_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 { - create_lskit_xml_response($kit_hash, $kitrepo_hash, $kitcomp_hash); + 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 @@ -5114,6 +5123,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 From 852fc3c1647874805f22f24055f002a3c98dff32 Mon Sep 17 00:00:00 2001 From: baiyuan Date: Mon, 3 Nov 2014 03:49:19 -0500 Subject: [PATCH 11/12] back to original kit.pm --- xCAT-server/lib/xcat/plugins/kit.pm | 321 +--------------------------- 1 file changed, 9 insertions(+), 312 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index a3cead27e..5db77268f 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2651,10 +2651,12 @@ sub rmkitcomp # Remove each kitcomponent from osimage. my @newosikitcomps; + my @myoskitcomps; foreach my $osikitcomp ( @osikitcomps ) { my $match = 0; foreach my $kitcomponent (keys %kitcomps) { if ( $kitcomponent eq $osikitcomp ) { + push @myoskitcomps, $osikitcomp; $match = 1; last; } @@ -2776,8 +2778,6 @@ sub rmkitcomp if ( !$match ) { if ( $debianflag ) { - #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}"); @@ -3251,6 +3251,7 @@ 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 @@ -3301,9 +3302,8 @@ sub rmkitcomp } } } - } - - + } + return; } @@ -4256,8 +4256,6 @@ 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) { @@ -4266,201 +4264,16 @@ sub lskit { xCAT::MsgUtils->message("I", $rsp, $::CALLBACK); return 0; } - 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 - { - 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 - { - 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); - } + 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 @@ -5123,122 +4936,6 @@ 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 From 2ace529feeeb9b3f52b6307d8023d23daad9ac3d Mon Sep 17 00:00:00 2001 From: baiyuan Date: Mon, 3 Nov 2014 03:55:24 -0500 Subject: [PATCH 12/12] range lskit to support -K -R -C and theirs xml format --- xCAT-server/lib/xcat/plugins/kit.pm | 325 +++++++++++++++++++++++++++- 1 file changed, 316 insertions(+), 9 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/kit.pm b/xCAT-server/lib/xcat/plugins/kit.pm index 5db77268f..72a9a2c83 100644 --- a/xCAT-server/lib/xcat/plugins/kit.pm +++ b/xCAT-server/lib/xcat/plugins/kit.pm @@ -2651,12 +2651,10 @@ sub rmkitcomp # Remove each kitcomponent from osimage. my @newosikitcomps; - my @myoskitcomps; foreach my $osikitcomp ( @osikitcomps ) { my $match = 0; foreach my $kitcomponent (keys %kitcomps) { if ( $kitcomponent eq $osikitcomp ) { - push @myoskitcomps, $osikitcomp; $match = 1; last; } @@ -2778,6 +2776,8 @@ sub rmkitcomp if ( !$match ) { if ( $debianflag ) { + #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}"); @@ -3251,7 +3251,6 @@ 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 @@ -3302,8 +3301,9 @@ sub rmkitcomp } } } - } - + } + + return; } @@ -4256,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) { @@ -4265,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 @@ -4936,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