ipmininet icon indicating copy to clipboard operation
ipmininet copied to clipboard

Impossible to use BBP RouteMapEntry call_action and exit_policy

Open Mathieu-COSYNS-Student opened this issue 3 years ago • 0 comments

As mentioned in https://github.com/cnp3/ipmininet/issues/107 and https://github.com/cnp3/ipmininet/issues/99. I don't think that in interface to configure BGP route maps is good.

I was looking for a way to configure exit_policy. I was not able to find a method in bgp.py to do that so I build a work around.

  def route_map_add_exit_policy(
                                router: RouterDescription,
                                route_map_name: str,
                                route_map_order: str,
                                exit_policy: Optional[str] = None):
      """
      ipmininet does not have a interface to add exit policies on route maps!
      This is a hacky why to do it.
      """
      route_maps = router.get_config(BGP).topo.getNodeInfo(
          router, 'bgp_route_maps', list)

      for route_map in route_maps:
          if route_map_name == route_map.name:
              for order, route_map_entry in route_map.entries.items():
                  if route_map_order == order:
                      route_map_entry.exit_policy = exit_policy

When I configure a router with this function and I start, an error occurs.

Couldnt render a config file( bgpd.mako )

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/dist-packages/ipmininet/router/config/base.py", line 334, in render
    cfg_content[filename] = template.render(**kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mako/template.py", line 473, in render
    return runtime._render(self, self.callable_, args, data)
  File "/usr/local/lib/python3.8/dist-packages/mako/runtime.py", line 878, in _render
    _render_context(
  File "/usr/local/lib/python3.8/dist-packages/mako/runtime.py", line 920, in _render_context
    _exec_template(inherit, lclcontext, args=args, kwargs=kwargs)
  File "/usr/local/lib/python3.8/dist-packages/mako/runtime.py", line 947, in _exec_template
    callable_(context, *args, **kwargs)
  File "/usr/local/lib/python3.8/dist-packages/ipmininet/router/config/templates/bgpd.mako", line 104, in render_body
    on-match ${rm.exit_policy}
AttributeError: 'RouteMap' object has no attribute 'exit_policy'

Mathieu-COSYNS-Student avatar Dec 03 '22 12:12 Mathieu-COSYNS-Student