Skip to content

Commit

Permalink
Merge pull request #277 from pr1ntf/remove-snaps
Browse files Browse the repository at this point in the history
Remove snaps
  • Loading branch information
trent-pr1ntf committed Jun 23, 2017
2 parents 4eb5781 + 16964ef commit 8f23684
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ resize <name> <diskN> <size>
disks <name>
snap <name>@<snap>
roll <name>@<snap>
rmsnap [-f] <name>@<snap>
clone [-r] <name> <clonename>
export <name>
snaplist
Expand Down
1 change: 1 addition & 0 deletions iohyve
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ iohyve version
disks <name>
snap <name>@<snap>
roll <name>@<snap>
rmsnap [-f] <name>@<snap>
clone [-r] <name> <clonename>
export <name>
snaplist
Expand Down
11 changes: 10 additions & 1 deletion iohyve.8
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -41,6 +41,7 @@
\fBiohyve\fP \fIdisks\fP <name>
\fBiohyve\fP \fIsnap\fP <name>@<\fIsnap\fP>
\fBiohyve\fP \fIroll\fP <name>@<\fIsnap\fP>
\fBiohyve\fP \fIrmsnap\fP [\fB-f\fP] <name>@<\fIsnap\fP>
\fBiohyve\fP \fIclone\fP [\fB-r\fP] <name> <clonename>
\fBiohyve\fP \fIexport\fP <name>
\fBiohyve\fP \fIsnaplist\fP
Expand Down Expand Up @@ -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 <name>@<\fIsnap\fP>' where <name> 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 <name>, 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
Expand Down
7 changes: 7 additions & 0 deletions iohyve.8.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ iohyve resize <name> <diskN> <size>
iohyve disks <name>
iohyve snap <name>@<snap>
iohyve roll <name>@<snap>
iohyve rmsnap [-f] <name>@<snap>
iohyve clone [-r] <name> <clonename>
iohyve export <name>
iohyve snaplist
Expand Down Expand Up @@ -235,6 +236,12 @@ roll Rollback guest to a snapshot.
name of the guest and <snap> is what you would
like to name the snapshot.

rmsnap Removes a snapshot of a guest
Usage: 'iohyve rmsnap <name>@<snap>' where <name> is the name
of the guest operating system. <snap> is the snapshot
you want removed. Use with caution. If [-f] is supplied
before the <name>, 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
Expand Down
4 changes: 4 additions & 0 deletions lib/ioh-cmd
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,10 @@ __parse_cmd () {
__zfs_rmprop "$@"
exit
;;
rmsnap)
__zfs_rmsnap "$@"
exit
;;
getall)
__zfs_getall "$@"
exit
Expand Down
27 changes: 27 additions & 0 deletions lib/ioh-zfs
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,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] <name>@<snapname>\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 </dev/tty
case "$an" in
y|Y) zfs destroy -r $pool/iohyve/$flagone
;;
*) echo "Not removed..."
;;
esac
fi
}

# Clone a guest
__zfs_cloneguest() {
local flag="$2"
Expand Down

0 comments on commit 8f23684

Please sign in to comment.