Skip to content

Commit

Permalink
cli: cluster delete mount option
Browse files Browse the repository at this point in the history
closes #387
  • Loading branch information
audrium authored and tiborsimko committed Sep 7, 2020
1 parent 1eb7ad3 commit dbf607d
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Expand Up @@ -4,6 +4,7 @@ Authors
The list of contributors in alphabetical order:

- `Anton Khodak <https://orcid.org/0000-0003-3263-4553>`_
- `Audrius Mecionis <https://orcid.org/0000-0002-3759-1663>`_
- `Dan Leehr <https://orcid.org/0000-0003-3221-9579>`_
- `Daniel Prelipcean <https://orcid.org/0000-0002-4855-194X>`_
- `Diego Rodriguez <https://orcid.org/0000-0003-0649-2002>`_
Expand Down
34 changes: 30 additions & 4 deletions reana/reana_dev/cluster.py
Expand Up @@ -376,11 +376,37 @@ def cluster_unpause():
run_command(cmd, "reana")


@click.option(
"-m",
"--mount",
"mounts",
multiple=True,
help="Which local path directories are to be deleted? [local_path:cluster_node_path]",
)
@cluster_commands.command(name="cluster-delete")
def cluster_delete():
"""Delete REANA cluster."""
cmd = "kind delete cluster"
run_command(cmd, "reana")
def cluster_delete(mounts): # noqa: D301
"""Delete REANA cluster.
\b
Example:
$ reana-dev cluster-delete -m /var/reana:/var/reana
"""
cmds = []
# delete cluster
cmds.append("kind delete cluster")
# remove only local paths where cluster path starts with /var/reana for safety
for mount in mounts:
local_path, cluster_node_path = mount.split(":")
if cluster_node_path.startswith("/var/reana"):
cmds.append("sudo rm -rf {}/*".format(local_path))
else:
msg = "Directory {} will not be deleted for safety reasons.".format(
local_path
)
display_message(msg, "reana")
# execute commands
for cmd in cmds:
run_command(cmd, "reana")


cluster_commands_list = list(cluster_commands.commands.values())

0 comments on commit dbf607d

Please sign in to comment.