def master_departed(interface='master'): if is_leader(): reset_password = True new_slave_addresses = [] old_slave_addresses = list_replication_users() for rid in relation_ids(interface): if related_units(rid): reset_password = False for unit in related_units(rid): if not relation_get( attribute='slave_address', rid=rid, unit=unit): log("No relation data for {}".format(unit), level=DEBUG) return new_slave_addresses.append( relation_get(attribute='slave_address', rid=rid, unit=unit)) for old_slave_address in old_slave_addresses: if old_slave_address not in new_slave_addresses: delete_replication_user(old_slave_address) if reset_password: leader_set({'async-rep-password': ''})
def master_departed(interface='master'): if is_leader(): reset_password = True new_slave_addresses = [] old_slave_addresses = list_replication_users() for rid in relation_ids(interface): if related_units(rid): reset_password = False for unit in related_units(rid): if not relation_get(attribute='slave_address', rid=rid, unit=unit): log("No relation data for {}".format(unit), level=DEBUG) return new_slave_addresses.append( relation_get(attribute='slave_address', rid=rid, unit=unit)) for old_slave_address in old_slave_addresses: if old_slave_address not in new_slave_addresses: delete_replication_user(old_slave_address) if reset_password: leader_set({'async-rep-password': ''})