lsdef --osimage to list osimage information
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@9751 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
53a7ed2501
commit
e56933c733
@ -8,7 +8,7 @@ B<lsdef> [B<-h>|B<--help>] [B<-t> I<object-types>]
|
||||
|
||||
B<lsdef> [B<-V>|B<--verbose>] [B<-l>|B<--long>] [B<-s>|B<--short>] [B<-a>|B<--all>] [B<-S>]
|
||||
[B<-t> I<object-types>] [B<-o> I<object-names>] [B<-z>|B<--stanza>] [B<-i> I<attr-list>]
|
||||
[B<-c>|B<--compress>] [[B<-w> I<attr>==I<val>] [B<-w> I<attr>=~I<val>] ...] [I<noderange>]
|
||||
[B<-c>|B<--compress>] [B<--osimage>][[B<-w> I<attr>==I<val>] [B<-w> I<attr>=~I<val>] ...] [I<noderange>]
|
||||
|
||||
|
||||
=head1 DESCRIPTION
|
||||
@ -60,6 +60,10 @@ See the "noderange" man page for details on supported formats.
|
||||
|
||||
A set of comma delimited object names.
|
||||
|
||||
=item B<--osimage>
|
||||
|
||||
Show all the osimage information for the node.
|
||||
|
||||
=item B<-t> I<object-types>
|
||||
|
||||
A set of comma delimited object types. Use the help option to get a list of valid objects.
|
||||
|
@ -261,6 +261,7 @@ sub processArgs
|
||||
'z|stanza' => \$::opt_z,
|
||||
'nocache' => \$::opt_nc,
|
||||
'S' => \$::opt_S,
|
||||
'osimage' => \$::opt_osimg,
|
||||
)
|
||||
)
|
||||
{
|
||||
@ -288,6 +289,22 @@ sub processArgs
|
||||
return 2;
|
||||
}
|
||||
|
||||
# -i and --osimage cannot be used together
|
||||
if ($::opt_i && $::opt_osimg) {
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] = "The flags \'-i'\ and \'--osimage'\ cannot be used together.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $::callback);
|
||||
return 2;
|
||||
}
|
||||
|
||||
# -z and --osimage cannot be used together
|
||||
if ($::opt_z && $::opt_osimg) {
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] = "The flags \'-z'\ and \'--osimage'\ cannot be used together.";
|
||||
xCAT::MsgUtils->message("E", $rsp, $::callback);
|
||||
return 2;
|
||||
}
|
||||
|
||||
# -l and -s cannot be used together
|
||||
if ($::opt_l && $::opt_s) {
|
||||
my $rsp;
|
||||
@ -2633,8 +2650,75 @@ sub defls
|
||||
}
|
||||
}
|
||||
}
|
||||
my %nodeosimagehash = ();
|
||||
if ($getnodes)
|
||||
{
|
||||
# Show osimage information
|
||||
if($::opt_osimg)
|
||||
{
|
||||
my %nodeosimgname;
|
||||
my %imghash;
|
||||
my %imglist;
|
||||
foreach my $obj (keys %myhash)
|
||||
{
|
||||
if ($myhash{$obj}{'objtype'} eq 'node')
|
||||
{
|
||||
my $osimagename;
|
||||
#provmethod can be set to osimage name
|
||||
if($myhash{$obj}{'provmethod'} && ($myhash{$obj}{'provmethod'} ne 'install')
|
||||
&& ($myhash{$obj}{'provmethod'} ne 'netboot') && ($myhash{$obj}{'provmethod'} ne 'statelite'))
|
||||
{
|
||||
$osimagename = $myhash{$obj}{'provmethod'};
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($myhash{$obj}{'os'} && $myhash{$obj}{'arch'}
|
||||
&& $myhash{$obj}{'provmethod'} && $myhash{$obj}{'profile'})
|
||||
{
|
||||
$osimagename = "$myhash{$obj}{'os'}-$myhash{$obj}{'arch'}-$myhash{$obj}{'provmethod'}-$myhash{$obj}{'profile'}";
|
||||
}
|
||||
}
|
||||
# do not call xCAT::DBobjUtils->getobjdefs for each object
|
||||
# for performance consideration
|
||||
if($osimagename)
|
||||
{
|
||||
if(!defined($imglist{$osimagename}))
|
||||
{
|
||||
$imglist{$osimagename} = 'osimage';
|
||||
}
|
||||
$nodeosimgname{$obj} = $osimagename;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Get osimage definition info in one invocation
|
||||
if(scalar(keys %imglist) > 0)
|
||||
{
|
||||
my @attrs = ();
|
||||
%imghash = xCAT::DBobjUtils->getobjdefs(\%imglist, 0, \@attrs);
|
||||
}
|
||||
|
||||
# Put the osimage definition in %nodeosimagehash
|
||||
foreach my $obj (keys %myhash)
|
||||
{
|
||||
if ($myhash{$obj}{'objtype'} eq 'node')
|
||||
{
|
||||
my $imgname = $nodeosimgname{$obj};
|
||||
if($imgname && defined($imghash{$imgname}))
|
||||
{
|
||||
my %imgentry = %{$imghash{$imgname}};
|
||||
foreach my $imgattr (keys %imgentry)
|
||||
{
|
||||
# Only store the attributes that are not in general node attributes
|
||||
if(!defined($myhash{$obj}{$imgattr}) && defined($imgentry{$imgattr}))
|
||||
{
|
||||
$nodeosimagehash{$obj}{$imgattr} = $imgentry{$imgattr};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
my $xcatdefaultsps;
|
||||
my $xcatdefaultspbs;
|
||||
my @TableRowArray = xCAT::DBobjUtils->getDBtable('postscripts');
|
||||
@ -2949,7 +3033,24 @@ sub defls
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
# Additional osimage attributes
|
||||
if(($type eq "node") && $::opt_osimg)
|
||||
{
|
||||
if(defined($nodeosimagehash{$obj}))
|
||||
{
|
||||
foreach my $attr (keys %{$nodeosimagehash{$obj}})
|
||||
{
|
||||
if (($attr eq "osname") || ($attr eq "osarch") || ($attr eq "osvers"))
|
||||
{
|
||||
next;
|
||||
}
|
||||
if($nodeosimagehash{$obj}{$attr})
|
||||
{
|
||||
push (@{$rsp_info->{data}}, " $attr=$nodeosimagehash{$obj}{$attr}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user