2
from subprocess import call, check_output
3
from os.path import join as pjoin
5
PROOF = "This text is the proof that storage-attached hook ran with"\
8
call(["juju-log", "Storage attached"])
9
storage_info = check_output("storage-get")
10
call(["juju-log", "Storage info: %s" % storage_info])
11
lines = storage_info.strip().splitlines()
12
out = dict((k.strip(),v.strip()) for k,v in
13
[line.split(":") for line in lines])
14
call(["juju-log", "Storage info parsed: %s" % out])
15
assert "kind" in out, "storage-get did not return kind"
16
assert "location" in out, "storage-get did not return location"
18
proof = PROOF % out["kind"]
19
plocation = pjoin(out["location"], "proof.txt")
20
with open(plocation, "w") as pfile:
24
call(["juju-log", "Storage proof failed: %s" % e])
26
call(["juju-log", "Storage proof written to %s" % plocation])