2424
2525import argparse
2626import os
27- import signal
2827import sys
2928import time
3029
@@ -39,7 +38,7 @@ import ovs.unixctl
3938
4039vlog = ovs .vlog .Vlog ("ovs-xapi-sync" )
4140session = None
42- force_run = False
41+ flush_cache = False
4342exiting = False
4443
4544
@@ -49,6 +48,12 @@ def unixctl_exit(conn, unused_argv, unused_aux):
4948 conn .reply (None )
5049
5150
51+ def unixctl_flush_cache (conn , unused_argv , unused_aux ):
52+ global flush_cache
53+ flush_cache = True
54+ conn .reply (None )
55+
56+
5257# Set up a session to interact with XAPI.
5358#
5459# On system start-up, OVS comes up before XAPI, so we can't log into the
@@ -226,14 +231,8 @@ def prune_schema(schema):
226231 schema .tables = new_tables
227232
228233
229- def handler (signum , _ ):
230- global force_run
231- if (signum == signal .SIGHUP ):
232- force_run = True
233-
234-
235234def main ():
236- global force_run
235+ global flush_cache
237236
238237 parser = argparse .ArgumentParser ()
239238 parser .add_argument ("database" , metavar = "DATABASE" ,
@@ -257,6 +256,8 @@ def main():
257256 ovs .daemon .daemonize ()
258257
259258 ovs .unixctl .command_register ("exit" , "" , 0 , 0 , unixctl_exit , None )
259+ ovs .unixctl .command_register ("flush-cache" , "" , 0 , 0 , unixctl_flush_cache ,
260+ None )
260261 error , unixctl_server = ovs .unixctl .UnixctlServer .create (None )
261262 if error :
262263 ovs .util .ovs_fatal (error , "could not create unixctl server" , vlog )
@@ -267,8 +268,6 @@ def main():
267268 while not os .path .exists (cookie_file ):
268269 time .sleep (1 )
269270
270- signal .signal (signal .SIGHUP , handler )
271-
272271 bridges = {} # Map from bridge name to nicira-bridge-id
273272 iface_ids = {} # Map from xs-vif-uuid to iface-id
274273 vm_ids = {} # Map from xs-vm-uuid to vm-id
@@ -279,19 +278,19 @@ def main():
279278 break ;
280279
281280 idl .run ()
282- if not force_run and seqno == idl .change_seqno :
281+ if not flush_cache and seqno == idl .change_seqno :
283282 poller = ovs .poller .Poller ()
284283 unixctl_server .wait (poller )
285284 idl .wait (poller )
286285 poller .block ()
287286 continue
288287
289- if force_run :
290- vlog .info ("Forced to re-run as the result of a SIGHUP " )
288+ if flush_cache :
289+ vlog .info ("Flushing cache as the result of unixctl. " )
291290 bridges = {}
292291 iface_ids = {}
293292 vm_ids = {}
294- force_run = False
293+ flush_cache = False
295294 seqno = idl .change_seqno
296295
297296 txn = ovs .db .idl .Transaction (idl )
0 commit comments