Commit e5a05ea8 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

PathComp component- Frontend:

- Merged logics to manage composition of config rules
parent d2bc0964
Loading
Loading
Loading
Loading
+2 −15
Original line number Diff line number Diff line
@@ -184,23 +184,10 @@ def compose_device_config_rules(

                device_endpoint_keys = set(itertools.product(device_keys, endpoint_keys))
                if len(device_endpoint_keys.intersection(endpoints_traversed)) == 0: continue
                subservice_config_rules.append(config_rule)

            match = RE_ENDPOINT_VLAN_SETTINGS.match(config_rule.custom.resource_key)
            if match is not None:
                device_uuid_or_name = match.group(1)
                device_name_or_uuid = device_name_mapping[device_uuid_or_name]
                device_keys = {device_uuid_or_name, device_name_or_uuid}

                endpoint_uuid_or_name = match.group(2)
                endpoint_name_or_uuid_1 = endpoint_name_mapping[(device_uuid_or_name, endpoint_uuid_or_name)]
                endpoint_name_or_uuid_2 = endpoint_name_mapping[(device_name_or_uuid, endpoint_uuid_or_name)]
                endpoint_keys = {endpoint_uuid_or_name, endpoint_name_or_uuid_1, endpoint_name_or_uuid_2}
                # TODO: check if vlan needs to be removed from config_rule
                #config_rule.custom.resource_key = re.sub('\/vlan\[[^\]]+\]', '', config_rule.custom.resource_key)

                device_endpoint_keys = set(itertools.product(device_keys, endpoint_keys))
                if len(device_endpoint_keys.intersection(endpoints_traversed)) == 0: continue
                # ! check later: vlan removed from config_rule
                config_rule.custom.resource_key = re.sub('\/vlan\[[^\]]+\]', '', config_rule.custom.resource_key)
                subservice_config_rules.append(config_rule)
        else:
            continue