From af1bf2fb3d96020fc2c8c6751ba18d12937d8153 Mon Sep 17 00:00:00 2001 From: Rishabh Dave Date: Wed, 14 Jul 2021 19:42:10 +0530 Subject: [PATCH] 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 --- qa/tasks/ceph_manager.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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, -- 2.47.3