def remove_alert(lib_env, alert_id): """ Remove alert with specified id. lib_env -- LibraryEnvironment alert_id -- id of alert which should be removed """ cib = lib_env.get_cib(REQUIRED_CIB_VERSION) alert.remove_alert(cib, alert_id) lib_env.push_cib(cib)
def test_success(self): alert.remove_alert(self.tree, "alert") assert_xml_equal( """ <cib> <configuration> <alerts> <alert id="alert-1" path="/next"/> </alerts> </configuration> </cib> """, etree.tostring(self.tree).decode())
def test_success(self): alert.remove_alert(self.tree, "alert") assert_xml_equal( """ <cib> <configuration> <alerts> <alert id="alert-1" path="/next"/> </alerts> </configuration> </cib> """, etree.tostring(self.tree).decode() )
def remove_alert(lib_env, alert_id_list): """ Remove alerts with specified ids. lib_env -- LibraryEnvironment alert_id_list -- list of alerts ids which should be removed """ cib = lib_env.get_cib(REQUIRED_CIB_VERSION) report_list = [] for alert_id in alert_id_list: try: alert.remove_alert(cib, alert_id) except LibraryError as e: report_list += e.args lib_env.report_processor.process_list(report_list) lib_env.push_cib(cib)
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), (severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "not-existing-id", "context_type": "alerts", "context_id": "", "id_description": "alert" }))
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), (severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "not-existing-id", "expected_types": ["alert"], "context_type": "alerts", "context_id": "", }, None))
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), ( severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {"alert": "not-existing-id"} ) )
def remove_alert(lib_env: LibraryEnvironment, alert_id_list): """ Remove alerts with specified ids. lib_env -- LibraryEnvironment alert_id_list -- list of alerts ids which should be removed """ cib = lib_env.get_cib() report_list: ReportItemList = [] for alert_id in alert_id_list: try: alert.remove_alert(cib, alert_id) except LibraryError as e: report_list += e.args if lib_env.report_processor.report_list(report_list).has_errors: raise LibraryError() lib_env.push_cib()
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), ( severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "not-existing-id", "context_type": "alerts", "context_id": "", "id_description": "alert" } ) )
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), ( severities.ERROR, report_codes.ID_NOT_FOUND, { "id": "not-existing-id", "expected_types": ["alert"], "context_type": "alerts", "context_id": "", }, None ) )
def test_not_existing_id(self): assert_raise_library_error( lambda: alert.remove_alert(self.tree, "not-existing-id"), (severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, { "alert": "not-existing-id" }))