add yardstick iruya 9.0.0 release notes
[yardstick.git] / yardstick / network_services / vnf_generic / vnf / base.py
index a776b09..8ef96b7 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (c) 2016-2017 Intel Corporation
+# Copyright (c) 2016-2019 Intel Corporation
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 # See the License for the specific language governing permissions and
 # limitations under the License.
-""" Base class implementation for generic vnf implementation """
 
 import abc
 
@@ -95,7 +94,7 @@ class VnfdHelper(dict):
         for interface in self.interfaces:
             virtual_intf = interface["virtual-interface"]
             if virtual_intf[key] == value:
-                return interface
+                return virtual_intf
         raise KeyError()
 
     def find_interface(self, **kwargs):
@@ -195,10 +194,22 @@ class GenericVNF(object):
         :return: {"kpi": value, "kpi2": value}
         """
 
+    @abc.abstractmethod
+    def start_collect(self):
+        """Start KPI collection
+        :return: None
+        """
+
+    @abc.abstractmethod
+    def stop_collect(self):
+        """Stop KPI collection
+        :return: None
+        """
+
 
 @six.add_metaclass(abc.ABCMeta)
 class GenericTrafficGen(GenericVNF):
-    """ Class providing file-like API for generic traffic generator """
+    """Class providing file-like API for generic traffic generator"""
 
     def __init__(self, name, vnfd):
         super(GenericTrafficGen, self).__init__(name, vnfd)
@@ -254,3 +265,23 @@ class GenericTrafficGen(GenericVNF):
         :return: True/False
         """
         pass
+
+    def start_collect(self):
+        """Start KPI collection.
+
+        Traffic measurements are always collected during injection.
+
+        Optional.
+
+        :return: True/False
+        """
+        pass
+
+    def stop_collect(self):
+        """Stop KPI collection.
+
+        Optional.
+
+        :return: True/False
+        """
+        pass