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}'
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
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
"""
content = Attribute(String, default='')
+ executable = Attribute(Bool,
+ description = 'Determines whether the file has to be set as an executable',
+ default = False)
#--------------------------------------------------------------------------
# Resource lifecycle
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})
import logging
import shlex
+import time
# Suppress logging from pylxd dependency on ws4py
# (this needs to be included before pylxd)
Method: Start the container
"""
self._container.start(wait = True)
- import time; time.sleep(1)
+ time.sleep(1)
@task
def __method_stop__(self):
{'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)
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 \\$*\\"
+'''
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
#------------------------------------------------------------------------------
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
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):
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):
#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 = '''
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
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