Commit 904df114 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Service component - L3NM gNMI OpenConfig:

- Fixed removal of interfaces and static routes
parent 9393130b
Loading
Loading
Loading
Loading
+18 −7
Original line number Diff line number Diff line
@@ -101,6 +101,10 @@ def _network_instance_interface(ni_name : str, interface : str, sub_interface_in
    data = {'name': ni_name, 'id': sub_interface_name, 'interface': interface, 'subinterface': sub_interface_index}
    return path, data

def _interface_switched_vlan(interface : str) -> Tuple[str, Dict]:
    path = '/interface[{:s}]/ethernet/switched-vlan'.format(interface)
    return path, {}

class EndpointComposer:
    def __init__(self, endpoint_uuid : str) -> None:
        self.uuid = endpoint_uuid
@@ -314,25 +318,32 @@ class DeviceComposer:
            json_config_rule(*_network_instance(network_instance_name, 'L3VRF'))

        parent_interfaces : Set[str] = set()
        configured_parents : Set[str] = set()
        for endpoint in self.endpoints.values():
            if not delete and endpoint.objekt is not None:
                if endpoint.objekt.name not in parent_interfaces:
            if endpoint.objekt is None:
                continue
            parent_interfaces.add(endpoint.objekt.name)
            if not delete and endpoint.objekt.name not in configured_parents:
                config_rules.append(json_config_rule_set(*_interface(
                    endpoint.objekt.name, index=0, address_ip=None, address_prefix=None, enabled=True
                )))
                    parent_interfaces.add(endpoint.objekt.name)
                configured_parents.add(endpoint.objekt.name)
            config_rules.extend(endpoint.get_config_rules(
                network_instance_name, self.service_vlan_id,
                access_vlan_tagged=self.access_vlan_tagged, delete=delete
            ))
            self.vlan_ids.update(endpoint.explicit_vlan_ids)

        if delete:
            for if_name in sorted(parent_interfaces):
                config_rules.append(json_config_rule_delete(*_interface_switched_vlan(if_name)))

        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:
        if len(self.static_routes) > 0 and not delete:
            config_rules.append(
                json_config_rule(*_network_instance_protocol_static(network_instance_name))
            )