def cluster_changed(): unison.ssh_authorized_peers(user=rabbit.SSH_USER, group='rabbit', peer_interface='cluster', ensure_local_user=True) rabbit.synchronize_service_credentials() if utils.is_relation_made('ha'): utils.juju_log( 'INFO', 'hacluster relation is present, skipping native ' 'rabbitmq cluster config.') return l_unit_no = os.getenv('JUJU_UNIT_NAME').split('/')[1] r_unit_no = os.getenv('JUJU_REMOTE_UNIT').split('/')[1] if l_unit_no < r_unit_no: utils.juju_log('INFO', 'cluster_joined: Relation lesser.') return cookie = utils.relation_get('cookie') if cookie is None: utils.juju_log('INFO', 'cluster_joined: cookie not yet set.') return if open(rabbit.COOKIE_PATH, 'r').read().strip() == cookie: utils.juju_log('INFO', 'Cookie already synchronized with peer.') else: utils.juju_log('INFO', 'Synchronizing erlang cookie from peer.') rabbit.service('stop') with open(rabbit.COOKIE_PATH, 'wb') as out: out.write(cookie) rabbit.service('start') # cluster with other nodes rabbit.cluster_with()
def cluster_joined(): unison.ssh_authorized_peers(user=rabbit.SSH_USER, group='rabbit', peer_interface='cluster', ensure_local_user=True) if utils.is_relation_made('ha'): utils.juju_log( 'INFO', 'hacluster relation is present, skipping native ' 'rabbitmq cluster config.') return l_unit_no = os.getenv('JUJU_UNIT_NAME').split('/')[1] r_unit_no = os.getenv('JUJU_REMOTE_UNIT').split('/')[1] if l_unit_no > r_unit_no: utils.juju_log('INFO', 'cluster_joined: Relation greater.') return rabbit.COOKIE_PATH = '/var/lib/rabbitmq/.erlang.cookie' if not os.path.isfile(rabbit.COOKIE_PATH): utils.juju_log('ERROR', 'erlang cookie missing from %s' % rabbit.COOKIE_PATH) return cookie = open(rabbit.COOKIE_PATH, 'r').read().strip() # add parent host to the relation local_hostname = subprocess.check_output(['hostname']).strip() utils.relation_set(cookie=cookie, host=local_hostname)
def cluster_changed(): unison.ssh_authorized_peers(user=rabbit.SSH_USER, group='rabbit', peer_interface='cluster', ensure_local_user=True) rabbit.synchronize_service_credentials() if utils.is_relation_made('ha'): utils.juju_log('INFO', 'hacluster relation is present, skipping native ' 'rabbitmq cluster config.') return l_unit_no = os.getenv('JUJU_UNIT_NAME').split('/')[1] r_unit_no = os.getenv('JUJU_REMOTE_UNIT').split('/')[1] if l_unit_no < r_unit_no: utils.juju_log('INFO', 'cluster_joined: Relation lesser.') return cookie = utils.relation_get('cookie') if cookie is None: utils.juju_log('INFO', 'cluster_joined: cookie not yet set.') return if open(rabbit.COOKIE_PATH, 'r').read().strip() == cookie: utils.juju_log('INFO', 'Cookie already synchronized with peer.') else: utils.juju_log('INFO', 'Synchronizing erlang cookie from peer.') rabbit.service('stop') with open(rabbit.COOKIE_PATH, 'wb') as out: out.write(cookie) rabbit.service('start') # cluster with other nodes rabbit.cluster_with()
def cluster_joined(): unison.ssh_authorized_peers(user=rabbit.SSH_USER, group='rabbit', peer_interface='cluster', ensure_local_user=True) if utils.is_relation_made('ha'): utils.juju_log('INFO', 'hacluster relation is present, skipping native ' 'rabbitmq cluster config.') return l_unit_no = os.getenv('JUJU_UNIT_NAME').split('/')[1] r_unit_no = os.getenv('JUJU_REMOTE_UNIT').split('/')[1] if l_unit_no > r_unit_no: utils.juju_log('INFO', 'cluster_joined: Relation greater.') return rabbit.COOKIE_PATH = '/var/lib/rabbitmq/.erlang.cookie' if not os.path.isfile(rabbit.COOKIE_PATH): utils.juju_log('ERROR', 'erlang cookie missing from %s' % rabbit.COOKIE_PATH) return cookie = open(rabbit.COOKIE_PATH, 'r').read().strip() # add parent host to the relation local_hostname = subprocess.check_output(['hostname']).strip() utils.relation_set(cookie=cookie, host=local_hostname)
def cluster_changed(): unison.ssh_authorized_peers(user=SSH_USER, group='keystone', peer_interface='cluster', ensure_local_user=True) synchronize_service_credentials() service_ports = { "keystone_admin": [ cluster.determine_haproxy_port(config['admin-port']), cluster.determine_api_port(config["admin-port"]) ], "keystone_service": [ cluster.determine_haproxy_port(config['service-port']), cluster.determine_api_port(config["service-port"]) ] } haproxy.configure_haproxy(service_ports)
def cluster_joined(): unison.ssh_authorized_peers(user=SSH_USER, group='keystone', peer_interface='cluster', ensure_local_user=True) update_config_block('DEFAULT', public_port=cluster.determine_api_port(config["service-port"])) update_config_block('DEFAULT', admin_port=cluster.determine_api_port(config["admin-port"])) if config_dirty(): utils.restart('keystone') service_ports = { "keystone_admin": [ cluster.determine_haproxy_port(config['admin-port']), cluster.determine_api_port(config["admin-port"]) ], "keystone_service": [ cluster.determine_haproxy_port(config['service-port']), cluster.determine_api_port(config["service-port"]) ] } haproxy.configure_haproxy(service_ports)