From 2b7b0b4e19d8665235ab35a961cd3288a498eea0 Mon Sep 17 00:00:00 2001 From: Yuan Bai Date: Thu, 9 Nov 2017 17:37:34 +0800 Subject: [PATCH] enhance my_ip_facing when multiple ips found for xcatmaster for mypost(#4274) * Using facing IP first than sitemaster * enhance my_ip_facing when multiple ips found --- xCAT-server/lib/perl/xCAT/Postage.pm | 41 +++++++++++++++++++++++++--- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/xCAT-server/lib/perl/xCAT/Postage.pm b/xCAT-server/lib/perl/xCAT/Postage.pm index ffcc0ba8d..d0ef0f3ab 100644 --- a/xCAT-server/lib/perl/xCAT/Postage.pm +++ b/xCAT-server/lib/perl/xCAT/Postage.pm @@ -413,8 +413,29 @@ sub makescript { $noderesent = $::GLOBAL_TAB_HASH{noderes}{$node}; } + unless ($master) { + #the ip address of the mn facing the compute node + my @ipfnd = xCAT::NetworkUtils->my_ip_facing($node); + my $ipfndscalar = @ipfnd; + unless ($ipfnd[0]) { + $master = $ipfnd[1]; + if ($ipfndscalar > 2) { + foreach my $ipinfnd (@ipfnd) { + if ($::XCATSITEVALS{master} and $ipinfnd eq $::XCATSITEVALS{master}) { + $master = $ipinfnd; + last; + } + } + } + if ($master) { + $::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} = $master; + } + } + } + if (!defined($master)) { $::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} = $::XCATSITEVALS{master}; + $master = $::XCATSITEVALS{master}; } #get the node type, service node or compute node @@ -1535,10 +1556,22 @@ sub collect_all_attribs_for_tables_in_template $::GLOBAL_TAB_HASH{noderes}{$node}{xcatmaster} eq "")) { my $value = undef; - my @valued = xCAT::NetworkUtils->my_ip_facing($node); - unless ($valued[0]) { $value = $valued[1]; } - - $::GLOBAL_TAB_HASH{$tabname}{$node}{$attrib} = $value; + my @ipfnd = xCAT::NetworkUtils->my_ip_facing($node); + my $ipfndscalar = @ipfnd; + unless ($ipfnd[0]) { + $value = $ipfnd[1]; + if ($ipfndscalar > 2) { + foreach my $ipinfnd (@ipfnd) { + if ($::XCATSITEVALS{master} and $ipinfnd eq $::XCATSITEVALS{master}) { + $value = $ipinfnd; + last; + } + } + } + } + if ($value) { + $::GLOBAL_TAB_HASH{$tabname}{$node}{$attrib} = $value; + } } # for nodetype.os and nodetype.arch