summaryrefslogtreecommitdiff
path: root/subplot/vmadm.py
diff options
context:
space:
mode:
Diffstat (limited to 'subplot/vmadm.py')
-rw-r--r--subplot/vmadm.py30
1 files changed, 30 insertions, 0 deletions
diff --git a/subplot/vmadm.py b/subplot/vmadm.py
index 2374baf..48737a3 100644
--- a/subplot/vmadm.py
+++ b/subplot/vmadm.py
@@ -1,4 +1,6 @@
+import logging
import os
+import yaml
def install_vmadm(ctx):
@@ -16,6 +18,34 @@ def install_vmadm(ctx):
# This can be removed once the Subplot lib/files library creates
# directories.
os.mkdir(".ssh")
+ os.mkdir("expected")
+
+
+def invoke_cloud_init(ctx, 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", filename, dirname])
+ runcmd_exit_code_is_zero(ctx)
+
+
+def directories_match(ctx, actual=None, expected=None):
+ assert_eq = globals()["assert_eq"]
+
+ efiles = list(sorted(os.listdir(expected)))
+ afiles = list(sorted(os.listdir(expected)))
+ assert_eq(efiles, afiles)
+ for filename in efiles:
+ with open(os.path.join("expected", filename)) as f:
+ edata = yaml.safe_load(f)
+ with open(os.path.join("actual", filename)) as f:
+ adata = yaml.safe_load(f)
+ if "runcmd" in adata:
+ del adata["runcmd"]
+ logging.debug(f"directories_match: filename={filename}")
+ logging.debug(f"directories_match: edata={edata!r}")
+ logging.debug(f"directories_match: adata={adata!r}")
+ assert_eq(edata, adata)
def create_vm(ctx, filename=None):