aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlberto Compagno <acompagn+fdio@cisco.com>2017-08-28 15:42:53 +0200
committerAlberto <acompagn+fdio@cisco.com>2017-08-28 17:11:45 +0200
commit190c70c461a3808297b397cda14f35867bd837f8 (patch)
treea758805fd0db3f36499b854c2a3407346cb86d01
parente4d3f8ca1c9e130c4cbb3211b9ac0850c2456973 (diff)
Using no-pci option rather than removing the dpdk-plugin in vpp. Removed starting and stopping of vpp in the host to add the uio devices in the containers. Added executable option in the TextFile resource. vICN now deploy the vppctl_wrapper command in every container runing vpp. Several bugfixes on the cicn plugin.
Change-Id: I395bf92771bf27cf25324d208b847b640ccc475c Signed-off-by: Alberto Compagno <acompagn+fdio@cisco.com>
-rw-r--r--vicn/resource/icn/cicn.py4
-rw-r--r--vicn/resource/linux/file.py14
-rw-r--r--vicn/resource/lxd/lxc_container.py3
-rw-r--r--vicn/resource/vpp/interface.py2
-rw-r--r--vicn/resource/vpp/scripts.py8
-rw-r--r--vicn/resource/vpp/vpp.py21
-rw-r--r--vicn/resource/vpp/vpp_commands.py5
-rw-r--r--vicn/resource/vpp/vpp_host.py18
8 files changed, 41 insertions, 34 deletions
diff --git a/vicn/resource/icn/cicn.py b/vicn/resource/icn/cicn.py
index 76dafe0e..8ab36ec9 100644
--- a/vicn/resource/icn/cicn.py
+++ b/vicn/resource/icn/cicn.py
@@ -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
diff --git a/vicn/resource/linux/file.py b/vicn/resource/linux/file.py
index 2a62f60e..24ead998 100644
--- a/vicn/resource/linux/file.py
+++ b/vicn/resource/linux/file.py
@@ -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})
diff --git a/vicn/resource/lxd/lxc_container.py b/vicn/resource/lxd/lxc_container.py
index 5b1d4e3b..a9f8483d 100644
--- a/vicn/resource/lxd/lxc_container.py
+++ b/vicn/resource/lxd/lxc_container.py
@@ -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):
diff --git a/vicn/resource/vpp/interface.py b/vicn/resource/vpp/interface.py
index d0538661..9dbd7fc3 100644
--- a/vicn/resource/vpp/interface.py
+++ b/vicn/resource/vpp/interface.py
@@ -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)
diff --git a/vicn/resource/vpp/scripts.py b/vicn/resource/vpp/scripts.py
index d5130212..06da7404 100644
--- a/vicn/resource/vpp/scripts.py
+++ b/vicn/resource/vpp/scripts.py
@@ -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 \\$*\\"
+'''
diff --git a/vicn/resource/vpp/vpp.py b/vicn/resource/vpp/vpp.py
index 8250f99a..9d4f7068 100644
--- a/vicn/resource/vpp/vpp.py
+++ b/vicn/resource/vpp/vpp.py
@@ -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):
diff --git a/vicn/resource/vpp/vpp_commands.py b/vicn/resource/vpp/vpp_commands.py
index 30898eae..acc89640 100644
--- a/vicn/resource/vpp/vpp_commands.py
+++ b/vicn/resource/vpp/vpp_commands.py
@@ -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 = '''
diff --git a/vicn/resource/vpp/vpp_host.py b/vicn/resource/vpp/vpp_host.py
index 29094451..60fdfd47 100644
--- a/vicn/resource/vpp/vpp_host.py
+++ b/vicn/resource/vpp/vpp_host.py
@@ -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