fix(core): vppctl path
[csit.git] / resources / libraries / python / ContainerUtils.py
index 3148acf..dc3d3d0 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2022 Cisco and/or its affiliates.
+# Copyright (c) 2023 Cisco and/or its affiliates.
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
 # You may obtain a copy of the License at:
@@ -587,6 +587,12 @@ class ContainerEngine:
         topo_instance = BuiltIn().get_library_instance(
             u"resources.libraries.python.topology.Topology"
         )
+        topo_instance.add_new_socket(
+            self.container.node,
+            SocketType.CLI,
+            self.container.name,
+            self.container.cli_socket,
+        )
         topo_instance.add_new_socket(
             self.container.node,
             SocketType.PAPI,
@@ -630,7 +636,7 @@ class ContainerEngine:
                 # Execute puts the command into single quotes,
                 # so inner arguments are enclosed in qouble quotes here.
                 self.execute(
-                    u'vppctl show pci 2>&1 | '
+                    u'/usr/bin/vppctl show pci 2>&1 | '
                     u'fgrep -v "Connection refused" | '
                     u'fgrep -v "No such file or directory"'
                 )
@@ -734,7 +740,7 @@ class ContainerEngine:
         """
         vpp_config = self.create_base_vpp_startup_config(cpuset_cpus)
         vpp_config.add_dpdk_dev(*devices)
-        vpp_config.add_dpdk_log_level(u".*,debug")
+        vpp_config.add_dpdk_log_level(u"debug")
         vpp_config.add_dpdk_no_tx_checksum_offload()
         vpp_config.add_dpdk_dev_default_rxq(rxq)
         vpp_config.add_plugin(u"enable", u"dpdk_plugin.so")
@@ -801,18 +807,6 @@ class ContainerEngine:
         :type name: str
         :raises RuntimeError: If applying cgroup settings via cgset failed.
         """
-        ret, _, _ = self.container.ssh.exec_command_sudo(
-            u"cgset -r cpuset.cpu_exclusive=0 /"
-        )
-        if int(ret) != 0:
-            raise RuntimeError(u"Failed to apply cgroup settings.")
-
-        ret, _, _ = self.container.ssh.exec_command_sudo(
-            u"cgset -r cpuset.mem_exclusive=0 /"
-        )
-        if int(ret) != 0:
-            raise RuntimeError(u"Failed to apply cgroup settings.")
-
         ret, _, _ = self.container.ssh.exec_command_sudo(
             f"cgcreate -g cpuset:/{name}"
         )
@@ -820,13 +814,13 @@ class ContainerEngine:
             raise RuntimeError(u"Failed to copy cgroup settings from root.")
 
         ret, _, _ = self.container.ssh.exec_command_sudo(
-            f"cgset -r cpuset.cpu_exclusive=0 /{name}"
+            f"cgset -r cpuset.cpus=0 /{name}"
         )
         if int(ret) != 0:
             raise RuntimeError(u"Failed to apply cgroup settings.")
 
         ret, _, _ = self.container.ssh.exec_command_sudo(
-            f"cgset -r cpuset.mem_exclusive=0 /{name}"
+            f"cgset -r cpuset.mems=0 /{name}"
         )
         if int(ret) != 0:
             raise RuntimeError(u"Failed to apply cgroup settings.")
@@ -857,7 +851,7 @@ class LXC(ContainerEngine):
             else u"amd64"
 
         image = self.container.image if self.container.image \
-            else f"-d ubuntu -r focal -a {target_arch}"
+            else f"-d ubuntu -r jammy -a {target_arch}"
 
         cmd = f"lxc-create -t download --name {self.container.name} " \
             f"-- {image} --no-validate"
@@ -1122,8 +1116,8 @@ class Docker(ContainerEngine):
             if self.container.mnt else u""
 
         cmd = f"docker run --privileged --detach --interactive --tty --rm " \
-            f"--cgroup-parent docker {cpuset_cpus} {cpuset_mems} {publish} " \
-            f"{env} {volume} --name {self.container.name} " \
+            f"--cgroup-parent docker.slice {cpuset_cpus} {cpuset_mems} " \
+            f"{publish} {env} {volume} --name {self.container.name} " \
             f"{self.container.image} {command}"
 
         ret, _, _ = self.container.ssh.exec_command_sudo(cmd)
@@ -1277,6 +1271,7 @@ class Container:
                 path = f"/tmp/vpp_sockets/{value}"
                 self.__dict__[u"socket_dir"] = path
                 self.__dict__[u"api_socket"] = f"{path}/api.sock"
+                self.__dict__[u"cli_socket"] = f"{path}/cli.sock"
                 self.__dict__[u"stats_socket"] = f"{path}/stats.sock"
             self.__dict__[attr] = value
         else: