summaryrefslogtreecommitdiff
path: root/subplot
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2022-01-21 08:58:47 +0200
committerLars Wirzenius <liw@liw.fi>2022-01-21 08:58:47 +0200
commit1fd70189973f247c4fab3e426151cda4e912e8ed (patch)
treea53e82bca6e7e53c1ce0f30112aba60f26f9e48e /subplot
parentaeabf043ae323bdb7b644a22ecd93a4658862c06 (diff)
downloadvmadm-1fd70189973f247c4fab3e426151cda4e912e8ed.tar.gz
refactor: use lib/runcmd's steps instead of custom ones
Subplot's lib/runcmd provides a "when I run ..." step that we can use, instead of having a custom "when I invoke ..." step. Less code, fewer bugs. Sponsored-by: author
Diffstat (limited to 'subplot')
-rw-r--r--subplot/vmadm.py52
-rw-r--r--subplot/vmadm.yaml31
2 files changed, 0 insertions, 83 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: