Example #1
0
def pause_groups(cass_client, groups):
    """
    Pause given groups by setting their paused=true
    """
    queries, params = [], {}
    for i, group in enumerate(groups):
        queries.append(
            ('UPDATE scaling_group SET paused=true WHERE '
             '"tenantId"=:tenantId{0} AND "groupId"=:groupId{0}').format(i))
        params["tenantId{}".format(i)] = group["tenantId"]
        params["groupId{}".format(i)] = group["groupId"]
    return cass_client.execute(batch(queries), params, DEFAULT_CONSISTENCY)
Example #2
0
def set_desired(reactor, conn, args):
    if not args.desired_csv:
        raise Exception("Please provide a --desired-csv")
    reader = csv.reader(open(args.desired_csv))

    query = ('UPDATE scaling_group SET desired=:desired{i} '
             'WHERE "tenantId"=:tenantId{i} AND "groupId"=:groupId{i}')
    queries, params = [], {}
    for i, (tenant_id, group_id, new_desired) in enumerate(reader):
        queries.append(query.format(i=i))
        params['tenantId{}'.format(i)] = tenant_id
        params['groupId{}'.format(i)] = group_id
        params['desired{}'.format(i)] = int(new_desired)
    yield conn.execute(batch(queries), params, ConsistencyLevel.ONE)
    returnValue(None)
Example #3
0
def insert_deleting_false(reactor, conn, args):
    """
    Insert false to all group's deleting column
    """
    store = CassScalingGroupCollection(conn, None, 3)
    groups = yield store.get_scaling_group_rows()
    query = ('INSERT INTO scaling_group ("tenantId", "groupId", deleting) '
             'VALUES (:tenantId{i}, :groupId{i}, false);')
    queries, params = [], {}
    for i, group in enumerate(groups):
        queries.append(query.format(i=i))
        params['tenantId{}'.format(i)] = group['tenantId']
        params['groupId{}'.format(i)] = group['groupId']
    yield conn.execute(batch(queries), params, ConsistencyLevel.ONE)
    returnValue(None)
Example #4
0
def insert_deleting_false(reactor, conn):
    """
    Insert false to all group's deleting column
    """
    groups = yield get_scaling_group_rows(conn)
    query = (
        'INSERT INTO scaling_group ("tenantId", "groupId", deleting) '
        'VALUES (:tenantId{i}, :groupId{i}, false);')
    queries, params = [], {}
    for i, group in enumerate(groups):
        queries.append(query.format(i=i))
        params['tenantId{}'.format(i)] = group['tenantId']
        params['groupId{}'.format(i)] = group['groupId']
    yield conn.execute(batch(queries), params, ConsistencyLevel.ONE)
    returnValue(None)
Example #5
0
def set_desired(reactor, conn, args):
    if not args.desired_csv:
        raise Exception("Please provide a --desired-csv")
    reader = csv.reader(open(args.desired_csv))

    query = (
        'UPDATE scaling_group SET desired=:desired{i} '
        'WHERE "tenantId"=:tenantId{i} AND "groupId"=:groupId{i}')
    queries, params = [], {}
    for i, (tenant_id, group_id, new_desired) in enumerate(reader):
        queries.append(query.format(i=i))
        params['tenantId{}'.format(i)] = tenant_id
        params['groupId{}'.format(i)] = group_id
        params['desired{}'.format(i)] = int(new_desired)
    yield conn.execute(batch(queries), params, ConsistencyLevel.ONE)
    returnValue(None)