summaryrefslogtreecommitdiffhomepage
path: root/test
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-11 09:05:02 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-11 18:49:03 +0900
commitb780f5e590a75b5980369e6623fc5c275f36cf4f (patch)
tree9aee01ed820fc55757eb96ca39fa62887404c37d /test
parentc2d4b6992c563bd992c08f9cd78df11a4c12eaf7 (diff)
test/quagga: add RawQuaggaBGPContainer for test with raw quagga config
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test')
-rw-r--r--test/lib/quagga.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/lib/quagga.py b/test/lib/quagga.py
index 4dd42d76..1f0d4d3b 100644
--- a/test/lib/quagga.py
+++ b/test/lib/quagga.py
@@ -244,3 +244,28 @@ class QuaggaBGPContainer(BGPContainer):
for d in daemon:
cmd = '/usr/bin/pkill {0} -SIGHUP'.format(d)
self.local(cmd, capture=True)
+
+
+class RawQuaggaBGPContainer(QuaggaBGPContainer):
+ def __init__(self, name, config, ctn_image_name='osrg/quagga', zebra=False):
+ asn = None
+ router_id = None
+ for line in config.split('\n'):
+ line = line.strip()
+ if line.startswith('router bgp'):
+ asn = int(line[len('router bgp'):].strip())
+ if line.startswith('bgp router-id'):
+ router_id = line[len('bgp router-id'):].strip()
+ if not asn:
+ raise Exception('asn not in quagga config')
+ if not router_id:
+ raise Exception('router-id not in quagga config')
+ self.config = config
+ super(RawQuaggaBGPContainer, self).__init__(name, asn, router_id,
+ ctn_image_name, zebra)
+
+ def create_config(self):
+ with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
+ print colors.yellow('[{0}\'s new config]'.format(self.name))
+ print colors.yellow(indent(self.config))
+ f.writelines(self.config)