From: Rishabh Dave Date: Wed, 14 Jul 2021 14:12:10 +0000 (+0530) Subject: qa: add a method to get keyring for a client_id X-Git-Tag: v18.0.0~469^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=af1bf2fb3d96020fc2c8c6751ba18d12937d8153;p=ceph.git qa: add a method to get keyring for a client_id The method wraps very frequently used code-phrase and adds check to avoid potential bugs. Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/ceph_manager.py b/qa/tasks/ceph_manager.py index 51d802cd7ce9..6eb9ba4e9f6d 100644 --- a/qa/tasks/ceph_manager.py +++ b/qa/tasks/ceph_manager.py @@ -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,