summaryrefslogtreecommitdiffhomepage
path: root/test/lib/gobgp.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/gobgp.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/gobgp.py')
-rw-r--r--test/lib/gobgp.py29
1 files changed, 27 insertions, 2 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py
index 7fa90291..601883e5 100644
--- a/test/lib/gobgp.py
+++ b/test/lib/gobgp.py
@@ -27,6 +27,7 @@ from fabric.utils import indent
import netaddr
import toml
import yaml
+import collections
from lib.base import (
BGPContainer,
@@ -55,7 +56,7 @@ class GoBGPContainer(BGPContainer):
def __init__(self, name, asn, router_id, ctn_image_name='osrg/gobgp',
log_level='debug', zebra=False, config_format='toml',
- zapi_version=2, ospfd_config=None):
+ zapi_version=2, bgp_config=None, ospfd_config=None):
super(GoBGPContainer, self).__init__(name, asn, router_id,
ctn_image_name)
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
@@ -72,6 +73,20 @@ class GoBGPContainer(BGPContainer):
self.zapi_version = zapi_version
self.config_format = config_format
+ # bgp_config is equivalent to config.BgpConfigSet structure
+ # Example:
+ # bgp_config = {
+ # 'global': {
+ # 'confederation': {
+ # 'config': {
+ # 'identifier': 10,
+ # 'member-as-list': [65001],
+ # }
+ # },
+ # },
+ # }
+ self.bgp_config = bgp_config or {}
+
# To start OSPFd in GoBGP container, specify 'ospfd_config' as a dict
# type value.
# Example:
@@ -294,6 +309,14 @@ class GoBGPContainer(BGPContainer):
if self.ospfd_config:
self._create_config_ospfd()
+ def _merge_dict(self, dct, merge_dct):
+ for k, v in merge_dct.iteritems():
+ if (k in dct and isinstance(dct[k], dict)
+ and isinstance(merge_dct[k], collections.Mapping)):
+ self._merge_dict(dct[k], merge_dct[k])
+ else:
+ dct[k] = merge_dct[k]
+
def _create_config_bgp(self):
config = {
'global': {
@@ -310,6 +333,8 @@ class GoBGPContainer(BGPContainer):
'neighbors': [],
}
+ self._merge_dict(config, self.bgp_config)
+
if self.zebra and self.zapi_version == 2:
config['global']['use-multiple-paths'] = {'config': {'enabled': True}}
@@ -349,7 +374,7 @@ class GoBGPContainer(BGPContainer):
'config': {
'neighbor-address': neigh_addr,
'neighbor-interface': interface,
- 'peer-as': peer.asn,
+ 'peer-as': info['remote_as'],
'auth-password': info['passwd'],
'vrf': info['vrf'],
'remove-private-as': info['remove_private_as'],