summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2021-03-13 14:51:19 +0200
committerLars Wirzenius <liw@liw.fi>2021-03-14 09:11:07 +0200
commitb8119579a246727805a03c5a8e60fb44109410f6 (patch)
treeb4e0698ae9f50b8757530f2332cb1c40872d4a5c /subplot
parentd4cba41b5674e6ca1cbd5669aeb42d5f7d62e8bd (diff)
downloadvmadm-b8119579a246727805a03c5a8e60fb44109410f6.tar.gz
fix: VMs can be restarted
Previously, the temporary file for the cloud-init configuration ISO was left attached to the VM. This meant the VM couldn't be turned off and back on again: the temporary no longer existed. Now we detach the ISO file after the VM has booted. As a side effect, vmadm has gained start and shutdown subcommands, so that the fix can be tested.
Diffstat (limited to 'subplot')
-rw-r--r--subplot/vmadm.py16
-rw-r--r--subplot/vmadm.yaml6
2 files changed, 22 insertions, 0 deletions
diff --git a/subplot/vmadm.py b/subplot/vmadm.py
index 6997c5b..dcdcbb6 100644
--- a/subplot/vmadm.py
+++ b/subplot/vmadm.py
@@ -81,6 +81,22 @@ def delete_vm(ctx, config=None, filename=None):
runcmd_exit_code_is_zero(ctx)
+def shutdown_vm(ctx, config=None, filename=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ runcmd_run(ctx, ["vmadm", "shutdown", "--config", config, filename])
+ runcmd_exit_code_is_zero(ctx)
+
+
+def start_vm(ctx, config=None, filename=None):
+ runcmd_run = globals()["runcmd_run"]
+ runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
+
+ runcmd_run(ctx, ["vmadm", "start", "--config", config, filename])
+ runcmd_exit_code_is_zero(ctx)
+
+
def run_hostname_over_ssh(ctx, config=None, target=None, args=None):
runcmd_run = globals()["runcmd_run"]
runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
diff --git a/subplot/vmadm.yaml b/subplot/vmadm.yaml
index 21662b6..76881e1 100644
--- a/subplot/vmadm.yaml
+++ b/subplot/vmadm.yaml
@@ -11,6 +11,12 @@
function: create_vm
cleanup: delete_vm
+- when: "I invoke vmadm shutdown --config {config} {filename}"
+ function: shutdown_vm
+
+- when: "I invoke vmadm start --config {config} {filename}"
+ function: start_vm
+
- when: "I invoke ssh -F {config} {target} {args:text}"
function: run_hostname_over_ssh