Commit 5283434f by Bach Dániel Committed by Your Name

remove NETNS arg

parent cc4e9a06
...@@ -5,7 +5,7 @@ import json ...@@ -5,7 +5,7 @@ import json
import logging import logging
from ovs import Switch from ovs import Switch
from utils import (NETNS, ns_exec, sudo, ADDRESSES, from utils import (ns_exec, sudo, ADDRESSES,
dhcp_no_free_re, dhcp_ack_re) dhcp_no_free_re, dhcp_ack_re)
DHCP_LOGFILE = getenv('DHCP_LOGFILE', '/var/log/syslog') DHCP_LOGFILE = getenv('DHCP_LOGFILE', '/var/log/syslog')
...@@ -29,8 +29,8 @@ logger = logging.getLogger(__name__) ...@@ -29,8 +29,8 @@ logger = logging.getLogger(__name__)
@task(name="firewall.reload_firewall") @task(name="firewall.reload_firewall")
def reload_firewall(data4, data6, save_config=True): def reload_firewall(data4, data6, save_config=True):
try: try:
ns_exec(NETNS, ('ip6tables-restore', '-c'), data6) ns_exec(('ip6tables-restore', '-c'), data6)
ns_exec(NETNS, ('iptables-restore', '-c'), data4) ns_exec(('iptables-restore', '-c'), data4)
except: except:
logging.critical('Unhandled exception: ', exc_info=True) logging.critical('Unhandled exception: ', exc_info=True)
raise raise
...@@ -60,7 +60,7 @@ def reload_firewall_vlan(data, save_config=True): ...@@ -60,7 +60,7 @@ def reload_firewall_vlan(data, save_config=True):
json.dump(data, f) json.dump(data, f)
try: try:
ns_exec(NETNS, ('ip', 'ro', 'add', 'default', 'via', ns_exec(('ip', 'ro', 'add', 'default', 'via',
getenv('GATEWAY', '152.66.243.254'))) getenv('GATEWAY', '152.66.243.254')))
except: except:
pass pass
...@@ -82,7 +82,7 @@ def ipset_save(data): ...@@ -82,7 +82,7 @@ def ipset_save(data):
data_new = [x['ipv4'] for x in data] data_new = [x['ipv4'] for x in data]
data_old = [] data_old = []
lines = ns_exec(NETNS, ('ipset', 'save', 'blacklist')) lines = ns_exec(('ipset', 'save', 'blacklist'))
for line in lines.splitlines(): for line in lines.splitlines():
x = r.match(line.rstrip()) x = r.match(line.rstrip())
if x: if x:
...@@ -101,7 +101,7 @@ def ipset_restore(l_add, l_del): ...@@ -101,7 +101,7 @@ def ipset_restore(l_add, l_del):
ipset += ['add blacklist %s' % x for x in l_add] ipset += ['add blacklist %s' % x for x in l_add]
ipset += ['del blacklist %s' % x for x in l_del] ipset += ['del blacklist %s' % x for x in l_del]
ns_exec(NETNS, ('ipset', 'restore', '-exist'), ns_exec(('ipset', 'restore', '-exist'),
'\n'.join(ipset) + '\n') '\n'.join(ipset) + '\n')
...@@ -137,9 +137,9 @@ def get_dhcp_clients(): ...@@ -137,9 +137,9 @@ def get_dhcp_clients():
def start_firewall(): def start_firewall():
try: try:
ns_exec(NETNS, ('ipset', 'create', 'blacklist', ns_exec(('ipset', 'create', 'blacklist', 'hash:ip',
'hash:ip', 'family', 'inet', 'hashsize', 'family', 'inet', 'hashsize', '4096', 'maxelem',
'4096', 'maxelem', '65536')) '65536'))
except: except:
pass pass
try: try:
......
...@@ -55,7 +55,7 @@ class Interface(object): ...@@ -55,7 +55,7 @@ class Interface(object):
def _run(self, *args): def _run(self, *args):
args = ('ip', 'addr', ) + args args = ('ip', 'addr', ) + args
return ns_exec(NETNS, args) return ns_exec(args)
def show(self): def show(self):
retval = [] retval = []
...@@ -79,7 +79,7 @@ class Interface(object): ...@@ -79,7 +79,7 @@ class Interface(object):
def up(self): def up(self):
if self.is_veth: if self.is_veth:
ns_exec(NETNS, ('ip', 'link', 'set', 'up', self.name)) ns_exec(('ip', 'link', 'set', 'up', self.name))
sudo(('ip', 'link', 'set', 'up', self.external_name)) sudo(('ip', 'link', 'set', 'up', self.external_name))
def migrate(self): def migrate(self):
......
...@@ -44,6 +44,6 @@ def sudo(args, stdin=None): ...@@ -44,6 +44,6 @@ def sudo(args, stdin=None):
return stdout return stdout
def ns_exec(netns, args, stdin=None): def ns_exec(args, stdin=None):
return sudo(('/sbin/ip', 'netns', 'exec', return sudo(('/sbin/ip', 'netns', 'exec',
NETNS) + args, stdin) 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