def _get_agent_facade( report_processor: reports.ReportProcessor, factory: ResourceAgentFacadeFactory, name: str, allow_absent_agent: bool, ) -> ResourceAgentFacade: try: if ":" in name: raise InvalidResourceAgentName(name) full_name = ResourceAgentName("stonith", None, name) return factory.facade_from_parsed_name(full_name) except (UnableToGetAgentMetadata, UnsupportedOcfVersion) as e: if allow_absent_agent: report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.warning(), is_stonith=True)) return factory.void_facade_from_parsed_name(full_name) report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.error(reports.codes.FORCE), is_stonith=True, )) raise LibraryError() from e except ResourceAgentError as e: report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.error(), is_stonith=True)) raise LibraryError() from e
def _get_agent_facade( report_processor: reports.ReportProcessor, factory: ResourceAgentFacadeFactory, allow_absent_agent: bool, name: ResourceAgentName, ) -> ResourceAgentFacade: try: return factory.facade_from_parsed_name(name) except UnableToGetAgentMetadata as e: if allow_absent_agent: report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.warning() ) ) return factory.void_facade_from_parsed_name(name) report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.error(reports.codes.FORCE) ) ) raise LibraryError() from e except ResourceAgentError as e: report_processor.report( resource_agent_error_to_report_item( e, reports.ReportItemSeverity.error() ) ) raise LibraryError() from e