]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
qa: add a method to get keyring for a client_id 42335/head
authorRishabh Dave <ridave@redhat.com>
Wed, 14 Jul 2021 14:12:10 +0000 (19:42 +0530)
committerRishabh Dave <ridave@redhat.com>
Fri, 8 Jul 2022 07:35:51 +0000 (13:05 +0530)
The method wraps very frequently used code-phrase and adds check to
avoid potential bugs.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
qa/tasks/ceph_manager.py

index 51d802cd7ce9d53cf7278863711465aff32aa03d..6eb9ba4e9f6d74ba1abf244abf01a5b40a2d8c7a 100644 (file)
@@ -1605,6 +1605,23 @@ class CephManager:
         kwargs['check_status'] = False
         return self.run_cluster_cmd(**kwargs).exitstatus
 
+    def get_keyring(self, client_id):
+        """
+        Return keyring for the given client.
+
+        :param client_id: str
+        :return keyring: str
+        """
+        if client_id.find('client.') != -1:
+            client_id = client_id.replace('client.', '')
+
+        keyring = self.run_cluster_cmd(args=f'auth get client.{client_id}',
+                                       stdout=StringIO()).\
+            stdout.getvalue().strip()
+
+        assert isinstance(keyring, str) and keyring != ''
+        return keyring
+
     def run_ceph_w(self, watch_channel=None):
         """
         Execute "ceph -w" in the background with stdout connected to a BytesIO,