diff options
author | IWASE Yusuke <iwase.yusuke0@gmail.com> | 2017-09-08 10:55:34 +0900 |
---|---|---|
committer | FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp> | 2017-09-14 14:58:33 +0900 |
commit | 8dd72278af9b80607964ca39decd48c9b02eece2 (patch) | |
tree | 9f067c02639ce53f42ec51f81c342523309ddfcc /test | |
parent | bb7d2f2541d67e7c2660ab80a91cb852e49ce1fb (diff) |
test/lib/gobgp: Add shared volume for Quagga
Currently, daemons of Quagga will fails to output their logs, because
those daemons (quagga user) does not have the permission to access to
the GoBGP config directory (owned by root user).
This patch prepares the volume for quagga user and enables daemons of
Quagga to output logs.
With this patch, those logs will be output into
"TEST_BASE_DIR/TEST_PREFIX/<CONTAINER_NAME>/quagga/" directory.
(default: /tmp/gobgp/<CONTAINER_NAME>/quagga/")
Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/gobgp.py | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/test/lib/gobgp.py b/test/lib/gobgp.py index 045eefaa..1123d53a 100644 --- a/test/lib/gobgp.py +++ b/test/lib/gobgp.py @@ -59,6 +59,8 @@ class GoBGPContainer(BGPContainer): super(GoBGPContainer, self).__init__(name, asn, router_id, ctn_image_name) self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME)) + self.quagga_config_dir = '{0}/quagga'.format(self.config_dir) + self.shared_volumes.append((self.quagga_config_dir, self.QUAGGA_VOLUME)) self.log_level = log_level self.prefix_set = None @@ -100,20 +102,18 @@ class GoBGPContainer(BGPContainer): def _start_zebra(self): if self.zapi_version == 2: - cmd = 'cp {0}/zebra.conf {1}/'.format(self.SHARED_VOLUME, self.QUAGGA_VOLUME) - self.local(cmd) - cmd = '/usr/lib/quagga/zebra -f {0}/zebra.conf'.format(self.QUAGGA_VOLUME) + daemon_bin = '/usr/lib/quagga/zebra' else: - cmd = 'zebra -u root -g root -f {0}/zebra.conf'.format(self.SHARED_VOLUME) + daemon_bin = 'zebra -u root -g root' + cmd = '{0} -f {1}/zebra.conf'.format(daemon_bin, self.QUAGGA_VOLUME) self.local(cmd, detach=True) def _start_ospfd(self): if self.zapi_version == 2: - cmd = 'cp {0}/ospfd.conf {1}/'.format(self.SHARED_VOLUME, self.QUAGGA_VOLUME) - self.local(cmd) - cmd = '/usr/lib/quagga/ospfd -f {0}/ospfd.conf'.format(self.QUAGGA_VOLUME) + daemon_bin = '/usr/lib/quagga/ospfd' else: - cmd = 'ospfd -u root -g root -f {0}/ospfd.conf'.format(self.SHARED_VOLUME) + daemon_bin = 'ospfd -u root -g root' + cmd = '{0} -f {1}/ospfd.conf'.format(daemon_bin, self.QUAGGA_VOLUME) self.local(cmd, detach=True) def run(self): @@ -288,6 +288,8 @@ class GoBGPContainer(BGPContainer): def create_config(self): self._create_config_bgp() if self.zebra: + local('mkdir -p {0}'.format(self.quagga_config_dir)) + local('chmod 777 {0}'.format(self.quagga_config_dir)) self._create_config_zebra() if self.ospfd_config: self._create_config_ospfd() @@ -468,13 +470,13 @@ class GoBGPContainer(BGPContainer): c = CmdBuffer() c << 'hostname zebra' c << 'password zebra' - c << 'log file {0}/zebra.log'.format(self.SHARED_VOLUME) + c << 'log file {0}/zebra.log'.format(self.QUAGGA_VOLUME) c << 'debug zebra packet' c << 'debug zebra kernel' c << 'debug zebra rib' c << '' - with open('{0}/zebra.conf'.format(self.config_dir), 'w') as f: + with open('{0}/zebra.conf'.format(self.quagga_config_dir), 'w') as f: print colors.yellow('[{0}\'s new zebra.conf]'.format(self.name)) print colors.yellow(indent(str(c))) f.writelines(str(c)) @@ -488,10 +490,10 @@ class GoBGPContainer(BGPContainer): c << ' redistribute {0}'.format(redistribute) for network, area in self.ospfd_config.get('networks', {}).items(): c << ' network {0} area {1}'.format(network, area) - c << 'log file {0}/ospfd.log'.format(self.SHARED_VOLUME) + c << 'log file {0}/ospfd.log'.format(self.QUAGGA_VOLUME) c << '' - with open('{0}/ospfd.conf'.format(self.config_dir), 'w') as f: + with open('{0}/ospfd.conf'.format(self.quagga_config_dir), 'w') as f: print colors.yellow('[{0}\'s new ospfd.conf]'.format(self.name)) print colors.yellow(indent(str(c))) f.writelines(str(c)) |