Created
November 25, 2015 23:20
-
-
Save nottrobin/1f64c29ff7aa170a1a21 to your computer and use it in GitHub Desktop.
Destroy all machines and services in a juju environment, without destroying the environment
This file contains hidden or 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 | |
| import yaml | |
| import subprocess | |
| status_command = "juju status" | |
| status_output = subprocess.check_output(status_command.split()) | |
| status = yaml.load(status_output) | |
| machines = status['machines'].keys() | |
| machines.remove('0') | |
| services = status['services'].keys() or [] | |
| if machines: | |
| print "Destroying machines: " + ', '.join(machines) | |
| try: | |
| destroy_machines = 'juju destroy-machine --force ' + ' '.join(machines) | |
| except: | |
| pass | |
| print subprocess.check_output(destroy_machines.split()) | |
| for service in services: | |
| print "Destroying service: " + service | |
| destroy_service = 'juju destroy-service ' + service | |
| print subprocess.check_output(destroy_service.split()) | |
| print "Done resetting" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment