Пример #1
0
 def test_set_context_doesnt_skip_with_env(self, stub_call, stub_which,
                                           fake_run, value):
     stub_call(('', '', 0))
     stub_which()
     os.environ['CEPH_VOLUME_SKIP_RESTORECON'] = value
     system.set_context('/tmp/foo')
     assert len(fake_run.calls)
Пример #2
0
def mount_tmpfs(path):
    process.run([
        'mount',
        '-t',
        'tmpfs', 'tmpfs',
        path
    ])

    # Restore SELinux context
    system.set_context(path)
Пример #3
0
def mount_tmpfs(path):
    process.run([
        'mount',
        '-t',
        'tmpfs', 'tmpfs',
        path
    ])

    # Restore SELinux context
    system.set_context(path)
Пример #4
0
def mount_osd(device, osd_id, **kw):
    extras = []
    is_vdo = kw.get('is_vdo', '0')
    if is_vdo == '1':
        extras = ['discard']
    destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id)
    command = ['mount', '-t', 'xfs', '-o']
    flags = conf.ceph.get_list(
        'osd',
        'osd_mount_options_xfs',
        default=constants.mount.get('xfs'),
        split=' ',
    )
    command.append(_normalize_mount_flags(flags, extras=extras))
    command.append(device)
    command.append(destination)
    process.run(command)

    # Restore SELinux context
    system.set_context(destination)
Пример #5
0
def mount_osd(device, osd_id, **kw):
    extras = []
    is_vdo = kw.get('is_vdo', '0')
    if is_vdo == '1':
        extras = ['discard']
    destination = '/var/lib/ceph/osd/%s-%s' % (conf.cluster, osd_id)
    command = ['mount', '-t', 'xfs', '-o']
    flags = conf.ceph.get_list(
        'osd',
        'osd_mount_options_xfs',
        default=constants.mount.get('xfs'),
        split=' ',
    )
    command.append(
        _normalize_mount_flags(flags, extras=extras)
    )
    command.append(device)
    command.append(destination)
    process.run(command)

    # Restore SELinux context
    system.set_context(destination)
Пример #6
0
 def test_selinuxenabled_is_not_enabled(self, stub_call, fake_run):
     stub_call(('', '', 1))
     system.set_context('/tmp/foo')
     assert fake_run.calls == []
Пример #7
0
 def test_selinuxenabled_doesnt_exist(self, mocked_call, fake_run):
     mocked_call.side_effect = FileNotFoundError()
     system.set_context('/tmp/foo')
     assert fake_run.calls == []
Пример #8
0
 def test_set_context_no_skip_on_executable(self, stub_call, stub_which,
                                            fake_run):
     stub_call(('', '', 0))
     stub_which('/bin/restorecon')
     system.set_context('/tmp/foo')
     assert len(fake_run.calls)
Пример #9
0
 def test_set_context_skips(self, stub_call, fake_run, value):
     stub_call(('', '', 0))
     os.environ['CEPH_VOLUME_SKIP_RESTORECON'] = value
     system.set_context('/tmp/foo')
     assert fake_run.calls == []
Пример #10
0
 def test_selinuxenabled_doesnt_exist(self, stub_call, fake_run):
     stub_call(('', 'command not found: selinuxenabled', 127))
     system.set_context('/tmp/foo')
     assert fake_run.calls == []