Have xnba.pm cope with extrnal cals to getstate

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12052 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2012-03-29 18:08:49 +00:00
parent e0a151ba9b
commit ef19a2bbdd

View File

@ -42,9 +42,20 @@ sub check_dhcp {
return 0;
}
sub _slow_get_tftpdir { #make up for paths where tftpdir is not passed in
my $nrtab = = xCAT::Table->new('noderes',-create=>0); #in order to detect per-node tftp directories
unless ($nrtab) { return $globaltftpdir; }
my $ent = $nrtab->getNodeAttribs($node,["tftpdir"]);
if ($ent and $ent->{tftpdir}) {
return $ent->{tftpdir};
} else {
return $globaltftpdir;
}
}
sub getstate {
my $node = shift;
my $tftpdir = shift;
unless ($tftpdir) { $tftpdir = _slow_get_tftpdir($node); }
if (check_dhcp($node)) {
if (-r $tftpdir . "/xcat/xnba/nodes/".$node) {
my $fhand;
@ -597,9 +608,17 @@ sub getNodesetStates {
}
my @nodes=@$noderef;
my $hashref=shift;
my $noderestab = xCAT::Table->new('noderes'); #in order to detect per-node tftp directories
my %nrhash = %{$noderestab->getNodesAttribs(\@nodes,[qw(tftpdir)])};
if (@nodes>0) {
foreach my $node (@nodes) {
my $tmp=getstate($node);
my $tftpdir;
if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) {
$tftpdir = $nrhash{$node}->[0]->{tftpdir};
} else {
$tftpdir = $globaltftpdir;
}
my $tmp=getstate($node,$tftpdir);
my @a=split(' ', $tmp);
my $stat = $a[0];
if (exists($hashref->{$stat})) {