def certs_changed(relation_id=None, unit=None): # Ensure Rabbit has restart before telling the clients as rabbit may # take time to restart. @rabbit.restart_on_change(rabbit.restart_map()) def render_and_restart(): rabbit.ConfigRenderer(rabbit.CONFIG_FILES()).write_all() render_and_restart() update_clients()
def certs_changed(relation_id=None, unit=None): # Ensure Rabbit has restart before telling the clients as rabbit may # take time to restart. @rabbit.restart_on_change(rabbit.restart_map()) def render_and_restart(): rabbit.ConfigRenderer( rabbit.CONFIG_FILES).write_all() render_and_restart() update_clients()
return if not os.path.isfile(rabbit.COOKIE_PATH): log('erlang cookie missing from %s' % rabbit.COOKIE_PATH, level=ERROR) return if is_leader(): log('Leader peer_storing cookie', level=INFO) cookie = open(rabbit.COOKIE_PATH, 'r').read().strip() peer_store('cookie', cookie) peer_store('leader_node_ip', unit_private_ip()) peer_store('leader_node_hostname', rabbit.get_unit_hostname()) @hooks.hook('cluster-relation-changed') @rabbit.restart_on_change(rabbit.restart_map()) def cluster_changed(relation_id=None, remote_unit=None): # Future travelers beware ordering is significant rdata = relation_get(rid=relation_id, unit=remote_unit) # sync passwords blacklist = ['hostname', 'private-address', 'public-address'] whitelist = [a for a in rdata.keys() if a not in blacklist] peer_echo(includes=whitelist) cookie = peer_retrieve('cookie') if not cookie: log('cluster_changed: cookie not yet set.', level=INFO) return if rdata:
shutil.move(s, d) if is_elected_leader('res_rabbitmq_vip'): rabbit.migrate_passwords_to_peer_relation() # explicitly update buggy file name naigos.passwd old = os.path.join('var/lib/rabbitmq', 'naigos.passwd') if os.path.isfile(old): new = os.path.join('var/lib/rabbitmq', 'nagios.passwd') shutil.move(old, new) MAN_PLUGIN = 'rabbitmq_management' @hooks.hook('config-changed') @rabbit.restart_on_change(rabbit.restart_map()) @harden() def config_changed(): # Update hosts with this unit's information rabbit.update_hosts_file({ rabbit.get_unit_ip(config_override=rabbit.CLUSTER_OVERRIDE_CONFIG, interface=rabbit.CLUSTER_INTERFACE): rabbit.get_unit_hostname() }) # Add archive source if provided add_source(config('source'), config('key')) apt_update(fatal=True) # Copy in defaults file for updated ulimits shutil.copyfile('templates/rabbitmq-server',
shutil.move(s, d) if is_elected_leader('res_rabbitmq_vip'): rabbit.migrate_passwords_to_peer_relation() # explicitly update buggy file name naigos.passwd old = os.path.join('var/lib/rabbitmq', 'naigos.passwd') if os.path.isfile(old): new = os.path.join('var/lib/rabbitmq', 'nagios.passwd') shutil.move(old, new) MAN_PLUGIN = 'rabbitmq_management' @hooks.hook('config-changed') @rabbit.restart_on_change(rabbit.restart_map()) @harden() def config_changed(): if config('prefer-ipv6'): rabbit.assert_charm_supports_ipv6() # Add archive source if provided add_source(config('source'), config('key')) apt_update(fatal=True) # Copy in defaults file for updated ulimits shutil.copyfile( 'templates/rabbitmq-server', '/etc/default/rabbitmq-server') # Install packages to ensure any changes to source # result in an upgrade if applicable.
if cookie_local == cookie: log('Cookie already synchronized with peer.') return service_stop('rabbitmq-server') with open(rabbit.COOKIE_PATH, 'wb') as out: out.write(cookie.encode('ascii')) if not is_unit_paused_set(): service_restart('rabbitmq-server') rabbit.wait_app() @hooks.hook('ha-relation-joined') @rabbit.restart_on_change({rabbit.ENV_CONF: rabbit.restart_map()[rabbit.ENV_CONF]}) def ha_joined(): corosync_bindiface = config('ha-bindiface') corosync_mcastport = config('ha-mcastport') vip = config('vip') vip_iface = config('vip_iface') vip_cidr = config('vip_cidr') rbd_name = config('rbd-name') vip_only = config('ha-vip-only') if None in [corosync_bindiface, corosync_mcastport, vip, vip_iface, vip_cidr, rbd_name] and vip_only is False: log('Insufficient configuration data to configure hacluster.', level=ERROR) sys.exit(1) elif None in [corosync_bindiface, corosync_mcastport, vip, vip_iface,