Properly decode output of create and destroy

This commit is contained in:
j3s 2020-05-16 16:55:18 -05:00
parent 942d629d6e
commit 7448cd90da

View File

@ -137,6 +137,7 @@ class ShellScriptVirtualization(VirtualizationInterface):
self.validate_completed_process(completedProcess, email)
lines = completedProcess.stdout.splitlines()
status = lines[len(lines)-1].decode("utf-8")
vmSettings = f"""
id={id}
@ -146,7 +147,7 @@ class ShellScriptVirtualization(VirtualizationInterface):
ssh_public_keys={ssh_keys_string}
"""
if not lines[len(lines)-1] == "success":
if not status == "success":
raise ValueError(f"""failed to create vm for {email} with:
{vmSettings}
stdout:
@ -160,8 +161,9 @@ class ShellScriptVirtualization(VirtualizationInterface):
completedProcess = run([join(current_app.root_path, 'shell_scripts/destroy.sh'), id], capture_output=True)
self.validate_completed_process(completedProcess, email)
lines = completedProcess.stdout.splitlines()
status = lines[len(lines)-1].decode("utf-8")
if not lines[len(lines)-1] == "success":
if not status == "success":
raise ValueError(f"""failed to destroy vm "{id}" for {email}:
stdout:
{completedProcess.stdout}