Merge "Revert "Use FRR instead of Quagga when testing""
This commit is contained in:
commit
29eeb05824
@ -20,7 +20,7 @@ import unittest
|
||||
|
||||
from os_ken.tests.integrated.common import docker_base as ctn_base
|
||||
from os_ken.tests.integrated.common import oskenbgp
|
||||
from os_ken.tests.integrated.common import frr
|
||||
from os_ken.tests.integrated.common import quagga
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -46,8 +46,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r_img = self.dockerimg.create_os_ken(image=image,
|
||||
check_exist=True)
|
||||
self.images.append(self.r_img)
|
||||
self.frr_img = 'quay.io/frr:9.0.0'
|
||||
self.images.append(self.frr_img)
|
||||
self.q_img = 'osrg/quagga'
|
||||
self.images.append(self.q_img)
|
||||
|
||||
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
|
||||
router_id='192.168.0.1',
|
||||
@ -58,9 +58,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r1_ip_cidr = self.brdc1.addif(self.r1)
|
||||
self.r1_ip = self.r1_ip_cidr.split('/')[0]
|
||||
|
||||
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.frr_img)
|
||||
self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.q_img)
|
||||
self.containers.append(self.q1)
|
||||
self.q1.add_route('192.168.160.0/24')
|
||||
self.q1.run(wait=True)
|
||||
|
@ -20,7 +20,7 @@ import unittest
|
||||
|
||||
from os_ken.tests.integrated.common import docker_base as ctn_base
|
||||
from os_ken.tests.integrated.common import oskenbgp
|
||||
from os_ken.tests.integrated.common import frr
|
||||
from os_ken.tests.integrated.common import quagga
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -45,8 +45,8 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r_img = self.dockerimg.create_os_ken(image=image,
|
||||
check_exist=True)
|
||||
self.images.append(self.r_img)
|
||||
self.frr_img = 'quay.io/frr:9.0.0'
|
||||
self.images.append(self.frr_img)
|
||||
self.q_img = 'osrg/quagga'
|
||||
self.images.append(self.q_img)
|
||||
|
||||
self.r1 = oskenbgp.OSKenBGPContainer(name='r1', asn=64512,
|
||||
router_id='192.168.0.1',
|
||||
@ -57,9 +57,9 @@ class BgpSpeakerTestBase(unittest.TestCase):
|
||||
self.r1_ip_cidr = self.brdc1.addif(self.r1)
|
||||
self.r1_ip = self.r1_ip_cidr.split('/')[0]
|
||||
|
||||
self.q1 = frr.FRRBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.frr_img)
|
||||
self.q1 = quagga.QuaggaBGPContainer(name='q1', asn=64522,
|
||||
router_id='192.168.0.2',
|
||||
ctn_image_name=self.q_img)
|
||||
self.containers.append(self.q1)
|
||||
self.q1.add_route('fc00:100::/64', route_info={'rf': 'ipv6'})
|
||||
self.q1.run(wait=True)
|
||||
|
@ -169,6 +169,37 @@ class DockerImage(object):
|
||||
return tagname
|
||||
self.cmd.sudo("docker rmi -f %s" % tagname, try_times=3)
|
||||
|
||||
def create_quagga(self, tagname='quagga', image=None, check_exist=False):
|
||||
if check_exist and self.exist(tagname):
|
||||
return tagname
|
||||
workdir = os.path.join(TEST_BASE_DIR, tagname)
|
||||
pkges = ' '.join([
|
||||
'telnet',
|
||||
'tcpdump',
|
||||
'quagga-bgpd',
|
||||
])
|
||||
if image:
|
||||
use_image = image
|
||||
else:
|
||||
use_image = self.baseimage
|
||||
c = CmdBuffer()
|
||||
c << 'FROM %s' % use_image
|
||||
c << 'RUN apt-get update'
|
||||
c << 'RUN apt-get install -qy --no-install-recommends %s' % pkges
|
||||
c << 'RUN echo "#!/bin/sh" > /bgpd'
|
||||
c << 'RUN echo mkdir -p /run/quagga >> /bgpd'
|
||||
c << 'RUN echo chmod 755 /run/quagga >> /bgpd'
|
||||
c << 'RUN echo chown quagga:quagga /run/quagga >> /bgpd'
|
||||
c << 'RUN echo exec /usr/sbin/bgpd >> /bgpd'
|
||||
c << 'RUN chmod +x /bgpd'
|
||||
c << 'CMD /bgpd'
|
||||
|
||||
self.cmd.sudo('rm -rf %s' % workdir)
|
||||
self.cmd.execute('mkdir -p %s' % workdir)
|
||||
self.cmd.execute("echo '%s' > %s/Dockerfile" % (str(c), workdir))
|
||||
self.build(tagname, workdir)
|
||||
return tagname
|
||||
|
||||
def create_os_ken(self, tagname='os_ken', image=None, check_exist=False):
|
||||
if check_exist and self.exist(tagname):
|
||||
return tagname
|
||||
|
@ -26,19 +26,20 @@ from . import docker_base as base
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FRRBGPContainer(base.BGPContainer):
|
||||
class QuaggaBGPContainer(base.BGPContainer):
|
||||
|
||||
WAIT_FOR_BOOT = 1
|
||||
SHARED_VOLUME = '/etc/frr'
|
||||
SHARED_VOLUME = '/etc/quagga'
|
||||
|
||||
def __init__(self, name, asn, router_id, ctn_image_name, zebra=False):
|
||||
super(FRRBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name)
|
||||
super(QuaggaBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name)
|
||||
self.shared_volumes.append((self.config_dir, self.SHARED_VOLUME))
|
||||
self.zebra = zebra
|
||||
self._create_config_debian()
|
||||
|
||||
def run(self, wait=False, w_time=WAIT_FOR_BOOT):
|
||||
w_time = super(FRRBGPContainer,
|
||||
w_time = super(QuaggaBGPContainer,
|
||||
self).run(wait=wait, w_time=self.WAIT_FOR_BOOT)
|
||||
return w_time
|
||||
|
||||
@ -163,6 +164,24 @@ class FRRBGPContainer(base.BGPContainer):
|
||||
self._create_config_zebra()
|
||||
self._create_config_daemons(zebra)
|
||||
|
||||
def _create_config_debian(self):
|
||||
c = base.CmdBuffer()
|
||||
c << 'vtysh_enable=yes'
|
||||
c << 'zebra_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'bgpd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospfd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospf6d_options=" --daemon -A ::1"'
|
||||
c << 'ripd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ripngd_options=" --daemon -A ::1"'
|
||||
c << 'isisd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'babeld_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'watchquagga_enable=yes'
|
||||
c << 'watchquagga_options=(--daemon)'
|
||||
with open('{0}/debian.conf'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
f.writelines(str(c))
|
||||
|
||||
def _create_config_daemons(self, zebra='no'):
|
||||
c = base.CmdBuffer()
|
||||
c << 'zebra=%s' % zebra
|
||||
@ -173,15 +192,6 @@ class FRRBGPContainer(base.BGPContainer):
|
||||
c << 'ripngd=no'
|
||||
c << 'isisd=no'
|
||||
c << 'babeld=no'
|
||||
c << 'vtysh_enable=yes'
|
||||
c << 'zebra_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'bgpd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospfd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ospf6d_options=" --daemon -A ::1"'
|
||||
c << 'ripd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'ripngd_options=" --daemon -A ::1"'
|
||||
c << 'isisd_options=" --daemon -A 127.0.0.1"'
|
||||
c << 'babeld_options=" --daemon -A 127.0.0.1"'
|
||||
with open('{0}/daemons'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
@ -249,9 +259,9 @@ class FRRBGPContainer(base.BGPContainer):
|
||||
c << 'debug bgp fsm'
|
||||
c << 'debug bgp updates'
|
||||
c << 'debug bgp events'
|
||||
c << 'log file {0}/frr.log'.format(self.SHARED_VOLUME)
|
||||
c << 'log file {0}/bgpd.log'.format(self.SHARED_VOLUME)
|
||||
|
||||
with open('{0}/frr.conf'.format(self.config_dir), 'w') as f:
|
||||
with open('{0}/bgpd.conf'.format(self.config_dir), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(str(c))
|
||||
f.writelines(str(c))
|
||||
@ -274,10 +284,10 @@ class FRRBGPContainer(base.BGPContainer):
|
||||
def vtysh(self, cmd, config=True):
|
||||
if not isinstance(cmd, list):
|
||||
cmd = [cmd]
|
||||
cmd = ' '.join("-C '{0}'".format(c) for c in cmd)
|
||||
cmd = ' '.join("-c '{0}'".format(c) for c in cmd)
|
||||
if config:
|
||||
return self.exec_on_ctn(
|
||||
"vtysh -d bgpd -C 'en' -C 'conf t' -C "
|
||||
"vtysh -d bgpd -c 'en' -c 'conf t' -c "
|
||||
"'router bgp {0}' {1}".format(self.asn, cmd),
|
||||
capture=True)
|
||||
else:
|
||||
@ -294,7 +304,7 @@ class FRRBGPContainer(base.BGPContainer):
|
||||
self.exec_on_ctn(cmd, capture=True)
|
||||
|
||||
|
||||
class RawFRRBGPContainer(FRRBGPContainer):
|
||||
class RawQuaggaBGPContainer(QuaggaBGPContainer):
|
||||
def __init__(self, name, config, ctn_image_name,
|
||||
zebra=False):
|
||||
asn = None
|
||||
@ -306,15 +316,15 @@ class RawFRRBGPContainer(FRRBGPContainer):
|
||||
if line.startswith('bgp router-id'):
|
||||
router_id = line[len('bgp router-id'):].strip()
|
||||
if not asn:
|
||||
raise Exception('asn not in FRR config')
|
||||
raise Exception('asn not in quagga config')
|
||||
if not router_id:
|
||||
raise Exception('router-id not in FRR config')
|
||||
raise Exception('router-id not in quagga config')
|
||||
self.config = config
|
||||
super(RawFRRBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name, zebra)
|
||||
super(RawQuaggaBGPContainer, self).__init__(name, asn, router_id,
|
||||
ctn_image_name, zebra)
|
||||
|
||||
def create_config(self):
|
||||
with open(os.path.join(self.config_dir, 'frr.conf'), 'w') as f:
|
||||
with open(os.path.join(self.config_dir, 'bgpd.conf'), 'w') as f:
|
||||
LOG.info("[%s's new config]", self.name)
|
||||
LOG.info(self.config)
|
||||
f.writelines(self.config)
|
Loading…
Reference in New Issue
Block a user