Loading src/pathcomp/frontend/service/algorithms/_Algorithm.py +20 −9 Original line number Diff line number Diff line Loading @@ -16,21 +16,25 @@ import json, logging, re, requests, uuid from typing import Dict, List, Optional, Tuple, Union from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import ( ConfigRule, Connection, Device, DeviceList, EndPointId, Link, LinkList, Service, ServiceStatusEnum, ServiceTypeEnum ConfigActionEnum, ConfigRule, Connection, Device, DeviceList, EndPointId, Link, LinkList, Service, ServiceStatusEnum, ServiceTypeEnum, ) from common.proto.pathcomp_pb2 import PathCompReply, PathCompRequest from common.tools.context_queries.Device import get_device from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_list_to_json from context.client.ContextClient import ContextClient from pathcomp.frontend.Config import BACKEND_URL from .tools.EroPathToHops import eropath_to_hops from .tools.ComposeConfigRules import ( compose_device_config_rules, compose_l2nm_config_rules, compose_l3nm_config_rules, compose_tapi_config_rules, generate_neighbor_endpoint_config_rules compose_device_config_rules, compose_l2nm_config_rules, compose_l3nm_config_rules, compose_tapi_config_rules, generate_neighbor_endpoint_config_rules, ) from .tools.ComposeRequest import compose_device, compose_link, compose_service from .tools.ComputeSubServices import ( convert_explicit_path_hops_to_connections, convert_explicit_path_hops_to_plain_connection) convert_explicit_path_hops_to_connections, convert_explicit_path_hops_to_plain_connection, ) SRC_END = 'src' DST_END = 'dst' Loading Loading @@ -236,20 +240,27 @@ class _Algorithm: RE_ENDPOINT_SETTINGS = re.compile(r'\/endpoints\/endpoint\[([^\]]+)\](\/settings)?') for config_rule in path_hop_device.device_config.config_rules: if config_rule.WhichOneof('config_rule') != 'custom': continue rw_config_rule = ConfigRule() rw_config_rule.CopyFrom(config_rule) resource_key = str(config_rule.custom.resource_key) ep_match = RE_ENDPOINT_SETTINGS.match(resource_key) if ep_match is None: continue endpoint_id = ep_match.group(1) if endpoint_id not in target_endpoint_ids: continue endpoint_name = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] resource_value : Dict = json.loads(config_rule.custom.resource_value) address_ip = resource_value.pop('address_ip', '0.0.0.0') if address_ip != '0.0.0.0': resource_value['address_ip'] = address_ip if len(resource_value) == 0: continue field_updates = {name:(value, False) for name,value in resource_value.items()} resource_key = '/device[{:s}]/endpoint[{:s}]/settings'.format( path_hop_device_name, endpoint_name ) rw_config_rule.custom.resource_key = resource_key service.service_config.config_rules.append(rw_config_rule) update_config_rule_custom( service.service_config.config_rules, resource_key, field_updates, new_action=ConfigActionEnum.CONFIGACTION_SET ) if path_hops is not None and len(path_hops) > 0: ingress_endpoint_id = service.service_endpoint_ids.add() Loading Loading
src/pathcomp/frontend/service/algorithms/_Algorithm.py +20 −9 Original line number Diff line number Diff line Loading @@ -16,21 +16,25 @@ import json, logging, re, requests, uuid from typing import Dict, List, Optional, Tuple, Union from common.DeviceTypes import DeviceTypeEnum from common.proto.context_pb2 import ( ConfigRule, Connection, Device, DeviceList, EndPointId, Link, LinkList, Service, ServiceStatusEnum, ServiceTypeEnum ConfigActionEnum, ConfigRule, Connection, Device, DeviceList, EndPointId, Link, LinkList, Service, ServiceStatusEnum, ServiceTypeEnum, ) from common.proto.pathcomp_pb2 import PathCompReply, PathCompRequest from common.tools.context_queries.Device import get_device from common.tools.grpc.ConfigRules import update_config_rule_custom from common.tools.grpc.Tools import grpc_message_list_to_json from context.client.ContextClient import ContextClient from pathcomp.frontend.Config import BACKEND_URL from .tools.EroPathToHops import eropath_to_hops from .tools.ComposeConfigRules import ( compose_device_config_rules, compose_l2nm_config_rules, compose_l3nm_config_rules, compose_tapi_config_rules, generate_neighbor_endpoint_config_rules compose_device_config_rules, compose_l2nm_config_rules, compose_l3nm_config_rules, compose_tapi_config_rules, generate_neighbor_endpoint_config_rules, ) from .tools.ComposeRequest import compose_device, compose_link, compose_service from .tools.ComputeSubServices import ( convert_explicit_path_hops_to_connections, convert_explicit_path_hops_to_plain_connection) convert_explicit_path_hops_to_connections, convert_explicit_path_hops_to_plain_connection, ) SRC_END = 'src' DST_END = 'dst' Loading Loading @@ -236,20 +240,27 @@ class _Algorithm: RE_ENDPOINT_SETTINGS = re.compile(r'\/endpoints\/endpoint\[([^\]]+)\](\/settings)?') for config_rule in path_hop_device.device_config.config_rules: if config_rule.WhichOneof('config_rule') != 'custom': continue rw_config_rule = ConfigRule() rw_config_rule.CopyFrom(config_rule) resource_key = str(config_rule.custom.resource_key) ep_match = RE_ENDPOINT_SETTINGS.match(resource_key) if ep_match is None: continue endpoint_id = ep_match.group(1) if endpoint_id not in target_endpoint_ids: continue endpoint_name = self.endpoint_name_mapping[(path_hop_device_id, endpoint_id)] resource_value : Dict = json.loads(config_rule.custom.resource_value) address_ip = resource_value.pop('address_ip', '0.0.0.0') if address_ip != '0.0.0.0': resource_value['address_ip'] = address_ip if len(resource_value) == 0: continue field_updates = {name:(value, False) for name,value in resource_value.items()} resource_key = '/device[{:s}]/endpoint[{:s}]/settings'.format( path_hop_device_name, endpoint_name ) rw_config_rule.custom.resource_key = resource_key service.service_config.config_rules.append(rw_config_rule) update_config_rule_custom( service.service_config.config_rules, resource_key, field_updates, new_action=ConfigActionEnum.CONFIGACTION_SET ) if path_hops is not None and len(path_hops) > 0: ingress_endpoint_id = service.service_endpoint_ids.add() Loading