From: Shilpa Jagannath Date: Tue, 26 Nov 2024 20:07:34 +0000 (-0800) Subject: qa/multisite: use boto s3_client X-Git-Tag: v18.2.5~148^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F60850%2Fhead;p=ceph.git qa/multisite: use boto s3_client Signed-off-by: Shilpa Jagannath --- diff --git a/src/test/rgw/rgw_multi/conn.py b/src/test/rgw/rgw_multi/conn.py index 59bc2fdd3d2f..462234a7f743 100644 --- a/src/test/rgw/rgw_multi/conn.py +++ b/src/test/rgw/rgw_multi/conn.py @@ -1,6 +1,7 @@ import boto import boto.s3.connection import boto.iam.connection +import boto3 def get_gateway_connection(gateway, credentials): """ connect to the given gateway """ @@ -39,3 +40,13 @@ def get_gateway_iam_connection(gateway, credentials): 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 diff --git a/src/test/rgw/rgw_multi/multisite.py b/src/test/rgw/rgw_multi/multisite.py index 5d4dcd1aa7ae..f47b0263d4de 100644 --- a/src/test/rgw/rgw_multi/multisite.py +++ b/src/test/rgw/rgw_multi/multisite.py @@ -3,7 +3,7 @@ from io import StringIO 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 """ @@ -27,6 +27,7 @@ class Gateway: self.secure_connection = None self.ssl_port = ssl_port self.iam_connection = None + self.s3_client = None @abstractmethod def start(self, args = []): @@ -190,6 +191,8 @@ class ZoneConn(object): 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):