New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issue when deleting a guest would actually delete all guests with a shared base name. Also made alterations to deletion function. #119

Closed
wants to merge 3 commits into
base: master
from

Conversation

Projects
None yet
1 participant
@EpiJunkie
Copy link
Contributor

EpiJunkie commented Apr 3, 2016

This pull request is to address an issue when issuing the command iohyve delete basenameguest where both basenameguest and basenameguest1 are deleted.

I removed the for loops as I believe it is unnecessary when using the -r flag with zfs destroy. The child datasets (eg iohyve guest disks) should be destroyed when using that flag alone.

Changed zfs destroy to use only the -r flag when not using the iohyve delete -f command as using zfs destroy -R transverses to clones. While clones are not implemented with iohyve, I think as a matter of caution, full destruction mode should be reserved for the use of iohyve delete -f instead.

Added various changes to the prompts and output for clarity and verbosity, it is the least we can do for the end user before they do something potentially unwanted.

Excerpt from man page for zfs destroy:

-r  Recursively destroy all children. If a snapshot
    is  specified,  destroy all  snapshots with this
    name in descendent file systems.

-R  Recursively destroy all dependents, including
    cloned file  systems  outside the target hierarchy.
    If a snapshot is specified, destroy all snapshots
    with this name in descendent  file  systems.

Before changes:

root@bhost:~ # iohyve list
Guest      VMM?  Running  rcboot?  Description
root@bhost:~ # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:~ # iohyve create basenameguest1 1G
printf: Illegal option -\
Creating basenameguest1...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 09:09:45 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 09:09:54 MDT 2016
root@bhost:~ # zfs list -H -t filesystem -o name | grep iohyve | grep basenameguest
tank/iohyve/basenameguest
tank/iohyve/basenameguest1
root@bhost:~ # iohyve delete basenameguest
Are you sure you want to delete basenameguest and all associated datasets [Y/N]? y
root@bhost:~ # iohyve list
Guest      VMM?  Running  rcboot?  Description

After changes:

root@bhost:~ # iohyve list
Guest      VMM?  Running  rcboot?  Description
root@bhost:~ # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:~ # iohyve create basenameguest1 1G
printf: Illegal option -\
Creating basenameguest1...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 12:06:34 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016
root@bhost:~ # iohyve delete basenameguest

[WARNING] Are you sure you want to permanently delete basenameguest and all child datasets?
Location: tank/iohyve/basenameguest [Y/N]? y
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016

root@bhost:~ # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 12:07:24 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016
root@bhost:~ # iohyve delete -f basenameguest

[WARNING] Forcing permanent deletion of basenameguest
Location: tank/iohyve/basenameguest including children and clones

Hit Ctrl+C in the next 10 seconds to cancel...
Deleting basenameguest at tank/iohyve/basenameguest...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016

This is my first commit. If I can do anything differently, please let me know. I am a system administrator by trade and committing code to a project is uncharted territory.

Fixed issue when deleting a guest would delete all guests with a shar…
…ed base name. Also made alterations to deletion function.

An example is basenameguest and basenameguest1 would be deleted when issuing the command "iohyve delete basenameguest"

I removed the for loops as I believe it is unnecessary due to using the -r flag with zfs destroy. The child datasets should be destroyed when using that flag alone.

Changed the zfs destroy to use only the -r flag as using -R transverses to clones as well. While clones are not currently implemented with iohyve, I think as a matter of
caution full destruction mode with the use of iohyve delete -f .

Added various changes to the prompts and output for clarity and verbosity, it’s the least we can do for the end user before they do something potentially unwanted.

Excerpt from man page for zfs destroy
-r 	Recursively destroy all children. If a snapshot
	is  specified,  destroy all  snapshots with this
	name in descendent file systems.

-R	Recursively destroy all dependents, including
	cloned file  systems  outside the target hierarchy.
	If a snapshot is specified, destroy all snapshots
	with this name in descendent  file  systems.

