Python moto.mock_autoscaling() Examples

The following are 4 code examples of moto.mock_autoscaling(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module moto , or try the search function .
Example #1
Source File: environment.py    From clusterman with Apache License 2.0 6 votes vote down vote up
def boto_patches(context):
    mock_sqs_obj = mock_sqs()
    mock_sqs_obj.start()
    mock_ec2_obj = mock_ec2()
    mock_ec2_obj.start()
    mock_autoscaling_obj = mock_autoscaling()
    mock_autoscaling_obj.start()
    vpc_response = ec2.create_vpc(CidrBlock='10.0.0.0/24')
    subnet_response = ec2.create_subnet(
        CidrBlock='10.0.0.0/24',
        VpcId=vpc_response['Vpc']['VpcId'],
        AvailabilityZone='us-west-2a'
    )
    context.subnet_id = subnet_response['Subnet']['SubnetId']
    yield
    mock_sqs_obj.stop()
    mock_ec2_obj.stop()
    mock_autoscaling_obj.stop() 
Example #2
Source File: conftest.py    From clusterman with Apache License 2.0 5 votes vote down vote up
def setup_autoscaling():
    mock_autoscaling_obj = moto.mock_autoscaling()
    mock_autoscaling_obj.start()
    yield
    mock_autoscaling_obj.stop() 
Example #3
Source File: conftest.py    From diffy with Apache License 2.0 5 votes vote down vote up
def autoscaling():
    with mock_autoscaling():
        yield boto3.client("autoscaling", region_name="us-east-1") 
Example #4
Source File: conftest.py    From jungle with MIT License 5 votes vote down vote up
def asg():
    """AutoScaling mock service"""
    mock = mock_autoscaling()
    mock.start()

    client = boto3.client('autoscaling')
    groups = []
    lcs = []
    for i in range(3):
        lc_config = dict(
            LaunchConfigurationName='lc-{0}'.format(i),
            ImageId='ami-xxxxxx',
            KeyName='mykey',
            InstanceType='c3.xlarge',
        )
        client.create_launch_configuration(**lc_config)
        lcs.append(lc_config)
        asg_config = dict(
            AutoScalingGroupName='asg-{0}'.format(i),
            LaunchConfigurationName='lc-{0}'.format(i),
            MaxSize=10,
            MinSize=2,
        )
        client.create_auto_scaling_group(**asg_config)
        groups.append(asg_config)

    yield {'lcs': lcs, 'groups': groups}
    mock.stop()