Commit 0dfabbf9 authored by Lluis Gifre Renom's avatar Lluis Gifre Renom
Browse files

Device component - gNMI OpenConfig Driver:

- Fixed removal of static routes on network instances
parent c9c72b6b
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -40,6 +40,23 @@ class NetworkInstanceStaticRouteHandler(_Handler):
            PATH_TMPL  = '/network-instances/network-instance[name={:s}]/protocols'
            PATH_TMPL += '/protocol[identifier={:s}][name={:s}]/static-routes/static[prefix={:s}]'
            str_path = PATH_TMPL.format(ni_name, identifier, proto_name, prefix)

            root_node : libyang.DContainer = yang_handler.get_data_path(
                '/openconfig-network-instance:network-instances'
            )
            yang_ni_pr_sr_path = root_node.find_path('/'.join([
                '', # add slash at the beginning
                'openconfig-network-instance:network-instances',
                'network-instance[name="{:s}"]'.format(ni_name),
                'protocols',
                'protocol[identifier="{:s}"][name="{:s}"]'.format(identifier, proto_name),
                'static-routes',
                'static[prefix="{:s}"]'.format(prefix)
            ]))
            if yang_ni_pr_sr_path is not None:
                yang_ni_pr_sr_path.unlink()
                yang_ni_pr_sr_path.free()

            str_data = json.dumps({})
            return str_path, str_data