Before changes:

root@bhost:/usr/local/sbin # iohyve list
Guest      VMM?  Running  rcboot?  Description
root@bhost:/usr/local/sbin # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:/usr/local/sbin # iohyve create basenameguest1 1G
printf: Illegal option -\
Creating basenameguest1...
root@bhost:/usr/local/sbin # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 09:09:45 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 09:09:54 MDT 2016
root@bhost:/usr/local/sbin # zfs list -H -t filesystem -o name | grep iohyve | grep basenameguest
tank/iohyve/basenameguest
tank/iohyve/basenameguest1
root@bhost:/usr/local/sbin # iohyve delete basenameguest
Are you sure you want to delete basenameguest and all associated datasets [Y/N]? y

After changes:

root@bhost:/usr/local/sbin # iohyve list
Guest      VMM?  Running  rcboot?  Description
root@bhost:/usr/local/sbin # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:/usr/local/sbin # iohyve create basenameguest1 1G
printf: Illegal option -\
Creating basenameguest1...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 12:06:34 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016
root@bhost:~ # iohyve delete basenameguest

[WARNING] Are you sure you want to permanently delete basenameguest and all child datasets?
Location: tank/iohyve/basenameguest [Y/N]? y
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016
root@bhost:~ # iohyve create basenameguest 1G
printf: Illegal option -\
Creating basenameguest...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest   NO    NO       NO       Sun Apr  3 12:07:24 MDT 2016
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016
root@bhost:~ # iohyve delete -f basenameguest

[WARNING] Forcing permanent deletion of basenameguest
Location: tank/iohyve/basenameguest including children and clones

Hit Ctrl+C in the next 10 seconds to cancel...
Deleting basenameguest at tank/iohyve/basenameguest...
root@bhost:~ # iohyve list
Guest           VMM?  Running  rcboot?  Description
basenameguest1  NO    NO       NO       Sun Apr  3 12:06:41 MDT 2016

@EpiJunkie EpiJunkie changed the title Fixed issue when deleting a guest would delete all guests with a shared base name. Also made alterations to deletion function. Fixed issue when deleting a guest would actually delete all guests with a shared base name. Also made alterations to deletion function. Apr 3, 2016

EpiJunkie added some commits Apr 3, 2016

Fixes issue when using getall && there is a space(s) in the description.
Utilizing `zfs` to display the text as desired. I removed the `-H` flag as it's primary purpose is to make parsing text easier, which we are not doing with the
`getall` subcommand. Using `sort` because it drives me crazy to have the order of the options change between guest outputs, this brings it to more consistent output. Using
`sed` to replace the text `iohyve:` with nothing.

Also added `iohyve/` to find the pool for consistency within the script.

Before changes:

```
root@bhost:~ # iohyve getall bguest
Getting guest props...
tap	tap7001
description	pfSense
name	guest
os	pfsense
ram	512M
cpu	2
bargs	-A_-H_-P
con	nmdm6
autogrub	\n
size	6G
install	no
persist	1
loader	bhyveload
boot	1
```

After changes:

```
root@bhost:~ # iohyve getall bguest
Getting bguest props...
autogrub       \n
bargs          -A_-H_-P
boot           1
con            nmdm6
cpu            2
description    pfSense - VPN In
install        no
loader         bhyveload
name           bguest
os             pfsense
persist        1
ram            512M
size           6G
tap            tap7001
```
Revert "Fixes issue when using getall && there is a space(s) in the d…
…escription."

This reverts commit 868a21c.

Going to create a seperate branch so that I can push individual changes to the source project.
@EpiJunkie

This comment has been minimized.

Copy link
Contributor Author

EpiJunkie commented Apr 3, 2016

Sorry I am making quiet a mess of this.

I am going to close this request and resubmit it the correct way under a new branch so that I can make multiple separate pull requests.

Thank you for everyone patience

@EpiJunkie EpiJunkie closed this Apr 3, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment