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 = [ |
| 10 | "nova-compute:shared-db mysql:shared-db", |
| 11 | "nova-compute:amqp rabbitmq-server:amqp", |
| 12 | "nova-compute glance", |
| 13 | "nova-compute nova-cloud-controller", |
| 14 | "ntp nova-compute", |
| 15 | "nova-compute nagios", |
| 16 | "nova-compute nrpe", |
| 17 | "nova-compute:nova-ceilometer ceilometer-agent:nova-ceilometer", |
| 18 | ] |
| 19 | |
| 20 | def addrelation(relation): |
| 21 | subprocess.check_call("juju add-relation %s" % relation, shell=True) |
| 22 | |
| 23 | def destroyrelation(relation): |
| 24 | subprocess.check_call("juju destroy-relation %s" % relation, shell=True) |
| 25 | |
| 26 | def addrelations(): |
| 27 | for relation in relations: |
| 28 | print "Adding relation %s" % relation |
| 29 | try: |
| 30 | addrelation(relation) |
| 31 | time.sleep(sleep_interval) |
| 32 | except: |
| 33 | pass |
| 34 | |
| 35 | def destroyrelations(): |
| 36 | for relation in relations: |
| 37 | print "Destroying relation %s" % relation |
| 38 | try: |
| 39 | destroyrelation(relation) |
| 40 | time.sleep(sleep_interval) |
| 41 | except: |
| 42 | pass |
| 43 | |
| 44 | def main(): |
| 45 | parser = argparse.ArgumentParser(description='Deploy OpenStack controller services') |
| 46 | parser.add_argument('--destroy', action='store_true', |
| 47 | help='Destroy the relations instead of adding them') |
| 48 | |
| 49 | args = parser.parse_args() |
| 50 | if args.destroy: |
| 51 | destroyrelations() |
| 52 | else: |
| 53 | addrelations() |
| 54 | |
| 55 | if __name__ =='__main__': |
| 56 | main() |