Commit b1757b8c by Bach Dániel

allow BRIDGE_TYPE=NONE option

parent bbcea33e
......@@ -4,8 +4,7 @@ import re
import json
import logging
from ovs import Switch, Bridge
from utils import (ns_exec, sudo, ADDRESSES,
from utils import (ns_exec, sudo, ADDRESSES, get_network_type,
dhcp_no_free_re, dhcp_ack_re)
DHCP_LOGFILE = getenv('DHCP_LOGFILE', '/var/log/syslog')
......@@ -26,12 +25,6 @@ celery.conf.update(CELERY_CACHE_BACKEND=CACHE_URI,
logger = logging.getLogger(__name__)
if getenv('BRIDGE_TYPE', 'OVS') == 'BRIDGE':
network_type = Bridge
else:
network_type = Switch
@task(name="firewall.reload_firewall")
def reload_firewall(data4, data6, save_config=True):
try:
......@@ -50,6 +43,11 @@ def reload_firewall(data4, data6, save_config=True):
@task(name="firewall.reload_firewall_vlan")
def reload_firewall_vlan(data, save_config=True):
network_type = get_network_type()
if network_type is None:
logger.info("Ignored reload_firewall_vlan() network type=%s",
network_type)
return
# Add additional addresses from config
for k, v in ADDRESSES.items():
data[k]['addresses'] += v
......
......@@ -13,6 +13,16 @@ MAC = getenv('MAC')
ADDRESSES = json.loads(getenv('ADDRESSES', '{}'))
HA = bool(getenv('HA', False))
def get_network_type():
from ovs import Switch, Bridge
if getenv('BRIDGE_TYPE', 'OVS') == 'BRIDGE':
return Bridge
elif getenv('BRIDGE_TYPE', 'OVS') == 'NONE':
return None
else:
return Switch
# 2013-06-26 12:16:59 DHCPACK on 10.4.0.14 to 5c:b5:24:e6:5c:81
# (android_b555bfdba7c837d) via vlan0004
......@@ -45,5 +55,8 @@ def sudo(args, stdin=None):
def ns_exec(args, stdin=None):
return sudo(('/sbin/ip', 'netns', 'exec',
NETNS) + args, stdin)
if get_network_type() is None:
return sudo(args, stdin)
else:
return sudo(('/sbin/ip', 'netns', 'exec',
NETNS) + args, stdin)
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 sign in to comment