summaryrefslogtreecommitdiffhomepage
path: root/test/lib/quagga.py
diff options
context:
space:
mode:
authorSatoshi Fujimoto <satoshi.fujimoto7@gmail.com>2017-10-04 16:01:09 +0900
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2017-11-07 21:53:46 +0900
commit88862a1017a48e1bb8d11f8d06d7d6ef24283425 (patch)
tree5274e9410f79dc787cb03840785864e6aa951ff2 /test/lib/quagga.py
parent002dca7e3b3c509ed6741343d5fecfeb183e19d2 (diff)
test/lib: Add bgp config structure for GoBGP/Quagga containers
This commit introduces 'bgp_config' attribute for GoBGP/Quagga containers to configure complex settings. Adding to this, this commit enables to configure BGP confederation settings to GoBGP/Quagga conrainers. Signed-off-by: Satoshi Fujimoto <satoshi.fujimoto7@gmail.com>
Diffstat (limited to 'test/lib/quagga.py')
-rw-r--r--test/lib/quagga.py23
1 files changed, 20 insertions, 3 deletions
diff --git a/test/lib/quagga.py b/test/lib/quagga.py
index 86a468d8..8f5f17c1 100644
--- a/test/lib/quagga.py
+++ b/test/lib/quagga.py
@@ -38,12 +38,24 @@ class QuaggaBGPContainer(BGPContainer):
WAIT_FOR_BOOT = 1
SHARED_VOLUME = '/etc/quagga'
- def __init__(self, name, asn, router_id, ctn_image_name='osrg/quagga', zebra=False):
+ def __init__(self, name, asn, router_id, ctn_image_name='osrg/quagga', bgpd_config=None, zebra=False):
super(QuaggaBGPContainer, self).__init__(name, asn, router_id,
ctn_image_name)
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
self.zebra = zebra
+ # bgp_config is equivalent to config.BgpConfigSet structure
+ # Example:
+ # bgpd_config = {
+ # 'global': {
+ # 'confederation': {
+ # 'identifier': 10,
+ # 'peers': [65001],
+ # },
+ # },
+ # }
+ self.bgpd_config = bgpd_config or {}
+
def run(self):
super(QuaggaBGPContainer, self).run()
return self.WAIT_FOR_BOOT
@@ -160,14 +172,19 @@ class QuaggaBGPContainer(BGPContainer):
if any(info['graceful_restart'] for info in self.peers.itervalues()):
c << 'bgp graceful-restart'
+ if 'global' in self.bgpd_config:
+ if 'confederation' in self.bgpd_config['global']:
+ conf = self.bgpd_config['global']['confederation']['config']
+ c << 'bgp confederation identifier {0}'.format(conf['identifier'])
+ c << 'bgp confederation peers {0}'.format(' '.join([str(i) for i in conf['member-as-list']]))
+
version = 4
for peer, info in self.peers.iteritems():
version = netaddr.IPNetwork(info['neigh_addr']).version
n_addr = info['neigh_addr'].split('/')[0]
if version == 6:
c << 'no bgp default ipv4-unicast'
-
- c << 'neighbor {0} remote-as {1}'.format(n_addr, peer.asn)
+ c << 'neighbor {0} remote-as {1}'.format(n_addr, info['remote_as'])
if info['is_rs_client']:
c << 'neighbor {0} route-server-client'.format(n_addr)
for typ, p in info['policies'].iteritems():