Exemple #1
0
def regions():
    """
    Get all available regions for the ELB service.
    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('elasticloadbalancing', connection_cls=ELBConnection)
Exemple #2
0
def regions():
    """
    Get all available regions for the Amazon Elastic MapReduce service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    return get_regions('elasticmapreduce', connection_cls=EmrConnection)
Exemple #3
0
def regions():
    """
    Get all available regions for the Auto Scaling service.
    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('autoscaling', connection_cls=AutoScaleConnection)
Exemple #4
0
def get_closest_region(service='ec2', repetitions=1):
    """
    Get the closest region for a particular service based on its average response time.

    :type service: str
    :param service: The service to attempt a connection to. By default, this is ``ec2``.

    :type repetitions: int
    :param repetitions: The number of measurements to take before calculating an average.
    """

    regions = [
        region.name for region in regioninfo.get_regions(service)
        if 'gov' not in region.name and 'cn' not in region.name
    ]

    latency = {}
    for region in regions:
        connection = Timer(
            "h.request('GET', '/')",
            "from http.client import HTTPSConnection; h=HTTPSConnection('%s.%s.amazonaws.com')"
            % (service, region))
        times = connection.repeat(repetitions, 1)
        avg_latency = sum(times) / float(len(times))
        latency[region] = avg_latency
        logger.info('Average latency to Amazon %s %s is %s' %
                    (service.upper(), region, latency[region]))

    region = min(latency, key=latency.get)

    return region
Exemple #5
0
def regions(provider=None):
    """
    Get all available regions for the Route53 service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo` instances
    """
    regions = get_regions(
        'route53',
        region_cls=Route53RegionInfo,
        connection_cls=Route53Connection,
        provider=provider
    )

    # For historical reasons, we had a "universal" endpoint as well.
    regions.append(
        Route53RegionInfo(
            name='universal',
            endpoint='route53.amazonaws.com',
            connection_cls=Route53Connection,
            provider=provider
        )
    )

    return regions
Exemple #6
0
def regions(**kw_params):
    """
    Get all available regions for the Amazon Simple Workflow service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    return get_regions('swf', connection_cls=boto.swf.layer1.Layer1)
Exemple #7
0
def get_closest_region(service="ec2", repetitions=1):
    """
    Get the closest region for a particular service based on its average response time.

    :type service: str
    :param service: The service to attempt a connection to. By default, this is ``ec2``.

    :type repetitions: int
    :param repetitions: The number of measurements to take before calculating an average.
    """

    regions = [
        region.name
        for region in regioninfo.get_regions(service)
        if "gov" not in region.name and "cn" not in region.name
    ]

    latency = {}
    for region in regions:
        connection = Timer(
            "h.request('GET', '/')",
            "from http.client import HTTPSConnection; h=HTTPSConnection('%s.%s.amazonaws.com')" % (service, region),
        )
        times = connection.repeat(repetitions, 1)
        avg_latency = sum(times) / float(len(times))
        latency[region] = avg_latency
        logger.info("Average latency to Amazon %s %s is %s" % (service.upper(), region, latency[region]))

    region = min(latency, key=latency.get)

    return region
Exemple #8
0
def regions():
    """
    Get all available regions for the SNS service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo` instances
    """
    return get_regions('sns', connection_cls=SNSConnection)
Exemple #9
0
def regions():
    """
    Get all available regions for the CloudWatch service.
    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('cloudwatch', connection_cls=CloudWatchConnection)
Exemple #10
0
def regions():
    """
    Get all available regions for the AWS CloudHSM service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cloudhsm.layer1 import CloudHSMConnection
    return get_regions('cloudhsm', connection_cls=CloudHSMConnection)
Exemple #11
0
def regions():
    """
    Get all available regions for the AWS ElastiCache service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.elasticache.layer1 import ElastiCacheConnection
    return get_regions('elasticache', connection_cls=ElastiCacheConnection)
Exemple #12
0
def regions():
    """
    Get all available regions for the Amazon Elastic MapReduce service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    return get_regions('elasticmapreduce', connection_cls=EmrConnection)
Exemple #13
0
def regions():
    """
    Get all available regions for the CloudFormation service.

    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions("cloudformation", connection_cls=CloudFormationConnection)
