diff options
Diffstat (limited to 'test/scenario_test/lib/gobgp.py')
-rw-r--r-- | test/scenario_test/lib/gobgp.py | 51 |
1 files changed, 18 insertions, 33 deletions
diff --git a/test/scenario_test/lib/gobgp.py b/test/scenario_test/lib/gobgp.py index c56337cd..433d779e 100644 --- a/test/scenario_test/lib/gobgp.py +++ b/test/scenario_test/lib/gobgp.py @@ -42,9 +42,7 @@ class GoBGPContainer(BGPContainer): local(cmd, capture=True) cmd = "chmod 755 {0}/start.sh".format(self.config_dir) local(cmd, capture=True) - cmd = 'docker exec -d {0} {1}/start.sh'.format(self.name, - self.SHARED_VOLUME) - local(cmd, capture=True) + self.local("{0}/start.sh".format(self.SHARED_VOLUME), flag='-d') def run(self): super(GoBGPContainer, self).run() @@ -62,10 +60,8 @@ class GoBGPContainer(BGPContainer): if peer not in self.peers: raise Exception('not found peer {0}'.format(peer.router_id)) peer_addr = self.peers[peer]['neigh_addr'].split('/')[0] - cmd = "docker exec {0} gobgp neighbor {1} {2}".format(self.name, - peer_addr, - cmd) - local(str(cmd), capture=True) + cmd = 'gobgp neighbor {0} {1}'.format(peer_addr, cmd) + self.local(cmd) def disable_peer(self, peer): self._trigger_peer_cmd('disable', peer) @@ -77,32 +73,24 @@ class GoBGPContainer(BGPContainer): if peer not in self.peers: raise Exception('not found peer {0}'.format(peer.router_id)) peer_addr = self.peers[peer]['neigh_addr'].split('/')[0] - gobgp = '/go/bin/gobgp' - cmd = CmdBuffer(' ') - cmd << "docker exec {0} {1}".format(self.name, gobgp) - cmd << "-j neighbor {0} local -a {1}".format(peer_addr, rf) - output = local(str(cmd), capture=True) + cmd = 'gobgp -j neighbor {0} local -a {1}'.format(peer_addr, rf) + output = self.local(cmd, capture=True) n = json.loads(output) return n def get_global_rib(self, prefix='', rf='ipv4'): - gobgp = '/go/bin/gobgp' - cmd = 'docker exec {0} {1} -j global rib {2} -a {3}'.format(self.name, - gobgp, - prefix, - rf) - output = local(cmd, capture=True) + cmd = 'gobgp -j global rib {0} -a {1}'.format(prefix, rf) + output = self.local(cmd, capture=True) return json.loads(output) def _get_adj_rib(self, adj_type, peer, prefix='', rf='ipv4'): if peer not in self.peers: raise Exception('not found peer {0}'.format(peer.router_id)) peer_addr = self.peers[peer]['neigh_addr'].split('/')[0] - gobgp = '/go/bin/gobgp' - cmd = 'docker exec {0} {1} neighbor {2}'\ - ' adj-{3} {4} -a {5} -j'.format(self.name, gobgp, peer_addr, - adj_type, prefix, rf) - output = local(cmd, capture=True) + cmd = 'gobgp neighbor {0} adj-{1} {2} -a {3} -j'.format(peer_addr, + adj_type, + prefix, rf) + output = self.local(cmd, capture=True) return json.loads(output) def get_adj_rib_in(self, peer, prefix='', rf='ipv4'): @@ -115,11 +103,8 @@ class GoBGPContainer(BGPContainer): if peer not in self.peers: raise Exception('not found peer {0}'.format(peer.router_id)) peer_addr = self.peers[peer]['neigh_addr'].split('/')[0] - gobgp = '/go/bin/gobgp' - cmd = 'docker exec {0} {1} -j neighbor {2}'.format(self.name, - gobgp, - peer_addr) - output = local(cmd, capture=True) + cmd = 'gobgp -j neighbor {0}'.format(peer_addr) + output = self.local(cmd, capture=True) return json.loads(output)['info']['bgp_state'] def create_config(self): @@ -172,9 +157,9 @@ class GoBGPContainer(BGPContainer): f.write(toml.dumps(config)) def reload_config(self): - cmd = 'docker exec {0} /usr/bin/pkill gobgpd -SIGHUP'.format(self.name) - local(cmd, capture=True) + cmd = '/usr/bin/pkill gobgpd -SIGHUP' + self.local(cmd) for v in self.routes.itervalues(): - cmd = 'docker exec {0} gobgp global '\ - 'rib add {1} -a {2}'.format(self.name, v['prefix'], v['rf']) - local(cmd, capture=True) + cmd = 'gobgp global '\ + 'rib add {0} -a {1}'.format(v['prefix'], v['rf']) + self.local(cmd) |