diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/base.py | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/test/lib/base.py b/test/lib/base.py index 6306ccf6..161bb9eb 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -382,18 +382,35 @@ class BGPContainer(Container): local_pref=None, identifier=None, reload_config=True): if route not in self.routes: self.routes[route] = [] - self.routes[route].append({'prefix': route, - 'rf': rf, - 'attr': attribute, - 'next-hop': nexthop, - 'as-path': aspath, - 'community': community, - 'med': med, - 'local-pref': local_pref, - 'extended-community': extendedcommunity, - 'identifier': identifier, - 'matchs': matchs, - 'thens': thens}) + self.routes[route].append({ + 'prefix': route, + 'rf': rf, + 'attr': attribute, + 'next-hop': nexthop, + 'as-path': aspath, + 'community': community, + 'med': med, + 'local-pref': local_pref, + 'extended-community': extendedcommunity, + 'identifier': identifier, + 'matchs': matchs, + 'thens': thens, + }) + if self.is_running and reload_config: + self.create_config() + self.reload_config() + + def del_route(self, route, identifier=None, reload_config=True): + if route not in self.routes: + return + if identifier: + new_paths = [] + for path in self.routes[route]: + if path['identifier'] != identifier: + new_paths.append(path) + self.routes[route] = new_paths + else: + self.routes[route] = [] if self.is_running and reload_config: self.create_config() self.reload_config() |