Merge "Make defaults can be override by local settings"

This commit is contained in:
Jenkins 2016-03-17 01:39:36 +00:00 committed by Gerrit Code Review
commit 44d1965789
6 changed files with 20 additions and 19 deletions

View File

@ -20,7 +20,7 @@ import sys
import netaddr
from astara_router import defaults
from astara_router import settings
from astara_router import utils
from astara_router.drivers import ip
@ -52,9 +52,9 @@ def configure_gunicorn(listen_ip):
"""
"""
if listen_ip.version == 6:
bind = "'[%s]:%d'" % (listen_ip, defaults.API_SERVICE)
bind = "'[%s]:%d'" % (listen_ip, settings.API_SERVICE)
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 = re.sub('\nbind(\s)?\=(\s)?.*', '\nbind = %s' % bind, config)

View File

@ -48,3 +48,7 @@ ORCHESTRATOR_METADATA_PORT = 9697
def internal_metadata_port(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']

View File

@ -20,7 +20,7 @@ import os
from astara_router.drivers import base
from astara_router.models import Network
from astara_router import defaults, utils
from astara_router import settings, utils
class Rule(object):
@ -199,8 +199,8 @@ class IPTablesManager(base.Manager):
# Open SSH, the HTTP API (5000) and the Nova metadata proxy (9697)
for port in (
defaults.SSH, defaults.API_SERVICE,
defaults.ORCHESTRATOR_METADATA_PORT
settings.SSH, settings.API_SERVICE,
settings.ORCHESTRATOR_METADATA_PORT
):
rules.append(Rule(
'-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 version, address, dhcp_port in (
(4, network.interface.first_v4, defaults.DHCP),
(6, network.interface.first_v6, defaults.DHCPV6)
(4, network.interface.first_v4, settings.DHCP),
(6, network.interface.first_v6, settings.DHCPV6)
):
if address:
# Allow DHCP
@ -295,10 +295,10 @@ class IPTablesManager(base.Manager):
'-A PREROUTING -i %s -d %s -p tcp -m tcp '
'--dport %s -j DNAT --to-destination %s:%s' % (
network.interface.ifname,
defaults.METADATA_DEST_ADDRESS,
defaults.HTTP,
settings.METADATA_DEST_ADDRESS,
settings.HTTP,
network.interface.first_v4,
defaults.internal_metadata_port(
settings.internal_metadata_port(
network.interface.ifname
)
), ip_version=4

View File

@ -17,7 +17,7 @@
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.utils import execute, replace_file

View File

@ -20,7 +20,7 @@ import re
import netaddr
from astara_router import defaults
from astara_router import settings
GROUP_NAME_LENGTH = 15
DEFAULT_AS = 64512
@ -719,9 +719,9 @@ class RouterConfiguration(SystemConfiguration):
orchestrator_conf = conf_dict.get('orchestrator', {})
self.metadata_address = orchestrator_conf.get(
'address', defaults.ORCHESTRATOR_METADATA_ADDRESS)
'address', settings.ORCHESTRATOR_METADATA_ADDRESS)
self.metadata_port = orchestrator_conf.get(
'metadata_port', defaults.ORCHESTRATOR_METADATA_PORT)
'metadata_port', settings.ORCHESTRATOR_METADATA_PORT)
self.floating_ips = [
FloatingIP.from_dict(fip)

View File

@ -1,7 +1,4 @@
# Configures which advanced service drivers are loaded by this
# instance of the appliance.
ENABLED_SERVICES = ['router']
from astara_router.defaults import * # noqa
# If astara_local_settings.py is located in your python path,
# it can be used to override the defaults. DIB will install this