From: Rishabh Dave Date: Fri, 26 Mar 2021 11:32:38 +0000 (+0530) Subject: qa/cephfs: modify get_key_from_keyfile() in mount.py X-Git-Tag: v18.0.0~772^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F40434%2Fhead;p=ceph.git qa/cephfs: modify get_key_from_keyfile() in mount.py CephFSMount.get_key_from_keyfile() should raise an exception instead of returning None if key is not found in keyring file. Fixes: https://tracker.ceph.com/issues/50010 Signed-off-by: Rishabh Dave --- diff --git a/qa/tasks/cephfs/mount.py b/qa/tasks/cephfs/mount.py index bb27b61d687f..f1691455a89e 100644 --- a/qa/tasks/cephfs/mount.py +++ b/qa/tasks/cephfs/mount.py @@ -577,13 +577,17 @@ class CephFSMount(object): def get_key_from_keyfile(self): # XXX: don't call run_shell(), since CephFS might be unmounted. - keyring = self.client_remote.run( - args=['sudo', 'cat', self.client_keyring_path], stdout=StringIO(), - omit_sudo=False).stdout.getvalue() + keyring = self.client_remote.read_file(self.client_keyring_path).\ + decode() + for line in keyring.split('\n'): if line.find('key') != -1: return line[line.find('=') + 1 : ].strip() + raise RuntimeError('Key not found in keyring file ' + f'{self.client_keyring_path}. Its contents are -\n' + f'{keyring}') + @property def config_path(self): """