diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-08-02 10:47:03 +0000 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-04-04 22:07:46 +0900 |
commit | c7985efcf5af6e16cf18d2ecc2fa145ce25a55a5 (patch) | |
tree | 42115ad08c0fcb1b17ceb6642687111881dba513 /test/lib/base.py | |
parent | 70a654a238cbdfbe84ad86ce935fe16e244919c3 (diff) |
test: add test for unnumbered bgp feature
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/lib/base.py')
-rw-r--r-- | test/lib/base.py | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/test/lib/base.py b/test/lib/base.py index 18fa487c..4b4ff4ef 100644 --- a/test/lib/base.py +++ b/test/lib/base.py @@ -293,36 +293,46 @@ class BGPContainer(Container): super(BGPContainer, self).run() return self.WAIT_FOR_BOOT + def peer_name(self, peer): + if peer not in self.peers: + raise Exception('not found peer {0}'.format(peer.router_id)) + name = self.peers[peer]['interface'] + if name == '': + name = self.peers[peer]['neigh_addr'].split('/')[0] + return name + def add_peer(self, peer, passwd=None, vpn=False, is_rs_client=False, policies=None, passive=False, is_rr_client=False, cluster_id=None, flowspec=False, bridge='', reload_config=True, as2=False, graceful_restart=None, local_as=None, prefix_limit=None, - v6=False, llgr=None, vrf=''): + v6=False, llgr=None, vrf='', interface=''): neigh_addr = '' local_addr = '' it = itertools.product(self.ip_addrs, peer.ip_addrs) if v6: it = itertools.product(self.ip6_addrs, peer.ip6_addrs) - for me, you in it: - if bridge != '' and bridge != me[2]: - continue - if me[2] == you[2]: - neigh_addr = you[1] - local_addr = me[1] - if v6: - addr, mask = local_addr.split('/') - local_addr = "{0}%{1}/{2}".format(addr, me[0], mask) - break - - if neigh_addr == '': - raise Exception('peer {0} seems not ip reachable'.format(peer)) + if interface == '': + for me, you in it: + if bridge != '' and bridge != me[2]: + continue + if me[2] == you[2]: + neigh_addr = you[1] + local_addr = me[1] + if v6: + addr, mask = local_addr.split('/') + local_addr = "{0}%{1}/{2}".format(addr, me[0], mask) + break + + if neigh_addr == '': + raise Exception('peer {0} seems not ip reachable'.format(peer)) if not policies: policies = {} self.peers[peer] = {'neigh_addr': neigh_addr, + 'interface': interface, 'passwd': passwd, 'vpn': vpn, 'flowspec': flowspec, |