Fix lsdef -i output for groups and misc code cleanup.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@1858 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
5e3113d925
commit
8a6f1c90d5
@ -1,4 +1,4 @@
|
||||
#!/usr/bin/env perl
|
||||
#!/usr/bin/env perl -w
|
||||
# IBM(c) 2007 EPL license http://www.eclipse.org/legal/epl-v10.html
|
||||
#####################################################
|
||||
#
|
||||
@ -15,6 +15,7 @@ use xCAT::DBobjUtils;
|
||||
use Data::Dumper;
|
||||
use Getopt::Long;
|
||||
use xCAT::MsgUtils;
|
||||
use strict;
|
||||
|
||||
# options can be bundled up like -vV
|
||||
Getopt::Long::Configure("bundling");
|
||||
@ -154,9 +155,9 @@ sub process_request
|
||||
($ret, $msg) = &defrm;
|
||||
}
|
||||
|
||||
my $rsp;
|
||||
if ($msg)
|
||||
{
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] = $msg;
|
||||
$::callback->($rsp);
|
||||
}
|
||||
@ -455,7 +456,7 @@ sub processArgs
|
||||
my @alreadydone; # the same attr may appear more then once
|
||||
my $outstr = "";
|
||||
|
||||
foreach $this_attr (@{$datatype->{'attrs'}})
|
||||
foreach my $this_attr (@{$datatype->{'attrs'}})
|
||||
{
|
||||
my $attr = $this_attr->{attr_name};
|
||||
my $desc = $this_attr->{description};
|
||||
@ -743,6 +744,8 @@ sub defmk
|
||||
my $rc = 0;
|
||||
my $error = 0;
|
||||
|
||||
my %objTypeLists;
|
||||
|
||||
# process the command line
|
||||
$rc = &processArgs;
|
||||
if ($rc != 0)
|
||||
@ -898,6 +901,7 @@ sub defmk
|
||||
{
|
||||
|
||||
# remove the old object
|
||||
my %objhash;
|
||||
$objhash{$obj} = $type;
|
||||
if (xCAT::DBobjUtils->rmobjdefs(\%objhash) != 0)
|
||||
{
|
||||
@ -1005,6 +1009,7 @@ sub defmk
|
||||
xCAT::DBobjUtils->getObjectsOfType('node');
|
||||
|
||||
# create a hash of obj names and types
|
||||
my %objhash;
|
||||
foreach my $n (@tmplist)
|
||||
{
|
||||
$objhash{$n} = 'node';
|
||||
@ -1022,13 +1027,12 @@ sub defmk
|
||||
|
||||
foreach my $testattr (keys %::WhereHash)
|
||||
{
|
||||
if ( !($myhash{$objname}{$testattr} =~ /\b$::WhereHash{$testattr}\b/) )
|
||||
|
||||
if ( !($myhash{$objname}{$testattr} =~ /\b$::WhereHash{$testattr}\b/) )
|
||||
{
|
||||
|
||||
# don't disply
|
||||
$addlist = 0;
|
||||
break;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1059,7 +1063,7 @@ sub defmk
|
||||
|
||||
# add this group name to the node entry in
|
||||
# the nodelist table
|
||||
$nodehash{$n}{groups} = $obj;
|
||||
#$nodehash{$n}{groups} = $obj;
|
||||
|
||||
# get the current value
|
||||
my $grps = $tab->getNodeAttribs($n, ['groups']);
|
||||
@ -1181,6 +1185,8 @@ sub defch
|
||||
my $error = 0;
|
||||
my $firsttime = 1;
|
||||
|
||||
my %objTypeLists;
|
||||
|
||||
# process the command line
|
||||
$rc = &processArgs;
|
||||
if ($rc != 0)
|
||||
@ -1339,7 +1345,7 @@ sub defch
|
||||
}
|
||||
|
||||
|
||||
if (!isDefined && $::opt_m)
|
||||
if (!$isDefined && $::opt_m)
|
||||
{
|
||||
|
||||
#error - cannot remove items from an object that does not exist.
|
||||
@ -1362,6 +1368,7 @@ sub defch
|
||||
|
||||
# what kind of group is this? - static or dynamic
|
||||
my $grptype;
|
||||
my %objhash;
|
||||
if ($isDefined)
|
||||
{
|
||||
$objhash{$obj} = $type;
|
||||
@ -1441,6 +1448,7 @@ sub defch
|
||||
my @tmplist = xCAT::DBobjUtils->getObjectsOfType('node');
|
||||
|
||||
# create a hash of obj names and types
|
||||
my %objhash;
|
||||
foreach my $n (@tmplist)
|
||||
{
|
||||
$objhash{$n} = 'node';
|
||||
@ -1487,7 +1495,7 @@ sub defch
|
||||
|
||||
# don't disply
|
||||
$addlist = 0;
|
||||
break;
|
||||
next;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1537,7 +1545,7 @@ sub defch
|
||||
# for each node in memberlist add this group
|
||||
# name to the groups attr of the node
|
||||
my %membhash;
|
||||
foreach $n (@memberlist)
|
||||
foreach my $n (@memberlist)
|
||||
{
|
||||
|
||||
$membhash{$n}{groups} = $obj;
|
||||
@ -1569,7 +1577,7 @@ sub defch
|
||||
# for each node in memberlist - remove this group
|
||||
# from the groups attr
|
||||
my %membhash;
|
||||
foreach $n (@memberlist)
|
||||
foreach my $n (@memberlist)
|
||||
{
|
||||
$membhash{$n}{groups} = $obj;
|
||||
$membhash{$n}{objtype} = 'node';
|
||||
@ -1589,7 +1597,7 @@ sub defch
|
||||
# for each node in memberlist add this group
|
||||
# name to the groups attr
|
||||
my %membhash;
|
||||
foreach $n (@memberlist)
|
||||
foreach my $n (@memberlist)
|
||||
{
|
||||
$membhash{$n}{groups} = $obj;
|
||||
$membhash{$n}{objtype} = 'node';
|
||||
@ -1619,7 +1627,7 @@ sub defch
|
||||
# from groups attr
|
||||
|
||||
my %membhash;
|
||||
foreach $n (@currentlist)
|
||||
foreach my $n (@currentlist)
|
||||
{
|
||||
$membhash{$n}{groups} = $obj;
|
||||
$membhash{$n}{objtype} = 'node';
|
||||
@ -1641,7 +1649,7 @@ sub defch
|
||||
# name to the groups attr
|
||||
|
||||
my %membhash;
|
||||
foreach $n (@memberlist)
|
||||
foreach my $n (@memberlist)
|
||||
{
|
||||
$membhash{$n}{groups} = $obj;
|
||||
$membhash{$n}{objtype} = 'node';
|
||||
@ -1677,7 +1685,7 @@ sub defch
|
||||
|
||||
# get the list of all defined group objects
|
||||
|
||||
@definedgroups = xCAT::DBobjUtils->getObjectsOfType(group);
|
||||
my @definedgroups = xCAT::DBobjUtils->getObjectsOfType("group");
|
||||
|
||||
# if we're creating the node or we're adding to or replacing
|
||||
# the "groups" attr then check if the group
|
||||
@ -1688,6 +1696,7 @@ sub defch
|
||||
# we either replace, add or take away from the "groups"
|
||||
# list
|
||||
# if not taking away then we must be adding or replacing
|
||||
my %GroupHash;
|
||||
foreach my $g (@grouplist)
|
||||
{
|
||||
if (!grep(/^$g$/, @definedgroups))
|
||||
@ -1937,6 +1946,7 @@ sub defls
|
||||
|
||||
my @objectlist;
|
||||
@::allobjnames;
|
||||
my @displayObjList;
|
||||
|
||||
my $numtypes = 0;
|
||||
|
||||
@ -2039,7 +2049,7 @@ sub defls
|
||||
# Get all object in this type list
|
||||
foreach my $t (@::clobjtypes)
|
||||
{
|
||||
@tmplist = xCAT::DBobjUtils->getObjectsOfType($t);
|
||||
my @tmplist = xCAT::DBobjUtils->getObjectsOfType($t);
|
||||
|
||||
if (scalar(@tmplist) > 1)
|
||||
{
|
||||
@ -2053,7 +2063,7 @@ sub defls
|
||||
{
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] =
|
||||
"Could not get objects of type \'$type\'.\n";
|
||||
"Could not get objects of type \'$t\'.\n";
|
||||
xCAT::MsgUtils->message("I", $rsp, $::callback);
|
||||
}
|
||||
}
|
||||
@ -2113,7 +2123,7 @@ sub defls
|
||||
|
||||
# don't disply
|
||||
$dodisplay = 0;
|
||||
break;
|
||||
next;
|
||||
}
|
||||
}
|
||||
if ($dodisplay)
|
||||
@ -2222,7 +2232,7 @@ sub defls
|
||||
my $datatype =
|
||||
$xCAT::Schema::defspec{$defhash{$obj}{'objtype'}};
|
||||
my @alreadydone;
|
||||
foreach $this_attr (@{$datatype->{'attrs'}})
|
||||
foreach my $this_attr (@{$datatype->{'attrs'}})
|
||||
{
|
||||
if (!grep(/^$this_attr->{attr_name}$/, @alreadydone)) {
|
||||
push(@attrlist, $this_attr->{attr_name});
|
||||
@ -2373,8 +2383,8 @@ sub defls
|
||||
{
|
||||
if (grep (/^$showattr$/, @::AttrList))
|
||||
{
|
||||
if ( ($obj eq 'group')
|
||||
&& ($showattr eq 'members'))
|
||||
|
||||
if ( ($defhash{$obj}{'objtype'} eq 'group') && ($showattr eq 'members'))
|
||||
{
|
||||
$defhash{$obj}{'grouptype'} = "static";
|
||||
my $memberlist =
|
||||
@ -2409,8 +2419,7 @@ sub defls
|
||||
{
|
||||
$defhash{$obj}{'grouptype'} = "static";
|
||||
my $memberlist =
|
||||
xCAT::DBobjUtils->getGroupMembers($obj,
|
||||
\%defhash);
|
||||
xCAT::DBobjUtils->getGroupMembers($obj,\%defhash);
|
||||
my $rsp;
|
||||
$rsp->{data}->[0] =
|
||||
" $showattr=$memberlist";
|
||||
@ -2631,8 +2640,9 @@ sub defrm
|
||||
{
|
||||
|
||||
# get the group object definition
|
||||
my %ghash;
|
||||
$ghash{$obj} = 'group';
|
||||
%grphash = xCAT::DBobjUtils->getobjdefs(\%ghash);
|
||||
my %grphash = xCAT::DBobjUtils->getobjdefs(\%ghash);
|
||||
if (!defined(%grphash))
|
||||
{
|
||||
my $rsp;
|
||||
|
Loading…
Reference in New Issue
Block a user