Ejemplo n.º 1
0
def _rs_create(params):
    rs_id = ReplicaSets().create(params)
    result = ReplicaSets().info(rs_id)
    result['links'] = all_replica_set_links(rs_id)
    # Add GET link to corresponding Server resource.
    for member in result['members']:
        member['links'] = [
            server_link('get-server-info', server_id=member['server_id']),
            replica_set_link('get-replica-set-member-info', rs_id,
                             member['_id'])
        ]
    return result
Ejemplo n.º 2
0
def _rs_create(params):
    rs_id = ReplicaSets().create(params)
    result = ReplicaSets().info(rs_id)
    result['links'] = all_replica_set_links(rs_id)
    # Add GET link to corresponding Server resource.
    for member in result['members']:
        member['links'] = [
            server_link('get-server-info', server_id=member['server_id']),
            replica_set_link(
                'get-replica-set-member-info', rs_id, member['_id'])
        ]
    return result
Ejemplo n.º 3
0
def rs_info(rs_id):
    logger.debug("rs_info({rs_id})".format(**locals()))
    if rs_id not in ReplicaSets():
        return send_result(404)
    result = ReplicaSets().info(rs_id)
    result['links'] = all_replica_set_links(rs_id, 'get-replica-set-info')
    for member in result['members']:
        member['links'] = [
            server_link('get-server-info', server_id=member['server_id']),
            replica_set_link('get-replica-set-member-info', rs_id,
                             member['_id'])
        ]
    return send_result(200, result)
Ejemplo n.º 4
0
def rs_info(rs_id):
    logger.debug("rs_info({rs_id})".format(**locals()))
    if rs_id not in ReplicaSets():
        return send_result(404)
    result = ReplicaSets().info(rs_id)
    result['links'] = all_replica_set_links(rs_id, 'get-replica-set-info')
    for member in result['members']:
        member['links'] = [
            server_link('get-server-info', server_id=member['server_id']),
            replica_set_link(
                'get-replica-set-member-info', rs_id, member['_id'])
        ]
    return send_result(200, result)
Ejemplo n.º 5
0
def rs_command(rs_id):
    logger.debug("rs_command({rs_id})".format(**locals()))
    if rs_id not in ReplicaSets():
        return send_result(404)
    command = get_json(request.body).get('action')
    if command is None:
        raise RequestError('Expected body with an {"action": ...}.')
    result = {
        'command_result': ReplicaSets().command(rs_id, command),
        'links': all_replica_set_links(rs_id, 'replica-set-command')
    }
    result['links'].append(
        replica_set_link('replica-set-command', self_rel=True))
    return send_result(200, result)
Ejemplo n.º 6
0
def rs_command(rs_id):
    logger.debug("rs_command({rs_id})".format(**locals()))
    if rs_id not in ReplicaSets():
        return send_result(404)
    command = get_json(request.body).get('action')
    if command is None:
        raise RequestError('Expected body with an {"action": ...}.')
    result = {
        'command_result': ReplicaSets().command(rs_id, command),
        'links': all_replica_set_links(rs_id, 'replica-set-command')
    }
    result['links'].append(
        replica_set_link('replica-set-command', self_rel=True))
    return send_result(200, result)
Ejemplo n.º 7
0
def rs_list():
    logger.debug("rs_list()")
    replica_sets = []
    for rs_id in ReplicaSets():
        repl_info = {'id': rs_id}
        repl_info['links'] = all_replica_set_links(rs_id, 'get-replica-sets')
        replica_sets.append(repl_info)
    response = {'links': [
        base_link('service'),
        base_link('get-releases'),
        sharded_cluster_link('get-sharded-clusters'),
        replica_set_link('get-replica-sets', self_rel=True),
        replica_set_link('add-replica-set'),
        server_link('get-servers')
    ]}
    response['replica_sets'] = replica_sets
    return send_result(200, response)
Ejemplo n.º 8
0
def rs_list():
    logger.debug("rs_list()")
    replica_sets = []
    for rs_id in ReplicaSets():
        repl_info = {'id': rs_id}
        repl_info['links'] = all_replica_set_links(rs_id, 'get-replica-sets')
        replica_sets.append(repl_info)
    response = {'links': [
        base_link('service'),
        base_link('get-releases'),
        sharded_cluster_link('get-sharded-clusters'),
        replica_set_link('get-replica-sets', self_rel=True),
        replica_set_link('add-replica-set'),
        server_link('get-servers')
    ]}
    response['replica_sets'] = replica_sets
    return send_result(200, response)