|
@@ -20,7 +20,7 @@ import boto.s3
|
|
|
import boto.s3.connection
|
|
import boto.s3.connection
|
|
|
import boto.utils
|
|
import boto.utils
|
|
|
|
|
|
|
|
-from aws.conf import get_default_region, has_iam_metadata
|
|
|
|
|
|
|
+from aws.conf import get_default_region, has_iam_metadata, DEFAULT_CALLING_FORMAT
|
|
|
|
|
|
|
|
|
|
|
|
|
HTTP_SOCKET_TIMEOUT_S = 60
|
|
HTTP_SOCKET_TIMEOUT_S = 60
|
|
@@ -37,7 +37,7 @@ class Client(object):
|
|
|
self._timeout = timeout
|
|
self._timeout = timeout
|
|
|
self._proxy_address = proxy_address
|
|
self._proxy_address = proxy_address
|
|
|
self._proxy_port = proxy_port
|
|
self._proxy_port = proxy_port
|
|
|
- self._calling_format = conf.DEFAULT_CALLING_FORMAT if calling_format is None else calling_format
|
|
|
|
|
|
|
+ self._calling_format = DEFAULT_CALLING_FORMAT if calling_format is None else calling_format
|
|
|
self._is_secure = is_secure
|
|
self._is_secure = is_secure
|
|
|
|
|
|
|
|
boto.config.add_section('Boto')
|
|
boto.config.add_section('Boto')
|
|
@@ -68,20 +68,25 @@ class Client(object):
|
|
|
# First attempt to connect via specified credentials
|
|
# First attempt to connect via specified credentials
|
|
|
if self._proxy_address is not None and self._proxy_port is not None:
|
|
if self._proxy_address is not None and self._proxy_port is not None:
|
|
|
connection = boto.s3.connection.S3Connection(aws_access_key_id=self._access_key_id,
|
|
connection = boto.s3.connection.S3Connection(aws_access_key_id=self._access_key_id,
|
|
|
- aws_secret_access_key=self._secret_access_key,
|
|
|
|
|
- security_token=self._security_token,
|
|
|
|
|
- is_secure=self._is_secure,
|
|
|
|
|
- calling_format=self._calling_format,
|
|
|
|
|
- proxy=self._proxy_address, proxy_port=self._proxy_port)
|
|
|
|
|
- else:
|
|
|
|
|
|
|
+ aws_secret_access_key=self._secret_access_key,
|
|
|
|
|
+ security_token=self._security_token,
|
|
|
|
|
+ is_secure=self._is_secure,
|
|
|
|
|
+ calling_format=self._calling_format,
|
|
|
|
|
+ proxy=self._proxy_address,
|
|
|
|
|
+ proxy_port=self._proxy_port)
|
|
|
|
|
+ elif self._region:
|
|
|
connection = boto.s3.connect_to_region(self._region,
|
|
connection = boto.s3.connect_to_region(self._region,
|
|
|
- aws_access_key_id=self._access_key_id,
|
|
|
|
|
- aws_secret_access_key=self._secret_access_key,
|
|
|
|
|
- security_token=self._security_token)
|
|
|
|
|
|
|
+ aws_access_key_id=self._access_key_id,
|
|
|
|
|
+ aws_secret_access_key=self._secret_access_key,
|
|
|
|
|
+ security_token=self._security_token)
|
|
|
|
|
+ else:
|
|
|
|
|
+ connection = boto.s3.connection.S3Connection(aws_access_key_id=self._access_key_id,
|
|
|
|
|
+ aws_secret_access_key=self._secret_access_key,
|
|
|
|
|
+ security_token=self._security_token)
|
|
|
|
|
|
|
|
if connection is None:
|
|
if connection is None:
|
|
|
# If no connection, attemt to fallback to IAM instance metadata
|
|
# If no connection, attemt to fallback to IAM instance metadata
|
|
|
- connection = boto.s3.connect_to_region(self._region)
|
|
|
|
|
|
|
+ connection = boto.connect_s3()
|
|
|
|
|
|
|
|
if connection is None:
|
|
if connection is None:
|
|
|
raise ValueError('Can not construct S3 Connection for region %s' % self._region)
|
|
raise ValueError('Can not construct S3 Connection for region %s' % self._region)
|