Commit 12fd85f1 authored by Romain Courteaud's avatar Romain Courteaud

Migrate hack to install production system on ipv4 only server

parent 16dd742a
......@@ -31,34 +31,8 @@ import zc.buildout
import sys
import netaddr
def validLoopBackAddress(ip):
if netaddr.IPAddress(ip).is_loopback():
return True
else:
return False
def validPublicAddress(ip):
return not validLoopBackAddress(ip)
class Recipe(slapos.recipe.erp5.Recipe):
def getLocalIPv4Address(self):
"""Returns local IPv4 address available on partition"""
# XXX: Lack checking for locality of address
if self.development:
# XXX: Development superhack.
return slapos.recipe.erp5.Recipe.getLocalIPv4Address(self)
return self._getIpAddress(validLoopBackAddress)
def getGlobalIPv6Address(self):
"""Returns global IPv6 address available on partition"""
if self.development:
# XXX: Development superhack.
return slapos.recipe.erp5.Recipe.getGlobalIPv6Address(self)
# XXX: Lack checking for globality of address
return self._getIpAddress(validPublicAddress)
def installProductionFrontend(self):
frontend_key, frontend_certificate = self.requestCertificate(
self.parameter_dict['frontend_name'])
......
......@@ -36,6 +36,15 @@ import logging
import zc.buildout
def validLoopBackAddress(ip):
if netaddr.IPAddress(ip).is_loopback():
return True
else:
return False
def validPublicAddress(ip):
return not validLoopBackAddress(ip)
class Recipe:
def __init__(self, buildout, name, options):
......@@ -58,11 +67,20 @@ class Recipe:
# XXX: Lack checking for locality of address
return self._getIpAddress(netaddr.valid_ipv4)
def getLoopbackIPv4Address(self):
"""Returns local IPv4 address available on partition"""
return self._getIpAddress(validLoopBackAddress)
def getGlobalIPv6Address(self):
"""Returns global IPv6 address available on partition"""
# XXX: Lack checking for globality of address
return self._getIpAddress(netaddr.valid_ipv6)
def getGlobalIPv4Address(self):
"""Returns global IPv4 address available on partition"""
# XXX: Lack checking for globality of address
return self._getIpAddress(validPublicAddress)
def install(self):
slap = slapos.slap.slap()
slap_connection = self.buildout['slap_connection']
......@@ -104,6 +122,13 @@ class Recipe:
buildout.set('slap-parameter', parameter, value)
buildout.add_section('slap-network-information')
if software_type in ('production', 'mariadb-prod'):
# XXX Hack for beteireflow production
buildout.set('slap-network-information', 'local-ipv4',
self.getLoopbackIPv4Address())
buildout.set('slap-network-information', 'global-ipv6',
self.getGlobalIPv4Address())
else:
buildout.set('slap-network-information', 'local-ipv4',
self.getLocalIPv4Address())
buildout.set('slap-network-information', 'global-ipv6',
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment