File: config_runner.py

package info (click to toggle)
pcs 0.12.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 16,148 kB
  • sloc: python: 238,810; xml: 20,833; ruby: 13,203; makefile: 1,595; sh: 484
file content (53 lines) | stat: -rw-r--r-- 2,128 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
from pcs_test.tools.command_env.config_runner_booth import BoothShortcuts
from pcs_test.tools.command_env.config_runner_cib import CibShortcuts
from pcs_test.tools.command_env.config_runner_corosync import CorosyncShortcuts
from pcs_test.tools.command_env.config_runner_pcmk import PcmkShortcuts
from pcs_test.tools.command_env.config_runner_sbd import SbdShortcuts
from pcs_test.tools.command_env.config_runner_scsi import ScsiShortcuts
from pcs_test.tools.command_env.mock_runner import Call as RunnerCall


class RunnerConfig:
    def __init__(self, call_collection, wrap_helper):
        self.__calls = call_collection

        self.booth = wrap_helper(BoothShortcuts(self.__calls))
        self.cib = wrap_helper(CibShortcuts(self.__calls))
        self.corosync = wrap_helper(CorosyncShortcuts(self.__calls))
        self.pcmk = wrap_helper(PcmkShortcuts(self.__calls))
        self.sbd = wrap_helper(SbdShortcuts(self.__calls))
        self.scsi = wrap_helper(ScsiShortcuts(self.__calls))

    def place(  # noqa: PLR0913
        self,
        command,
        *,
        name="",
        stdout="",
        stderr="",
        returncode=0,
        check_stdin=None,
        before=None,
        instead=None,
        env=None,
    ):
        # pylint: disable=too-many-arguments
        """
        Place new call to a config.

        string command -- cmdline call (e.g. "crm_mon --one-shot --as-xml")
        string name -- name of the call; it is possible to get it by the method
            "get"
        string stdout -- stdout of the call
        string stderr -- stderr of the call
        int returncode -- returncode of the call
        callable check_stdin -- callable that can check if stdin is as expected
        string before -- name of another call to insert this call before it
        string instead -- name of another call to replace it by this call
        dict env -- CommandRunner environment variables
        """
        call = RunnerCall(
            command, stdout, stderr, returncode, check_stdin, env=env
        )
        self.__calls.place(name, call, before, instead)
        return self