diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2015-11-07 19:44:59 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2015-11-08 05:05:36 -0800 |
commit | 2f6db55c6743cdd568f1555b91017a6f2c09695d (patch) | |
tree | f022bb9bae68b89d3a682edeb2bfcdac7005eedb /test/scenario_test/lib/gobgp.py | |
parent | d53a5d11d9f3b0ee762a0510ff6608e69ed595ff (diff) |
scenario_test: test local-pref and med handling
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/scenario_test/lib/gobgp.py')
-rw-r--r-- | test/scenario_test/lib/gobgp.py | 23 |
1 files changed, 18 insertions, 5 deletions
diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py index f126047d..042d6696 100644 --- a/test/scenario_test/lib/gobgp.py +++ b/test/scenario_test/lib/gobgp.py @@ -18,6 +18,11 @@ import json import toml from itertools import chain +def extract_path_attribute(path, typ): + for a in path['attrs']: + if a['type'] == typ: + return a + return None class GoBGPContainer(BGPContainer): @@ -105,7 +110,7 @@ class GoBGPContainer(BGPContainer): for d in ret: for p in d["paths"]: p["nexthop"] = self._get_nexthop(p) - p["as_path"] = self._get_as_path(p) + p["aspath"] = self._get_as_path(p) return ret def get_global_rib(self, prefix='', rf='ipv4'): @@ -115,7 +120,7 @@ class GoBGPContainer(BGPContainer): for d in ret: for p in d["paths"]: p["nexthop"] = self._get_nexthop(p) - p["as_path"] = self._get_as_path(p) + p["aspath"] = self._get_as_path(p) return ret def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4'): @@ -129,7 +134,7 @@ class GoBGPContainer(BGPContainer): ret = [p["paths"][0] for p in json.loads(output)] for p in ret: p["nexthop"] = self._get_nexthop(p) - p["as_path"] = self._get_as_path(p) + p["aspath"] = self._get_as_path(p) return ret def get_adj_rib_in(self, peer, prefix='', rf='ipv4'): @@ -308,8 +313,16 @@ class GoBGPContainer(BGPContainer): self.local(cmd) for v in self.routes.itervalues(): if v['rf'] == 'ipv4' or v['rf'] == 'ipv6': - cmd = 'gobgp global '\ - 'rib add {0} -a {1}'.format(v['prefix'], v['rf']) + r = CmdBuffer(' ') + r << 'gobgp global -a {0}'.format(v['rf']) + r << 'rib add {0}'.format(v['prefix']) + if v['next-hop']: + r << 'nexthop {0}'.format(v['next-hop']) + if v['local-pref']: + r << 'local-pref {0}'.format(v['local-pref']) + if v['med']: + r << 'med {0}'.format(v['med']) + cmd = str(r) elif v['rf'] == 'ipv4-flowspec' or v['rf'] == 'ipv6-flowspec': cmd = 'gobgp global '\ 'rib add match {0} then {1} -a {2}'.format(' '.join(v['matchs']), ' '.join(v['thens']), v['rf']) |