Exemple #14
0
def regions():
    """
    Get all available regions for the AWS Datapipeline service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.datapipeline.layer1 import DataPipelineConnection
    return get_regions('datapipeline', connection_cls=DataPipelineConnection)
Exemple #15
0
def regions(provider=None):
    """
    Get all available regions for the SNS service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo` instances
    """
    return get_regions('sns', connection_cls=SNSConnection, provider=provider)
Exemple #16
0
def regions():
    """
    Get all available regions for the Amazon Cognito Sync service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cognito.sync.layer1 import CognitoSyncConnection
    return get_regions('cognito-sync', connection_cls=CognitoSyncConnection)
Exemple #17
0
def regions():
    """
    Get all available regions for the AWS Lambda service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.awslambda.layer1 import AWSLambdaConnection
    return get_regions('awslambda', connection_cls=AWSLambdaConnection)
Exemple #18
0
def regions():
    """
    Get all available regions for the Amazon CloudSearch service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cloudsearch2.layer1 import CloudSearchConnection
    return get_regions('cloudsearch', connection_cls=CloudSearchConnection)
Exemple #19
0
def regions():
    """
    Get all available regions for the Amazon DynamoDB service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.dynamodb2.layer1 import DynamoDBConnection
    return get_regions('dynamodb', connection_cls=DynamoDBConnection)
def regions():
    """
    Get all available regions for the SDB service.

    :rtype: list
    :return: A list of :class:`boto.sdb.regioninfo.RegionInfo` instances
    """
    return get_regions('sdb', region_cls=SDBRegionInfo)
Exemple #21
0
def regions():
    """
    Get all available regions for the AWS Elastic Beanstalk service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.beanstalk.layer1 import Layer1
    return get_regions('elasticbeanstalk', connection_cls=Layer1)
Exemple #22
0
def regions():
    """
    Get all available regions for the Amazon Kinesis service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.kinesis.layer1 import KinesisConnection
    return get_regions('kinesis', connection_cls=KinesisConnection)
Exemple #23
0
def regions():
    """
    Get all available regions for the ELB service.

    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('elasticloadbalancing', connection_cls=ELBConnection)
Exemple #24
0
def regions(**kw_params):
    """
    Get all available regions for the Amazon Simple Workflow service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    return get_regions('swf', connection_cls=boto.swf.layer1.Layer1)
Exemple #25
0
def regions():
    """
    Get all available regions for the STS service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo` instances
    """
    return get_regions('sts', connection_cls=STSConnection)
Exemple #26
0
def regions():
    """
    Get all available regions for the Auto Scaling service.

    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('autoscaling', connection_cls=AutoScaleConnection)
Exemple #27
0
def regions(provider=None):
    """
    Get all available regions for the STS service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo` instances
    """
    return get_regions('sts', connection_cls=STSConnection, provider=provider)
Exemple #28
0
def regions():
    """
    Get all available regions for the Amazon OpsWorks service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.opsworks.layer1 import OpsWorksConnection
    return get_regions('opsworks', connection_cls=OpsWorksConnection)
Exemple #29
0
def regions():
    """
    Get all available regions for the Amazon Glacier service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.glacier.layer2 import Layer2
    return get_regions('glacier', connection_cls=Layer2)
Exemple #30
0
def regions():
    """
    Get all available regions for the CloudWatch service.

    :rtype: list
    :return: A list of :class:`boto.RegionInfo` instances
    """
    return get_regions('cloudwatch', connection_cls=CloudWatchConnection)
Exemple #31
0
def regions():
    """
    Get all available regions for the Amazon Support service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.support.layer1 import SupportConnection
    return get_regions('support', connection_cls=SupportConnection)
def regions():
    """
    Get all available regions for the SQS service.

    :rtype: list
    :return: A list of :class:`boto.sqs.regioninfo.RegionInfo`
    """
    return get_regions('sqs', region_cls=SQSRegionInfo)
Exemple #33
0
def regions():
    """
    Get all available regions for the AWS Redshift service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.redshift.layer1 import RedshiftConnection
    return get_regions('redshift', connection_cls=RedshiftConnection)
Exemple #34
0
def regions():
    """
    Get all available regions for the AWS DirectConnect service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.directconnect.layer1 import DirectConnectConnection
    return get_regions('directconnect', connection_cls=DirectConnectConnection)
Exemple #35
0
def regions():
    """
    Get all available regions for the AWS CodeDeploy service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.codedeploy.layer1 import CodeDeployConnection
    return get_regions('codedeploy', connection_cls=CodeDeployConnection)
Exemple #36
0
def regions():
    """
    Get all available regions for the AWS Datapipeline service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.datapipeline.layer1 import DataPipelineConnection
    return get_regions('datapipeline', connection_cls=DataPipelineConnection)
Exemple #37
0
def regions():
    """
    Get all available regions for the Amazon EC2 Container Service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.ec2containerservice import EC2ContainerServiceConnection
    return get_regions('', connection_cls=EC2ContainerServiceConnection)
