#!/usr/bin/env python3
# tests/phase-05/make_fixtures.py OUTDIR
# Emit juju-status JSON (octavia blocked vs active) + the plain-text `-f value -c <col>`
# outputs the openstack shim replays for resource/image lists.
import json, os, sys
out = sys.argv[1]
os.makedirs(out, exist_ok=True)
def wj(name, obj):
with open(os.path.join(out, name), "w") as f: json.dump(obj, f, indent=2)
def wt(name, text):
with open(os.path.join(out, name), "w") as f: f.write(text)
def octavia_status(current, message):
return {"model": {"name": "openstack"},
"applications": {"octavia": {"units": {"octavia/0": {
"workload-status": {"current": current, "message": message},
"juju-status": {"current": "idle"}}}}}}
wj("status-blocked.json", octavia_status(
"blocked", "Awaiting end-user execution of `configure-resources` action to create required resources"))
wj("status-active.json", octavia_status("active", "Unit is ready"))
# openstack `-f value -c Name` outputs (one name per line; empty file = none)
wt("nets-empty", ""); wt("nets-present", "lb-mgmt-net\n")
wt("subs-empty", ""); wt("subs-present", "lb-mgmt-subnetv6\n")
wt("sgs-empty", ""); wt("sgs-present", "lb-mgmt-sec-grp\n")
# openstack image list `-c Status` outputs
wt("imgs-empty", ""); wt("imgs-active", "active\n")
print("fixtures written to", out)