f"create interface memif id {i} socket-id 2 master\n"
f"set interface state memif2/{i} up\n"
f"set interface l2 bridge memif2/{i} 2\n"
- f"set ip arp memif2/{i} {tg_if_ip4} {tg_if_mac} "
+ f"set ip neighbor memif2/{i} {tg_if_ip4} {tg_if_mac} "
f"static\n\n"
)
self.container.name,
f"/tmp/vpp_sockets/{self.container.name}/stats.sock"
)
+ self.verify_vpp()
+ self.adjust_privileges()
def restart_vpp(self):
"""Restart VPP service inside a container."""
self.execute(u"pkill vpp")
self.start_vpp()
- self.execute(u"cat /tmp/vppd.log")
# TODO Rewrite to use the VPPUtil.py functionality and remove this.
def verify_vpp(self, retries=120, retry_wait=1):
:param retries: Check for VPP for this number of times Default: 120
:param retry_wait: Wait for this number of seconds between retries.
"""
- cmd = (u"vppctl show pci 2>&1 | "
- u"fgrep -v 'Connection refused' | "
- u"fgrep -v 'No such file or directory'")
-
for _ in range(retries + 1):
try:
- self.execute(cmd)
+ self.execute(
+ u"vppctl show pci 2>&1 | "
+ u"fgrep -v 'Connection refused' | "
+ u"fgrep -v 'No such file or directory'"
+ )
break
except RuntimeError:
sleep(retry_wait)
else:
- msg = f"VPP did not come up in container: {self.container.name}"
- raise RuntimeError(msg)
+ self.execute(u"cat /tmp/vppd.log")
+ raise RuntimeError(
+ f"VPP did not come up in container: {self.container.name}"
+ )
+
+ def adjust_privileges(self):
+ """Adjust privileges to control VPP without sudo."""
+ self.execute("chmod -R o+rwx /run/vpp")
def create_base_vpp_startup_config(self, cpuset_cpus=None):
"""Create base startup configuration of VPP on container.
:type cpuset_cpus: list
"""
vpp_config = self.create_base_vpp_startup_config(cpuset_cpus)
- vpp_config.add_plugin(u"enable", u"crypto_ia32_plugin.so")
+ vpp_config.add_plugin(u"enable", u"crypto_native_plugin.so")
vpp_config.add_plugin(u"enable", u"crypto_ipsecmb_plugin.so")
vpp_config.add_plugin(u"enable", u"crypto_openssl_plugin.so")
running = u"/tmp/running.exec"
template = f"{Constants.RESOURCES_TPL_CONTAINER}/{template_file}"
- with open(template, "r") as src_file:
+ with open(template, u"rt") as src_file:
src = Template(src_file.read())
self.execute(f'echo "{src.safe_substitute(**kwargs)}" > {running}')