import getopt
import os
+import signal
import subprocess
import sys
import syslog
vsctl="/usr/bin/ovs-vsctl"
session = None
+force_run = False
# Set up a session to interact with XAPI.
#
print "Other options:"
print " -h, --help display this help message"
sys.exit(0)
-
+
+def handler(signum, frame):
+ global force_run
+ if (signum == signal.SIGHUP):
+ force_run = True
+
def main(argv):
+ global force_run
+
try:
options, args = getopt.gnu_getopt(
argv[1:], 'h', ['help'] + ovs.daemon.LONG_OPTIONS)
# tasks, we need it. Wait here until it's up.
while not os.path.exists("/var/run/xapi_init_complete.cookie"):
time.sleep(1)
+
+ signal.signal(signal.SIGHUP, handler)
bridges = {}
interfaces = {}
while True:
- if not idl.run():
+ if not force_run and not idl.run():
poller = ovs.poller.Poller()
idl.wait(poller)
poller.block()
continue
-
+
+ if force_run:
+ bridges = {}
+ interfaces = {}
+ force_run = False
+
new_bridges = {}
for rec in idl.data["Bridge"].itervalues():
name = rec.name.as_scalar()
if name not in bridges:
update_network_uuids(name, ids)
- update_bridge_id(name, ids)
+ if (name not in bridges) or (bridges[name] != ids):
+ update_bridge_id(name, ids)
bridges = new_bridges
if interfaces != new_interfaces:
for name,ids in new_interfaces.items():
- update_iface_id(name, ids)
+ if (name not in interfaces) or (interfaces[name] != ids):
+ update_iface_id(name, ids)
interfaces = new_interfaces
if __name__ == '__main__':