Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 12
0
Arquivo: __init__.py Projeto: 10sr/hue
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 20
0
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 32
0
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 43
0
Arquivo: __init__.py Projeto: 10sr/hue
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 49
0
Arquivo: __init__.py Projeto: 10sr/hue
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)
Exemplo n.º 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)
Exemplo n.º 51
0
Arquivo: __init__.py Projeto: 10sr/hue
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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)
Exemplo n.º 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)