diff --git a/perl-xCAT/xCAT/DBobjUtils.pm b/perl-xCAT/xCAT/DBobjUtils.pm index 04ea5ed7b..5c8117852 100644 --- a/perl-xCAT/xCAT/DBobjUtils.pm +++ b/perl-xCAT/xCAT/DBobjUtils.pm @@ -1949,6 +1949,22 @@ sub getNetwkInfo $nethash{$node}{'gateway'} = ''; } $nethash{$node}{'myselfgw'} = 1; + # For hwctrl commands, it is possible that this subroutine is called + # on MN instead of SN, if the hcp SN is not set + if (xCAT::Utils->isMN() && !$nethash{$node}{'gateway'}) + { + # does not have ip address in this subnet, + # use the node attribute 'xcatmaster' + my $noderestab = xCAT::Table->new('noderes'); + my $et = $noderestab->getNodeAttribs($node, ['xcatmaster']); + if ($et and defined($et->{'xcatmaster'})) + { + my $value = $et->{'xcatmaster'}; + $nethash{$node}{'gateway'} = xCAT::NetworkUtils->getipaddr($value); + } + $noderestab->close(); + } + } next; } diff --git a/xCAT-server/lib/xcat/plugins/networks.pm b/xCAT-server/lib/xcat/plugins/networks.pm index bd0849778..4d6ea8faf 100644 --- a/xCAT-server/lib/xcat/plugins/networks.pm +++ b/xCAT-server/lib/xcat/plugins/networks.pm @@ -482,6 +482,13 @@ sub donets $gw = $netgw{'0.0.0.0'}{'0.0.0.0'}; #default gatetway } } + # set gateway to keyword , + # to indicate to use the cluster-facing ip address + # on this management node or service node + if (!$gw) + { + $gw = ""; + } # use convention for netname attr my $netn;