summaryrefslogtreecommitdiffhomepage
path: root/test/lib/quagga.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/lib/quagga.py')
-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)