Commit 8655f815 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service - gNMI OpenConfig Service Handler:

- Generalized configuration of network instances
parent 8c0ed513
Loading
Loading
Loading
Loading
+12 −9
Original line number Diff line number Diff line
@@ -21,8 +21,9 @@ from service.service.service_handler_api.AnyTreeTools import TreeNode

LOGGER = logging.getLogger(__name__)

#NETWORK_INSTANCE = 'teraflowsdn'
#NETWORK_INSTANCE = 'teraflowsdn' # TODO: investigate; sometimes it does not create/delete static rules properly
NETWORK_INSTANCE = 'default'
DEFAULT_NETWORK_INSTANCE = 'default'

RE_IF    = re.compile(r'^\/interface\[([^\]]+)\]$')
RE_SUBIF = re.compile(r'^\/interface\[([^\]]+)\]\/subinterface\[([^\]]+)\]$')
@@ -109,11 +110,13 @@ class EndpointComposer:
        if self.ipv4_address is None: return []
        if self.ipv4_prefix_len is None: return []
        json_config_rule = json_config_rule_delete if delete else json_config_rule_set
        config_rules = [
            #json_config_rule(*_network_instance_interface(
            #    network_instance_name, self.objekt.name, self.sub_interface_index
            #)),
        ]

        config_rules : List[Dict] = list()
        if network_instance_name != DEFAULT_NETWORK_INSTANCE:
            config_rules.append(json_config_rule(*_network_instance_interface(
                network_instance_name, self.objekt.name, self.sub_interface_index
            )))

        if delete:
            config_rules.extend([
                json_config_rule(*_interface(
@@ -226,9 +229,9 @@ class DeviceComposer:
        if self.objekt.device_type not in SELECTED_DEVICES: return []

        json_config_rule = json_config_rule_delete if delete else json_config_rule_set
        config_rules = [
            #json_config_rule(*_network_instance(network_instance_name, 'L3VRF'))
        ]
        config_rules : List[Dict] = list()
        if network_instance_name != DEFAULT_NETWORK_INSTANCE:
            json_config_rule(*_network_instance(network_instance_name, 'L3VRF'))
        for endpoint in self.endpoints.values():
            config_rules.extend(endpoint.get_config_rules(network_instance_name, delete=delete))
        if len(self.static_routes) > 0: