From 51a84fe36c69f72a48247ec61b137e545245452e Mon Sep 17 00:00:00 2001 From: IWASE Yusuke Date: Thu, 20 Jul 2017 13:46:58 +0900 Subject: test/lib/base/BGPContainer: Enable to delete route Signed-off-by: IWASE Yusuke --- test/lib/base.py | 41 +++++++++++++++++++++++++++++------------ 1 file 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() -- cgit v1.2.3