コード例 #1
0
def exec_systemd_new_unit(cmds, slice_name):
    # TODO: We set unique uuid for every run to not use the same unit twice
    # and prevent systemd-run race (BZ#1259468). This uuid could be dropped
    # when BZ#1272368 will be solved or when we use systemd >= v220.
    unit = uuid.uuid4()
    cmds = systemd.wrap(cmds, scope=True, unit=unit, slice=slice_name)

    return exec_sync(cmds)
コード例 #2
0
def test_accounting():
    accounting = (
        systemd.Accounting.CPU,
        systemd.Accounting.Memory,
        systemd.Accounting.BlockIO,
    )
    cmd = systemd.wrap(['a', 'b'], accounting=accounting)
    res = [
        systemd.SYSTEMD_RUN,
        '--property=CPUAccounting=1',
        '--property=MemoryAccounting=1',
        '--property=BlockIOAccounting=1',
        'a',
        'b',
    ]
    assert cmd == res
コード例 #3
0
def _mount(fs_spec, fs_file, mntOpts=None, vfstype=None, cgroup=None):
    """
    Called from supervdsm for running the mount command as root.
    """
    cmd = [constants.EXT_MOUNT]

    if vfstype is not None:
        cmd.extend(("-t", vfstype))

    if mntOpts:
        cmd.extend(("-o", mntOpts))

    cmd.extend((fs_spec, fs_file))

    if cgroup:
        cmd = systemd.wrap(cmd, scope=True, slice=cgroup)

    _runcmd(cmd)
コード例 #4
0
def test_uid_gid():
    cmd = systemd.wrap(['a', 'b'], uid=36, gid=36)
    res = [systemd.SYSTEMD_RUN, '--uid=36', '--gid=36', 'a', 'b']
    assert cmd == res
コード例 #5
0
def test_slice():
    cmd = systemd.wrap(['a', 'b'], slice='slice')
    res = [systemd.SYSTEMD_RUN, '--slice=slice', 'a', 'b']
    assert cmd == res
コード例 #6
0
def test_unit():
    cmd = systemd.wrap(['a', 'b'], unit='unit')
    res = [systemd.SYSTEMD_RUN, '--unit=unit', 'a', 'b']
    assert cmd == res
コード例 #7
0
def test_scope():
    cmd = systemd.wrap(['a', 'b'], scope=True)
    res = [systemd.SYSTEMD_RUN, '--scope', 'a', 'b']
    assert cmd == res
コード例 #8
0
def test_wrap_defaults():
    cmd = systemd.wrap(['a', 'b'])
    res = [systemd.SYSTEMD_RUN, 'a', 'b']
    assert cmd == res