def _update_pl_proxy_cluster(existing_config, verbose):
    existing_shards = _get_current_shards(existing_config)
    config = PartitionConfig()
    new_shard_configs = config.get_shards()

    shards_to_update = get_shards_to_update(existing_shards, new_shard_configs)

    if not shards_to_update:
        print 'No changes. Exiting.'
    else:
        print "Shards to update:"
        existing_shards_by_id = {shard.id: shard for shard in existing_shards}
        for new in shards_to_update:
            print "    {}  ->   {}".format(
                existing_shards_by_id[new.id].get_server_option_string(),
                new.get_server_option_string()
            )
        if _confirm("Update these shards?"):
            alter_sql = _get_alter_server_sql(shards_to_update)
            if verbose:
                print alter_sql

            with connections[config.get_proxy_db()].cursor() as cursor:
                cursor.execute(alter_sql)
        else:
            print 'Abort'
Esempio n. 2
0
def _update_pl_proxy_cluster(existing_config, verbose):
    existing_shards = _get_current_shards(existing_config)
    config = PartitionConfig()
    new_shard_configs = config.get_shards()

    shards_to_update = get_shards_to_update(existing_shards, new_shard_configs)

    if not shards_to_update:
        print 'No changes. Exiting.'
    else:
        print "Shards to update:"
        existing_shards_by_id = {shard.id: shard for shard in existing_shards}
        for new in shards_to_update:
            print "    {}  ->   {}".format(
                existing_shards_by_id[new.id].get_server_option_string(),
                new.get_server_option_string()
            )
        if _confirm("Update these shards?"):
            alter_sql = _get_alter_server_sql(shards_to_update)
            if verbose:
                print alter_sql

            with connections[config.get_proxy_db()].cursor() as cursor:
                cursor.execute(alter_sql)
        else:
            print 'Abort'
def create_pl_proxy_cluster(verbose=False, drop_existing=False):
    config = PartitionConfig()
    proxy_db = config.get_proxy_db()

    if drop_existing:
        with connections[proxy_db].cursor() as cursor:
            cursor.execute(get_drop_server_sql())

    config_sql = get_pl_proxy_server_config_sql(config.get_shards())
    user_mapping_sql = get_user_mapping_sql()

    if verbose:
        print 'Running SQL'
        print config_sql
        print user_mapping_sql

    with connections[proxy_db].cursor() as cursor:
        cursor.execute(config_sql)
        cursor.execute(user_mapping_sql)
Esempio n. 4
0
def create_pl_proxy_cluster(verbose=False, drop_existing=False):
    config = PartitionConfig()
    proxy_db = config.get_proxy_db()

    if drop_existing:
        with connections[proxy_db].cursor() as cursor:
            cursor.execute(get_drop_server_sql())

    config_sql = get_pl_proxy_server_config_sql(config.get_shards())
    user_mapping_sql = get_user_mapping_sql()

    if verbose:
        print 'Running SQL'
        print config_sql
        print user_mapping_sql

    with connections[proxy_db].cursor() as cursor:
        cursor.execute(config_sql)
        cursor.execute(user_mapping_sql)