Merge "multi-queue: Add basic multi-queue functionality"
[vswitchperf.git] / core / traffic_controller.py
1 # Copyright 2015 Intel Corporation.
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #   http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 """Interface to traffic controllers
16 """
17
18 class ITrafficController(object):
19     """Abstract class which defines a traffic controller object
20
21     Used to setup and control a traffic generator for a particular deployment
22     scenario.
23     """
24
25     def send_traffic(self, traffic):
26         """Triggers traffic to be sent from the traffic generator.
27
28         This is a blocking function.
29
30         :param traffic: A dictionary describing the traffic to send.
31         """
32         raise NotImplementedError(
33             "The TrafficController does not implement",
34             "the \"send_traffic\" function.")
35
36     def send_traffic_async(self, traffic, function):
37         """Triggers traffic to be sent  asynchronously.
38
39         This is not a blocking function.
40
41         :param traffic: A dictionary describing the traffic to send.
42         :param function: A dictionary describing the function to call between
43              send and wait in the form:
44              function = {
45                  'function' : package.module.function,
46                  'args' : args
47              }
48              If this function requires more than one argument, all should be
49              should be passed using the args list and appropriately handled.
50          """
51         raise NotImplementedError(
52             "The TrafficController does not implement",
53             "the \"send_traffic_async\" function.")
54
55     def stop_traffic(self):
56         """Kills traffic being sent from the traffic generator.
57         """
58         raise NotImplementedError(
59             "The TrafficController does not implement",
60             "the \"stop_traffic\" function.")