Esempio n. 1
0
File: alert.py Progetto: idevat/pcs
def remove_recipient(lib_env, recipient_id):
    """
    Remove existing recipient.

    lib_env -- LibraryEnvironment
    recipient_id -- if of recipient to be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    alert.remove_recipient(cib, recipient_id)
    lib_env.push_cib(cib)
Esempio n. 2
0
def remove_recipient(lib_env, recipient_id):
    """
    Remove existing recipient.

    lib_env -- LibraryEnvironment
    recipient_id -- if of recipient to be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    alert.remove_recipient(cib, recipient_id)
    lib_env.push_cib(cib)
Esempio n. 3
0
 def test_success(self):
     alert.remove_recipient(self.tree, "alert-recipient-2")
     assert_xml_equal(
         """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert" path="/path">
                         <recipient id="alert-recipient" value="test_val"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """,
         etree.tostring(self.tree).decode())
Esempio n. 4
0
def remove_recipient(lib_env, recipient_id_list):
    """
    Remove specified recipients.

    lib_env -- LibraryEnvironment
    recipient_id_list -- list of recipients ids to be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    report_list = []
    for recipient_id in recipient_id_list:
        try:
            alert.remove_recipient(cib, recipient_id)
        except LibraryError as e:
            report_list += e.args
    lib_env.report_processor.process_list(report_list)
    lib_env.push_cib()
Esempio n. 5
0
 def test_recipient_not_exists(self):
     assert_raise_library_error(
         lambda: alert.remove_recipient(self.tree, "recipient"),
         (severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient",
             "id_description": "Recipient"
         }))
Esempio n. 6
0
 def test_success(self):
     alert.remove_recipient(self.tree, "alert-recipient-2")
     assert_xml_equal(
         """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert" path="/path">
                         <recipient id="alert-recipient" value="test_val"/>
                     </alert>
                 </alerts>
             </configuration>
         </cib>
         """,
         etree.tostring(self.tree).decode()
     )
Esempio n. 7
0
def remove_recipient(lib_env, recipient_id_list):
    """
    Remove specified recipients.

    lib_env -- LibraryEnvironment
    recipient_id_list -- list of recipients ids to be removed
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    report_list = []
    for recipient_id in recipient_id_list:
        try:
            alert.remove_recipient(cib, recipient_id)
        except LibraryError as e:
            report_list += e.args
    lib_env.report_processor.process_list(report_list)
    lib_env.push_cib(cib)
Esempio n. 8
0
File: alert.py Progetto: vvidic/pcs
def remove_recipient(lib_env: LibraryEnvironment, recipient_id_list):
    """
    Remove specified recipients.

    lib_env -- LibraryEnvironment
    recipient_id_list -- list of recipients ids to be removed
    """
    cib = lib_env.get_cib()
    report_list: ReportItemList = []
    for recipient_id in recipient_id_list:
        try:
            alert.remove_recipient(cib, recipient_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()
Esempio n. 9
0
 def test_recipient_not_exists(self):
     assert_raise_library_error(
         lambda: alert.remove_recipient(self.tree, "recipient"),
         (severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "recipient",
             "expected_types": ["recipient"],
             "context_type": "alerts",
             "context_id": "",
         }, None))
Esempio n. 10
0
 def test_recipient_not_exists(self):
     assert_raise_library_error(
         lambda: alert.remove_recipient(self.tree, "recipient"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "recipient",
                 "id_description": "Recipient"
             }
         )
     )
Esempio n. 11
0
 def test_recipient_not_exists(self):
     assert_raise_library_error(
         lambda: alert.remove_recipient(self.tree, "recipient"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "recipient",
                 "expected_types": ["recipient"],
                 "context_type": "alerts",
                 "context_id": "",
             },
             None
         )
     )