From c97a2ee34f2a6e8c55003a4e0a1989ebc03f7f04 Mon Sep 17 00:00:00 2001 From: ISHIDA Wataru Date: Thu, 12 May 2016 03:02:57 +0000 Subject: test/bird: add RawBirdContainer for test with raw bird config Signed-off-by: ISHIDA Wataru --- test/lib/bird.py | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test/lib/bird.py') diff --git a/test/lib/bird.py b/test/lib/bird.py index c08a381c..598276bc 100644 --- a/test/lib/bird.py +++ b/test/lib/bird.py @@ -76,3 +76,28 @@ class BirdContainer(BGPContainer): if not _is_running(): raise RuntimeError() try_several_times(_reload) + + +class RawBirdContainer(BirdContainer): + def __init__(self, name, config, ctn_image_name='osrg/bird'): + 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 bird config') + if not router_id: + raise Exception('router-id not in bird config') + self.config = config + super(RawBirdContainer, self).__init__(name, asn, router_id, + ctn_image_name) + + def create_config(self): + with open('{0}/bird.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) -- cgit v1.2.3