summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>2016-05-11 09:14:01 +0000
committerFUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>2016-05-11 18:49:03 +0900
commitc9f75965848ce8b4827a33549c3c6741661578fd (patch)
treec46cedff07f47a5ac1550114b576ffc0192570d5
parentb780f5e590a75b5980369e6623fc5c275f36cf4f (diff)
test/exabgp: add RawExaBGPContainer for test with raw exabgp config
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
-rw-r--r--test/lib/exabgp.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/lib/exabgp.py b/test/lib/exabgp.py
index 22eaf51f..e3934c79 100644
--- a/test/lib/exabgp.py
+++ b/test/lib/exabgp.py
@@ -164,3 +164,30 @@ class ExaBGPContainer(BGPContainer):
if not _is_running():
raise RuntimeError()
try_several_times(_reload)
+
+
+class RawExaBGPContainer(ExaBGPContainer):
+ def __init__(self, name, config, ctn_image_name='osrg/exabgp',
+ exabgp_path=''):
+ asn = None
+ router_id = None
+ for line in config.split('\n'):
+ line = line.strip()
+ if line.startswith('local-as'):
+ asn = int(line[len('local-as'):].strip('; '))
+ if line.startswith('router-id'):
+ router_id = line[len('router-id'):].strip('; ')
+ if not asn:
+ raise Exception('asn not in exabgp config')
+ if not router_id:
+ raise Exception('router-id not in exabgp config')
+ self.config = config
+
+ super(RawExaBGPContainer, self).__init__(name, asn, router_id,
+ ctn_image_name, exabgp_path)
+
+ def create_config(self):
+ with open('{0}/exabgpd.conf'.format(self.config_dir), 'w') as f:
+ print colors.yellow('[{0}\'s new config]'.format(self.name))
+ print colors.yellow(self.config)
+ f.write(self.config)