Using no-pci option rather than removing the dpdk-plugin in vpp. Removed starting... 25/8225/3
authorAlberto Compagno <[email protected]>
Mon, 28 Aug 2017 13:42:53 +0000 (15:42 +0200)
committerAlberto <[email protected]>
Mon, 28 Aug 2017 15:11:45 +0000 (17:11 +0200)
Change-Id: I395bf92771bf27cf25324d208b847b640ccc475c
Signed-off-by: Alberto Compagno <[email protected]>
vicn/resource/icn/cicn.py
vicn/resource/linux/file.py
vicn/resource/lxd/lxc_container.py
vicn/resource/vpp/interface.py
vicn/resource/vpp/scripts.py
vicn/resource/vpp/vpp.py
vicn/resource/vpp/vpp_commands.py
vicn/resource/vpp/vpp_host.py

index 76dafe0..8ab36ec 100644 (file)
@@ -31,7 +31,7 @@ from vicn.resource.vpp.vpp_commands import CMD_VPP_ENABLE_PLUGIN
 
 CMD_VPP_CICN_GET = "vppctl_wrapper cicn show"
 CMD_VPP_ADD_ICN_ROUTE = 'vppctl_wrapper cicn cfg fib add prefix {route.prefix} face {route.face.id}'
-CMD_VPP_ADD_ICN_FACE = 'vppctl_wrapper cicn cfg face add local {face.src_ip}:{face.src_port} remote {face.dst_ip}:{face.dst_port}'
+CMD_VPP_ADD_ICN_FACE = 'vppctl_wrapper cicn cfg face add local {face.src.ip4_address}:{face.src_port} remote {face.dst.ip4_address}:{face.dst_port}'
 
 CMD_VPP_CICN_GET_CACHE_SIZE = 'vppctl_wrapper cicn show | grep "CS entries" | grep -Eo "[0-9]+"'
 CMD_VPP_CICN_SET_CACHE_SIZE = 'vppctl_wrapper cicn control param cs size {self.cache_size}'
@@ -95,7 +95,7 @@ class CICNForwarder(Forwarder):
         for face in self.faces:
             face_task = face_task > BashTask(self.node, CMD_VPP_ADD_ICN_FACE,
                     {'face':face},
-                    parse = (lambda x : parse_face(x, face)), lock = lock)
+                    parse = (lambda x, y=face : parse_face(x, y)), lock = lock)
 
         if not self.routes:
             from vicn.resource.icn.route import Route
index 2a62f60..24ead99 100644 (file)
@@ -34,6 +34,10 @@ GREP_FILE_CMD   = "cat {file.filename}"
 
 CMD_PRINT_TO_FILE = 'echo -n "{file.content}" > {file.filename}'
 
+GET_FILE_EXEC_CMD = 'test -x {file.filename} && echo True || echo False'
+
+CMD_MAKE_FILE_EXEC = 'chmod +x {file.filename}'
+
 class File(Resource):
     """
     Resource: File
@@ -95,6 +99,9 @@ class TextFile(File):
     """
 
     content = Attribute(String, default='')
+    executable = Attribute(Bool,
+            description = 'Determines whether the file has to be set as an executable',
+            default = False)
 
     #--------------------------------------------------------------------------
     # Resource lifecycle
@@ -115,3 +122,10 @@ class TextFile(File):
     def _get_content(self):
         return BashTask(self.node, GREP_FILE_CMD, {'file': self},
                 parse =( lambda x : x.stdout))
+
+    def _get_executable(self):
+        return BashTask(self.node, GET_FILE_EXEC_CMD, {'file': self},
+                parse =( lambda x : x.stdout))
+
+    def _set_executable(self):
+        return BashTask(self.node, CMD_MAKE_FILE_EXEC, {'file':self})
index 5b1d4e3..a9f8483 100644 (file)
@@ -18,6 +18,7 @@
 
 import logging
 import shlex
+import time
 
 # Suppress logging from pylxd dependency on ws4py
 # (this needs to be included before pylxd)
