Andy Bavier | 8d51c6c | 2015-04-01 11:40:22 -0400 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import subprocess |
| 4 | import time |
| 5 | import argparse |
| 6 | |
| 7 | sleep_interval = 1 |
| 8 | |
| 9 | relations = ["keystone mysql", |
| 10 | "nova-cloud-controller mysql", |
| 11 | "nova-cloud-controller rabbitmq-server", |
| 12 | "nova-cloud-controller glance", |
| 13 | "nova-cloud-controller keystone", |
| 14 | "glance mysql", |
| 15 | "glance keystone", |
| 16 | "quantum-gateway mysql", |
| 17 | "quantum-gateway rabbitmq-server", |
| 18 | "quantum-gateway nova-cloud-controller", |
| 19 | "openstack-dashboard keystone", |
| 20 | "ntp nova-cloud-controller", |
| 21 | "mysql nagios", |
| 22 | "rabbitmq-server nagios", |
| 23 | "keystone nagios", |
| 24 | "glance nagios", |
| 25 | "nova-cloud-controller nagios", |
| 26 | "quantum-gateway nagios", |
| 27 | "openstack-dashboard nagios", |
| 28 | "nagios nrpe", |
| 29 | "mysql nrpe", |
| 30 | "rabbitmq-server nrpe", |
| 31 | "keystone nrpe", |
| 32 | "glance nrpe", |
| 33 | "nova-cloud-controller nrpe", |
| 34 | "quantum-gateway nrpe", |
| 35 | "openstack-dashboard nrpe", |
| 36 | "ceilometer mongodb", |
| 37 | "ceilometer rabbitmq-server", |
| 38 | "ceilometer:identity-service keystone:identity-service", |
| 39 | "ceilometer:ceilometer-service ceilometer-agent:ceilometer-service", |
| 40 | "ceilometer nagios", |
| 41 | "ceilometer nrpe", |
| 42 | ] |
| 43 | |
| 44 | def addrelation(relation): |
| 45 | subprocess.check_call("juju add-relation %s" % relation, shell=True) |
| 46 | |
| 47 | def destroyrelation(relation): |
| 48 | subprocess.check_call("juju destroy-relation %s" % relation, shell=True) |
| 49 | |
| 50 | def addrelations(): |
| 51 | for relation in relations: |
| 52 | print "Adding relation %s" % relation |
| 53 | try: |
| 54 | addrelation(relation) |
| 55 | time.sleep(sleep_interval) |
| 56 | except: |
| 57 | pass |
| 58 | |
| 59 | def destroyrelations(): |
| 60 | for relation in relations: |
| 61 | print "Destroying relation %s" % relation |
| 62 | try: |
| 63 | destroyrelation(relation) |
| 64 | time.sleep(sleep_interval) |
| 65 | except: |
| 66 | pass |
| 67 | |
| 68 | def main(): |
| 69 | parser = argparse.ArgumentParser(description='Deploy OpenStack controller services') |
| 70 | parser.add_argument('--destroy', action='store_true', |
| 71 | help='Destroy the relations instead of adding them') |
| 72 | |
| 73 | args = parser.parse_args() |
| 74 | if args.destroy: |
| 75 | destroyrelations() |
| 76 | else: |
| 77 | addrelations() |
| 78 | |
| 79 | if __name__ =='__main__': |
| 80 | main() |