From 1ffeee2ca2ec2e22f35a3aa399031b54d61588f4 Mon Sep 17 00:00:00 2001 From: Dan Farnsworth Date: Wed, 12 May 2021 14:56:22 -0600 Subject: [PATCH] Add support for 'reset_full' config option per component --- README.md | 4 +++- devlab_bench/actions/reset.py | 18 ++++++++++++++++++ devlab_bench/actions/up.py | 2 +- 3 files changed, 22 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d86a591..46317d5 100644 --- a/README.md +++ b/README.md @@ -142,7 +142,8 @@ The structure looks like this: "group": INT, "number": INT }, - "reset_paths": [] + "reset_paths": [], + "reset_full": [] } ``` @@ -166,6 +167,7 @@ All Keys that are in **bold** are required | shell | String | The path to the shell inside the container that will be the default command when using the devlab [sh](#sh-action) action | | ordinal | Hash | This is used indicate the order of the components. When parallel execution is supported, the `group` key indicates the components that can be brought up at the same time, `number` indicates the order inside the group to start up | | reset_paths | List of Strings | These are paths to files and diretories relative to the `paths['component_persistence']` that should be deleted when performing a devlab [reset](#reset-action) | +| reset_full | List of Strings | Paths to files and directories relative to the `paths['component_persistence']`, that should be removed as part of a devlab [reset](#reset-action) `--full` action | ## Network Config Structure The structure looks like this: diff --git a/devlab_bench/actions/reset.py b/devlab_bench/actions/reset.py index 6bf09c4..6d39ce3 100644 --- a/devlab_bench/actions/reset.py +++ b/devlab_bench/actions/reset.py @@ -184,6 +184,24 @@ def action(targets='*', reset_wizard=False, full=False, **kwargs): shutil.rmtree(full_path) except KeyError: pass + if full: + log.info("Resetting 'full' reset files for component '%s'", comp) + try: + for fpath in comp_config['reset_full']: + full_path = '{PROJ_ROOT}/{comp_pers}/{component}/{path}'.format( + PROJ_ROOT=devlab_bench.PROJ_ROOT, + comp_pers=config['paths']['component_persistence'], + component=comp, + path=fpath + ).replace('..', '') + if os.path.isdir(full_path): + log.debug("Removing directory: '%s'", full_path) + shutil.rmtree(full_path) + if os.path.isfile(full_path): + log.debug("Removing file: '%s'", full_path) + os.remove(full_path) + except KeyError: + pass if 'devlab' in components_to_reset: log.info("Resetting devlab specific files") try: diff --git a/devlab_bench/actions/up.py b/devlab_bench/actions/up.py index f3395e6..39c770e 100644 --- a/devlab_bench/actions/up.py +++ b/devlab_bench/actions/up.py @@ -279,7 +279,7 @@ def component_up(name, comp_config, skip_provision=False, keep_up_on_error=False if 'pre_scripts' in comp_config: for script in comp_config['pre_scripts']: log.debug("Found Pre script: '%s'", script) - script_ret = script_runner(script, name=comp_cont_name, log=log) + script_ret = script_runner(script, name=comp_cont_name, interactive=True, log_output=True) if script_ret[0] != 0: errors = True break