Fix IPSec client to use hostname in workers nodes
This commits changes IPSec client to use hostname instead of IP Address on swanctl configuration parameter local addr in worker nodes. Test Plan: PASS: In a DX system with IPsec enabled and security association established in both controllers, add a worker node and observe that IPSec will be enabled and security association will established in the three nodes without manually intervention. Story: 2010940 Task: 50039 Change-Id: Idba336e3870f33db840846578441984e11b0d574 Signed-off-by: Leonardo Mendes <Leonardo.MendesSantana@windriver.com>
This commit is contained in:
parent
159039de4c
commit
bcac3d13f7
|
@ -189,7 +189,7 @@ class Client(object):
|
|||
self.local_addr = self.hostname[constants.UNIT_HOSTNAME] + ', ' \
|
||||
+ self.hostname[constants.FLOATING_UNIT_HOSTNAME]
|
||||
else:
|
||||
self.local_addr = utils.get_ip_addr(self.ifname)
|
||||
self.local_addr = self.hostname[constants.UNIT_HOSTNAME]
|
||||
|
||||
LOG.info("Generating config files and restart ipsec")
|
||||
strong = config.StrongswanPuppet(self.hostname[constants.UNIT_HOSTNAME],
|
||||
|
|
|
@ -11,7 +11,6 @@ TCP_SERVER = (DEFAULT_BIND_ADDR, DEFAULT_LISTEN_PORT)
|
|||
|
||||
PLATAFORM_CONF_FILE = '/etc/platform/platform.conf'
|
||||
|
||||
SIOCGIFADDR = 0x8915
|
||||
SIOCGIFHWADDR = 0x8927
|
||||
|
||||
API_VERSION_CERT_MANAGER = 'cert-manager.io/v1'
|
||||
|
|
|
@ -55,16 +55,6 @@ def get_management_interface():
|
|||
return get_plataform_conf('management_interface')
|
||||
|
||||
|
||||
def get_ip_addr(ifname):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
ifstruct = struct.pack('256s', bytes(ifname[:15], 'utf-8'))
|
||||
info = fcntl.ioctl(s.fileno(), constants.SIOCGIFADDR, ifstruct)
|
||||
return socket.inet_ntoa(info[20:24])
|
||||
except Exception as e:
|
||||
LOG.exception("Error getting ip address: %s" % (e))
|
||||
|
||||
|
||||
def get_hw_addr(ifname):
|
||||
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
|
||||
try:
|
||||
|
|
Loading…
Reference in New Issue