Пример #1
0
def do_restart_server(server, options_override=None):
    log_info("Restarting server '%s'..." % server.id)

    if server.is_online():
        do_stop_server(server)
    else:
        log_info("Server '%s' is not running." % server.id)

    do_start_server(server, options_override)
Пример #2
0
def do_restart_server(server, options_override=None):
    log_info("Restarting server '%s'..." % server.id)

    if server.is_online():
        do_stop_server(server)
    else:
        log_info("Server '%s' is not running." % server.id)

    do_start_server(server, options_override)
Пример #3
0
def resync_secondary(server_id):

    server = repository.lookup_and_validate_server(server_id)
    server.validate_local_op("resync-secondary")

    log_info("Checking if server '%s' is secondary..." % server_id)
    # get the server status
    status = server.get_status(admin=True)
    if not status["connection"]:
        msg = "Server '%s' does not seem to be running. For more details," " run 'mongoctl status %s'" % (
            server_id,
            server_id,
        )
        raise MongoctlException(msg)
    elif "error" in status:
        msg = (
            "There was an error while connecting to server '%s' (error:%s)."
            " For more details, run 'mongoctl status %s'" % (server_id, status["error"], server_id)
        )
        raise MongoctlException(msg)

    rs_state = None
    if "selfReplicaSetStatusSummary" in status:
        rs_state = status["selfReplicaSetStatusSummary"]["stateStr"]

    if rs_state not in ["SECONDARY", "RECOVERING"]:
        msg = (
            "Server '%s' is not a secondary member or cannot be determined"
            " as secondary (stateStr='%s'. For more details, run 'mongoctl"
            " status %s'" % (server_id, rs_state, server_id)
        )
        raise MongoctlException(msg)

    do_stop_server(server)

    log_info("Deleting server's '%s' dbpath '%s'..." % (server_id, server.get_db_path()))

    shutil.rmtree(server.get_db_path())

    do_start_server(server)
Пример #4
0
def resync_secondary(server_id):

    server = repository.lookup_and_validate_server(server_id)
    server.validate_local_op("resync-secondary")

    log_info("Checking if server '%s' is secondary..." % server_id)
    # get the server status
    status = server.get_status(admin=True)
    if not status['connection']:
        msg = ("Server '%s' does not seem to be running. For more details,"
               " run 'mongoctl status %s'" % (server_id, server_id))
        raise MongoctlException(msg)
    elif 'error' in status:
        msg = ("There was an error while connecting to server '%s' (error:%s)."
               " For more details, run 'mongoctl status %s'" %
               (server_id, status['error'], server_id))
        raise MongoctlException(msg)

    rs_state = None
    if 'selfReplicaSetStatusSummary' in status:
        rs_state = status['selfReplicaSetStatusSummary']['stateStr']

    if rs_state not in ['SECONDARY', 'RECOVERING']:
        msg = ("Server '%s' is not a secondary member or cannot be determined"
               " as secondary (stateStr='%s'. For more details, run 'mongoctl"
               " status %s'" % (server_id, rs_state, server_id))
        raise MongoctlException(msg)

    do_stop_server(server)

    log_info("Deleting server's '%s' dbpath '%s'..." %
             (server_id, server.get_db_path()))

    shutil.rmtree(server.get_db_path())

    do_start_server(server)