-Allow schema to specify a column to treat in the same special way that we treat 'node'
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4162 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
83b000bf68
commit
021f0e991a
@ -251,6 +251,7 @@ mp => {
|
||||
mpa => {
|
||||
cols => [qw(mpa username password comments disable)],
|
||||
keys => [qw(mpa)],
|
||||
nodecol => "mpa",
|
||||
table_desc => 'Contains info about each Management Module and how to access it.',
|
||||
descriptions => {
|
||||
mpa => 'Hostname of the management module.',
|
||||
@ -369,6 +370,7 @@ noderes => {
|
||||
switches => {
|
||||
cols => [qw(switch snmpversion username password privacy auth comments disable)],
|
||||
keys => [qw(switch)],
|
||||
nodecol => "switch",
|
||||
table_desc => 'Parameters to use when interrogating switches',
|
||||
descriptions => {
|
||||
switch => 'The hostname/address of the switch to which the settings apply',
|
||||
|
@ -28,7 +28,6 @@ package xCAT::Table;
|
||||
use xCAT::MsgUtils;
|
||||
use Sys::Syslog;
|
||||
use Storable qw/freeze thaw/;
|
||||
use Data::Dumper;
|
||||
use IO::Socket;
|
||||
BEGIN
|
||||
{
|
||||
@ -50,7 +49,6 @@ my $cachethreshold=16; #How many nodes in 'getNodesAttribs' before switching to
|
||||
use DBI;
|
||||
|
||||
use strict;
|
||||
#use Data::Dumper;
|
||||
use Scalar::Util qw/weaken/;
|
||||
require xCAT::Schema;
|
||||
require xCAT::NodeRange;
|
||||
@ -169,7 +167,6 @@ sub handle_dbc_conn {
|
||||
$data .= $lastline;
|
||||
}
|
||||
my $request = thaw($data);
|
||||
use Data::Dumper;
|
||||
my $response;
|
||||
my @returndata;
|
||||
if ($request->{'wantarray'}) {
|
||||
@ -1466,15 +1463,19 @@ sub _build_cache { #PRIVATE FUNCTION, PLEASE DON'T CALL DIRECTLY
|
||||
$self->{_use_cache} = 0; #This function must disable cache
|
||||
#to function
|
||||
my $attriblist = shift;
|
||||
unless (grep /^node$/,@$attriblist) {
|
||||
push @$attriblist,'node';
|
||||
my $nodekey = "node";
|
||||
if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) {
|
||||
$nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}
|
||||
};
|
||||
unless (grep /^$nodekey$/,@$attriblist) {
|
||||
push @$attriblist,$nodekey;
|
||||
}
|
||||
my @tabcache = $self->getAllAttribs(@$attriblist);
|
||||
$self->{_tablecache} = \@tabcache;
|
||||
$self->{_nodecache} = {};
|
||||
if ($tabcache[0]->{node}) {
|
||||
if ($tabcache[0]->{$nodekey}) {
|
||||
foreach(@tabcache) {
|
||||
push @{$self->{_nodecache}->{$_->{node}}},$_;
|
||||
push @{$self->{_nodecache}->{$_->{$nodekey}}},$_;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1700,7 +1701,11 @@ sub getNodeAttribs_nosub_returnany
|
||||
my @results;
|
||||
|
||||
#my $recurse = ((scalar(@_) == 1) ? shift : 1);
|
||||
@results = $self->getAttribs({node => $node}, @attribs);
|
||||
my $nodekey = "node";
|
||||
if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) {
|
||||
$nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}
|
||||
};
|
||||
@results = $self->getAttribs({$nodekey => $node}, @attribs);
|
||||
my $data = $results[0];
|
||||
if (!defined($data))
|
||||
{
|
||||
@ -1714,7 +1719,7 @@ sub getNodeAttribs_nosub_returnany
|
||||
my $group;
|
||||
foreach $group (@nodegroups)
|
||||
{
|
||||
@results = $self->getAttribs({node => $group}, @attribs);
|
||||
@results = $self->getAttribs({$nodekey => $group}, @attribs);
|
||||
$data = $results[0];
|
||||
if ($data != undef)
|
||||
{
|
||||
|
@ -1061,8 +1061,13 @@ sub nodels
|
||||
$matchtypes{$_->[0]} = $_->[3];
|
||||
}
|
||||
}
|
||||
my $nodekey = "node";
|
||||
if (defined $xCAT::Schema::tabspec{$tab}->{nodecol}) {
|
||||
$nodekey = $xCAT::Schema::tabspec{$tab}->{nodecol}
|
||||
};
|
||||
|
||||
my $removenodecol=1;
|
||||
if (grep /^node$/,@cols) {
|
||||
if (grep /^$nodekey$/,@cols) {
|
||||
$removenodecol=0;
|
||||
}
|
||||
my $rechash=$tabh->getNodesAttribs($nodes,\@cols);
|
||||
@ -1075,7 +1080,7 @@ sub nodels
|
||||
|
||||
foreach (keys %$rec)
|
||||
{
|
||||
if ($_ eq "node" and $removenodecol) { next; }
|
||||
if ($_ eq $nodekey and $removenodecol) { next; }
|
||||
$satisfiedreqs{$_}=1;
|
||||
my %datseg=();
|
||||
if (defined $values{$_}) {
|
||||
|
Loading…
Reference in New Issue
Block a user