Esempio n. 1
0
def scale(cluster, service, desired_count, access_key_id, secret_access_key,
          region, profile, timeout, ignore_warnings):
    """
    Scale a service up or down.

    \b
    CLUSTER is the name of your cluster (e.g. 'my-custer') within ECS.
    SERVICE is the name of your service (e.g. 'my-app') within ECS.
    DESIRED_COUNT is the number of tasks your service should run.
    """
    try:
        client = get_client(access_key_id, secret_access_key, region, profile)
        scaling = ScaleAction(client, cluster, service)
        click.secho('Updating service')
        scaling.scale(desired_count)
        click.secho('Successfully changed desired count to: %s\n' %
                    desired_count,
                    fg='green')
        wait_for_finish(action=scaling,
                        timeout=timeout,
                        title='Scaling service',
                        success_message='Scaling successful',
                        failure_message='Scaling failed',
                        ignore_warnings=ignore_warnings)

    except Exception as e:
        click.secho('%s\n' % str(e), fg='red', err=True)
        exit(1)
Esempio n. 2
0
def test_scale_action(client):
    action = ScaleAction(client, CLUSTER_NAME, SERVICE_NAME)
    updated_service = action.scale(5)

    assert action.service.desired_count == 5
    assert isinstance(updated_service, EcsService)

    client.describe_services.assert_called_once_with(CLUSTER_NAME, SERVICE_NAME)
    client.update_service.assert_called_once_with(action.service.cluster, action.service.name,
                                                  5, action.service.task_definition)
Esempio n. 3
0
def test_scale_action(client):
    action = ScaleAction(client, CLUSTER_NAME, SERVICE_NAME)
    updated_service = action.scale(5)

    assert action.service.desired_count == 5
    assert isinstance(updated_service, EcsService)

    client.describe_services.assert_called_once_with(CLUSTER_NAME,
                                                     SERVICE_NAME)
    client.update_service.assert_called_once_with(
        action.service.cluster, action.service.name, 5,
        action.service.task_definition)
Esempio n. 4
0
def scale(cluster, service, desired_count, access_key_id, secret_access_key, region, profile, timeout):
    """
    Scale a service up or down.

    \b
    CLUSTER is the name of your cluster (e.g. 'my-custer') within ECS.
    SERVICE is the name of your service (e.g. 'my-app') within ECS.
    DESIRED_COUNT is the number of tasks your service should run.
    """
    try:
        client = get_client(access_key_id, secret_access_key, region, profile)
        scaling = ScaleAction(client, cluster, service)
        click.secho('Updating service')
        scaling.scale(desired_count)
        click.secho('Successfully changed desired count to: %s\n' % desired_count, fg='green')
        wait_for_finish(scaling, timeout, 'Scaling service', 'Scaling successful', 'Scaling failed')

    except Exception as e:
        click.secho('%s\n' % str(e), fg='red', err=True)
        exit(1)