Apply changes from xnba.pm to pxe.pm and yaboot.pm for getstate external calls

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@12053 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
jbjohnso 2012-03-29 18:14:03 +00:00
parent ef19a2bbdd
commit 24ee4eb3ce
2 changed files with 39 additions and 5 deletions

View File

@ -41,9 +41,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 . "/pxelinux.cfg/".$node) {
my $fhand;
@ -612,8 +623,16 @@ 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 $tftpdir;
if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) {
$tftpdir = $nrhash{$node}->[0]->{tftpdir};
} else {
$tftpdir = $globaltftpdir;
}
my $tmp=getstate($node);
my @a=split(' ', $tmp);
$stat = $a[0];

View File

@ -15,7 +15,7 @@ my %normalnodes;
my $callback;
my $sub_req;
my $dhcpconf = "/etc/dhcpd.conf";
my $globaltftpdir = "/tftpboot";
my $globaltftpdir = xCAT::Utils->getTftpDir();
#my $dhcpver = 3;
my %usage = (
@ -43,13 +43,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;
if (!$tftpdir)
{
$tftpdir = xCAT::Utils->getTftpDir();
}
unless ($tftpdir) { $tftpdir = _slow_get_tftpdir($node); }
if (check_dhcp($node)) {
if (-r $tftpdir . "/etc/".$node) {
my $fhand;
@ -588,9 +595,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 $tftpdir;
if ($nrhash{$node}->[0] and $nrhash{$node}->[0]->{tftpdir}) {
$tftpdir = $nrhash{$node}->[0]->{tftpdir};
} else {
$tftpdir = $globaltftpdir;
}
my $tmp=getstate($node);
my @a=split(' ', $tmp);
$stat = $a[0];