Beispiel #1
0
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)
Beispiel #2
0
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)
Beispiel #3
0
 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())
Beispiel #4
0
 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()
     )
Beispiel #5
0
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)
Beispiel #6
0
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)
Beispiel #7
0
 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"
         }))
Beispiel #8
0
 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))
Beispiel #9
0
 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"}
         )
     )
Beispiel #10
0
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()
Beispiel #11
0
 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"
             }
         )
     )
Beispiel #12
0
 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
         )
     )
Beispiel #13
0
 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"
         }))