summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-21 07:00:13 +0000
committerLars Wirzenius <liw@liw.fi>2022-01-21 07:00:13 +0000
commit0f81ce2cf72c33cd7d08f18a8e3a11dc843e3456 (patch)
treea53e82bca6e7e53c1ce0f30112aba60f26f9e48e
parentaeabf043ae323bdb7b644a22ecd93a4658862c06 (diff)
parent1fd70189973f247c4fab3e426151cda4e912e8ed (diff)
downloadvmadm-0f81ce2cf72c33cd7d08f18a8e3a11dc843e3456.tar.gz
Merge branch 'runcmd' into 'main'
refactor: use lib/runcmd's steps instead of custom ones See merge request larswirzenius/vmadm!55
-rw-r--r--subplot/vmadm.py52
-rw-r--r--subplot/vmadm.yaml31
-rw-r--r--vmadm.md25
3 files changed, 13 insertions, 95 deletions
diff --git a/subplot/vmadm.py b/subplot/vmadm.py
index e6cd234..dd9388d 100644
--- a/subplot/vmadm.py
+++ b/subplot/vmadm.py
@@ -42,14 +42,6 @@ def ensure_base_image(ctx):
shutil.copy(base, "base.qcow2")
-def invoke_cloud_init(ctx, config=None, filename=None, dirname=None):
- runcmd_run = globals()["runcmd_run"]
- runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
-
- runcmd_run(ctx, ["vmadm", "cloud-init", "--config", config, filename, dirname])
- runcmd_exit_code_is_zero(ctx)
-
-
def directories_match(ctx, actual=None, expected=None):
assert_eq = globals()["assert_eq"]
@@ -69,50 +61,6 @@ def directories_match(ctx, actual=None, expected=None):
assert_eq(edata, adata)
-def create_vm(ctx, config=None, filename=None):
- runcmd_run = globals()["runcmd_run"]
- runcmd_exit_code_is_zero = globals()["runcmd_exit_code_is_zero"]
-
- ctx["config"] = config
- ctx["spec"] = filename
- runcmd_run(ctx, ["vmadm", "new", "--config", config, filename])
- runcmd_exit_code_is_zero(ctx)
-
-
-def delete_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", "delete", "--config", ctx["config"], ctx["spec"]])
- 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"]
-
- # Fix permissions for .ssh and its contents.
- runcmd_run(ctx, ["chmod", "-R", "u=rwX,go=", ".ssh"])
- runcmd_run(ctx, ["ssh", "-F", config, target] + args.split())
- runcmd_exit_code_is_zero(ctx)
-
-
def stdout_json_matches(ctx, filename=None):
runcmd_get_stdout = globals()["runcmd_get_stdout"]
diff --git a/subplot/vmadm.yaml b/subplot/vmadm.yaml
index 4c64a9b..4fe5e0c 100644
--- a/subplot/vmadm.yaml
+++ b/subplot/vmadm.yaml
@@ -8,37 +8,6 @@
python:
function: ensure_base_image
-- when: "I invoke vmadm cloud-init --config {config} {filename} {dirname}"
- impl:
- python:
- function: invoke_cloud_init
-
-- when: "I invoke vmadm new --config {config} {filename}"
- impl:
- python:
- function: create_vm
- cleanup: delete_vm
-
-- when: "I invoke vmadm delete --config {config} {filename}"
- impl:
- python:
- function: delete_vm
-
-- when: "I invoke vmadm shutdown --config {config} {filename}"
- impl:
- python:
- function: shutdown_vm
-
-- when: "I invoke vmadm start --config {config} {filename}"
- impl:
- python:
- function: start_vm
-
-- when: "I invoke ssh -F {config} {target} {args:text}"
- impl:
- python:
- function: run_hostname_over_ssh
-
- then: "directories {actual} and {expected} are identical"
impl:
python:
diff --git a/vmadm.md b/vmadm.md
index 1db6307..8bfd476 100644
--- a/vmadm.md
+++ b/vmadm.md
@@ -162,7 +162,7 @@ given file config.yaml
given file .ssh/id_rsa.pub from init_ssh_key_pub
given file expected/init-test/meta-data from init-metadata
given file expected/init-test/user-data from init-userdata
-when I invoke vmadm cloud-init --config config.yaml init.yaml actual
+when I run vmadm cloud-init --config config.yaml init.yaml actual
then directories actual/init-test and expected/init-test are identical
~~~
@@ -228,17 +228,18 @@ given file .ssh/id_rsa from ssh_key
given file .ssh/id_rsa.pub from ssh_key_pub
given file .ssh/config from ssh_config
given file .ssh/known_hosts from known_hosts
+when I run chmod -R u=rwX,go= .ssh
~~~
Then we create the VM, and verify that we can log in.
~~~scenario
-when I invoke vmadm new --config config.yaml smoke.yaml
-when I invoke ssh -F .ssh/config debian@smoke hostname
+when I run vmadm new --config config.yaml smoke.yaml
+when I run ssh -F .ssh/config debian@smoke hostname
then stdout contains "smoke"
-when I invoke ssh -F .ssh/config debian@smoke df -h /
+when I run ssh -F .ssh/config debian@smoke df -h /
then stdout matches regex 4\.\dG
-when I invoke ssh -F .ssh/config debian@smoke free -m
+when I run ssh -F .ssh/config debian@smoke free -m
then stdout matches regex Mem:\s+19\d\d\s
~~~
@@ -246,24 +247,24 @@ Then we shut it down, twice. The second time is to verify shutting
down works even if the VM is already shut down.
~~~scenario
-when I invoke vmadm shutdown --config config.yaml smoke.yaml
-when I invoke vmadm shutdown --config config.yaml smoke.yaml
+when I run vmadm shutdown --config config.yaml smoke.yaml
+when I run vmadm shutdown --config config.yaml smoke.yaml
~~~
Then we start it back up again and verify we can log in. Then we start
it again, while it's already running, to verify that that works.
~~~scenario
-when I invoke vmadm start --config config.yaml smoke.yaml
-when I invoke ssh -F .ssh/config debian@smoke hostname
-when I invoke vmadm start --config config.yaml smoke.yaml
+when I run vmadm start --config config.yaml smoke.yaml
+when I run ssh -F .ssh/config debian@smoke hostname
+when I run vmadm start --config config.yaml smoke.yaml
~~~
Finally, we delete it twice.
~~~scenario
-when I invoke vmadm delete --config config.yaml smoke.yaml
-when I invoke vmadm delete --config config.yaml smoke.yaml
+when I run vmadm delete --config config.yaml smoke.yaml
+when I run vmadm delete --config config.yaml smoke.yaml
~~~