Ejemplo n.º 1
0
def _remove_server(group_id, server_id):
    """Remove a server from a group.
    """
    group = _retrieve_group(group_id)
    server = _retrieve_server(server_id, group_id)

    if group.master == server.uuid:
        raise _errors.ServerError(
            "Cannot remove server (%s), which is master in group (%s). "
            "Please, demote it first." % (server.uuid, group_id))

    _server.MySQLServer.remove(server)
    server.disconnect()
    _server.ConnectionManager().purge_connections(server)
Ejemplo n.º 2
0
def _set_status_faulty(server, update_only):
    """Set server's status to fauly and trigger a failover if the server
    is a master.

    This function assumes that the SERVER_LOST event is executed before
    the FAIL_OVER event.
    """
    server.status = _server.MySQLServer.FAULTY
    _server.ConnectionManager().kill_connections(server)

    if not update_only:
        group = _server.Group.fetch(server.group_id)
        if group.master == server.uuid:
            _LOGGER.info("Master (%s) in group (%s) has "
                         "been lost.", server.uuid, group.group_id)
            _events.trigger_within_procedure("FAIL_OVER", group.group_id)

    _events.trigger_within_procedure("SERVER_LOST", server.group_id,
                                     str(server.uuid))