aboutsummaryrefslogtreecommitdiffstats
path: root/vnfs/vnf/vnf.py
diff options
context:
space:
mode:
authorMartin Klozik <martinx.klozik@intel.com>2015-09-25 18:00:17 +0100
committerMaryam Tahhan <maryam.tahhan@intel.com>2015-10-07 14:53:13 +0000
commit89e23da8e473387b2e6cb37a2b882d2d3c68655c (patch)
tree41bd86bc1447bf9bcbfa33cd95f175c258ede9d7 /vnfs/vnf/vnf.py
parent1550b638fca662c5e68556702ff0316c3fc9562c (diff)
Enable PVVP deployment for DPDK Vhost User and Vhost Cuse
Generic PVVP deployment support has been added. Two new testcase scenarios for throughput and back2back tests with PVVP deployment were added. Original implementation of PVP has been refactored Following files were affected: modified: conf/01_testcases.conf modified: conf/02_vswitch.conf modified: conf/04_vnf.conf modified: core/__init__.py modified: core/component_factory.py modified: core/loader/loader_servant.py modified: core/vnf_controller.py deleted: core/vnf_controller_p2p.py deleted: core/vnf_controller_pvp.py modified: core/vswitch_controller_p2p.py modified: core/vswitch_controller_pvp.py new file: core/vswitch_controller_pvvp.py modified: docs/to-be-reorganized/NEWS.rst modified: docs/to-be-reorganized/quickstart.rst modified: src/dpdk/dpdk.py modified: src/ovs/ofctl.py modified: testcases/testcase.py modified: tools/tasks.py new file: vnfs/qemu/qemu.py new file: vnfs/qemu/qemu_dpdk.py modified: vnfs/qemu/qemu_dpdk_vhost_cuse.py modified: vnfs/qemu/qemu_dpdk_vhost_user.py modified: vnfs/vnf/vnf.py modified: vswitches/ovs_dpdk_vhost.py Change-Id: Ib6869a29337a184cb58c57fd96bba1183aba00ab JIRA: VSPERF-68, VSPERF-69 Signed-off-by: Martin Klozik (martinx.klozik@intel.com) Reviewed-by: Maryam Tahhan <maryam.tahhan@intel.com> Reviewed-by: Brian Castelli <brian.castelli@spirent.com>
Diffstat (limited to 'vnfs/vnf/vnf.py')
-rw-r--r--vnfs/vnf/vnf.py70
1 files changed, 37 insertions, 33 deletions
diff --git a/vnfs/vnf/vnf.py b/vnfs/vnf/vnf.py
index c746aa83..f8d2df90 100644
--- a/vnfs/vnf/vnf.py
+++ b/vnfs/vnf/vnf.py
@@ -16,55 +16,56 @@
Interface for VNF.
"""
+import time
+from tools import tasks
-class IVnf(object):
+class IVnf(tasks.Process):
"""
Interface for VNF.
"""
- def __init__(self, memory, cpus,
- monitor_path, shared_path_host,
- shared_path_guest, guest_prompt):
+ _number_vnfs = 0
+
+ def __init__(self):
"""
Initialization method.
Purpose of this method is to initialize all
common Vnf data, no services should be started by
this call (use ``start`` method instead).
-
- :param memory: Virtual RAM size in megabytes.
- :param cpus: Number of Processors.
- :param monitor_path: Configure monitor to given path.
- :param shared_path_host: HOST path to shared location.
- :param shared_path_guest: GUEST path to shared location.
- :param guest_prompt: preconfigured command prompt which is used
- in execute_and_wait & wait methods
- to detect if particular call is finished.
"""
- raise NotImplementedError()
+ self._number = IVnf._number_vnfs
+ IVnf._number_vnfs = IVnf._number_vnfs + 1
+ self._log_prefix = 'vnf_%d_cmd : ' % self._number
def start(self):
"""
Starts VNF instance.
+
+ This is a blocking function
"""
- raise NotImplementedError()
+ super(IVnf, self).start()
def stop(self):
"""
Stops VNF instance.
"""
- raise NotImplementedError()
+ self._logger.info('Killing VNF...')
+
+ # force termination of VNF and wait for it to terminate; It will avoid
+ # sporadic reboot of host. (caused by hugepages or DPDK ports)
+ super(IVnf, self).kill(signal='-9', sleep=10)
- def execute(self, command, delay=30):
+ def execute(self, cmd, delay=0):
"""
- execute ``command`` with given ``delay``.
+ execute ``cmd`` with given ``delay``.
This method makes asynchronous call to guest system
and waits given ``delay`` before returning. Can be
used with ``wait`` method to create synchronous call.
- :param command: Command to execute on guest system.
+ :param cmd: Command to execute on guest system.
:param delay: Delay (in seconds) to wait after sending
command before returning. Please note that
this value can be floating point which
@@ -72,17 +73,19 @@ class IVnf(object):
:returns: None.
"""
- raise NotImplementedError()
+ self._logger.debug('%s%s', self._log_prefix, cmd)
+ self._child.sendline(cmd)
+ time.sleep(delay)
- def wait(self, guest_prompt, timeout=30):
+ def wait(self, prompt='', timeout=30):
"""
- wait for ``guest_prompt`` on guest system for given ``timeout``.
+ wait for ``prompt`` on guest system for given ``timeout``.
This method ends based on two conditions:
- * ``guest_prompt`` has been detected
+ * ``prompt`` has been detected
* ``timeout`` has been reached.
- :param guest_prompt: method end condition. If ``guest_prompt``
+ :param prompt: method end condition. If ``prompt``
won't be detected during given timeout,
method will return False.
:param timeout: Time to wait for prompt (in seconds).
@@ -92,28 +95,29 @@ class IVnf(object):
:returns: True if result_cmd has been detected before
timeout has been reached, False otherwise.
"""
- raise NotImplementedError()
+ self._child.expect(prompt, timeout=timeout)
- def execute_and_wait(self, command, timeout=30, guest_prompt=None):
+ def execute_and_wait(self, cmd, timeout=30, prompt=''):
"""
- execute ``command`` with given ``timeout``.
+ execute ``cmd`` with given ``timeout``.
This method makes synchronous call to guest system
- and waits till ``command`` execution is finished
- (based on ``guest_prompt value) or ''timeout'' has
+ and waits till ``cmd`` execution is finished
+ (based on ``prompt value) or ''timeout'' has
been reached.
- :param command: Command to execute on guest system.
+ :param cmd: Command to execute on guest system.
:param timeout: Timeout till the end of execution is not
detected.
- :param guest_prompt: method end condition. If ``guest_prompt``
+ :param prompt: method end condition. If ``prompt``
won't be detected during given timeout,
method will return False. If no argument
or None value will be passed, default
- ``guest_prompt`` passed in __init__
+ ``prompt`` passed in __init__
method will be used.
:returns: True if end of execution has been detected
before timeout has been reached, False otherwise.
"""
- raise NotImplementedError()
+ self.execute(cmd)
+ self.wait(prompt=prompt, timeout=timeout)