示例#1
0
文件: alert.py 项目: rriifftt/pcs
def update_recipient(lib_env,
                     recipient_id,
                     instance_attribute_dict,
                     meta_attribute_dict,
                     recipient_value=None,
                     description=None,
                     allow_same_value=False):
    """
    Update existing recipient.

    lib_env -- LibraryEnvironment
    recipient_id -- id of recipient to be updated
    instance_attribute_dict -- dictionary of instance attributes to update
    meta_attribute_dict -- dictionary of meta attributes to update
    recipient_value -- new recipient value, if None old value will stay
        unchanged
    description -- new description, if empty string, old description will be
        deleted, if None old value will stay unchanged
    allow_same_value -- if True unique recipient value is not required
    """
    if not recipient_value and recipient_value is not None:
        raise LibraryError(
            reports.cib_alert_recipient_invalid_value(recipient_value))
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    recipient = alert.update_recipient(lib_env.report_processor,
                                       cib,
                                       recipient_id,
                                       recipient_value=recipient_value,
                                       description=description,
                                       allow_same_value=allow_same_value)
    alert.update_instance_attributes(recipient, instance_attribute_dict)
    alert.update_meta_attributes(recipient, meta_attribute_dict)

    lib_env.push_cib(cib)
示例#2
0
文件: alert.py 项目: tomjelinek/pcs
def update_recipient(
    lib_env,
    recipient_id,
    instance_attribute_dict,
    meta_attribute_dict,
    recipient_value=None,
    description=None,
    allow_same_value=False
):
    """
    Update existing recipient.

    lib_env -- LibraryEnvironment
    recipient_id -- id of recipient to be updated
    instance_attribute_dict -- dictionary of instance attributes to update
    meta_attribute_dict -- dictionary of meta attributes to update
    recipient_value -- new recipient value, if None old value will stay
        unchanged
    description -- new description, if empty string, old description will be
        deleted, if None old value will stay unchanged
    allow_same_value -- if True unique recipient value is not required
    """
    if not recipient_value and recipient_value is not None:
        raise LibraryError(
            reports.cib_alert_recipient_invalid_value(recipient_value)
        )
    cib = lib_env.get_cib(REQUIRED_CIB_VERSION)
    id_provider = IdProvider(cib)
    recipient = alert.update_recipient(
        lib_env.report_processor,
        cib,
        recipient_id,
        recipient_value=recipient_value,
        description=description,
        allow_same_value=allow_same_value
    )
    arrange_first_instance_attributes(
        recipient, instance_attribute_dict, id_provider
    )
    arrange_first_meta_attributes(
        recipient, meta_attribute_dict, id_provider
    )

    lib_env.push_cib()