From fc3d11791e60a3e031dfce7766c8aa45eb78a758 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 24 Oct 2022 02:01:01 +0200 Subject: [PATCH] Implement ynh_lxc_snapshot_delete --- lib/ynh_lxd | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/lib/ynh_lxd b/lib/ynh_lxd index 57e31be..b8b0275 100644 --- a/lib/ynh_lxd +++ b/lib/ynh_lxd @@ -415,6 +415,31 @@ ynh_lxc_snapshot_create () { fi } +# Delete a snapshot of an LXC container +# +# usage: ynh_lxc_snapshot_delete --name=name --snapname=snapname +# | arg: -n, --name= - name of the LXC +# | arg: -s, --snapname= - name of the snapshot +# +# Requires YunoHost version *.*.* or higher. +ynh_lxc_snapshot_delete () { + # Declare an array to define the options of this helper. + local legacy_args=ns + local -A args_array=([n]=name= [s]=snapname=) + local name + local snapname + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if ynh_lxc_snapshot_exists --name="$name" --snapname="$snapname" + then + lxc delete $name/$snapname + return 0 + else + return 1 + fi +} + # Load a snapshot of an LXC container # # usage: ynh_lxc_snapshot_load --name=name --snapname=snapname