Created
July 24, 2014 09:07
-
-
Save niedbalski/474e96e68f28de491cea to your computer and use it in GitHub Desktop.
Get a specific entry on juju get
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Usage: | |
$ juju get-grep service config_entry | |
""" | |
__author__ == "Jorge Niedbalski R. <jorge.niedbalski@canonical.com>" | |
import subprocess | |
import sys | |
import yaml | |
import pprint | |
def juju_get(service, juju_env=None): | |
cmd = ['juju', 'get', service] | |
if juju_env: | |
cmd.append(['-e', juju_env]) | |
status_raw = subprocess.check_output(cmd) | |
return yaml.safe_load(status_raw) | |
def main(): | |
if not len(sys.argv) >= 2: | |
print >> sys.stderr, __doc__ | |
sys.exit(-1) | |
(service, entry) = (sys.argv[1], sys.argv[2]) | |
pprint.pprint(juju_get(service)['settings'].get(entry)) | |
if __name__ == "__main__": | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment