def sh_command(cluster_id):
    logger.debug("sh_command({cluster_id})".format(**locals()))
    if cluster_id not in ShardedClusters():
        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': ShardedClusters().command(cluster_id, command),
        'links': all_sharded_cluster_links(cluster_id,
                                           rel_to='sharded-cluster-command')
    }
    return send_result(200, result)
示例#2
0
def sh_command(cluster_id):
    logger.debug("sh_command({cluster_id})".format(**locals()))
    if cluster_id not in ShardedClusters():
        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':
        ShardedClusters().command(cluster_id, command),
        'links':
        all_sharded_cluster_links(cluster_id, rel_to='sharded-cluster-command')
    }
    return send_result(200, result)
示例#3
0
def _sh_create(params):
    cluster_id = ShardedClusters().create(params)
    result = ShardedClusters().info(cluster_id)
    result['links'] = all_sharded_cluster_links(cluster_id)
    for router in result['routers']:
        router['links'] = [
            server_link('get-server-info', server_id=router['id'])
        ]
    for cfg in result['configsvrs']:
        cfg['links'] = [server_link('get-server-info', server_id=cfg['id'])]
    for sh in result['shards']:
        sh['links'] = [
            sharded_cluster_link('get-shard-info', cluster_id, sh['id']),
            _server_or_rs_link(sh)
        ]
    return result
def sh_list():
    logger.debug("sh_list()")
    sharded_clusters = []
    for cluster_id in ShardedClusters():
        cluster_info = {'id': cluster_id}
        cluster_info['links'] = all_sharded_cluster_links(
            cluster_id, rel_to='get-sharded-clusters')
        sharded_clusters.append(cluster_info)
    response = {'links': [
        base_link('service'),
        base_link('get-releases'),
        sharded_cluster_link('get-sharded-clusters', self_rel=True),
        sharded_cluster_link('add-sharded-cluster'),
        replica_set_link('get-replica-sets'),
        server_link('get-servers')
    ]}
    response['sharded_clusters'] = sharded_clusters
    return send_result(200, response)
def _sh_create(params):
    cluster_id = ShardedClusters().create(params)
    result = ShardedClusters().info(cluster_id)
    result['links'] = all_sharded_cluster_links(cluster_id)
    for router in result['routers']:
        router['links'] = [
            server_link('get-server-info', server_id=router['id'])
        ]
    for cfg in result['configsvrs']:
        cfg['links'] = [
            server_link('get-server-info', server_id=cfg['id'])
        ]
    for sh in result['shards']:
        sh['links'] = [
            sharded_cluster_link('get-shard-info', cluster_id, sh['id']),
            _server_or_rs_link(sh)
        ]
    return result
示例#6
0
def info(cluster_id):
    logger.debug("info({cluster_id})".format(**locals()))
    if cluster_id not in ShardedClusters():
        return send_result(404)
    result = ShardedClusters().info(cluster_id)
    result['links'] = all_sharded_cluster_links(
        cluster_id, rel_to='get-sharded-cluster-info')
    for router in result['routers']:
        router['links'] = [
            server_link('get-server-info', server_id=router['id'])
        ]
    for cfg in result['configsvrs']:
        cfg['links'] = [server_link('get-server-info', server_id=cfg['id'])]
    for sh in result['shards']:
        sh['links'] = [
            sharded_cluster_link('get-shard-info', cluster_id, sh['id']),
            _server_or_rs_link(sh)
        ]
    return send_result(200, result)
示例#7
0
def sh_list():
    logger.debug("sh_list()")
    sharded_clusters = []
    for cluster_id in ShardedClusters():
        cluster_info = {'id': cluster_id}
        cluster_info['links'] = all_sharded_cluster_links(
            cluster_id, rel_to='get-sharded-clusters')
        sharded_clusters.append(cluster_info)
    response = {
        'links': [
            base_link('service'),
            base_link('get-releases'),
            sharded_cluster_link('get-sharded-clusters', self_rel=True),
            sharded_cluster_link('add-sharded-cluster'),
            replica_set_link('get-replica-sets'),
            server_link('get-servers')
        ]
    }
    response['sharded_clusters'] = sharded_clusters
    return send_result(200, response)
def info(cluster_id):
    logger.debug("info({cluster_id})".format(**locals()))
    if cluster_id not in ShardedClusters():
        return send_result(404)
    result = ShardedClusters().info(cluster_id)
    result['links'] = all_sharded_cluster_links(
        cluster_id, rel_to='get-sharded-cluster-info')
    for router in result['routers']:
        router['links'] = [
            server_link('get-server-info', server_id=router['id'])
        ]
    for cfg in result['configsvrs']:
        cfg['links'] = [
            server_link('get-server-info', server_id=cfg['id'])
        ]
    for sh in result['shards']:
        sh['links'] = [
            sharded_cluster_link('get-shard-info', cluster_id, sh['id']),
            _server_or_rs_link(sh)
        ]
    return send_result(200, result)