@@ -251,7 +252,7 @@ class LxcContainer(Node):
         Method: Start the container
         """
         self._container.start(wait = True)
-        import time; time.sleep(1)
+        time.sleep(1)
 
     @task
     def __method_stop__(self):
index d053866..9dbd7fc 100644 (file)
@@ -151,8 +151,6 @@ class VPPInterface(Resource):
                     {'vpp_interface': self},
                     lock = self.vpp.vppctl_lock)
 
-            self.parent.set('ip4_address', None)
-            self.parent.set('ip6_address', None)
             self.parent.set('offload', False)
             self.parent.remote.set('offload', False)
 
index d513021..06da740 100644 (file)
@@ -285,3 +285,11 @@ APPARMOR_VPP_PROFILE = '''
 lxc.aa_profile = lxc-dpdk
 lxc.mount.entry = hugetlbfs dev/hugepages hugetlbfs rw,relatime,create=dir 0 0
 lxc.mount.auto = sys:rw'''
+
+FN_VPPCTL_WRAPPER_SCRIPT='/usr/bin/vppctl_wrapper'
+
+TPL_VPPCTL_WRAPPER_SCRIPT='''#!/bin/bash
+TIMEOUT=5
+
+flock /tmp/vppctl.lock -c \\"timeout \\$TIMEOUT vppctl \\$*\\"
+'''
index 8250f99..9d4f706 100644 (file)
@@ -31,10 +31,11 @@ from vicn.resource.linux.file           import TextFile
 from vicn.resource.vpp.dpdk_device      import DpdkDevice
 from vicn.resource.vpp.scripts          import FN_VPP_DPDK_SCRIPT
 from vicn.resource.vpp.scripts          import TPL_VPP_DPDK_DAEMON_SCRIPT
+from vicn.resource.vpp.scripts          import FN_VPPCTL_WRAPPER_SCRIPT
+from vicn.resource.vpp.scripts          import TPL_VPPCTL_WRAPPER_SCRIPT
 from vicn.resource.vpp.vpp_commands     import CMD_VPP_DISABLE, CMD_VPP_STOP
 from vicn.resource.vpp.vpp_commands     import CMD_VPP_START
 from vicn.resource.vpp.vpp_commands     import CMD_VPP_ENABLE_PLUGIN
-from vicn.resource.vpp.vpp_commands     import CMD_REMOVE_DPDK_PLUGIN
 from vicn.resource.vpp.vpp_host         import VPPHost
 
 #------------------------------------------------------------------------------
@@ -136,8 +137,8 @@ class VPP(LinuxApplication):
                 dpdk_list.append('dev ' + interface.pci_address)
 
         setup = setup + '''\n}\n\n'''
+        setup = setup + 'dpdk {'
         if dpdk_list:
-            setup = setup + 'dpdk {'
             # add socket_mem
             # On numa architecture socket-mem requires to set the amount of memory
             # to be reserved on each numa node
@@ -156,13 +157,21 @@ class VPP(LinuxApplication):
             for dpdk_dev in dpdk_list:
                 setup = setup + ''' \n  ''' + dpdk_dev
             setup = setup + '''\n}'''
+        else:
+            setup = setup + '''\n no-pci \n}'''
 
         dpdk_setup_file = TextFile(node = self.node,
                 filename = FN_VPP_DPDK_SCRIPT,
                 content = setup,
                 overwrite = True)
 
-        return dpdk_setup_file
+        vppctl_wrapper_file = TextFile(node = self.node,
+                filename = FN_VPPCTL_WRAPPER_SCRIPT,
+                content = TPL_VPPCTL_WRAPPER_SCRIPT,
+                executable = True,
+                overwrite = True)
+
+        return dpdk_setup_file | vppctl_wrapper_file
 
     @inherit_parent
     def __create__(self):
@@ -179,11 +188,7 @@ class VPP(LinuxApplication):
                 found = True
                 break
 
-        remove_dpdk_plugin = EmptyTask()
-        if (not found):
-            remove_dpdk_plugin = BashTask(self.node, CMD_REMOVE_DPDK_PLUGIN, lock = lock)
-
-        return (((vpp_disable > vpp_stop) | enable_ip_forward) > (remove_dpdk_plugin > start_vpp))
+        return (((vpp_disable > vpp_stop) | enable_ip_forward) > start_vpp)
 
     @inherit_parent
     def __delete__(self):
index 30898ea..acc8964 100644 (file)
@@ -13,11 +13,6 @@ flock /tmp/vppctl.lock -c "systemctl stop vpp"
 #killall -9 vpp_main || true
 CMD_VPP_ENABLE_PLUGIN = 'vppctl_wrapper {plugin} control start'
 
-CMD_REMOVE_DPDK_PLUGIN = '''
-rm /usr/lib/vpp_api_test_plugins/dpdk_test_plugin.so
-rm /usr/lib/vpp_plugins/dpdk_plugin.so
-'''
-
 ##### VPP INTERFACES #####
 
 CMD_VPP_CREATE_IFACE = '''
index 2909445..60fdfd4 100644 (file)
@@ -96,11 +96,7 @@ class VPPHost(LinuxApplication):
                 filename = FN_APPARMOR_DPDK_SCRIPT,
                 content = TPL_APPARMOR_DPDK_SCRIPT,
                 overwrite = True)
-        startup_conf = TextFile(node = self.node,
-                filename = FN_VPP_DPDK_SCRIPT,
-                content = TPL_VPP_DPDK_DAEMON_SCRIPT,
-                overwrite = True)
-        return app_armor_file | startup_conf
+        return app_armor_file
 
     @inherit_parent
     @task
@@ -118,23 +114,13 @@ class VPPHost(LinuxApplication):
         sysctl_hugepages = BashTask(self.node, CMD_SYSCTL_HUGEPAGES,
                 {'nb_hp': DEFAULT_NB_HUGEPAGES})
 
-        # Hook
-        # The following is needed to create uio devices in /dev. They are
-        # required to let vpp to use dpdk (or other compatibles) nics. From a
-        # container, vpp cannot create those devices, therefore we need to
-        # create them in the host and then mount them on each container running
-        # vpp (and using a physical nic)
-        stop_vpp = BashTask(self.node, CMD_VPP_STOP_SERVICE + " || true")
-        disable_vpp = BashTask(self.node, CMD_VPP_DISABLE + " || true")
-        disable_vpp = stop_vpp > disable_vpp
-
         create_uio = EmptyTask()
         for device in self.dpdk_devices:
             create_uio = create_uio > BashTask(self.node,
                     CMD_CREATE_UIO_DEVICES, {'pci_address' : device})
 
         return ((modules | app_armor_reload) | sysctl_hugepages) > \
-            (disable_vpp > create_uio)
+            create_uio
 
     #--------------------------------------------------------------------------
     # Attributes