From d866669b3ebb34ec3b23b44a85cff3a9b64fb88e Mon Sep 17 00:00:00 2001 From: Shilpa Jagannath Date: Tue, 26 Nov 2024 12:07:34 -0800 Subject: [PATCH] qa/multisite: use boto s3_client Signed-off-by: Shilpa Jagannath --- src/test/rgw/rgw_multi/conn.py | 11 +++++++++++ src/test/rgw/rgw_multi/multisite.py | 5 ++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/test/rgw/rgw_multi/conn.py b/src/test/rgw/rgw_multi/conn.py index 59bc2fdd3d2f7..462234a7f743e 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 5d4dcd1aa7ae1..f47b0263d4def 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): -- 2.47.3