self.rbytes = config.get('rbytes', False)
self.inst = None
self.addr = None
+ self._mount_bin = ['adjust-ulimits', 'ceph-coverage', self.test_dir +\
+ '/archive/coverage', '/bin/mount', '-t', 'ceph']
def mount(self, mntopts=[], check_status=True, **kwargs):
self.update_attrs(**kwargs)
if not self.cephfs_mntpt:
self.cephfs_mntpt = '/'
- stderr = StringIO()
- try:
- self.client_remote.run(args=['mkdir', '-p', self.hostfs_mntpt],
- timeout=(5*60), stderr=stderr)
- except CommandFailedError:
- if 'file exists' not in stderr.getvalue().lower():
- raise
+ self._create_mntpt()
retval = self._run_mount_cmd(mntopts, check_status)
if retval:
return retval
+ self._set_filemode_on_mntpt()
+
+ self.mounted = True
+
+ def _create_mntpt(self):
stderr = StringIO()
try:
- self.client_remote.run(
- args=['sudo', 'chmod', '1777', self.hostfs_mntpt],
- stderr=stderr, timeout=(5*60))
+ self.client_remote.run(args=['mkdir', '-p', self.hostfs_mntpt],
+ timeout=(5*60), stderr=stderr)
except CommandFailedError:
- # the client does not have write permissions in the caps it holds
- # for the Ceph FS that was just mounted.
- if 'permission denied' in stderr.getvalue().lower():
- pass
+ if 'file exists' not in stderr.getvalue().lower():
+ raise
+ def _run_mount_cmd(self, mntopts, check_status):
+ mount_cmd = self._get_mount_cmd(mntopts)
+ mountcmd_stdout, mountcmd_stderr = StringIO(), StringIO()
- self.mounted = True
+ try:
+ self.client_remote.run(args=mount_cmd, timeout=(30*60),
+ stdout=mountcmd_stdout,
+ stderr=mountcmd_stderr, omit_sudo=False)
+ except CommandFailedError as e:
+ log.info('mount command failed')
+ if check_status:
+ raise
+ else:
+ return (e, mountcmd_stdout.getvalue(),
+ mountcmd_stderr.getvalue())
+ log.info('mount command passed')
- def _run_mount_cmd(self, mntopts, check_status):
+ def _get_mount_cmd(self, mntopts):
opts = 'norequire_active_mds'
if self.client_id:
opts += ',name=' + self.client_id
if mntopts:
opts += ',' + ','.join(mntopts)
+ mount_cmd = ['sudo'] + self._nsenter_args
mount_dev = ':' + self.cephfs_mntpt
- prefix = ['sudo', 'adjust-ulimits', 'ceph-coverage',
- self.test_dir + '/archive/coverage',
- 'nsenter',
- '--net=/var/run/netns/{0}'.format(self.netns_name)]
- cmdargs = prefix + ['/bin/mount', '-t', 'ceph', mount_dev,
- self.hostfs_mntpt, '-v', '-o', opts]
+ mount_cmd += self._mount_bin + [mount_dev, self.hostfs_mntpt, '-v',
+ '-o', opts]
- mountcmd_stdout, mountcmd_stderr = StringIO(), StringIO()
+ return mount_cmd
+
+ @property
+ def _nsenter_args(self):
+ return ['nsenter', f'--net=/var/run/netns/{self.netns_name}']
+
+ def _set_filemode_on_mntpt(self):
+ stderr = StringIO()
try:
- self.client_remote.run(args=cmdargs, timeout=(30*60),
- stdout=mountcmd_stdout,
- stderr=mountcmd_stderr)
- except CommandFailedError as e:
- log.info('mount command failed')
- if check_status:
- raise
- else:
- return (e, mountcmd_stdout.getvalue(),
- mountcmd_stderr.getvalue())
- log.info('mount command passed')
+ self.client_remote.run(
+ args=['sudo', 'chmod', '1777', self.hostfs_mntpt],
+ stderr=stderr, timeout=(5*60))
+ except CommandFailedError:
+ # the client does not have write permissions in the caps it holds
+ # for the Ceph FS that was just mounted.
+ if 'permission denied' in stderr.getvalue().lower():
+ pass
def umount(self, force=False):
if not self.is_mounted():