diff options
author | George Paraskevopoulos <geopar@intracom-telecom.com> | 2017-03-16 17:04:16 +0200 |
---|---|---|
committer | Brady Johnson <brady.allen.johnson@ericsson.com> | 2017-03-17 08:41:14 +0000 |
commit | 8869d175363dfec69cc70fd8cb9bef56e8ebc115 (patch) | |
tree | 7231320b81b872a3bfcf785832f3e21221a39ca9 | |
parent | 189642fff7428457d3992c365eab9a9f5c0bea90 (diff) |
Implement delete.sh as a python module
We need to call delete.sh after each test is run. The script is
implemented as a python module and called inside run_tests.py
Change-Id: I23a794be522b4713a44cc1d56587e0aadc6f1210
Signed-off-by: George Paraskevopoulos <geopar@intracom-telecom.com>
-rw-r--r-- | sfc/lib/cleanup.py | 71 | ||||
-rw-r--r-- | sfc/tests/functest/run_tests.py | 2 |
2 files changed, 73 insertions, 0 deletions
diff --git a/sfc/lib/cleanup.py b/sfc/lib/cleanup.py new file mode 100644 index 00000000..cf3349d3 --- /dev/null +++ b/sfc/lib/cleanup.py @@ -0,0 +1,71 @@ +import functest.utils.functest_logger as ft_logger +import functest.utils.openstack_utils as os_utils +import functest.utils.openstack_tacker as os_tacker +import utils + + +logger = ft_logger.Logger(__name__).getLogger() + + +def delete_vnfds(): + t = os_tacker.get_tacker_client() + for vnfd in os_tacker.list_vnfds(t): + logger.info("Removing vnfd: {0}".format(vnfd)) + os_tacker.delete_vnfd(t, vnfd_id=vnfd) + + +def delete_vnfs(): + t = os_tacker.get_tacker_client() + for vnf in os_tacker.list_vnfs(t): + logger.info("Removing vnf: {0}".format(vnf)) + os_tacker.delete_vnf(t, vnf_id=vnf) + + +def delete_sfcs(): + t = os_tacker.get_tacker_client() + for sfc in os_tacker.list_sfcs(t): + logger.info("Removing sfc: {0}".format(sfc)) + os_tacker.delete_sfc(t, sfc_id=sfc) + + +def delete_sfc_clfs(): + t = os_tacker.get_tacker_client() + for sfc_clf in os_tacker.list_sfc_classifiers(t): + logger.info("Removing sfc classifier: {0}".format(sfc_clf)) + os_tacker.delete_sfc_classifier(t, sfc_clf_id=sfc_clf) + + +def delete_floating_ips(): + n = os_utils.get_nova_client() + for fip in os_utils.get_floating_ips(n): + logger.info("Removing floating ip: {0}".format(fip.ip)) + os_utils.delete_floating_ip(n, fip.id) + + +def delete_stacks(): + logger.info("Removing stack: sfc") + utils.run_cmd('openstack stack delete sfc --y') + logger.info("Removing stack: sfc_test1") + utils.run_cmd('openstack stack delete sfc_test1 --y') + logger.info("Removing stack: sfc_test2") + utils.run_cmd('openstack stack delete sfc_test2 --y') + + +def delete_instances(): + n = os_utils.get_nova_client() + for inst in os_utils.get_instances(n): + logger.info("Removing instance: {0}".format(inst.id)) + os_utils.delete_instance(n, inst.id) + + +def cleanup(): + delete_sfc_clfs() + delete_sfcs() + delete_vnfs() + delete_stacks() + delete_floating_ips() + delete_instances() + + +if __name__ == '__main__': + cleanup() diff --git a/sfc/tests/functest/run_tests.py b/sfc/tests/functest/run_tests.py index 762e6b3d..f728cfdc 100644 --- a/sfc/tests/functest/run_tests.py +++ b/sfc/tests/functest/run_tests.py @@ -19,6 +19,7 @@ import functest.utils.functest_logger as ft_logger import functest.utils.functest_utils as ft_utils import functest.utils.openstack_utils as os_utils import opnfv.utils.ovs_logger as ovs_log +import sfc.lib.cleanup as sfc_cleanup import sfc.lib.config as sfc_config from opnfv.deployment.factory import Factory as DeploymentFactory @@ -115,6 +116,7 @@ def main(): details = result.get("details") push_results( test_name_db, start_time, end_time, status, details) + sfc_cleanup.cleanup() overall_end_time = time.time() if args.report: |