def create_with_set(constraint_section, tag_name, options, resource_set_list): if not resource_set_list: raise LibraryError(reports.empty_resource_set_list()) element = etree.SubElement(constraint_section, tag_name) element.attrib.update(options) for resource_set_item in resource_set_list: resource_set.create(element, resource_set_item) return element
def create_with_set(constraint_section, tag_name, options, resource_set_list): if not resource_set_list: raise LibraryError( ReportItem.error(reports.messages.EmptyResourceSetList())) element = SubElement(constraint_section, tag_name) element.attrib.update(options) for resource_set_item in resource_set_list: resource_set.create(element, resource_set_item) return element
def test_resource_set_to_parent(self): constraint_element = etree.Element("constraint") resource_set.create( constraint_element, {"ids": ["A", "B"], "options": {"sequential": "true"}}, ) assert_xml_equal(etree.tostring(constraint_element).decode(), """ <constraint> <resource_set id="pcs_rsc_set_A_B" sequential="true"> <resource_ref id="A"></resource_ref> <resource_ref id="B"></resource_ref> </resource_set> </constraint> """)
def create_with_set(constraint_section, tag_name, options, resource_set_list): if not resource_set_list: raise LibraryError( ReportItem.error(reports.messages.EmptyResourceSetList())) element = SubElement(constraint_section, tag_name) element.attrib.update(options) if tag_name == "rsc_order": all_resource_ids = [] for resource_set_item in resource_set_list: all_resource_ids.extend(resource_set_item["ids"]) resource_set.is_resource_in_same_group(get_root(constraint_section), all_resource_ids) for resource_set_item in resource_set_list: resource_set.create(element, resource_set_item) return element