def slave_changed(interface='slave'): for rid in relation_ids(interface): for unit in related_units(rid): rdata = relation_get(unit=unit, rid=rid) if rdata.get('leader'): if rdata.get('master_address') is not get_slave_status(): slave_departed() slave_joined()