예제 #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)
예제 #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)
예제 #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)
예제 #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
예제 #5
0
파일: __init__.py 프로젝트: prufrax/boto
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
예제 #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)
예제 #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
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #12
0
파일: __init__.py 프로젝트: 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)
예제 #13
0
파일: __init__.py 프로젝트: Babyfacer/boto
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)
예제 #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)
예제 #15
0
파일: __init__.py 프로젝트: prufrax/boto
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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #23
0
파일: __init__.py 프로젝트: merckhung/libui
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)
예제 #24
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #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)
예제 #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)
예제 #27
0
파일: __init__.py 프로젝트: prufrax/boto
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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #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)
예제 #36
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #37
0
파일: __init__.py 프로젝트: 18600597055/hue
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)
예제 #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)
예제 #39
0
파일: __init__.py 프로젝트: prufrax/boto
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)
예제 #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)
예제 #41
0
파일: __init__.py 프로젝트: prufrax/boto
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)
예제 #42
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #43
0
파일: __init__.py 프로젝트: 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)
예제 #44
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #45
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #46
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #47
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #48
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #49
0
파일: __init__.py 프로젝트: 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)
예제 #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)
예제 #51
0
파일: __init__.py 프로젝트: 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)
예제 #52
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #53
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #54
0
파일: __init__.py 프로젝트: C2Devel/boto
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)
예제 #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)
예제 #56
0
파일: __init__.py 프로젝트: prufrax/boto
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)
예제 #57
0
파일: __init__.py 프로젝트: prufrax/boto
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)