Skip to content

Commit

Permalink
Fix bug which could occur if ds name invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
johnramsden committed Jun 10, 2018
1 parent fd253b3 commit 13c4850
Showing 1 changed file with 20 additions and 11 deletions.
31 changes: 20 additions & 11 deletions zedenv/cli/activate.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,17 +245,26 @@ def zedenv_activate(boot_environment: str,
f"\n{err}\nStopping activation.\n"
}, exit_on_error=True)

if not pyzfscmds.utility.dataset_exists(
be_requested) and not pyzfscmds.utility.is_clone(be_requested):
ZELogger.log({
"level": "EXCEPTION",
"message": f"Boot environment {boot_environment} doesn't exist'\n"
}, exit_on_error=True)
else:
ZELogger.verbose_log({
"level": "INFO",
"message": f"Boot environment {boot_environment} exists'\n"
}, verbose)
if not pyzfscmds.utility.dataset_exists(be_requested):
ds_is_clone = None
try:
ds_is_clone = pyzfscmds.utility.is_clone(be_requested)
except RuntimeError:
ZELogger.log({
"level": "EXCEPTION",
"message": f"Boot environment {boot_environment} doesn't exist'\n"
}, exit_on_error=True)

if not ds_is_clone:
ZELogger.log({
"level": "EXCEPTION",
"message": f"Boot environment {boot_environment} doesn't exist'\n"
}, exit_on_error=True)

ZELogger.verbose_log({
"level": "INFO",
"message": f"Boot environment {boot_environment} exists'\n"
}, verbose)

if current_be == be_requested:
ZELogger.verbose_log({
Expand Down

0 comments on commit 13c4850

Please sign in to comment.