X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FContainerUtils.py;h=6fea8044434dbe702939b42c61b73bac802ad157;hb=9efba1d574916eded1a6d4d8580e092a8831033b;hp=a324465eaf0d2f710939ab696c2e7195e1291f97;hpb=f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f;p=csit.git diff --git a/resources/libraries/python/ContainerUtils.py b/resources/libraries/python/ContainerUtils.py index a324465eaf..6fea804443 100644 --- a/resources/libraries/python/ContainerUtils.py +++ b/resources/libraries/python/ContainerUtils.py @@ -21,7 +21,7 @@ from collections import OrderedDict, Counter from resources.libraries.python.ssh import SSH from resources.libraries.python.Constants import Constants -from resources.libraries.python.topology import Topology +from resources.libraries.python.topology import Topology, SocketType from resources.libraries.python.VppConfigGenerator import VppConfigGenerator @@ -430,6 +430,22 @@ class ContainerEngine(object): self.execute('supervisorctl reload') self.execute('supervisorctl start vpp') + from robot.libraries.BuiltIn import BuiltIn + topo_instance = BuiltIn().get_library_instance( + 'resources.libraries.python.topology.Topology') + topo_instance.add_new_socket( + self.container.node, + SocketType.PAPI, + self.container.name, + '{root}/tmp/vpp_sockets/{name}/api.sock'. + format(root=self.container.root, name=self.container.name)) + topo_instance.add_new_socket( + self.container.node, + SocketType.STATS, + self.container.name, + '{root}/tmp/vpp_sockets/{name}/stats.sock'. + format(root=self.container.root, name=self.container.name)) + def restart_vpp(self): """Restart VPP service inside a container.""" self.execute('supervisorctl restart vpp') @@ -449,7 +465,8 @@ class ContainerEngine(object): vpp_config.add_unix_cli_listen() vpp_config.add_unix_nodaemon() vpp_config.add_unix_exec('/tmp/running.exec') - vpp_config.add_socksvr() + vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH) + vpp_config.add_statseg_per_node_counters(value='on') # We will pop the first core from the list to be a main core vpp_config.add_cpu_main_core(str(cpuset_cpus.pop(0))) # If more cores in the list, the rest will be used as workers. @@ -499,7 +516,8 @@ class ContainerEngine(object): vpp_config.add_unix_cli_listen() vpp_config.add_unix_nodaemon() vpp_config.add_unix_exec('/tmp/running.exec') - vpp_config.add_socksvr() + vpp_config.add_socksvr(socket=Constants.SOCKSVR_PATH) + vpp_config.add_statseg_per_node_counters(value='on') vpp_config.add_plugin('disable', 'dpdk_plugin.so') # Apply configuration @@ -593,8 +611,12 @@ class LXC(ContainerEngine): else: return + target_arch = 'arm64' \ + if Topology.get_node_arch(self.container.node) == 'aarch64' \ + else 'amd64' + image = self.container.image if self.container.image else\ - "-d ubuntu -r bionic -a amd64" + "-d ubuntu -r bionic -a {arch}".format(arch=target_arch) cmd = 'lxc-create -t download --name {c.name} -- {image} '\ '--no-validate'.format(c=self.container, image=image) @@ -613,13 +635,16 @@ class LXC(ContainerEngine): if self.container.mnt: for mount in self.container.mnt: host_dir, guest_dir = mount.split(':') + if host_dir.endswith('/'): + self.container.ssh.exec_command_sudo( + "sh -c 'mkdir -p {host_dir}'".format(host_dir=host_dir)) options = 'bind,create=dir' \ if guest_dir.endswith('/') else 'bind,create=file' entry = 'lxc.mount.entry = {host_dir} '\ - '/var/lib/lxc/{c.name}/rootfs{guest_dir} none ' \ + '{guest_dir} none ' \ '{options} 0 0'.format(c=self.container, host_dir=host_dir, - guest_dir=guest_dir, + guest_dir=guest_dir[1:], options=options) ret, _, _ = self.container.ssh.exec_command_sudo( "sh -c 'echo \"{e}\" >> /var/lib/lxc/{c.name}/config'". @@ -786,8 +811,10 @@ class Docker(ContainerEngine): return if not self.container.image: - setattr(self.container, 'image', - Constants.DOCKER_SUT_IMAGE_UBUNTU) + img = Constants.DOCKER_SUT_IMAGE_UBUNTU_ARM \ + if Topology.get_node_arch(self.container.node) == 'aarch64' \ + else Constants.DOCKER_SUT_IMAGE_UBUNTU + setattr(self.container, 'image', img) cmd = 'docker pull {image}'.format(image=self.container.image) @@ -795,6 +822,7 @@ class Docker(ContainerEngine): if int(ret) != 0: raise RuntimeError('Failed to create container {c.name}.' .format(c=self.container)) + if self.container.cpuset_cpus: self._configure_cgroup('docker')