~hduran-8/juju-ci-tools/repository_add_storagetest

« back to all changes in this revision

Viewing changes to trusty/storagetest/hooks/filesystem-storage-attached

  • Committer: Horacio Durán
  • Date: 2015-06-24 15:23:56 UTC
  • mfrom: (20.1.2 repository)
  • Revision ID: horacio.duran@canonical.com-20150624152356-rpq9picusne5bicd
Added storagetest charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/python
 
2
from subprocess import call, check_output
 
3
from os.path import join as pjoin
 
4
 
 
5
PROOF =  "This text is the proof that storage-attached hook ran with"\
 
6
         " %s storage"
 
7
 
 
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"
 
17
 
 
18
proof = PROOF % out["kind"]
 
19
plocation = pjoin(out["location"], "proof.txt")
 
20
with open(plocation, "w") as pfile:
 
21
    try:
 
22
        pfile.write(proof)
 
23
    except Exception, e:
 
24
        call(["juju-log", "Storage proof failed: %s" % e])
 
25
 
 
26
call(["juju-log", "Storage proof written to %s" % plocation])