def find_valid_resource_id(report_processor, cib, in_clone_allowed, _id): parent_tags = resource.clone.ALL_TAGS + [resource.bundle.TAG] resource_element = find_element_by_tag_and_id( parent_tags + [resource.primitive.TAG, resource.group.TAG], cib, _id, ) if resource_element.tag in parent_tags: return resource_element.attrib["id"] clone = find_parent(resource_element, parent_tags) if clone is None: return resource_element.attrib["id"] if in_clone_allowed: report_processor.process( reports.resource_for_constraint_is_multiinstance( resource_element.attrib["id"], "clone" if clone.tag == "master" else 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" if clone.tag == "master" else 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 ))
def find_valid_resource_id(report_processor, cib, in_clone_allowed, id): parent_tags = resource.clone.ALL_TAGS + [resource.bundle.TAG] resource_element = find_element_by_tag_and_id( parent_tags + [resource.primitive.TAG, resource.group.TAG], cib, id, ) if resource_element.tag in parent_tags: return resource_element.attrib["id"] clone = find_parent(resource_element, parent_tags) if clone is None: return resource_element.attrib["id"] if in_clone_allowed: report_processor.process( reports.resource_for_constraint_is_multiinstance( resource_element.attrib["id"], "clone" if clone.tag == "master" else 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" if clone.tag == "master" else 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))
def find_valid_resource_id( report_processor, cib, can_repair_to_clone, in_clone_allowed, id ): resource_element = find_element_by_tag_and_id( resource.clone.ALL_TAGS + [resource.primitive.TAG, resource.group.TAG], cib, id, id_description="resource" ) if resource_element.tag in resource.clone.ALL_TAGS: return resource_element.attrib["id"] clone = find_parent(resource_element, resource.clone.ALL_TAGS) 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 ))
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))