Commit 41f5615a by Kálmán Viktor

Merge branch 'systemd_feature' into 'master'

Systemd feature

Add systemd units and systemd detector.

See merge request !3
parents af42f3a5 c89adcec
......@@ -5,7 +5,7 @@ import json
import logging
from utils import (ns_exec, sudo, ADDRESSES, get_network_type,
dhcp_no_free_re, dhcp_ack_re)
dhcp_no_free_re, dhcp_ack_re, is_there_systemd)
DHCP_LOGFILE = getenv('DHCP_LOGFILE', '/var/log/syslog')
VLAN_CONF = getenv('VLAN_CONF', 'vlan.conf')
......@@ -77,7 +77,11 @@ def reload_firewall_vlan(data, save_config=True):
def reload_dhcp(data):
with open('/etc/dhcp/dhcpd.conf.generated', 'w') as f:
f.write("\n".join(data) + "\n")
sudo(('/etc/init.d/isc-dhcp-server', 'restart'))
if is_there_systemd():
sudo(('/bin/systemctl', 'restart', 'dhcpd'))
else:
sudo(('/etc/init.d/isc-dhcp-server', 'restart'))
logger.info("DHCP configuration is reloaded.")
......
[Unit]
Description=CIRCLE firewall init
After=network.target
#Before=firewall.service
[Service]
User=root
Group=root
Type=oneshot
ExecStart=/bin/bash -c "/bin/systemctl restart openvswitch ; /sbin/ip netns add fw || true; ovs-vsctl del-br firewall || true; /sbin/ip netns exec fw sysctl -f /etc/sysctl.d/60-circle-firewall.conf ; /sbin/ip netns exec fw ip link set lo up"
[Install]
WantedBy=multi-user.target
[Unit]
Description=CIRCLE firewall
After=network.target
Requires=firewall-init.service
After=firewall-init.service
[Service]
User=fw
Group=fw
WorkingDirectory=/home/fw/fwdriver
ExecStart=/bin/bash -c ". /home/fw/.virtualenvs/fw/bin/postactivate; . /home/fw/.virtualenvs/fw/bin/activate; exec celeryd -A fw -Q %H.firewall --loglevel=info -c 1"
#ExecStartPost=/bin/sudo /bin/systemctl restart dhcpd
Restart=always
[Install]
WantedBy=multi-user.target
setuptools==0.9.8
amqp==1.0.13
anyjson==0.3.3
argparse==1.2.1
billiard==2.7.3.32
celery==3.0.23
distribute==0.6.24
distribute==0.7.3
kombu==2.5.14
netaddr==0.7.10
python-dateutil==2.1
......
import os
from os import getenv
import subprocess as sp
import logging
......@@ -60,3 +61,8 @@ def ns_exec(args, stdin=None):
else:
return sudo(('/sbin/ip', 'netns', 'exec',
NETNS) + args, stdin)
def is_there_systemd():
return os.path.isfile("/bin/systemctl")
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