+def collect_ovsdb():
+ if not os.path.isfile(OPENVSWITCH_CONF_DB):
+ return
+
+ max_size = 10*MB
+
+ try:
+ if os.path.getsize(OPENVSWITCH_CONF_DB) > max_size:
+ if os.path.isfile(OPENVSWITCH_COMPACT_DB):
+ os.unlink(OPENVSWITCH_COMPACT_DB)
+
+ output = StringIO.StringIO()
+ max_time = 5
+ procs = [ProcOutput(['ovsdb-tool', 'compact',
+ OPENVSWITCH_CONF_DB, OPENVSWITCH_COMPACT_DB],
+ max_time, output)]
+ run_procs([procs])
+ file_output(CAP_NETWORK_STATUS, [OPENVSWITCH_COMPACT_DB])
+ else:
+ file_output(CAP_NETWORK_STATUS, [OPENVSWITCH_CONF_DB])
+ except OSError, e:
+ return
+
+def cleanup_ovsdb():
+ try:
+ if os.path.isfile(OPENVSWITCH_COMPACT_DB):
+ os.unlink(OPENVSWITCH_COMPACT_DB)
+ except:
+ return
+