]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/test/rgw/rgw_multi/multisite.py
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / test / rgw / rgw_multi / multisite.py
index 78e8a6b56e8481616f8815acbd0ff1da22a95120..5d4dcd1aa7ae1480c038f2d33088b027ede9aa93 100644 (file)
@@ -1,9 +1,9 @@
 from abc import ABCMeta, abstractmethod
-from six import StringIO
+from io import StringIO
 
 import json
 
-from .conn import get_gateway_connection
+from .conn import get_gateway_connection, get_gateway_iam_connection, get_gateway_secure_connection
 
 class Cluster:
     """ interface to run commands against a distinct ceph cluster """
@@ -18,13 +18,15 @@ class Gateway:
     """ interface to control a single radosgw instance """
     __metaclass__ = ABCMeta
 
-    def __init__(self, host = None, port = None, cluster = None, zone = None, proto = 'http', connection = None):
+    def __init__(self, host = None, port = None, cluster = None, zone = None, ssl_port = 0):
         self.host = host
         self.port = port
         self.cluster = cluster
         self.zone = zone
-        self.proto = proto
-        self.connection = connection
+        self.connection = None
+        self.secure_connection = None
+        self.ssl_port = ssl_port
+        self.iam_connection = None
 
     @abstractmethod
     def start(self, args = []):
@@ -37,7 +39,7 @@ class Gateway:
         pass
 
     def endpoint(self):
-        return '%s://%s:%d' % (self.proto, self.host, self.port)
+        return 'http://%s:%d' % (self.host, self.port)
 
 class SystemObject:
     """ interface for system objects, represented in json format and
@@ -71,9 +73,7 @@ class SystemObject:
         data and retcode """
         s, r = self.command(cluster, cmd, args or [], **kwargs)
         if r == 0:
-            output = s.decode('utf-8')
-            output = output[output.find('{'):] # trim extra output before json
-            data = json.loads(output)
+            data = json.loads(s)
             self.load_from_json(data)
             self.data = data
         return self.data, r
@@ -163,9 +163,15 @@ class Zone(SystemObject, SystemObject.CreateDelete, SystemObject.GetSet, SystemO
     def tier_type(self):
         raise NotImplementedError
 
+    def syncs_from(self, zone_name):
+        return zone_name != self.name
+
     def has_buckets(self):
         return True
 
+    def has_roles(self):
+        return True
+
     def get_conn(self, credentials):
         return ZoneConn(self, credentials) # not implemented, but can be used
 
@@ -181,10 +187,24 @@ class ZoneConn(object):
 
         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)
+
+            self.iam_conn = get_gateway_iam_connection(self.zone.gateways[0], self.credentials)
+
+            # 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_iam_connection(gw, self.credentials)
+
 
     def get_connection(self):
         return self.conn
 
+    def get_iam_connection(self):
+        return self.iam_conn
+
     def get_bucket(self, bucket_name, credentials):
         raise NotImplementedError
 
@@ -344,14 +364,18 @@ class Credentials:
         return ['--access-key', self.access_key, '--secret', self.secret]
 
 class User(SystemObject):
-    def __init__(self, uid, data = None, name = None, credentials = None):
+    def __init__(self, uid, data = None, name = None, credentials = None, tenant = None):
         self.name = name
         self.credentials = credentials or []
+        self.tenant = tenant
         super(User, self).__init__(data, uid)
 
     def user_arg(self):
         """ command-line argument to specify this user """
-        return ['--uid', self.id]
+        args = ['--uid', self.id]
+        if self.tenant:
+            args += ['--tenant', self.tenant]
+        return args
 
     def build_command(self, command):
         """ build a command line for the given command and args """