test_spec: LTD: Add Caution for Scaleability Address Time-out.
[vswitchperf.git] / core / component_factory.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 """Functions for creating controller objects based on deployment or traffic
16 """
17
18 from core.traffic_controller_rfc2544 import TrafficControllerRFC2544
19 from core.vswitch_controller_p2p import VswitchControllerP2P
20 from core.vswitch_controller_pvp import VswitchControllerPVP
21 from core.vswitch_controller_pvvp import VswitchControllerPVVP
22 from core.vnf_controller import VnfController
23 from tools.load_gen.stress.stress import Stress
24 from tools.load_gen.stress_ng.stress_ng import StressNg
25 from tools.load_gen.dummy.dummy import DummyLoadGen
26
27
28 def __init__():
29     """Finds and loads all the modules required.
30
31     Very similar code to load_trafficgens().
32     """
33     pass
34
35 def create_traffic(traffic_type, trafficgen_class):
36     """Return a new IVSwitchController for the traffic type.
37
38     The returned traffic controller has the given traffic type and traffic
39     generator class.
40
41     traffic_types: 'rfc2544_throughput'
42
43     :param traffic_type: Name of traffic type
44     :param trafficgen_class: Reference to traffic generator class to be used.
45     :return: A new ITrafficController
46     """
47     return TrafficControllerRFC2544(trafficgen_class)
48
49
50 def create_vswitch(deployment_scenario, vswitch_class, bidir=True):
51     """Return a new IVSwitchController for the deployment_scenario.
52
53     The returned controller is configured with the given vSwitch class.
54
55     Deployment scenarios: 'p2p', 'pvp'
56
57     :param deployment_scenario: The deployment scenario name
58     :param vswitch_class: Reference to vSwitch class to be used.
59     :return: IVSwitchController for the deployment_scenario
60     """
61     deployment_scenario = deployment_scenario.lower()
62     if deployment_scenario.find("p2p") >= 0:
63         return VswitchControllerP2P(vswitch_class)
64     elif deployment_scenario.find("pvp") >= 0:
65         return VswitchControllerPVP(vswitch_class, bidir)
66     elif deployment_scenario.find("pvvp") >= 0:
67         return VswitchControllerPVVP(vswitch_class, bidir)
68
69 def create_vnf(deployment_scenario, vnf_class):
70     """Return a new VnfController for the deployment_scenario.
71
72     The returned controller is configured with the given VNF class.
73
74     Deployment scenarios: 'p2p', 'pvp'
75
76     :param deployment_scenario: The deployment scenario name
77     :param vswitch_class: Reference to vSwitch class to be used.
78     :return: VnfController for the deployment_scenario
79     """
80     return VnfController(deployment_scenario, vnf_class)
81
82 def create_collector(collector_class, result_dir, test_name):
83     """Return a new Collector of the given class
84
85     :param collector_class: The collector class to be used.
86     :param result_dir: Directory with test results
87     :param test_name: Test to be run
88     :return: A new CollectorController.
89     """
90     return collector_class(result_dir, test_name)
91
92 def create_loadgen(loadgen_type, loadgen_cfg):
93     """Return a new ILoadGenerator for the loadgen type.
94
95     The returned load generator has the given loadgen type and loadgen
96     generator class.
97
98     :param loadgen_type: Name of loadgen type
99     :param loadgen_class: Reference to load generator class to be used.
100     :return: A new ILoadGenerator class
101     """
102     loadgen_type = loadgen_type.lower()
103     if loadgen_type.find("dummy") >= 0:
104         return DummyLoadGen(loadgen_cfg)
105     elif loadgen_type.find("stress-ng") >= 0:
106         return StressNg(loadgen_cfg)
107     elif loadgen_type.find("stress") >= 0:
108         return Stress(loadgen_cfg)
109
110