示例#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
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
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
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)