Fix warnings reported by gen_doc.sh
[csit.git] / resources / libraries / python / ContainerUtils.py
index ed058b7..9dabc73 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2017 Cisco and/or its affiliates.
+# Copyright (c) 2018 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:
@@ -156,6 +156,12 @@ class ContainerManager(object):
             self.engine.install_vpp()
             self.engine.restart_vpp()
 
+    def restart_vpp_in_all_containers(self):
+        """Restart VPP on all containers."""
+        for container in self.containers:
+            self.engine.container = self.containers[container]
+            self.engine.restart_vpp()
+
     def configure_vpp_in_all_containers(self, vat_template_file):
         """Configure VPP in all containers.
 
@@ -166,18 +172,23 @@ class ContainerManager(object):
         dut_cnt = len(Counter([self.containers[container].node['host']
                                for container in self.containers]))
         container_cnt = len(self.containers)
-        mod = dut_cnt/container_cnt
+        mod = container_cnt/dut_cnt
 
         for i, container in enumerate(self.containers):
+            mid1 = i % mod + 1
+            mid2 = i % mod + 1
+            sid1 = i % mod * 2 + 1
+            sid2 = i % mod * 2 + 2
             self.engine.container = self.containers[container]
             self.engine.create_vpp_startup_config()
-            self.engine.create_vpp_exec_config(vat_template_file,
-                                               memif_id1=i % mod * 2 + 1,
-                                               memif_id2=i % mod * 2 + 2,
-                                               socket1='memif-{c.name}-1'
-                                               .format(c=self.engine.container),
-                                               socket2='memif-{c.name}-2'
-                                               .format(c=self.engine.container))
+            self.engine.create_vpp_exec_config(vat_template_file, mid1=mid1,
+                                               mid2=mid2, sid1=sid1, sid2=sid2,
+                                               socket1='memif-{c.name}-{sid}'
+                                               .format(c=self.engine.container,
+                                                       sid=sid1),
+                                               socket2='memif-{c.name}-{sid}'
+                                               .format(c=self.engine.container,
+                                                       sid=sid2))
 
     def stop_all_containers(self):
         """Stop all containers."""
@@ -270,9 +281,9 @@ class ContainerEngine(object):
     def install_vpp(self, install_dkms=False):
         """Install VPP inside a container.
 
-        :param install_dkms: If install dkms package. This will impact install
-        time. Dkms is required for installation of vpp-dpdk-dkms. Default is
-        false.
+        :param install_dkms: If install dkms package. This will impact
+            install time. Dkms is required for installation of vpp-dpdk-dkms.
+            Default is false.
         :type install_dkms: bool
         """
         self.execute('ln -s /dev/null /etc/sysctl.d/80-vpp.conf')
@@ -286,6 +297,7 @@ class ContainerEngine(object):
                          'do dpkg -i --force-all {0}/install_dir/$i; done'
                          .format(self.container.guest_dir))
         self.execute('apt-get -f install -y')
+        self.execute('apt-get install -y ca-certificates')
         self.execute('echo "{0}" >> {1}'
                      .format(
                          '[program:vpp]\n'
@@ -299,6 +311,7 @@ class ContainerEngine(object):
     def restart_vpp(self):
         """Restart VPP service inside a container."""
         self.execute('supervisorctl restart vpp')
+        self.execute('cat /tmp/supervisord.log')
 
     def create_vpp_startup_config(self,
                                   config_filename='/etc/vpp/startup.conf'):
@@ -321,7 +334,7 @@ class ContainerEngine(object):
         if cpuset_cpus:
             corelist_workers = ','.join(str(cpu) for cpu in cpuset_cpus)
             vpp_config.add_cpu_corelist_workers(corelist_workers)
-        vpp_config.add_plugin_disable('dpdk_plugin.so')
+        vpp_config.add_plugin('disable', 'dpdk_plugin.so')
 
         self.execute('mkdir -p /etc/vpp/')
         self.execute('echo "{c}" | tee {f}'
@@ -405,10 +418,10 @@ class LXC(ContainerEngine):
         """Acquire a privileged system object where configuration is stored.
 
         :param force: If a container exists, destroy it and create a new
-        container.
+            container.
         :type force: bool
         :raises RuntimeError: If creating the container or writing the container
-        config fails.
+            config fails.
         """
         if self.is_container_present():
             if force:
@@ -621,6 +634,8 @@ class Docker(ContainerEngine):
 
         cpuset_mems = '--cpuset-mems={0}'.format(self.container.cpuset_mems)\
             if self.container.cpuset_mems is not None else ''
+        # Temporary workaround - disabling due to bug in memif
+        cpuset_mems = ''
 
         env = '{0}'.format(
             ' '.join('--env %s' % env for env in self.container.env))\