Merge "Make defaults can be override by local settings"
This commit is contained in:
commit
44d1965789
@ -20,7 +20,7 @@ import sys
|
|||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
from astara_router import defaults
|
from astara_router import settings
|
||||||
from astara_router import utils
|
from astara_router import utils
|
||||||
from astara_router.drivers import ip
|
from astara_router.drivers import ip
|
||||||
|
|
||||||
@ -52,9 +52,9 @@ def configure_gunicorn(listen_ip):
|
|||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
if listen_ip.version == 6:
|
if listen_ip.version == 6:
|
||||||
bind = "'[%s]:%d'" % (listen_ip, defaults.API_SERVICE)
|
bind = "'[%s]:%d'" % (listen_ip, settings.API_SERVICE)
|
||||||
else:
|
else:
|
||||||
bind = "'%s:%d'" % (listen_ip, defaults.API_SERVICE)
|
bind = "'%s:%d'" % (listen_ip, settings.API_SERVICE)
|
||||||
|
|
||||||
config = open('/etc/astara_gunicorn_config.py', 'r').read()
|
config = open('/etc/astara_gunicorn_config.py', 'r').read()
|
||||||
config = re.sub('\nbind(\s)?\=(\s)?.*', '\nbind = %s' % bind, config)
|
config = re.sub('\nbind(\s)?\=(\s)?.*', '\nbind = %s' % bind, config)
|
||||||
|
@ -48,3 +48,7 @@ ORCHESTRATOR_METADATA_PORT = 9697
|
|||||||
|
|
||||||
def internal_metadata_port(ifname):
|
def internal_metadata_port(ifname):
|
||||||
return BASE_METADATA_PORT + int(re.sub('[a-zA-Z]', '', ifname))
|
return BASE_METADATA_PORT + int(re.sub('[a-zA-Z]', '', ifname))
|
||||||
|
|
||||||
|
# Configures which advanced service drivers are loaded by this
|
||||||
|
# instance of the appliance.
|
||||||
|
ENABLED_SERVICES = ['router']
|
||||||
|
@ -20,7 +20,7 @@ import os
|
|||||||
|
|
||||||
from astara_router.drivers import base
|
from astara_router.drivers import base
|
||||||
from astara_router.models import Network
|
from astara_router.models import Network
|
||||||
from astara_router import defaults, utils
|
from astara_router import settings, utils
|
||||||
|
|
||||||
|
|
||||||
class Rule(object):
|
class Rule(object):
|
||||||
@ -199,8 +199,8 @@ class IPTablesManager(base.Manager):
|
|||||||
|
|
||||||
# Open SSH, the HTTP API (5000) and the Nova metadata proxy (9697)
|
# Open SSH, the HTTP API (5000) and the Nova metadata proxy (9697)
|
||||||
for port in (
|
for port in (
|
||||||
defaults.SSH, defaults.API_SERVICE,
|
settings.SSH, settings.API_SERVICE,
|
||||||
defaults.ORCHESTRATOR_METADATA_PORT
|
settings.ORCHESTRATOR_METADATA_PORT
|
||||||
):
|
):
|
||||||
rules.append(Rule(
|
rules.append(Rule(
|
||||||
'-A INPUT -i %s -p tcp -m tcp --dport %s -j ACCEPT' % (
|
'-A INPUT -i %s -p tcp -m tcp --dport %s -j ACCEPT' % (
|
||||||
@ -231,8 +231,8 @@ class IPTablesManager(base.Manager):
|
|||||||
for network in self.get_internal_networks(config):
|
for network in self.get_internal_networks(config):
|
||||||
|
|
||||||
for version, address, dhcp_port in (
|
for version, address, dhcp_port in (
|
||||||
(4, network.interface.first_v4, defaults.DHCP),
|
(4, network.interface.first_v4, settings.DHCP),
|
||||||
(6, network.interface.first_v6, defaults.DHCPV6)
|
(6, network.interface.first_v6, settings.DHCPV6)
|
||||||
):
|
):
|
||||||
if address:
|
if address:
|
||||||
# Allow DHCP
|
# Allow DHCP
|
||||||
@ -295,10 +295,10 @@ class IPTablesManager(base.Manager):
|
|||||||
'-A PREROUTING -i %s -d %s -p tcp -m tcp '
|
'-A PREROUTING -i %s -d %s -p tcp -m tcp '
|
||||||
'--dport %s -j DNAT --to-destination %s:%s' % (
|
'--dport %s -j DNAT --to-destination %s:%s' % (
|
||||||
network.interface.ifname,
|
network.interface.ifname,
|
||||||
defaults.METADATA_DEST_ADDRESS,
|
settings.METADATA_DEST_ADDRESS,
|
||||||
defaults.HTTP,
|
settings.HTTP,
|
||||||
network.interface.first_v4,
|
network.interface.first_v4,
|
||||||
defaults.internal_metadata_port(
|
settings.internal_metadata_port(
|
||||||
network.interface.ifname
|
network.interface.ifname
|
||||||
)
|
)
|
||||||
), ip_version=4
|
), ip_version=4
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
from astara_router.defaults import internal_metadata_port
|
from astara_router.settings import internal_metadata_port
|
||||||
from astara_router.drivers import base
|
from astara_router.drivers import base
|
||||||
from astara_router.utils import execute, replace_file
|
from astara_router.utils import execute, replace_file
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ import re
|
|||||||
|
|
||||||
import netaddr
|
import netaddr
|
||||||
|
|
||||||
from astara_router import defaults
|
from astara_router import settings
|
||||||
|
|
||||||
GROUP_NAME_LENGTH = 15
|
GROUP_NAME_LENGTH = 15
|
||||||
DEFAULT_AS = 64512
|
DEFAULT_AS = 64512
|
||||||
@ -719,9 +719,9 @@ class RouterConfiguration(SystemConfiguration):
|
|||||||
|
|
||||||
orchestrator_conf = conf_dict.get('orchestrator', {})
|
orchestrator_conf = conf_dict.get('orchestrator', {})
|
||||||
self.metadata_address = orchestrator_conf.get(
|
self.metadata_address = orchestrator_conf.get(
|
||||||
'address', defaults.ORCHESTRATOR_METADATA_ADDRESS)
|
'address', settings.ORCHESTRATOR_METADATA_ADDRESS)
|
||||||
self.metadata_port = orchestrator_conf.get(
|
self.metadata_port = orchestrator_conf.get(
|
||||||
'metadata_port', defaults.ORCHESTRATOR_METADATA_PORT)
|
'metadata_port', settings.ORCHESTRATOR_METADATA_PORT)
|
||||||
|
|
||||||
self.floating_ips = [
|
self.floating_ips = [
|
||||||
FloatingIP.from_dict(fip)
|
FloatingIP.from_dict(fip)
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
from astara_router.defaults import * # noqa
|
||||||
# Configures which advanced service drivers are loaded by this
|
|
||||||
# instance of the appliance.
|
|
||||||
ENABLED_SERVICES = ['router']
|
|
||||||
|
|
||||||
# If astara_local_settings.py is located in your python path,
|
# If astara_local_settings.py is located in your python path,
|
||||||
# it can be used to override the defaults. DIB will install this
|
# it can be used to override the defaults. DIB will install this
|
||||||
|
Loading…
Reference in New Issue
Block a user