From df0a17d223c858759e2709b570d3398e53883dbb Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Mon, 13 Sep 2010 18:54:26 +0000 Subject: [PATCH] -Have 'getAllNodeAttribs' honor nodecol -Have MacMap use getAllNodeAttribs to allow for noderange described switches/inheritence -Fix getbmcconfig to use a suffix that will pass complexity rules -Fix getbmcconfig to pass through bmcport even if genpasswords is in use git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@7437 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- perl-xCAT/xCAT/MacMap.pm | 2 +- perl-xCAT/xCAT/Table.pm | 19 +++++++++++++------ xCAT-server/lib/xcat/plugins/bmcconfig.pm | 4 ++-- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/perl-xCAT/xCAT/MacMap.pm b/perl-xCAT/xCAT/MacMap.pm index d69dc1006..bba958d55 100644 --- a/perl-xCAT/xCAT/MacMap.pm +++ b/perl-xCAT/xCAT/MacMap.pm @@ -138,7 +138,7 @@ sub refresh_table { $self->{mactable}={}; $self->{switchtab} = xCAT::Table->new('switch', -create => 1); $self->{switchestab} = xCAT::Table->new('switches', -create => 1); - my @switchentries=$self->{switchestab}->getAllAttribs(qw(switch snmpversion username password privacy auth)); + my @switchentries=$self->{switchestab}->getAllNodeAttribs([qw(switch snmpversion username password privacy auth)]); $self->{switchparmhash}={}; my $community = "public"; $self->{sitetab} = xCAT::Table->new('site'); diff --git a/perl-xCAT/xCAT/Table.pm b/perl-xCAT/xCAT/Table.pm index f9201f870..27e538590 100644 --- a/perl-xCAT/xCAT/Table.pm +++ b/perl-xCAT/xCAT/Table.pm @@ -2811,19 +2811,23 @@ sub getAllNodeAttribs my %donenodes ; #Remember those that have been done once to not return same node multiple times my $query; + my $nodekey = "node"; + if (defined $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol}) { + $nodekey = $xCAT::Schema::tabspec{$self->{tabname}}->{nodecol} + }; if ($xcatcfg =~ /^mysql:/) { #for mysql - $query = $self->{dbh}->prepare('SELECT node FROM ' + $query = $self->{dbh}->prepare('SELECT '.$nodekey.' FROM ' . $self->{tabname} . " WHERE " . q(`disable`) . " is NULL or " . q(`disable`) . " in ('0','no','NO','No','nO')"); } else { if ($xcatcfg =~ /^DB2:/) { #for DB2 - my $qstring = "Select \"node\" FROM "; + my $qstring = "Select \"$nodekey\" FROM "; $qstring .= $self->{tabname}; $qstring .= " WHERE \"disable\" is NULL OR \"disable\" LIKE '0' OR \"disable\" LIKE 'no' OR \"disable\" LIKE 'NO' OR \"disable\" LIKE 'No' OR \"disable\" LIKE 'nO'"; $query = $self->{dbh}->prepare($qstring); } else { # for other dbs $query = - $self->{dbh}->prepare('SELECT node FROM ' + $self->{dbh}->prepare('SELECT '.$nodekey.' FROM ' . $self->{tabname} . " WHERE \"disable\" is NULL or \"disable\" in ('','0','no','NO','no')"); } @@ -2841,11 +2845,14 @@ sub getAllNodeAttribs while (my $data = $query->fetchrow_hashref()) { - unless ($data->{node} =~ /^$/ || !defined($data->{node})) + unless ($data->{$nodekey} =~ /^$/ || !defined($data->{$nodekey})) { #ignore records without node attrib, not possible? my @nodes = - xCAT::NodeRange::noderange($data->{node}) + xCAT::NodeRange::noderange($data->{$nodekey}) ; #expand node entry, to make groups expand + unless (@nodes) { #in the event of an entry not in nodelist, use entry value verbatim + @nodes = ($data->{$nodekey}); + } #my $localhash = $self->getNodesAttribs(\@nodes,$attribq); #NOTE: This is stupid, rebuilds the cache for every entry, FIXME foreach (@nodes) { @@ -2866,7 +2873,7 @@ sub getAllNodeAttribs #populate node attribute by default, this sort of expansion essentially requires it. #$attrs->{node} = $_; foreach my $att (@attrs) { - $att->{node} = $_; + $att->{$nodekey} = $_; } $donenodes{$_} = 1; diff --git a/xCAT-server/lib/xcat/plugins/bmcconfig.pm b/xCAT-server/lib/xcat/plugins/bmcconfig.pm index e1826e2d1..f478aa09a 100644 --- a/xCAT-server/lib/xcat/plugins/bmcconfig.pm +++ b/xCAT-server/lib/xcat/plugins/bmcconfig.pm @@ -107,9 +107,9 @@ sub process_request { } $tmphash=($sitetable->getAttribs({key=>'genpasswords'},'value'))[0]; if ($tmphash->{value} eq "1" or $tmphash->{value} =~ /y(es)?/i) { - $password = genpassword(8); + $password = genpassword(8)."1c"; $gennedpassword=1; - $tmphash=$ipmitable->getNodeAttribs($node,['bmc','username']); + $tmphash=$ipmitable->getNodeAttribs($node,['bmc','username','bmcport']); } else { $tmphash=$ipmitable->getNodeAttribs($node,['bmc','username','bmcport','password']); if ($tmphash->{password}) {