qa/cephfs: check for Ceph FS before mounting

If the given Ceph FS, or the default Ceph FS when no Ceph FS is given,
is absent, abort the execution with AsssertionError and an error
message.

Signed-off-by: Rishabh Dave <ridave@redhat.com>
This commit is contained in:
Rishabh Dave 2021-02-24 00:05:48 +05:30
parent db0b85b440
commit 95eb0043bf

View File

@ -123,6 +123,18 @@ class CephFSMount(object):
def netns_name(self, name):
self._netns_name = name
def assert_that_ceph_fs_exists(self):
output = self.client_remote.run(args='ceph fs ls', stdout=StringIO()).\
stdout.getvalue()
if self.cephfs_name:
assert self.cephfs_name in output, \
'expected ceph fs is not present on the cluster'
log.info(f'Mounting Ceph FS {self.cephfs_name}; just confirmed its presence on cluster')
else:
assert 'No filesystems enabled' not in output, \
'ceph cluster has no ceph fs, not even the default ceph fs'
log.info('Mounting default Ceph FS; just confirmed its presence on cluster')
def assert_and_log_minimum_mount_details(self):
"""
Make sure we have minimum details required for mounting. Ideally, this
@ -136,6 +148,8 @@ class CephFSMount(object):
'3. the remote machine where CephFS will be mounted.\n')
raise RuntimeError(errmsg)
self.assert_that_ceph_fs_exists()
log.info('Mounting Ceph FS. Following are details of mount; remember '
'"None" represents Python type None -')
log.info(f'self.client_remote.hostname = {self.client_remote.hostname}')