Skip to content

Instantly share code, notes, and snippets.

@tpsilva
Created March 24, 2020 12:39
Show Gist options
  • Save tpsilva/29d520c1a2f95fadf468abfab0dd2eae to your computer and use it in GitHub Desktop.
Save tpsilva/29d520c1a2f95fadf468abfab0dd2eae to your computer and use it in GitHub Desktop.
Simple script that logs your juju controller out of the charmstore
#!/usr/bin/env python
"""
This is a tool for logging your controller out of the charmstore
Usage:
{0} controller-name
"""
import json
import os
import subprocess
import sys
def main():
filename = "{}/.local/share/juju/cookies/{}.json".format(
os.path.expanduser("~"), sys.argv[1])
if not os.path.exists(filename):
print("Could not find juju json file. Please make sure the " \
"controller name is correct")
sys.exit(-1)
with open(filename) as f:
creds = json.load(f)
creds = [c for c in creds if c["Domain"] != "api.jujucharms.com"]
with open(filename, "w") as f:
json.dump(creds, f)
if __name__ == "__main__":
if len(sys.argv) != 2:
print(__doc__.format(sys.argv[0]))
sys.exit(-1)
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment