mount = pathify(split_src_dst[0])
filename = os.path.basename(split_src_dst[0])
if len(split_src_dst) > 1:
- dst = split_src_dst[1] + ':z' if len(split_src_dst) == 3 else split_src_dst[1]
+ dst = split_src_dst[1]
+ if len(split_src_dst) == 3:
+ dst = '{}:{}'.format(dst, split_src_dst[2])
mounts[mount] = dst
else:
- mounts[mount] = '/mnt/{}:z'.format(filename)
+ mounts[mount] = '/mnt/{}'.format(filename)
if ctx.command:
command = ctx.command
else:
assert retval == 0
assert ctx.keyring == 'foo'
+ @mock.patch('cephadm.CephContainer')
+ def test_mount_no_dst(self, m_ceph_container, cephadm_fs):
+ cmd = ['shell', '--mount', '/etc/foo']
+ with with_cephadm_ctx(cmd) as ctx:
+ retval = cd.command_shell(ctx)
+ assert retval == 0
+ assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/mnt/foo'
+
+ @mock.patch('cephadm.CephContainer')
+ def test_mount_with_dst_no_opt(self, m_ceph_container, cephadm_fs):
+ cmd = ['shell', '--mount', '/etc/foo:/opt/foo/bar']
+ with with_cephadm_ctx(cmd) as ctx:
+ retval = cd.command_shell(ctx)
+ assert retval == 0
+ assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/opt/foo/bar'
+
+ @mock.patch('cephadm.CephContainer')
+ def test_mount_with_dst_and_opt(self, m_ceph_container, cephadm_fs):
+ cmd = ['shell', '--mount', '/etc/foo:/opt/foo/bar:Z']
+ with with_cephadm_ctx(cmd) as ctx:
+ retval = cd.command_shell(ctx)
+ assert retval == 0
+ assert m_ceph_container.call_args.kwargs['volume_mounts']['/etc/foo'] == '/opt/foo/bar:Z'
class TestCephVolume(object):