import boto
import boto.s3.connection
import boto.iam.connection
+import boto3
def get_gateway_connection(gateway, credentials):
""" connect to the given gateway """
port = gateway.port,
is_secure = False)
return gateway.iam_connection
+
+def get_gateway_s3_client(gateway, credentials, region):
+ """ connect to boto3 s3 client api of the given gateway """
+ if gateway.s3_client is None:
+ gateway.s3_client = boto3.client('s3',
+ endpoint_url='http://' + gateway.host + ':' + str(gateway.port),
+ aws_access_key_id=credentials.access_key,
+ aws_secret_access_key=credentials.secret,
+ region_name=region)
+ return gateway.s3_client
import json
-from .conn import get_gateway_connection, get_gateway_iam_connection, get_gateway_secure_connection
+from .conn import get_gateway_connection, get_gateway_iam_connection, get_gateway_secure_connection, get_gateway_s3_client
class Cluster:
""" interface to run commands against a distinct ceph cluster """
self.secure_connection = None
self.ssl_port = ssl_port
self.iam_connection = None
+ self.s3_client = None
@abstractmethod
def start(self, args = []):
self.secure_conn = get_gateway_secure_connection(self.zone.gateways[0], self.credentials)
self.iam_conn = get_gateway_iam_connection(self.zone.gateways[0], self.credentials)
+ region = "" if self.zone.zonegroup is None else self.zone.zonegroup.name
+ self.s3_client = get_gateway_s3_client(self.zone.gateways[0], self.credentials, region)
# create connections for the rest of the gateways (if exist)
for gw in list(self.zone.gateways):