From 2170c7196f1521de62d7ac30706e7ebfbf417858 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Mon, 3 Nov 2014 07:13:53 -0800 Subject: [PATCH 1/3] 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 2/3] 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 47c91ef186e918cb6cbbe5724b35e05a49683fb9 Mon Sep 17 00:00:00 2001 From: zhaoertao Date: Mon, 3 Nov 2014 07:48:57 -0800 Subject: [PATCH 3/3] 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