def push_cib(self, modifiers=None, name="env.push_cib", load_key="runner.cib.load", wait=False, exception=None, instead=None, **modifier_shortcuts): """ Create call for pushing cib. 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|False wait -- wait for pacemaker idle Exception|None exception -- exception that should raise env.push_cib 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_xml = modify_cib( self.__calls.get(load_key).stdout, modifiers, **modifier_shortcuts) self.__calls.place(name, PushCibCall(cib_xml, wait=wait, exception=exception), instead=instead)
def push_cib( self, modifiers=None, name="env.push_cib", load_key="runner.cib.load", wait=False, exception=None, instead=None, **modifier_shortcuts ): """ Create call for pushing cib. 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|False wait -- wait for pacemaker idle Exception|None exception -- exception that should raise env.push_cib 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_xml = modify_cib( self.__calls.get(load_key).stdout, modifiers, **modifier_shortcuts ) self.__calls.place( name, PushCibCall(cib_xml, wait=wait, exception=exception), instead=instead )
def load( self, modifiers=None, name="runner.cib.load", filename=None, before=None, returncode=0, stderr=None, instead=None, env=None, **modifier_shortcuts, ): """ Create call for loading cib. string name -- key of the call list of callable modifiers -- every callable takes etree.Element and returns new etree.Element with desired modification. string filename -- points to file with cib in the content string before -- key of call before which this new call is to be placed int returncode string stderr string instead -- key of call instead of which this new call is to be placed dict env -- CommandRunner environment variables 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) """ # pylint: disable=too-many-arguments if (returncode != 0 or stderr is not None) and ( modifiers is not None or filename is not None or modifier_shortcuts ): raise AssertionError( "Do not combine parameters 'returncode' and 'stderr' with" " parameters 'modifiers', 'filename' and 'modifier_shortcuts'" ) command = ["cibadmin", "--local", "--query"] if returncode != 0: call = RunnerCall( command, stderr=stderr, returncode=returncode, env=env ) else: with open( rc(filename if filename else self.cib_filename) ) as cib_file: cib = modify_cib( cib_file.read(), modifiers, **modifier_shortcuts ) call = RunnerCall(command, stdout=cib, env=env) self.__calls.place(name, call, before=before, instead=instead)
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), ), )
def load( self, modifiers=None, name="runner.cib.load", filename=None, before=None, returncode=0, stderr=None, instead=None, **modifier_shortcuts ): """ Create call for loading cib. string name -- key of the call list of callable modifiers -- every callable takes etree.Element and returns new etree.Element with desired modification. string filename -- points to file with cib in the content string before -- key of call before which this new call is to be placed int returncode string stderr 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) """ if(returncode != 0 or stderr is not None) and ( modifiers is not None or filename is not None or modifier_shortcuts ): raise AssertionError( "Do not combine parameters 'returncode' and 'stderr' with" " parameters 'modifiers', 'filename' and 'modifier_shortcuts'" ) command = "cibadmin --local --query" if returncode != 0: call = RunnerCall(command, stderr=stderr, returncode=returncode) else: cib = modify_cib( open(rc(filename if filename else self.cib_filename)).read(), modifiers, **modifier_shortcuts ) call = RunnerCall(command, stdout=cib) self.__calls.place(name, call, before=before, instead=instead)
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, )
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=create_check_stdin_xml(cib), ), instead=instead, )