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