]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa/multisite: use boto s3_client 60850/head
authorShilpa Jagannath <smanjara@redhat.com>
Tue, 26 Nov 2024 20:07:34 +0000 (12:07 -0800)
committerShilpa Jagannath <smanjara@redhat.com>
Mon, 6 Jan 2025 19:47:26 +0000 (11:47 -0800)
Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/test/rgw/rgw_multi/conn.py
src/test/rgw/rgw_multi/multisite.py

index 59bc2fdd3d2f7b1a3246ad4019d2bdfdcea2334b..462234a7f743ed6d6e437696a7b082984224f223 100644 (file)
@@ -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
index 5d4dcd1aa7ae1480c038f2d33088b027ede9aa93..f47b0263d4def350d640c68b10ae96338a5754a4 100644 (file)
@@ -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):