From 88862a1017a48e1bb8d11f8d06d7d6ef24283425 Mon Sep 17 00:00:00 2001 From: Satoshi Fujimoto Date: Wed, 4 Oct 2017 16:01:09 +0900 Subject: 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 --- test/lib/quagga.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'test/lib/quagga.py') 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(): -- cgit v1.2.3