def create_role(tree, role_id, description=""): """ role_id id of desired role description role description """ check_new_id_applicable(tree, "ACL role", role_id) role = etree.SubElement(get_acls(tree), "acl_role", id=role_id) if description: role.set("description", description)
def create_group(acl_section, group_id): """ Creates new acl_group element with specified id. Raises LibraryError if tree contains element with id group_id. acl_section -- etree node group_id -- id of new group """ check_new_id_applicable(acl_section, "ACL group", group_id) return etree.SubElement(acl_section, TAG_GROUP, id=group_id)
def create_group(tree, group_id): """ Creates new acl_group element with specified id. Raises LibraryError if tree contains element with id group_id. tree -- etree node group_id -- id of new group """ check_new_id_applicable(tree, "ACL group", group_id) return etree.SubElement(get_acls(tree), "acl_group", id=group_id)
def create_role(acl_section, role_id, description=None): """ Create new role element and add it to cib. Returns newly created role element. role_id id of desired role description role description """ check_new_id_applicable(acl_section, "ACL role", role_id) role = etree.SubElement(acl_section, TAG_ROLE, id=role_id) if description: role.set("description", description) return role
def create_alert(tree, alert_id, path, description=""): """ Create new alert element. Returns newly created element. Raises LibraryError if element with specified id already exists. tree -- cib etree node alert_id -- id of new alert, it will be generated if it is None path -- path to script description -- description """ if alert_id: check_new_id_applicable(tree, "alert-id", alert_id) else: alert_id = find_unique_id(tree, "alert") alert = etree.SubElement(get_alerts(tree), "alert", id=alert_id, path=path) if description: alert.set("description", description) return alert