Skip to content

Commit

Permalink
Merge branch 'master' into 'master'
Browse files Browse the repository at this point in the history
Add support for 'reset_full' config option per component and fix pre_script log output

See merge request evernym/utilities/devlab!4
  • Loading branch information
dmartinez911 committed May 18, 2021
2 parents 9b284cd + 1ffeee2 commit 0b92153
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ The structure looks like this:
"group": INT,
"number": INT
},
"reset_paths": []
"reset_paths": [],
"reset_full": []
}
```

Expand All @@ -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:
Expand Down
18 changes: 18 additions & 0 deletions devlab_bench/actions/reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion devlab_bench/actions/up.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b92153

Please sign in to comment.