Region work for ec2 and SQS #715

Closed
wants to merge 8 commits into
from
View
@@ -41,7 +41,7 @@
from boto.ec2.snapshot import SnapshotAttribute
from boto.ec2.zone import Zone
from boto.ec2.securitygroup import SecurityGroup
-from boto.ec2.regioninfo import RegionInfo
+from boto.ec2.regioninfo import RegionInfo,EC2RegionInfo
from boto.ec2.instanceinfo import InstanceInfo
from boto.ec2.reservedinstance import ReservedInstancesOffering
from boto.ec2.reservedinstance import ReservedInstance
@@ -70,14 +70,16 @@ def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, host=None, port=None,
proxy=None, proxy_port=None,
proxy_user=None, proxy_pass=None, debug=0,
- https_connection_factory=None, region=None, path='/',
+ https_connection_factory=None, region=None, region_name=None, path='/',
api_version=None, security_token=None):
"""
Init method to create a new connection to EC2.
"""
if not region:
- region = RegionInfo(self, self.DefaultRegionName,
- self.DefaultRegionEndpoint)
+ if not region_name:
+ region = EC2RegionInfo(self, self.DefaultRegionName)
+ else:
+ region = EC2RegionInfo(self, region_name)
self.region = region
AWSQueryConnection.__init__(self, aws_access_key_id,
aws_secret_access_key,
View
@@ -30,5 +30,7 @@ class EC2RegionInfo(RegionInfo):
def __init__(self, connection=None, name=None, endpoint=None):
from boto.ec2.connection import EC2Connection
+ if name:
+ endpoint = RegionInfo.service_endpoint_templates(self, 'ec2').format(name)
RegionInfo.__init__(self, connection, name, endpoint,
EC2Connection)
View
@@ -62,3 +62,10 @@ def connect(self, **kw_params):
return self.connection_cls(region=self, **kw_params)
+ def service_endpoint_templates(self, service_name=None):
+ service_endpoints = {
+ 'sqs' : 'sqs.{0}.amazonaws.com',
+ 'ec2' : 'ec2.{0}.amazonaws.com'
+ }
+ return service_endpoints[service_name]
+
View
@@ -33,19 +33,21 @@ class SQSConnection(AWSQueryConnection):
A Connection to the SQS Service.
"""
DefaultRegionName = 'us-east-1'
- DefaultRegionEndpoint = 'sqs.us-east-1.amazonaws.com'
+ #DefaultRegionEndpoint = 'sqs.us-east-1.amazonaws.com'
APIVersion = '2011-10-01'
DefaultContentType = 'text/plain'
ResponseError = SQSError
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
proxy_user=None, proxy_pass=None, debug=0,
- https_connection_factory=None, region=None, path='/',
+ https_connection_factory=None, region=None, region_name=None, path='/',
security_token=None):
if not region:
- region = SQSRegionInfo(self, self.DefaultRegionName,
- self.DefaultRegionEndpoint)
+ if not region_name:
+ region = SQSRegionInfo(self, self.DefaultRegionName)
+ else:
+ region = SQSRegionInfo(self, region_name)
self.region = region
AWSQueryConnection.__init__(self, aws_access_key_id,
aws_secret_access_key,
View
@@ -28,5 +28,7 @@ class SQSRegionInfo(RegionInfo):
def __init__(self, connection=None, name=None, endpoint=None):
from boto.sqs.connection import SQSConnection
+ if name:
+ endpoint = RegionInfo.service_endpoint_templates(self, 'sqs').format(name)
RegionInfo.__init__(self, connection, name, endpoint,
SQSConnection)
View
Binary file not shown.