Merge branch 'master' of ssh://git.code.sf.net/p/xcat/xcat-core

This commit is contained in:
baiyuan 2014-11-03 03:35:12 -05:00
commit b15e8e9db8

View File

@ -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,60 @@ sub lskit {
xCAT::MsgUtils->message("I", $rsp, $::CALLBACK);
return 0;
}
if ( defined($::opt_K) || defined($::opt_R) || defined($::opt_C) ) {
# Option -R for kit repo attributes
if ( defined($::opt_R) ) {
if ( ! defined($::opt_x)) {
if ( defined($::opt_K) ){
lskit_K($kit_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;
# 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);
}
}
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 +4365,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);
}
#----------------------------------------------------------------------------
@ -5059,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