예제 #1
0
파일: alert.py 프로젝트: junaruga/pcs
def update_alert(
    lib_env,
    alert_id,
    path,
    instance_attribute_dict,
    meta_attribute_dict,
    description=None
):
    """
    Update existing alert with specified id.

    lib_env -- LibraryEnvironment
    alert_id -- id of alert to be updated
    path -- new path, if None old value will stay unchanged
    instance_attribute_dict -- dictionary of instance attributes to update
    meta_attribute_dict -- dictionary of meta attributes to update
    description -- new description, if empty string, old description will be
        deleted, if None old value will stay unchanged
    """

    alert_el = alert.update_alert(
        lib_env.get_cib(REQUIRED_CIB_VERSION),
        alert_id,
        path,
        description
    )
    alert.update_instance_attributes(alert_el, instance_attribute_dict)
    alert.update_meta_attributes(alert_el, meta_attribute_dict)

    lib_env.push_cib()
예제 #2
0
파일: alert.py 프로젝트: HideoYamauchi/pcs
def update_alert(
    lib_env,
    alert_id,
    path,
    instance_attribute_dict,
    meta_attribute_dict,
    description=None
):
    """
    Update existing alert with specified id.

    lib_env -- LibraryEnvironment
    alert_id -- id of alert to be updated
    path -- new path, if None old value will stay unchanged
    instance_attribute_dict -- dictionary of instance attributes to update
    meta_attribute_dict -- dictionary of meta attributes to update
    description -- new description, if empty string, old description will be
        deleted, if None old value will stay unchanged
    """
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)

    alert_el = alert.update_alert(cib, alert_id, path, description)
    alert.update_instance_attributes(alert_el, instance_attribute_dict)
    alert.update_meta_attributes(alert_el, meta_attribute_dict)

    lib_env.push_cib(cib)
예제 #3
0
파일: alert.py 프로젝트: vvidic/pcs
def update_alert(
    lib_env: LibraryEnvironment,
    alert_id,
    path,
    instance_attribute_dict,
    meta_attribute_dict,
    description=None,
):
    """
    Update existing alert with specified id.

    lib_env -- LibraryEnvironment
    alert_id -- id of alert to be updated
    path -- new path, if None old value will stay unchanged
    instance_attribute_dict -- dictionary of instance attributes to update
    meta_attribute_dict -- dictionary of meta attributes to update
    description -- new description, if empty string, old description will be
        deleted, if None old value will stay unchanged
    """

    cib = lib_env.get_cib()
    id_provider = IdProvider(cib)
    alert_el = alert.update_alert(cib, alert_id, path, description)
    arrange_first_instance_attributes(alert_el, instance_attribute_dict,
                                      id_provider)
    arrange_first_meta_attributes(alert_el, meta_attribute_dict, id_provider)

    lib_env.push_cib()
예제 #4
0
파일: test_alert.py 프로젝트: cwjenkins/pcs
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "alert0",
             "context_type": "alerts",
             "context_id": "",
             "id_description": "alert"
         }))
예제 #5
0
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (severities.ERROR, report_codes.ID_NOT_FOUND, {
             "id": "alert0",
             "expected_types": ["alert"],
             "context_type": "alerts",
             "context_id": "",
         }, None))
예제 #6
0
파일: test_alert.py 프로젝트: dchirikov/pcs
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (
             severities.ERROR,
             report_codes.CIB_ALERT_NOT_FOUND,
             {"alert": "alert0"}
         )
     )
예제 #7
0
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "alert0",
                 "context_type": "alerts",
                 "context_id": "",
                 "id_description": "alert"
             }
         )
     )
예제 #8
0
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (
             severities.ERROR,
             report_codes.ID_NOT_FOUND,
             {
                 "id": "alert0",
                 "expected_types": ["alert"],
                 "context_type": "alerts",
                 "context_id": "",
             },
             None
         )
     )
예제 #9
0
 def test_remove_description(self):
     assert_xml_equal(
         '<alert id="alert1" path="/path1"/>',
         etree.tostring(alert.update_alert(self.tree, "alert1", None,
                                           "")).decode())
     assert_xml_equal(
         """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert" path="/path"/>
                     <alert id="alert1" path="/path1"/>
                 </alerts>
             </configuration>
         </cib>
         """,
         etree.tostring(self.tree).decode())
예제 #10
0
 def test_update_path(self):
     assert_xml_equal(
         '<alert id="alert" path="/test/path"/>',
         etree.tostring(alert.update_alert(self.tree, "alert",
                                           "/test/path")).decode())
     assert_xml_equal(
         """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert" path="/test/path"/>
                     <alert id="alert1" path="/path1" description="nothing"/>
                 </alerts>
             </configuration>
         </cib>
         """,
         etree.tostring(self.tree).decode())
예제 #11
0
 def test_remove_path(self):
     assert_xml_equal(
         '<alert id="alert" path="/path"/>',
         etree.tostring(alert.update_alert(self.tree, "alert", "")).decode()
     )
     assert_xml_equal(
         """
         <cib>
             <configuration>
                 <alerts>
                     <alert id="alert" path="/path"/>
                     <alert id="alert1" path="/path1" description="nothing"/>
                 </alerts>
             </configuration>
         </cib>
         """,
         etree.tostring(self.tree).decode()
     )
예제 #12
0
 def test_id_not_exists(self):
     assert_raise_library_error(
         lambda: alert.update_alert(self.tree, "alert0", "/test"),
         (severities.ERROR, report_codes.CIB_ALERT_NOT_FOUND, {
             "alert": "alert0"
         }))