def Call(name, types, modules, *args): params = MergeDicts(modules) result = ModelLinkList() for type in GetCollection(types): factory = GetLinkFactory(params, type) links = CallFactoryMethod(factory, name, args) result = result.append(links) return result
def DiscoverConnect(sources, target_attributes, allowed_links, chain_attribute, chain_filters, link_type, max_length, connect_function = None, debug = None): """ sources - ModelList of elements to start from target_attributes - list of attributes (pairs) to detect target attributes allowed_links - list of attributes (pairs) to filter allowed links during traversing chain_attribute - attribute that will be used to generate path string for chain_filters the path string will be generated using values of the required attributes, separated by '-' e.g. "ib_node-ib_port-ib_port-ib_switch_element-ib_switch" chain_filters - list of regular expressions, all of them must succeed on target path string , or it will be discarded link_type - type for a new link example: DiscoverConnect(list_of_switches, [("type", "ib_switch"), ("type", "node")], [("type", "ib")], "type", ["^.*-ib_port-ib_port-[^p]*$"], "logical_ib") """ result = ModelLinkList() for source in sources: result = result.append(DiscoverConnectOne(source, target_attributes, allowed_links, chain_attribute, chain_filters, link_type, max_length, connect_function, debug)) return result