diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-07-20 13:46:58 +0900 |
---|---|---|
committer | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-07-20 14:49:51 +0900 |
commit | 51a84fe36c69f72a48247ec61b137e545245452e (patch) | |
tree | a0827eb6f11cd1de84a13fb534fb847de901eedd | |
parent | 9acf225f6bcec1b9744d02181b34dd45aa92d904 (diff) |
test/lib/base/BGPContainer: Enable to delete route
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
-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() |