From: Shilpa Jagannath Date: Tue, 20 Jan 2026 23:42:30 +0000 (-0500) Subject: qa/multisite: switch to boto3 in multisite test libraries X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=09d0ebe488ace047abe43cc9f27c2feca57a6c70;p=ceph-ci.git qa/multisite: switch to boto3 in multisite test libraries Signed-off-by: Shilpa Jagannath (cherry picked from commit c84efd9af5a4e2845745285ada994aad072eb2a0) Signed-off-by: Adam C. Emerson --- diff --git a/src/test/rgw/rgw_multi/conn.py b/src/test/rgw/rgw_multi/conn.py index e3f7cd77704..1f914dc0e15 100644 --- a/src/test/rgw/rgw_multi/conn.py +++ b/src/test/rgw/rgw_multi/conn.py @@ -5,32 +5,28 @@ import boto.sts.connection import boto3 from boto.regioninfo import RegionInfo -def get_gateway_connection(gateway, credentials): +def get_gateway_connection(gateway, credentials, region): """ connect to the given gateway """ # Always create a new connection to the gateway to ensure each set of credentials gets its own connection - conn = boto.connect_s3(aws_access_key_id = credentials.access_key, - aws_secret_access_key = credentials.secret, - host = gateway.host, - port = gateway.port, - is_secure = False, - calling_format = boto.s3.connection.OrdinaryCallingFormat()) + conn = 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) if gateway.connection is None: gateway.connection = conn return conn -def get_gateway_secure_connection(gateway, credentials): +def get_gateway_secure_connection(gateway, credentials, region): """ secure connect to the given gateway """ if gateway.ssl_port == 0: return None if gateway.secure_connection is None: - gateway.secure_connection = boto.connect_s3( - aws_access_key_id = credentials.access_key, - aws_secret_access_key = credentials.secret, - host = gateway.host, - port = gateway.ssl_port, - is_secure = True, - validate_certs=False, - calling_format = boto.s3.connection.OrdinaryCallingFormat()) + gateway.secure_connection = 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.secure_connection def get_gateway_iam_connection(gateway, credentials, region): @@ -62,19 +58,6 @@ def get_gateway_sts_connection(gateway, credentials, region): return gateway.sts_connection -def get_gateway_s3_client(gateway, credentials, region): - """ connect to boto3 s3 client api of the given gateway """ - # Always create a new connection to the gateway to ensure each set of credentials gets its own connection - 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) - if gateway.s3_client is None: - gateway.s3_client = s3_client - return s3_client - - def get_gateway_sns_client(gateway, credentials, region): """ connect to boto3 s3 client api of the given gateway """ if gateway.sns_client is None: diff --git a/src/test/rgw/rgw_multi/multisite.py b/src/test/rgw/rgw_multi/multisite.py index 982ebe3ea7d..842344abdd3 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, get_gateway_s3_client, get_gateway_sns_client, get_gateway_sts_connection, get_gateway_temp_s3_client +from .conn import get_gateway_connection, get_gateway_iam_connection, get_gateway_secure_connection, get_gateway_sns_client, get_gateway_sts_connection, get_gateway_temp_s3_client class Cluster: """ interface to run commands against a distinct ceph cluster """ @@ -27,7 +27,6 @@ class Gateway: self.secure_connection = None self.ssl_port = ssl_port self.iam_connection = None - self.s3_client = None self.sns_client = None self.sts_connection = None @@ -189,18 +188,16 @@ class ZoneConn(object): self.credentials = credentials if self.zone.gateways is not None: - self.conn = get_gateway_connection(self.zone.gateways[0], self.credentials) - self.secure_conn = get_gateway_secure_connection(self.zone.gateways[0], self.credentials) - region = "" if self.zone.zonegroup is None else self.zone.zonegroup.name self.iam_conn = get_gateway_iam_connection(self.zone.gateways[0], self.credentials, region) - self.s3_client = get_gateway_s3_client(self.zone.gateways[0], self.credentials, region) + self.conn = get_gateway_connection(self.zone.gateways[0], self.credentials, region) + self.secure_conn = get_gateway_connection(self.zone.gateways[0], self.credentials, region) self.sns_client = get_gateway_sns_client(self.zone.gateways[0], self.credentials, region) self.temp_s3_client = None # create connections for the rest of the gateways (if exist) for gw in list(self.zone.gateways): - get_gateway_connection(gw, self.credentials) - get_gateway_secure_connection(gw, self.credentials) + get_gateway_connection(gw, self.credentials, region) + get_gateway_secure_connection(gw, self.credentials, region) get_gateway_iam_connection(gw, self.credentials, region) diff --git a/src/test/rgw/rgw_multi/tests.py b/src/test/rgw/rgw_multi/tests.py index b90e925e0b9..45226a58a91 100644 --- a/src/test/rgw/rgw_multi/tests.py +++ b/src/test/rgw/rgw_multi/tests.py @@ -75,12 +75,6 @@ run_prefix=''.join(random.choice(string.ascii_lowercase) for _ in range(6)) num_roles = 0 num_topic = 0 -def get_zone_connection(zone, credentials): - """ connect to the zone's first gateway """ - if isinstance(credentials, list): - credentials = credentials[0] - return get_gateway_connection(zone.gateways[0], credentials) - def mdlog_list(zone, period = None): cmd = ['mdlog', 'list'] if period: