Example #1
0
File: alert.py Project: idevat/pcs
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)
Example #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)
Example #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())
Example #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()
     )
Example #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)
Example #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)
Example #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"
         }))
Example #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))
Example #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"}
         )
     )
Example #10
0
File: alert.py Project: vvidic/pcs
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()
Example #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"
             }
         )
     )
Example #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
         )
     )
Example #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"
         }))