hute 3.11.0サポートs 3カスタムendpoint
5826 ワード
#/opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/desktop/libs/aws/src/aws/conf.py
def get_default_region():
return AWS_ACCOUNTS['default'].REGION.get()
+DEFAULT_CALLING_FORMAT='boto.s3.connection.S3Connection.DefaultCallingFormat'
AWS_ACCOUNTS = UnspecifiedConfigSection(
...
REGION=Config(
key='region',
default='us-east-1',
type=str
+ ),
+ PROXY_ADDRESS=Config(
+ help=_('Alternate address for endpoint.'),
+ key='proxy_address',
+ default=None,
+ type=str
+ ),
+ PROXY_PORT=Config(
+ help=_('Alternate port for endpoint.'),
+ key='proxy_port',
+ default=None,
+ type=int
+ ),
+ CALLING_FORMAT=Config(
+ key='calling_format',
+ default=DEFAULT_CALLING_FORMAT,
+ type=str
+ ),
+ IS_SECURE=Config(
+ key='is_secure',
+ default=True,
+ type=coerce_bool
#/opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/desktop/libs/aws/src/aws/client.py
import boto
import boto.s3
+import boto.s3.connection
import boto.utils
from aws.conf import get_default_region, has_iam_metadata
@@ -27,12 +28,17 @@
class Client(object):
def __init__(self, aws_access_key_id=None, aws_secret_access_key=None, aws_security_token=None, region=None,
- timeout=HTTP_SOCKET_TIMEOUT_S):
+ timeout=HTTP_SOCKET_TIMEOUT_S, proxy_address=None,
+ proxy_port=None, calling_format=None, is_secure=True):
self._access_key_id = aws_access_key_id
self._secret_access_key = aws_secret_access_key
self._security_token = aws_security_token
self._region = region.lower() if region else get_default_region()
self._timeout = timeout
+ self._proxy_address = proxy_address
+ self._proxy_port = proxy_port
+ self._calling_format = conf.DEFAULT_CALLING_FORMAT if calling_format is None else calling_format
+ self._is_secure = is_secure
boto.config.add_section('Boto')
boto.config.set('Boto', 'http_socket_timeout', str(self._timeout))
@@ -51,15 +57,27 @@ def from_config(cls, conf):
aws_access_key_id=access_key_id,
aws_secret_access_key=secret_access_key,
aws_security_token=security_token,
- region=conf.REGION.get()
+ region=conf.REGION.get(),
+ proxy_address=conf.PROXY_ADDRESS.get(),
+ proxy_port=conf.PROXY_PORT.get(),
+ calling_format=conf.CALLING_FORMAT.get(),
+ is_secure=conf.IS_SECURE.get()
)
def get_s3_connection(self):
# First attempt to connect via specified credentials
- connection = boto.s3.connect_to_region(self._region,
- aws_access_key_id=self._access_key_id,
- aws_secret_access_key=self._secret_access_key)
+ if self._proxy_address is not None and self._proxy_port is not None:
+ # , boto.connect_s3, patchset boto.s3.connection.S3Connection, connection bad resopnse,
+ connection = boto.connect_s3(
+ aws_access_key_id = self._access_key_id,
+ aws_secret_access_key = self._secret_access_key,
+ host = self._proxy_address,
+ port = self._proxy_port,
+ is_secure = self._is_secure,
+ calling_format = self._calling_format
+ )
+ else:
+ connection = boto.s3.connect_to_region(self._region,
+ aws_access_key_id=self._access_key_id,
+ aws_secret_access_key=self._secret_access_key)
proxy_address,porxy_port,is_secure,calling_format
[aws]
[[aws_accounts]]
[[[default]]]
access_key_id= your access_key_id
secret_access_key= your secret_access_key
allow_environment_credentials=false
region=us-east-1
proxy_address=10.213.44.119
proxy_port=7480
is_secure=false
calling_format=boto.s3.connection.OrdinaryCallingFormat
# /opt/cloudera/parcels/CDH-5.9.0-1.cdh5.9.0.p0.23/lib/hue/desktop/libs/aws/src/aws/s3/init.py 139L, 4066C
try:
stripped = time.strptime(datetime[:-4], '%a, %d %b %Y %H:%M:%S')
assert datetime[-4:] == ' GMT', 'Time [%s] is not in GMT.' % datetime
except ValueError:
stripped = time.strptime(datetime[:-5], '%Y-%m-%dT%H:%M:%S')
# assert datetime[-5:] == '.000Z', 'Time [%s] is not in GMT.' % datetime
return int(calendar.timegm(stripped))