Add support for custom ports on RADOS and S3 storage engines

This commit is contained in:
Joseph Schorr 2016-12-01 13:22:27 -05:00
parent 2c637fe5ce
commit f4bcf68928
3 changed files with 14 additions and 4 deletions

View file

@ -437,7 +437,7 @@ class _CloudStorage(BaseStorageV2):
class S3Storage(_CloudStorage):
def __init__(self, context, storage_path, s3_bucket, s3_access_key=None,
s3_secret_key=None, host=None):
s3_secret_key=None, host=None, port=None):
upload_params = {
'encrypt_key': True,
}
@ -447,6 +447,10 @@ class S3Storage(_CloudStorage):
raise ValueError('host name must not start with http:// or https://')
connect_kwargs['host'] = host
if port:
connect_kwargs['port'] = int(port)
super(S3Storage, self).__init__(context, boto.s3.connection.S3Connection, boto.s3.key.Key,
connect_kwargs, upload_params, storage_path, s3_bucket,
access_key=s3_access_key or None,
@ -535,7 +539,7 @@ class GoogleCloudStorage(_CloudStorage):
class RadosGWStorage(_CloudStorage):
def __init__(self, context, hostname, is_secure, storage_path, access_key, secret_key,
bucket_name):
bucket_name, port=None):
upload_params = {}
connect_kwargs = {
'host': hostname,
@ -543,6 +547,9 @@ class RadosGWStorage(_CloudStorage):
'calling_format': boto.s3.connection.OrdinaryCallingFormat(),
}
if port:
connect_kwargs['port'] = int(port)
super(RadosGWStorage, self).__init__(context, boto.s3.connection.S3Connection,
boto.s3.key.Key, connect_kwargs, upload_params,
storage_path, bucket_name, access_key, secret_key)