diff options
author | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-12 03:02:57 +0000 |
---|---|---|
committer | ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp> | 2016-05-12 03:05:05 +0000 |
commit | c97a2ee34f2a6e8c55003a4e0a1989ebc03f7f04 (patch) | |
tree | 20a4a9dad7bdfd9ee0a855d579a18807baf2d2a7 /test/lib/bird.py | |
parent | cbb4a6ace6561e74c881e6bf9c95b7fac9260a8d (diff) |
test/bird: add RawBirdContainer for test with raw bird config
Signed-off-by: ISHIDA Wataru <ishida.wataru@lab.ntt.co.jp>
Diffstat (limited to 'test/lib/bird.py')
-rw-r--r-- | test/lib/bird.py | 25 |
1 files changed, 25 insertions, 0 deletions
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) |