示例#1
0
文件: tag.py 项目: zht750808/pcs
def config(
    env: LibraryEnvironment,
    tag_filter: Sequence[str],
) -> Iterable[Dict[str, Iterable[str]]]:
    """
    Get tags specified in tag_filter or if empty, then get all the tags
    configured.

    env -- provides all for communication with externals
    tag_filter -- list of tags we want to get
    """
    tags_section: _Element = get_tags(env.get_cib(REQUIRED_CIB_VERSION))
    if tag_filter:
        tag_element_list, report_list = tag.find_tag_elements_by_ids(
            tags_section,
            tag_filter,
        )
        if env.report_processor.report_list(report_list).has_errors:
            raise LibraryError()
    else:
        tag_element_list = tag.get_list_of_tag_elements(tags_section)
    return [
        tag.tag_element_to_dict(tag_element)
        for tag_element in tag_element_list
    ]
示例#2
0
文件: test_tag.py 项目: ldming/pcs
 def test_success(self):
     element_list = lib.get_list_of_tag_elements(get_tags(self.test_tree))
     self.assertEqual(
         [lib.tag_element_to_dict(element) for element in element_list],
         [
             {"tag_id": "first_tag", "idref_list": ["idref1", "idref2"],},
             {
                 "tag_id": "second_tag",
                 "idref_list": ["ref1", "ref2", "ref3"],
             },
         ],
     )