~gary/charms/oneiric/buildbot-master/dynamic-relationship

« back to all changes in this revision

Viewing changes to tests/get-unit-info

  • Committer: Benji York
  • Date: 2012-02-02 18:35:04 UTC
  • mto: This revision was merged to the branch mainline in revision 9.
  • Revision ID: benji@benjiyork.com-20120202183504-ei87ouuzip0i3c1g
add some docs and spiff up the tests

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
import yaml
2
 
import sys
3
 
from subprocess import Popen, PIPE
4
 
 
5
 
def get_unit_info(service_name, item_name):
6
 
    status = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
7
 
    services = status["services"][service_name]
8
 
    units = services["units"]
9
 
    item = units.items()[0][1][item_name]
10
 
    return item
11
 
 
12
 
def main():
13
 
    d = yaml.safe_load(Popen(['juju','status'],stdout=PIPE).stdout)
14
 
    service_name = sys.argv[1]
15
 
    item_name = sys.argv[2]
16
 
    print get_unit_info(service_name, item_name)
17
 
 
18
 
if __name__ == "__main__":
19
 
    main()