diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 10c082164..edf491639 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -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]; diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index 734ad917d..986cf9c26 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -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];