Loading src/service/service/service_handlers/l3nm_gnmi_openconfig/ConfigRuleComposer.py +16 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,11 @@ def _network_instance(ni_name : str, ni_type : str) -> Tuple[str, Dict]: data = {'name': ni_name, 'type': ni_type} return path, data def _network_instance_vlan(ni_name : str, vlan_id : int, vlan_name : str = None) -> Tuple[str, Dict]: path = '/network_instance[{:s}]/vlan[{:s}]'.format(ni_name, str(vlan_id)) data = {'name': ni_name, 'vlan_id': vlan_id, 'vlan_name': vlan_name} return path, data def _network_instance_protocol(ni_name : str, protocol : str) -> Tuple[str, Dict]: path = '/network_instance[{:s}]/protocols[{:s}]'.format(ni_name, protocol) data = {'name': ni_name, 'identifier': protocol, 'protocol_name': protocol} Loading Loading @@ -216,6 +221,7 @@ class DeviceComposer: self.static_routes : Dict[str, Dict[int, str]] = dict() # {prefix => {metric => next_hop}} self.service_vlan_id : Optional[int] = None self.access_vlan_tagged = False self.vlan_ids : Set[int] = set() def set_endpoint_alias(self, endpoint_name : str, endpoint_uuid : str) -> None: self.aliases[endpoint_name] = endpoint_uuid Loading Loading @@ -292,6 +298,9 @@ class DeviceComposer: ) -> List[Dict]: self.service_vlan_id = service_vlan_id self.access_vlan_tagged = access_vlan_tagged self.vlan_ids = set() if self.service_vlan_id is not None: self.vlan_ids.add(self.service_vlan_id) SELECTED_DEVICES = { DeviceTypeEnum.PACKET_POP.value, DeviceTypeEnum.PACKET_ROUTER.value, Loading @@ -308,6 +317,13 @@ class DeviceComposer: network_instance_name, self.service_vlan_id, access_vlan_tagged=self.access_vlan_tagged, delete=delete )) self.vlan_ids.update(endpoint.explicit_vlan_ids) for vlan_id in sorted(self.vlan_ids): vlan_name = 'tfs-vlan-{:s}'.format(str(vlan_id)) config_rules.append(json_config_rule(*_network_instance_vlan( network_instance_name, vlan_id, vlan_name=vlan_name ))) if len(self.static_routes) > 0: config_rules.append( json_config_rule(*_network_instance_protocol_static(network_instance_name)) Loading Loading
src/service/service/service_handlers/l3nm_gnmi_openconfig/ConfigRuleComposer.py +16 −0 Original line number Diff line number Diff line Loading @@ -70,6 +70,11 @@ def _network_instance(ni_name : str, ni_type : str) -> Tuple[str, Dict]: data = {'name': ni_name, 'type': ni_type} return path, data def _network_instance_vlan(ni_name : str, vlan_id : int, vlan_name : str = None) -> Tuple[str, Dict]: path = '/network_instance[{:s}]/vlan[{:s}]'.format(ni_name, str(vlan_id)) data = {'name': ni_name, 'vlan_id': vlan_id, 'vlan_name': vlan_name} return path, data def _network_instance_protocol(ni_name : str, protocol : str) -> Tuple[str, Dict]: path = '/network_instance[{:s}]/protocols[{:s}]'.format(ni_name, protocol) data = {'name': ni_name, 'identifier': protocol, 'protocol_name': protocol} Loading Loading @@ -216,6 +221,7 @@ class DeviceComposer: self.static_routes : Dict[str, Dict[int, str]] = dict() # {prefix => {metric => next_hop}} self.service_vlan_id : Optional[int] = None self.access_vlan_tagged = False self.vlan_ids : Set[int] = set() def set_endpoint_alias(self, endpoint_name : str, endpoint_uuid : str) -> None: self.aliases[endpoint_name] = endpoint_uuid Loading Loading @@ -292,6 +298,9 @@ class DeviceComposer: ) -> List[Dict]: self.service_vlan_id = service_vlan_id self.access_vlan_tagged = access_vlan_tagged self.vlan_ids = set() if self.service_vlan_id is not None: self.vlan_ids.add(self.service_vlan_id) SELECTED_DEVICES = { DeviceTypeEnum.PACKET_POP.value, DeviceTypeEnum.PACKET_ROUTER.value, Loading @@ -308,6 +317,13 @@ class DeviceComposer: network_instance_name, self.service_vlan_id, access_vlan_tagged=self.access_vlan_tagged, delete=delete )) self.vlan_ids.update(endpoint.explicit_vlan_ids) for vlan_id in sorted(self.vlan_ids): vlan_name = 'tfs-vlan-{:s}'.format(str(vlan_id)) config_rules.append(json_config_rule(*_network_instance_vlan( network_instance_name, vlan_id, vlan_name=vlan_name ))) if len(self.static_routes) > 0: config_rules.append( json_config_rule(*_network_instance_protocol_static(network_instance_name)) Loading