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 ...@@ -31,34 +31,8 @@ import zc.buildout
import sys import sys
import netaddr 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): 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): def installProductionFrontend(self):
frontend_key, frontend_certificate = self.requestCertificate( frontend_key, frontend_certificate = self.requestCertificate(
self.parameter_dict['frontend_name']) self.parameter_dict['frontend_name'])
......
...@@ -36,6 +36,15 @@ import logging ...@@ -36,6 +36,15 @@ import logging
import zc.buildout 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: class Recipe:
def __init__(self, buildout, name, options): def __init__(self, buildout, name, options):
...@@ -58,11 +67,20 @@ class Recipe: ...@@ -58,11 +67,20 @@ class Recipe:
# XXX: Lack checking for locality of address # XXX: Lack checking for locality of address
return self._getIpAddress(netaddr.valid_ipv4) return self._getIpAddress(netaddr.valid_ipv4)
def getLoopbackIPv4Address(self):
"""Returns local IPv4 address available on partition"""
return self._getIpAddress(validLoopBackAddress)
def getGlobalIPv6Address(self): def getGlobalIPv6Address(self):
"""Returns global IPv6 address available on partition""" """Returns global IPv6 address available on partition"""
# XXX: Lack checking for globality of address # XXX: Lack checking for globality of address
return self._getIpAddress(netaddr.valid_ipv6) 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): def install(self):
slap = slapos.slap.slap() slap = slapos.slap.slap()
slap_connection = self.buildout['slap_connection'] slap_connection = self.buildout['slap_connection']
...@@ -104,6 +122,13 @@ class Recipe: ...@@ -104,6 +122,13 @@ class Recipe:
buildout.set('slap-parameter', parameter, value) buildout.set('slap-parameter', parameter, value)
buildout.add_section('slap-network-information') 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', buildout.set('slap-network-information', 'local-ipv4',
self.getLocalIPv4Address()) self.getLocalIPv4Address())
buildout.set('slap-network-information', 'global-ipv6', 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