Example #1
0
    def get_rule_in_effect_status(
        self,
        rule_id,
        returncode=0,
        name="runner.pcmk.get_rule_in_effect_status",
        cib_load_name="runner.cib.load",
    ):
        """
        Create a call for running a tool to get rule expired status

        string rule_id -- id of the rule to be checked
        int returncode -- result of the check
        sting name -- key of the call
        string cib_load_name -- key of a call from whose stdout the cib is taken
        """
        cib_xml = self.__calls.get(cib_load_name).stdout
        self.__calls.place(
            name,
            RunnerCall(
                ["crm_rule", "--check", "--rule", rule_id, "--xml-text", "-"],
                check_stdin=CheckStdinEqualXml(cib_xml),
                stdout="",
                stderr="",
                returncode=returncode,
            ),
        )
Example #2
0
    def push_independent(
        self, cib, name="runner.cib.push_independent", instead=None,
    ):
        """
        Create call for pushing cib.
        Cib is specified as an argument.

        string name -- key of the call
        string cib -- whole cib to push
        string instead -- key of call instead of which this new call is to be
            placed
        """
        self.__calls.place(
            name,
            RunnerCall(
                [
                    "cibadmin",
                    "--replace",
                    "--verbose",
                    "--xml-pipe",
                    "--scope",
                    "configuration",
                ],
                check_stdin=CheckStdinEqualXml(cib),
            ),
            instead=instead,
        )
Example #3
0
 def push_diff(
     self,
     name="runner.cib.push_diff",
     cib_diff="resulting diff",
     stdout="",
     stderr="",
     returncode=0,
     env=None,
 ):
     """
     Create a call for pushing a diff of CIBs
     string name -- key of the call
     string cib_diff -- the diff of CIBs
     dict env -- CommandRunner environment variables
     """
     self.__calls.place(
         name,
         RunnerCall(
             ["cibadmin", "--patch", "--verbose", "--xml-pipe"],
             check_stdin=CheckStdinEqualXml(cib_diff),
             stdout=stdout,
             stderr=stderr,
             returncode=returncode,
             env=env,
         ),
     )
Example #4
0
    def simulate_cib(
        self,
        new_cib_filepath,
        transitions_filepath,
        cib_modifiers=None,
        cib_load_name="runner.cib.load",
        stdout="",
        stderr="",
        returncode=0,
        name="runner.pcmk.simulate_cib",
        **modifier_shortcuts,
    ):
        """
        Create a call for simulating effects of cib changes

        string new_cib_filepath -- a temp file for storing a new cib
        string transitions_filepath -- a temp file for storing transitions
        list of callable modifiers -- every callable takes etree.Element and
            returns new etree.Element with desired modification
        string cib_load_name -- key of a call from whose stdout the cib is taken
        string stdout -- pacemaker's stdout
        string stderr -- pacemaker's stderr
        int returncode -- pacemaker's returncode
        string name -- key of the call
        dict modifier_shortcuts -- a new modifier is generated from each
            modifier shortcut.
            As key there can be keys of MODIFIER_GENERATORS.
            Value is passed into appropriate generator from MODIFIER_GENERATORS.
            For details see pcs_test.tools.fixture_cib (mainly the variable
            MODIFIER_GENERATORS - please refer it when you are adding params
            here)
        """
        cib_xml = modify_cib(
            self.__calls.get(cib_load_name).stdout,
            cib_modifiers,
            **modifier_shortcuts,
        )
        cmd = [
            "crm_simulate",
            "--simulate",
            "--save-output",
            new_cib_filepath,
            "--save-graph",
            transitions_filepath,
            "--xml-pipe",
        ]
        self.__calls.place(
            name,
            RunnerCall(
                " ".join(cmd),
                stdout=stdout,
                stderr=stderr,
                returncode=returncode,
                check_stdin=CheckStdinEqualXml(cib_xml),
            ),
        )
Example #5
0
    def push(
        self,
        modifiers=None,
        name="runner.cib.push",
        load_key="runner.cib.load",
        instead=None,
        stderr="",
        returncode=0,
        **modifier_shortcuts,
    ):
        """
        Create call for pushing cib.
        Cib is taken from the load call by default.

        string name -- key of the call
        list of callable modifiers -- every callable takes etree.Element and
            returns new etree.Element with desired modification.
        string load_key -- key of a call from which stdout can be cib taken
        string instead -- key of call instead of which this new call is to be
            placed
        dict modifier_shortcuts -- a new modifier is generated from each
            modifier shortcut.
            As key there can be keys of MODIFIER_GENERATORS.
            Value is passed into appropriate generator from MODIFIER_GENERATORS.
            For details see pcs_test.tools.fixture_cib (mainly the variable
            MODIFIER_GENERATORS - please refer it when you are adding params
            here)
        """
        cib = modify_cib(
            self.__calls.get(load_key).stdout, modifiers, **modifier_shortcuts
        )
        self.__calls.place(
            name,
            RunnerCall(
                [
                    "cibadmin",
                    "--replace",
                    "--verbose",
                    "--xml-pipe",
                    "--scope",
                    "configuration",
                ],
                stderr=stderr,
                returncode=returncode,
                check_stdin=CheckStdinEqualXml(cib),
            ),
            instead=instead,
        )
Example #6
0
 def push_diff(self,
               name="runner.cib.push_diff",
               cib_diff="resulting diff",
               stdout="",
               stderr="",
               returncode=0):
     """
     Create a call for pushing a diff of CIBs
     string name -- key of the call
     string cib_diff -- the diff of CIBs
     """
     self.__calls.place(
         name,
         RunnerCall(
             "cibadmin --patch --verbose --xml-pipe",
             check_stdin=CheckStdinEqualXml(cib_diff),
             stdout=stdout,
             stderr=stderr,
             returncode=returncode,
         ),
     )