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