Exemple #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_run(cmds, scope=True, unit=unit, slice=slice_name)

    return exec_sync(cmds)
Exemple #2
0
def systemd_run(unit_name, cgroup_slice, *args):
    return commands.execCmd(
        cmdutils.systemd_run(
            args,
            unit=unit_name,
            slice=cgroup_slice,
            accounting=_ACCOUNTING,
        ))
Exemple #3
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_run(cmds, scope=True, unit=unit, slice=slice_name)

    return exec_sync(cmds)
Exemple #4
0
def systemd_run(unit_name, cgroup_slice, *args):
    return commands.execCmd(
        cmdutils.systemd_run(
            args,
            unit=unit_name,
            slice=cgroup_slice,
            accounting=_ACCOUNTING,
        )
    )
Exemple #5
0
 def test_accounting(self):
     accounting = (
         cmdutils.Accounting.CPU,
         cmdutils.Accounting.Memory,
         cmdutils.Accounting.BlockIO,
     )
     cmd = cmdutils.systemd_run(['a', 'b'], accounting=accounting)
     res = [
         cmdutils.SYSTEMD_RUN,
         '--property=CPUAccounting=1',
         '--property=MemoryAccounting=1',
         '--property=BlockIOAccounting=1',
         'a',
         'b',
     ]
     self.assertEqual(cmd, res)
Exemple #6
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 = cmdutils.systemd_run(cmd, scope=True, slice=cgroup)

    _runcmd(cmd)
Exemple #7
0
def _mount(fs_spec, fs_file, mntOpts=None, vfstype=None, timeout=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 = cmdutils.systemd_run(cmd, scope=True, slice=cgroup)

    _runcmd(cmd, timeout)
Exemple #8
0
 def test_slice(self):
     cmd = cmdutils.systemd_run(['a', 'b'], slice='slice')
     res = [cmdutils.SYSTEMD_RUN, '--slice=slice', 'a', 'b']
     self.assertEqual(cmd, res)
Exemple #9
0
 def test_unit(self):
     cmd = cmdutils.systemd_run(['a', 'b'], unit='unit')
     res = [cmdutils.SYSTEMD_RUN, '--unit=unit', 'a', 'b']
     self.assertEqual(cmd, res)
Exemple #10
0
 def test_scope(self):
     cmd = cmdutils.systemd_run(['a', 'b'], scope=True)
     res = [cmdutils.SYSTEMD_RUN, '--scope', 'a', 'b']
     self.assertEqual(cmd, res)
Exemple #11
0
 def test_defaults(self):
     cmd = cmdutils.systemd_run(['a', 'b'])
     res = [cmdutils.SYSTEMD_RUN, 'a', 'b']
     self.assertEqual(cmd, res)