Ejemplo n.º 1
0
 def test_find_correct_tag(self):
     tree = etree.XML("""
         <root>
             <rsc_set id="A" />
             <primitive id="A" />
         </root>
     """)
     element = find_by_id(tree, "A")
     self.assertEqual(element.tag, "primitive")
Ejemplo n.º 2
0
 def test_find_correct_tag(self):
     tree = etree.XML("""
         <root>
             <rsc_set id="A" />
             <primitive id="A" />
         </root>
     """)
     element = find_by_id(tree, "A")
     self.assertEqual(element.tag, "primitive")
Ejemplo n.º 3
0
def find_valid_resource_id(
    report_processor, cib, can_repair_to_clone, in_clone_allowed, id
):
    resource_element = resource.find_by_id(cib, id)

    if(resource_element is None):
        raise LibraryError(reports.resource_does_not_exist(id))

    if resource_element.tag in resource.TAGS_CLONE:
        return resource_element.attrib["id"]

    clone = find_parent(resource_element, resource.TAGS_CLONE)
    if clone is None:
        return resource_element.attrib["id"]

    if can_repair_to_clone:
        #this is workaround for web ui, console should not use it, so we do not
        #warn about it
        return clone.attrib["id"]

    if in_clone_allowed:
        report_processor.process(
            reports.resource_for_constraint_is_multiinstance(
                resource_element.attrib["id"],
                clone.tag,
                clone.attrib["id"],
                ReportItemSeverity.WARNING,
            )
        )
        return resource_element.attrib["id"]

    raise LibraryError(reports.resource_for_constraint_is_multiinstance(
        resource_element.attrib["id"],
        clone.tag,
        clone.attrib["id"],
        ReportItemSeverity.ERROR,
        #repair to clone is workaround for web ui, so we put only information
        #about one forceable possibility
        forceable=report_codes.FORCE_CONSTRAINT_MULTIINSTANCE_RESOURCE
    ))
Ejemplo n.º 4
0
def find_valid_resource_id(report_processor, cib, can_repair_to_clone,
                           in_clone_allowed, id):
    resource_element = resource.find_by_id(cib, id)

    if (resource_element is None):
        raise LibraryError(reports.resource_does_not_exist(id))

    if resource_element.tag in resource.TAGS_CLONE:
        return resource_element.attrib["id"]

    clone = find_parent(resource_element, resource.TAGS_CLONE)
    if clone is None:
        return resource_element.attrib["id"]

    if can_repair_to_clone:
        #this is workaround for web ui, console should not use it, so we do not
        #warn about it
        return clone.attrib["id"]

    if in_clone_allowed:
        report_processor.process(
            reports.resource_for_constraint_is_multiinstance(
                resource_element.attrib["id"],
                clone.tag,
                clone.attrib["id"],
                ReportItemSeverity.WARNING,
            ))
        return resource_element.attrib["id"]

    raise LibraryError(
        reports.resource_for_constraint_is_multiinstance(
            resource_element.attrib["id"],
            clone.tag,
            clone.attrib["id"],
            ReportItemSeverity.ERROR,
            #repair to clone is workaround for web ui, so we put only information
            #about one forceable possibility
            forceable=report_codes.FORCE_CONSTRAINT_MULTIINSTANCE_RESOURCE))