Addition of Configurable Sampling and Configurable Confirmation Retry
[yardstick.git] / yardstick / network_services / traffic_profile / base.py
index 9064985..9eba550 100644 (file)
 # 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 for the generic traffic profile implementation """
 
-from __future__ import absolute_import
-from yardstick.common.utils import import_modules_from_package, itersubclasses
+from yardstick.common import exceptions
+from yardstick.common import utils
 
 
 class TrafficProfile(object):
@@ -22,6 +21,8 @@ class TrafficProfile(object):
     This class defines the behavior
 
     """
+    UPLINK = "uplink"
+    DOWNLINK = "downlink"
 
     @staticmethod
     def get(tp_config):
@@ -31,20 +32,19 @@ class TrafficProfile(object):
         :return:
         """
         profile_class = tp_config["traffic_profile"]["traffic_type"]
-        import_modules_from_package(
-            "yardstick.network_services.traffic_profile")
         try:
-            return next(c for c in itersubclasses(TrafficProfile)
+            return next(c for c in utils.itersubclasses(TrafficProfile)
                         if c.__name__ == profile_class)(tp_config)
         except StopIteration:
-            raise RuntimeError("No implementation for %s", profile_class)
+            raise exceptions.TrafficProfileNotImplemented(
+                profile_class=profile_class)
 
     def __init__(self, tp_config):
         # e.g. RFC2544 start_ip, stop_ip, drop_rate,
         # IMIX = {"10K": 0.1, "100M": 0.5}
         self.params = tp_config
 
-    def execute(self, traffic_generator):
+    def execute_traffic(self, traffic_generator, **kawrgs):
         """ This methods defines the behavior of the traffic generator.
         It will be called in a loop until the traffic generator exits.