From 847c80616703025f6bfb5a41a9b89130487515d6 Mon Sep 17 00:00:00 2001 From: pr1ntf Date: Fri, 23 Jun 2017 01:55:49 +0000 Subject: [PATCH 1/2] add rmsnap function --- lib/ioh-cmd | 4 ++++ lib/ioh-zfs | 27 +++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/lib/ioh-cmd b/lib/ioh-cmd index 7e3f28b..b8b1582 100644 --- a/lib/ioh-cmd +++ b/lib/ioh-cmd @@ -138,6 +138,10 @@ __parse_cmd () { __zfs_rmprop "$@" exit ;; + rmsnap) + __zfs_rmsnap "$@" + exit + ;; getall) __zfs_getall "$@" exit diff --git a/lib/ioh-zfs b/lib/ioh-zfs index 881bedf..d9ecc4a 100644 --- a/lib/ioh-zfs +++ b/lib/ioh-zfs @@ -137,6 +137,33 @@ __zfs_rollguest() { fi } +# Remove a snap +__zfs_rmsnap() { + local flagone="$2" + local flagtwo="$3" + if [ $flagone = "-f" ]; then + if [ -z "$flagtwo" ]; then + printf "missing argument\nusage:\n" + printf "\trmsnap [-f] @\n" + exit 1 + fi + echo "Removing snapshot $flagtwo" + echo "I hope it was a snapshot and not a guest." + local pool="$(zfs list -t snapshot | cut -d '/' -f-3 | grep "$flagtwo" | head -n1 | cut -f1 -d/)" + zfs destroy -r $pool/iohyve/$flagtwo + else + local pool="$(zfs list -t snapshot | cut -d '/' -f-3 | grep "$flagone" | head -n1 | cut -f1 -d/)" + echo "Warning: if you supply a guestname and not a guestname@snapname, you will destroy the guest." + read -p "Are you sure you want to remove $flagone [Y/N]? " an Date: Fri, 23 Jun 2017 02:06:38 +0000 Subject: [PATCH 2/2] document rmsnap --- README.md | 1 + iohyve | 1 + iohyve.8 | 11 ++++++++++- iohyve.8.txt | 7 +++++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 8e798c0..20312b3 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ resize disks snap @ roll @ +rmsnap [-f] @ clone [-r] export snaplist diff --git a/iohyve b/iohyve index b7bbe9c..7a1ab76 100755 --- a/iohyve +++ b/iohyve @@ -70,6 +70,7 @@ iohyve version disks snap @ roll @ + rmsnap [-f] @ clone [-r] export snaplist diff --git a/iohyve.8 b/iohyve.8 index d7cf66a..2b0c6eb 100644 --- a/iohyve.8 +++ b/iohyve.8 @@ -1,5 +1,5 @@ .\" Text automatically generated by txt2man -.TH iohyve 8 "17 May 2017" "" "FreeBSD System Manager's Manual" +.TH iohyve 8 "23 June 2017" "" "FreeBSD System Manager's Manual" .SH NAME \fBiohyve(8) \fP- bhyve manager/launcher v0.7.8 "I'd Rather be in the Delta Quadrant Edition" \fB @@ -41,6 +41,7 @@ \fBiohyve\fP \fIdisks\fP \fBiohyve\fP \fIsnap\fP @<\fIsnap\fP> \fBiohyve\fP \fIroll\fP @<\fIsnap\fP> +\fBiohyve\fP \fIrmsnap\fP [\fB-f\fP] @<\fIsnap\fP> \fBiohyve\fP \fIclone\fP [\fB-r\fP] \fBiohyve\fP \fIexport\fP \fBiohyve\fP \fIsnaplist\fP @@ -316,6 +317,14 @@ name of the guest and <\fIsnap\fP> is what you would like to name the snapshot. .TP .B +\fIrmsnap\fP +Removes a snapshot of a guest +Usage: '\fBiohyve\fP \fIrmsnap\fP @<\fIsnap\fP>' where is the name +of the guest operating system. <\fIsnap\fP> is the snapshot +you want removed. Use with caution. If [\fB-f\fP] is supplied +before the , there is no prompt to \fIremove\fP. +.TP +.B \fIclone\fP Clone a guest. Note that this will \fIclone\fP all of the properties. If you want to use the \fIclone\fP and the original guest at the diff --git a/iohyve.8.txt b/iohyve.8.txt index 5d294ec..187a396 100644 --- a/iohyve.8.txt +++ b/iohyve.8.txt @@ -37,6 +37,7 @@ iohyve resize iohyve disks iohyve snap @ iohyve roll @ +iohyve rmsnap [-f] @ iohyve clone [-r] iohyve export iohyve snaplist @@ -235,6 +236,12 @@ roll Rollback guest to a snapshot. name of the guest and is what you would like to name the snapshot. +rmsnap Removes a snapshot of a guest + Usage: 'iohyve rmsnap @' where is the name + of the guest operating system. is the snapshot + you want removed. Use with caution. If [-f] is supplied + before the , there is no prompt to remove. + clone Clone a guest. Note that this will clone all of the properties. If you want to use the clone and the original guest at the same time you will need to change the tap and nmdm properties