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()
def reload_config(self): cmd = CmdBuffer(' ') cmd << 'docker exec' cmd << '{0} cp {1}/bgp.conf'.format(self.name, self.SHARED_VOLUME) cmd << '/etc/bagpipe-bgp/' local(str(cmd), capture=True) cmd = 'docker exec {0} service bagpipe-bgp restart'.format(self.name) local(cmd, capture=True)
def _start_bird(self): c = CmdBuffer() c << '#!/bin/sh' c << 'bird' cmd = 'echo "{0:s}" > {1}/start.sh'.format(c, self.config_dir) local(cmd) cmd = 'chmod 755 {0}/start.sh'.format(self.config_dir) local(cmd) self.local('{0}/start.sh'.format(self.SHARED_VOLUME))
def run(self): super(BagpipeContainer, self).run() cmd = CmdBuffer(' ') cmd << 'docker exec' cmd << '{0} cp {1}/bgp.conf'.format(self.name, self.SHARED_VOLUME) cmd << '/etc/bagpipe-bgp/' local(str(cmd), capture=True) cmd = 'docker exec {0} service bagpipe-bgp start'.format(self.name) local(cmd, capture=True)
def _start_gobgp(self, graceful_restart=False): c = CmdBuffer() c << '#!/bin/sh' c << '/go/bin/gobgpd -f {0}/gobgpd.conf -l {1} -p {2} -t {3} > ' \ '{0}/gobgpd.log 2>&1'.format(self.SHARED_VOLUME, self.log_level, '-r' if graceful_restart else '', self.config_format) cmd = 'echo "{0:s}" > {1}/start.sh'.format(str(c), self.config_dir) local(cmd, capture=True) cmd = "chmod 755 {0}/start.sh".format(self.config_dir) local(cmd, capture=True) self.local("{0}/start.sh".format(self.SHARED_VOLUME), detach=True)
g5 = GoBGPContainer(name='g5', asn=100, router_id='192.168.0.6', ctn_image_name=parser_option.gobgp_image, log_level=parser_option.gobgp_log_level) time.sleep(g5.run()) g4 = self.ctns['g4'] g4.add_peer(g5, replace_peer_as=True) g5.add_peer(g4) g4.wait_for(expected_state=BGP_FSM_ESTABLISHED, peer=g5) def f(): rib = g5.get_global_rib() self.assertEqual(rib[0]['paths'][0]['aspath'], [200, 200, 200, 200, 200]) assert_several_times(f) if __name__ == '__main__': output = local("which docker 2>&1 > /dev/null ; echo $?", capture=True) if int(output) is not 0: print("docker not found") sys.exit(1) nose.main(argv=sys.argv, addplugins=[OptionParser()], defaultTest=sys.argv[0])
def _copy_helper_app(self): import lib mod_dir = os.path.dirname(lib.__file__) local('docker cp {0}/yabgp_helper.py' ' {1}:/root/'.format(mod_dir, self.docker_name()))