Exemple #38
0
def regions():
    """
    Get all available regions for the Amazon Route 53 Domains service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.route53.domains.layer1 import Route53DomainsConnection
    return get_regions('route53domains',
                       connection_cls=Route53DomainsConnection)
Exemple #39
0
def regions(provider=None):
    """
    Get all available regions for the AWS Cloudtrail service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cloudtrail.layer1 import CloudTrailConnection
    return get_regions('cloudtrail', connection_cls=CloudTrailConnection, provider=provider)
Exemple #40
0
def regions():
    """
    Get all available regions for the AWS Config service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.kms.layer1 import ConfigServiceConnection
    return get_regions('configservice', connection_cls=ConfigServiceConnection)
Exemple #41
0
def regions(provider=None):
    """
    Get all available regions for the Amazon Support service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.support.layer1 import SupportConnection
    return get_regions('support', connection_cls=SupportConnection, provider=provider)
Exemple #42
0
def regions():
    """
    Get all available regions for the Amazon OpsWorks service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.opsworks.layer1 import OpsWorksConnection
    return get_regions('opsworks', connection_cls=OpsWorksConnection)
Exemple #43
0
def regions():
    """
    Get all available regions for the AWS CloudHSM service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cloudhsm.layer1 import CloudHSMConnection
    return get_regions('cloudhsm', connection_cls=CloudHSMConnection)
Exemple #44
0
def regions():
    """
    Get all available regions for the Amazon Cognito Sync service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cognito.sync.layer1 import CognitoSyncConnection
    return get_regions('cognito-sync', connection_cls=CognitoSyncConnection)
Exemple #45
0
def regions():
    """
    Get all available regions for the CloudWatch Logs service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.logs.layer1 import CloudWatchLogsConnection
    return get_regions('logs', connection_cls=CloudWatchLogsConnection)
Exemple #46
0
def regions():
    """
    Get all available regions for the Amazon CloudSearch service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.cloudsearch2.layer1 import CloudSearchConnection
    return get_regions('cloudsearch', connection_cls=CloudSearchConnection)
Exemple #47
0
def regions():
    """
    Get all available regions for the AWS DirectConnect service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.directconnect.layer1 import DirectConnectConnection
    return get_regions('directconnect', connection_cls=DirectConnectConnection)
Exemple #48
0
def regions():
    """
    Get all available regions for the AWS Lambda service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.awslambda.layer1 import AWSLambdaConnection
    return get_regions('awslambda',
                       connection_cls=AWSLambdaConnection)
Exemple #49
0
def regions():
    """
    Get all available regions for the Amazon Route 53 Domains service.
    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.route53.domains.layer1 import Route53DomainsConnection
    return get_regions('route53domains',
                       connection_cls=Route53DomainsConnection)
Exemple #50
0
def regions():
    """
    Get all available regions for the Amazon EC2 Container Service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.ec2containerservice import EC2ContainerServiceConnection
    return get_regions('', connection_cls=EC2ContainerServiceConnection)
Exemple #51
0
def regions():
    """
    Get all available regions for the AWS Redshift service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.redshift.layer1 import RedshiftConnection
    return get_regions('redshift', connection_cls=RedshiftConnection)
Exemple #52
0
def regions():
    """
    Get all available regions for the Amazon DynamoDB service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.dynamodb2.layer1 import DynamoDBConnection
    return get_regions('dynamodb', connection_cls=DynamoDBConnection)
Exemple #53
0
def regions():
    """
    Get all available regions for the Amazon Kinesis service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.kinesis.layer1 import KinesisConnection
    return get_regions('kinesis', connection_cls=KinesisConnection)
Exemple #54
0
def regions():
    """
    Get all available regions for the Amazon Glacier service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.glacier.layer2 import Layer2
    return get_regions('glacier', connection_cls=Layer2)
Exemple #55
0
def regions():
    """
    Get all available regions for the Amazon DynamoDB service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    import boto.dynamodb.layer2
    return get_regions('dynamodb', connection_cls=boto.dynamodb.layer2.Layer2)
Exemple #56
0
def regions(provider=None):
    """
    Get all available regions for the AWS ElastiCache service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.elasticache.layer1 import ElastiCacheConnection
    return get_regions('elasticache', connection_cls=ElastiCacheConnection, provider=provider)
Exemple #57
0
def regions(provider=None):
    """
    Get all available regions for the RDS service.

    :rtype: list
    :return: A list of :class:`boto.regioninfo.RegionInfo`
    """
    from boto.rds2.layer1 import RDSConnection
    return get_regions('rds', connection_cls=RDSConnection, provider=provider)