X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FContainerUtils.py;h=111861ab33e652f18d427bd38d0a31ef11340fcd;hb=14a71b74b414df7616ccb5ada3d50ecb90d96bae;hp=6e413c64f023b8e4295c834063cbd4e49aaaa5d3;hpb=dee46d5cedf38248eaf6a54dd273e93a592007b0;p=csit.git diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index 6e413c64f0..111861ab33 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -368,7 +368,7 @@ class ContainerManager: 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" ) @@ -564,12 +564,13 @@ class ContainerEngine: 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): @@ -578,19 +579,25 @@ class ContainerEngine: :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. @@ -668,7 +675,7 @@ class ContainerEngine: :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") @@ -689,7 +696,7 @@ class ContainerEngine: 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}')