Cleanup ONOS runtime generated files when cleaning up or shutting down ONOS cluster
Change-Id: I6dff4c4eb4398a18649a15647e3efc0415f528a9
diff --git a/src/test/setup/cord-test.py b/src/test/setup/cord-test.py
index 529103c..5992eba 100755
--- a/src/test/setup/cord-test.py
+++ b/src/test/setup/cord-test.py
@@ -712,6 +712,7 @@
for onos in onos_list:
Container.dckr.kill(onos)
Container.dckr.remove_container(onos, force=True)
+ Onos.cleanup_runtime()
return 0
diff --git a/src/test/utils/CordContainer.py b/src/test/utils/CordContainer.py
index ce23271..e764757 100644
--- a/src/test/utils/CordContainer.py
+++ b/src/test/utils/CordContainer.py
@@ -327,6 +327,16 @@
os.system(cmd)
except: pass
+ @classmethod
+ def cleanup_runtime(cls):
+ '''Cleanup ONOS runtime generated files'''
+ files = ( Onos.cluster_cfg, os.path.join(Onos.host_config_dir, 'network-cfg.json') )
+ for f in files:
+ if os.access(f, os.F_OK):
+ try:
+ os.unlink(f)
+ except: pass
+
def __init__(self, name = NAME, image = 'onosproject/onos', prefix = '', tag = 'latest',
boot_delay = 60, restart = False, network_cfg = None, cluster = False):
if restart is True: