diff options
author | Wataru Ishida <ishida.wataru@lab.ntt.co.jp> | 2016-08-20 19:15:53 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2016-08-25 15:53:14 +0900 |
commit | 3235c0618cfc320c0ad751d83d850ec714fa1c49 (patch) | |
tree | 9bbc51cdb4e549dcb0567248d16c99dffd74e68d /test/lib/gobgp.py | |
parent | b3c874da2581eb71d8c137d956e792565193ec0e (diff) |
api/cli: kill cmd package custom path/destination structs
reuse table package
Signed-off-by: Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/lib/gobgp.py')
-rw-r--r-- | test/lib/gobgp.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index d16610f0..316e8535 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -121,23 +121,29 @@ class GoBGPContainer(BGPContainer): cmd = 'gobgp -j neighbor {0} local {1} -a {2}'.format(peer_addr, prefix, rf) output = self.local(cmd, capture=True) ret = json.loads(output) - for d in ret: - for p in d["paths"]: + dsts = [] + for k, v in ret.iteritems(): + for p in v: p["nexthop"] = self._get_nexthop(p) p["aspath"] = self._get_as_path(p) p["local-pref"] = self._get_local_pref(p) - return ret + p["prefix"] = k + dsts.append({'paths': v, 'prefix': k}) + return dsts def get_global_rib(self, prefix='', rf='ipv4'): cmd = 'gobgp -j global rib {0} -a {1}'.format(prefix, rf) output = self.local(cmd, capture=True) ret = json.loads(output) - for d in ret: - for p in d["paths"]: + dsts = [] + for k, v in ret.iteritems(): + for p in v: p["nexthop"] = self._get_nexthop(p) p["aspath"] = self._get_as_path(p) p["local-pref"] = self._get_local_pref(p) - return ret + p["prefix"] = k + dsts.append({'paths': v, 'prefix': k}) + return dsts def monitor_global_rib(self, queue, rf='ipv4'): host = self.ip_addrs[0][1].split('/')[0] @@ -168,7 +174,7 @@ class GoBGPContainer(BGPContainer): adj_type, prefix, rf) output = self.local(cmd, capture=True) - ret = [p["paths"][0] for p in json.loads(output)] + ret = [p[0] for p in json.loads(output).itervalues()] for p in ret: p["nexthop"] = self._get_nexthop(p) p["aspath"] = self._get_as_path(p) |