From 71c9db88683c7246b3182672e3223ffa491a64c9 Mon Sep 17 00:00:00 2001 From: jbjohnso Date: Wed, 18 Mar 2009 14:11:30 +0000 Subject: [PATCH] -Defer determination of ip facing managed node until write to tftp, to enable dynamic http load balance git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2930 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-server/lib/xcat/plugins/anaconda.pm | 7 +------ xCAT-server/lib/xcat/plugins/pxe.pm | 12 +++++++++++- xCAT-server/lib/xcat/plugins/sles.pm | 7 +------ xCAT-server/lib/xcat/plugins/yaboot.pm | 13 ++++++++++++- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/xCAT-server/lib/xcat/plugins/anaconda.pm b/xCAT-server/lib/xcat/plugins/anaconda.pm index 657687830..b1403b8da 100644 --- a/xCAT-server/lib/xcat/plugins/anaconda.pm +++ b/xCAT-server/lib/xcat/plugins/anaconda.pm @@ -302,12 +302,7 @@ sub mknetboot #} #else #{ - my $ipfn = xCAT::Utils->my_ip_facing($node); - if ($ipfn) - { - $imgsrv = $ipfn; #guessing self is second best - - } + $imgsrv = '!myipfn!'; #} } } diff --git a/xCAT-server/lib/xcat/plugins/pxe.pm b/xCAT-server/lib/xcat/plugins/pxe.pm index 254b5ab7d..243cb85cf 100644 --- a/xCAT-server/lib/xcat/plugins/pxe.pm +++ b/xCAT-server/lib/xcat/plugins/pxe.pm @@ -66,6 +66,11 @@ sub setstate { my %chainhash = %{shift()}; my %machash = %{shift()}; my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); + if ($kern->{kcmdline} =~ /!myipfn!/) { + my $ipfn = xCAT::Utils->my_ip_facing($node); + unless ($ipfn) { return (1,"Unable to identify IP facing client node"); } + $kern->{kcmdline} =~ s/!myipfn!/$ipfn/; + } my $pcfg; open($pcfg,'>',$tftpdir."/pxelinux.cfg/".$node); my $cref=$chainhash{$node}->[0]; #$chaintab->getNodeAttribs($node,['currstate']); @@ -314,7 +319,12 @@ sub process_request { $response{node}->[0]->{data}->[0]= getstate($_); $callback->(\%response); } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate - setstate($_,\%bphash,\%chainhash,\%machash); + ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash); + if ($rc) { + $response{node}->[0]->{errorcode}->[0]= $rc; + $response{node}->[0]->{errorc}->[0]= $errstr; + $callback->(\%response); + } } } if ($args[0] ne 'stat') { diff --git a/xCAT-server/lib/xcat/plugins/sles.pm b/xCAT-server/lib/xcat/plugins/sles.pm index 9a9ba7591..c029cc893 100644 --- a/xCAT-server/lib/xcat/plugins/sles.pm +++ b/xCAT-server/lib/xcat/plugins/sles.pm @@ -162,12 +162,7 @@ sub mknetboot #} #else #{ - my $ipfn = xCAT::Utils->my_ip_facing($node); - if ($ipfn) - { - $imgsrv = $ipfn; #guessing self is second best - - } + $imgsrv = '!myipfn!'; #} } } diff --git a/xCAT-server/lib/xcat/plugins/yaboot.pm b/xCAT-server/lib/xcat/plugins/yaboot.pm index 79cc6dc0a..85e8270b1 100644 --- a/xCAT-server/lib/xcat/plugins/yaboot.pm +++ b/xCAT-server/lib/xcat/plugins/yaboot.pm @@ -70,6 +70,11 @@ sub setstate { my %chainhash = %{shift()}; my %machash = %{shift()}; my $kern = $bphash{$node}->[0]; #$bptab->getNodeAttribs($node,['kernel','initrd','kcmdline']); + if ($kern->{kcmdline} =~ /!myipfn!/) { + my $ipfn = xCAT::Utils->my_ip_facing($node); + unless ($ipfn) { return (1,"Unable to identify IP facing client node"); } + $kern->{kcmdline} =~ s/!myipfn!/$ipfn/; + } my $pcfg; unless (-d "$tftpdir/etc") { mkpath("$tftpdir/etc"); @@ -285,6 +290,8 @@ sub process_request { my $chainhash=$chaintab->getNodesAttribs(\@nodes,['currstate']); my $mactab=xCAT::Table->new('mac',-create=>1); my $machash=$mactab->getNodesAttribs(\@nodes,['mac']); + my $rc; + my $errstr; foreach (@nodes) { my %response; @@ -293,7 +300,11 @@ sub process_request { $response{node}->[0]->{data}->[0]= getstate($_); $callback->(\%response); } elsif ($args[0]) { #If anything else, send it on to the destiny plugin, then setstate - setstate($_,$bphash,$chainhash,$machash); + ($rc,$errstr) = setstate($_,$bphash,$chainhash,$machash); + if ($rc) { + $response{node}->[0]->{errorcode}->[0]= $rc; + $response{node}->[0]->{errorc}->[0]= $errstr; + $callback->(\%response); } } my @normalnodeset = keys %normalnodes;