def assert_wait_fail(self, command, cib_resources_xml): wait_error_message = outdent( """\ Pending actions: Action 39: stonith-vm-rhel72-1-reboot on vm-rhel72-1 Error performing operation: Timer expired """ ) runner.set_runs(fixture_pre_timeout_calls(cib_resources_xml) + [ Call( "crm_resource --wait --timeout=10", stderr=wait_error_message, returncode=62, ), ]) assert_raise_library_error( command, ( severities.ERROR, report_codes.WAIT_FOR_IDLE_TIMED_OUT, { "reason": wait_error_message.strip(), }, None ) ) runner.assert_everything_launched()
def fixture_agent_load_calls(): return [ Call( "crm_resource --show-metadata ocf:heartbeat:Dummy", open(rc("resource_agent_ocf_heartbeat_dummy.xml")).read() ), ]
def call_wait(timeout, retval=0, stderr=""): return [ Call( "crm_resource --wait --timeout={0}".format(timeout), stderr=stderr, returncode=retval ), ]
def fixture_pre_timeout_calls(cib_resources_xml): return ( fixture_agent_load_calls() + [ Call("crm_resource -?", "--wait"), ] + fixture_cib_calls(cib_resources_xml) )
def fixture_cib_calls(cib_resources_xml): cib_xml = open(rc("cib-empty.xml")).read() cib = etree.fromstring(cib_xml) resources_section = cib.find(".//resources") for child in etree.fromstring(cib_resources_xml): resources_section.append(child) return [ Call("cibadmin --local --query", cib_xml), Call( "cibadmin --replace --verbose --xml-pipe --scope configuration", check_stdin=Call.create_check_stdin_xml(etree.tostring(cib)) ), ]
def call_wait_supported(): return [ Call("crm_resource -?", "--wait"), ]
def call_status(status): return [ Call("/usr/sbin/crm_mon --one-shot --as-xml --inactive", status), ]
def call_cib_upgrade(): return [ Call("cibadmin --upgrade --force"), ]
def call_cib_push(cib): return [ Call("cibadmin --replace --verbose --xml-pipe --scope configuration", check_stdin=Call.create_check_stdin_xml(cib)), ]
def call_cib_load(cib): return [ Call("cibadmin --local --query", cib), ]