Loading src/pathcomp/frontend/service/algorithms/_Algorithm.py +25 −23 Original line number Diff line number Diff line Loading @@ -48,8 +48,10 @@ class _Algorithm: self.device_list : List[Dict] = list() self.device_dict : Dict[str, Tuple[Dict, Device]] = dict() self.device_uuid_mapping : Dict[str, str] = dict() self.device_name_mapping : Dict[str, str] = dict() self.endpoint_dict : Dict[str, Dict[str, Tuple[Dict, EndPointId]]] = dict() self.endpoint_uuid_mapping : Dict[Tuple[str, str], str] = dict() self.endpoint_name_mapping : Dict[Tuple[str, str], str] = dict() self.link_list : List[Dict] = list() self.link_dict : Dict[str, Tuple[Dict, Link]] = dict() Loading @@ -68,8 +70,10 @@ class _Algorithm: _device_uuid = grpc_device.device_id.device_uuid.uuid _device_name = grpc_device.name self.device_name_mapping[_device_name] = _device_uuid self.device_name_mapping[_device_uuid] = _device_uuid self.device_uuid_mapping[_device_name] = _device_uuid self.device_uuid_mapping[_device_uuid] = _device_uuid self.device_name_mapping[_device_name] = _device_name self.device_name_mapping[_device_uuid] = _device_name device_endpoint_dict : Dict[str, Tuple[Dict, EndPointId]] = dict() for json_endpoint,grpc_endpoint in zip(json_device['device_endpoints'], grpc_device.device_endpoints): Loading @@ -79,10 +83,14 @@ class _Algorithm: _endpoint_uuid = grpc_endpoint.endpoint_id.endpoint_uuid.uuid _endpoint_name = grpc_endpoint.name self.endpoint_name_mapping[(_device_uuid, _endpoint_name)] = _endpoint_uuid self.endpoint_name_mapping[(_device_name, _endpoint_name)] = _endpoint_uuid self.endpoint_name_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_uuid self.endpoint_name_mapping[(_device_name, _endpoint_uuid)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_uuid, _endpoint_name)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_name, _endpoint_name)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_name, _endpoint_uuid)] = _endpoint_uuid self.endpoint_name_mapping[(_device_uuid, _endpoint_name)] = _endpoint_name self.endpoint_name_mapping[(_device_name, _endpoint_name)] = _endpoint_name self.endpoint_name_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_name self.endpoint_name_mapping[(_device_name, _endpoint_uuid)] = _endpoint_name self.endpoint_dict[device_uuid] = device_endpoint_dict Loading Loading @@ -195,31 +203,27 @@ class _Algorithm: compose_device_config_rules( config_rules, service.service_config.config_rules, path_hops, self.device_name_mapping, self.endpoint_name_mapping) self.device_uuid_mapping, self.endpoint_uuid_mapping) for path_hop in path_hops: path_hop_device_id = path_hop['device'] path_hop_ingress_ep_id = path_hop['ingress_ep'] path_hop_egress_ep_id = path_hop['egress_ep'] path_hop_device_uuid = self.device_name_mapping [path_hop_device_id] path_hop_ingress_ep_uuid = self.endpoint_name_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_uuid = self.endpoint_name_mapping[(path_hop_device_id, path_hop_egress_ep_id )] path_hop_device_uuid = self.device_uuid_mapping [path_hop_device_id] path_hop_ingress_ep_uuid = self.endpoint_uuid_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_uuid = self.endpoint_uuid_mapping[(path_hop_device_id, path_hop_egress_ep_id )] path_hop_ingress_ep_name = self.endpoint_name_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_name = self.endpoint_name_mapping[(path_hop_device_id, path_hop_egress_ep_id )] target_endpoint_ids = set() target_endpoint_ids.add(path_hop_ingress_ep_uuid) target_endpoint_ids.add(path_hop_egress_ep_uuid) target_endpoint_ids.add(path_hop_ingress_ep_name) target_endpoint_ids.add(path_hop_egress_ep_name) path_hop_device = self.device_dict[path_hop_device_uuid][1] path_hop_ingress_ep = self.endpoint_dict[path_hop_device_uuid][path_hop_ingress_ep_uuid][1] path_hop_egress_ep = self.endpoint_dict[path_hop_device_uuid][path_hop_egress_ep_uuid ][1] path_hop_device_name = path_hop_device.name path_hop_ingress_ep_name = path_hop_ingress_ep.name path_hop_egress_ep_name = path_hop_egress_ep.name target_endpoint_ids.add(path_hop_ingress_ep_name) target_endpoint_ids.add(path_hop_egress_ep_name) RE_ENDPOINT_SETTINGS = re.compile(r'\/endpoints\/endpoint\[([^\]]+)\](\/settings)?') for config_rule in path_hop_device.device_config.config_rules: Loading @@ -232,9 +236,7 @@ class _Algorithm: endpoint_id = ep_match.group(1) if endpoint_id not in target_endpoint_ids: continue endpoint_uuid = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] endpoint = self.endpoint_dict[path_hop_device_uuid][endpoint_uuid][1] endpoint_name = endpoint.name endpoint_name = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] resource_key = '/device[{:s}]/endpoint[{:s}]/settings'.format( path_hop_device_name, endpoint_name ) Loading Loading @@ -293,7 +295,7 @@ class _Algorithm: path_hops = eropath_to_hops(service_path_ero['devices'], self.endpoint_to_link_dict) json_generated_config_rules = generate_neighbor_endpoint_config_rules( json_orig_config_rules, path_hops, self.device_name_mapping, self.endpoint_name_mapping json_orig_config_rules, path_hops, self.device_uuid_mapping, self.endpoint_uuid_mapping ) json_extended_config_rules = list() json_extended_config_rules.extend(json_orig_config_rules) Loading Loading
src/pathcomp/frontend/service/algorithms/_Algorithm.py +25 −23 Original line number Diff line number Diff line Loading @@ -48,8 +48,10 @@ class _Algorithm: self.device_list : List[Dict] = list() self.device_dict : Dict[str, Tuple[Dict, Device]] = dict() self.device_uuid_mapping : Dict[str, str] = dict() self.device_name_mapping : Dict[str, str] = dict() self.endpoint_dict : Dict[str, Dict[str, Tuple[Dict, EndPointId]]] = dict() self.endpoint_uuid_mapping : Dict[Tuple[str, str], str] = dict() self.endpoint_name_mapping : Dict[Tuple[str, str], str] = dict() self.link_list : List[Dict] = list() self.link_dict : Dict[str, Tuple[Dict, Link]] = dict() Loading @@ -68,8 +70,10 @@ class _Algorithm: _device_uuid = grpc_device.device_id.device_uuid.uuid _device_name = grpc_device.name self.device_name_mapping[_device_name] = _device_uuid self.device_name_mapping[_device_uuid] = _device_uuid self.device_uuid_mapping[_device_name] = _device_uuid self.device_uuid_mapping[_device_uuid] = _device_uuid self.device_name_mapping[_device_name] = _device_name self.device_name_mapping[_device_uuid] = _device_name device_endpoint_dict : Dict[str, Tuple[Dict, EndPointId]] = dict() for json_endpoint,grpc_endpoint in zip(json_device['device_endpoints'], grpc_device.device_endpoints): Loading @@ -79,10 +83,14 @@ class _Algorithm: _endpoint_uuid = grpc_endpoint.endpoint_id.endpoint_uuid.uuid _endpoint_name = grpc_endpoint.name self.endpoint_name_mapping[(_device_uuid, _endpoint_name)] = _endpoint_uuid self.endpoint_name_mapping[(_device_name, _endpoint_name)] = _endpoint_uuid self.endpoint_name_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_uuid self.endpoint_name_mapping[(_device_name, _endpoint_uuid)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_uuid, _endpoint_name)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_name, _endpoint_name)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_uuid self.endpoint_uuid_mapping[(_device_name, _endpoint_uuid)] = _endpoint_uuid self.endpoint_name_mapping[(_device_uuid, _endpoint_name)] = _endpoint_name self.endpoint_name_mapping[(_device_name, _endpoint_name)] = _endpoint_name self.endpoint_name_mapping[(_device_uuid, _endpoint_uuid)] = _endpoint_name self.endpoint_name_mapping[(_device_name, _endpoint_uuid)] = _endpoint_name self.endpoint_dict[device_uuid] = device_endpoint_dict Loading Loading @@ -195,31 +203,27 @@ class _Algorithm: compose_device_config_rules( config_rules, service.service_config.config_rules, path_hops, self.device_name_mapping, self.endpoint_name_mapping) self.device_uuid_mapping, self.endpoint_uuid_mapping) for path_hop in path_hops: path_hop_device_id = path_hop['device'] path_hop_ingress_ep_id = path_hop['ingress_ep'] path_hop_egress_ep_id = path_hop['egress_ep'] path_hop_device_uuid = self.device_name_mapping [path_hop_device_id] path_hop_ingress_ep_uuid = self.endpoint_name_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_uuid = self.endpoint_name_mapping[(path_hop_device_id, path_hop_egress_ep_id )] path_hop_device_uuid = self.device_uuid_mapping [path_hop_device_id] path_hop_ingress_ep_uuid = self.endpoint_uuid_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_uuid = self.endpoint_uuid_mapping[(path_hop_device_id, path_hop_egress_ep_id )] path_hop_ingress_ep_name = self.endpoint_name_mapping[(path_hop_device_id, path_hop_ingress_ep_id)] path_hop_egress_ep_name = self.endpoint_name_mapping[(path_hop_device_id, path_hop_egress_ep_id )] target_endpoint_ids = set() target_endpoint_ids.add(path_hop_ingress_ep_uuid) target_endpoint_ids.add(path_hop_egress_ep_uuid) target_endpoint_ids.add(path_hop_ingress_ep_name) target_endpoint_ids.add(path_hop_egress_ep_name) path_hop_device = self.device_dict[path_hop_device_uuid][1] path_hop_ingress_ep = self.endpoint_dict[path_hop_device_uuid][path_hop_ingress_ep_uuid][1] path_hop_egress_ep = self.endpoint_dict[path_hop_device_uuid][path_hop_egress_ep_uuid ][1] path_hop_device_name = path_hop_device.name path_hop_ingress_ep_name = path_hop_ingress_ep.name path_hop_egress_ep_name = path_hop_egress_ep.name target_endpoint_ids.add(path_hop_ingress_ep_name) target_endpoint_ids.add(path_hop_egress_ep_name) RE_ENDPOINT_SETTINGS = re.compile(r'\/endpoints\/endpoint\[([^\]]+)\](\/settings)?') for config_rule in path_hop_device.device_config.config_rules: Loading @@ -232,9 +236,7 @@ class _Algorithm: endpoint_id = ep_match.group(1) if endpoint_id not in target_endpoint_ids: continue endpoint_uuid = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] endpoint = self.endpoint_dict[path_hop_device_uuid][endpoint_uuid][1] endpoint_name = endpoint.name endpoint_name = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] resource_key = '/device[{:s}]/endpoint[{:s}]/settings'.format( path_hop_device_name, endpoint_name ) Loading Loading @@ -293,7 +295,7 @@ class _Algorithm: path_hops = eropath_to_hops(service_path_ero['devices'], self.endpoint_to_link_dict) json_generated_config_rules = generate_neighbor_endpoint_config_rules( json_orig_config_rules, path_hops, self.device_name_mapping, self.endpoint_name_mapping json_orig_config_rules, path_hops, self.device_uuid_mapping, self.endpoint_uuid_mapping ) json_extended_config_rules = list() json_extended_config_rules.extend(json_orig_config_rules) Loading