X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=core%2Fcomponent_factory.py;h=af237e5078e698d160a0a9ac1b20b96f534bf0ef;hb=a64311b5ba40d31e438732979eb97cc8e94e7a6e;hp=eb963d6f5deea0a421d7f8d73fdc0dec1ce89f88;hpb=3a61d8b18d966a940e40ca403ce8ed2b05c44eda;p=vswitchperf.git diff --git a/core/component_factory.py b/core/component_factory.py index eb963d6f..af237e50 100644 --- a/core/component_factory.py +++ b/core/component_factory.py @@ -18,9 +18,12 @@ from core.traffic_controller_rfc2544 import TrafficControllerRFC2544 from core.vswitch_controller_p2p import VswitchControllerP2P from core.vswitch_controller_pvp import VswitchControllerPVP -from core.vnf_controller_p2p import VnfControllerP2P -from core.vnf_controller_pvp import VnfControllerPVP -from core.collector_controller import CollectorController +from core.vswitch_controller_pvvp import VswitchControllerPVVP +from core.vnf_controller import VnfController +from core.pktfwd_controller import PktFwdController +from tools.load_gen.stress.stress import Stress +from tools.load_gen.stress_ng.stress_ng import StressNg +from tools.load_gen.dummy.dummy import DummyLoadGen def __init__(): @@ -38,15 +41,14 @@ def create_traffic(traffic_type, trafficgen_class): traffic_types: 'rfc2544_throughput' - :param traffic_type: Name of traffic type + :param traffic_type: Name of traffic type :param trafficgen_class: Reference to traffic generator class to be used. :return: A new ITrafficController """ - #TODO - full mapping from all traffic_types to - #correct controller class return TrafficControllerRFC2544(trafficgen_class) -def create_vswitch(deployment_scenario, vswitch_class): + +def create_vswitch(deployment_scenario, vswitch_class, traffic): """Return a new IVSwitchController for the deployment_scenario. The returned controller is configured with the given vSwitch class. @@ -55,18 +57,19 @@ def create_vswitch(deployment_scenario, vswitch_class): :param deployment_scenario: The deployment scenario name :param vswitch_class: Reference to vSwitch class to be used. + :param traffic: Dictionary with traffic specific details :return: IVSwitchController for the deployment_scenario """ - #TODO - full mapping from all deployment_scenarios to - #correct controller class deployment_scenario = deployment_scenario.lower() if deployment_scenario.find("p2p") >= 0: - return VswitchControllerP2P(vswitch_class) + return VswitchControllerP2P(vswitch_class, traffic) elif deployment_scenario.find("pvp") >= 0: - return VswitchControllerPVP(vswitch_class) + return VswitchControllerPVP(vswitch_class, traffic) + elif deployment_scenario.find("pvvp") >= 0: + return VswitchControllerPVVP(vswitch_class, traffic) def create_vnf(deployment_scenario, vnf_class): - """Return a new IVnfController for the deployment_scenario. + """Return a new VnfController for the deployment_scenario. The returned controller is configured with the given VNF class. @@ -74,28 +77,45 @@ def create_vnf(deployment_scenario, vnf_class): :param deployment_scenario: The deployment scenario name :param vswitch_class: Reference to vSwitch class to be used. - :return: IVnfController for the deployment_scenario + :return: VnfController for the deployment_scenario """ - #TODO - full mapping from all deployment_scenarios to - #correct controller class - deployment_scenario = deployment_scenario.lower() - if deployment_scenario.find("p2p") >= 0: - return VnfControllerP2P(vnf_class) - elif deployment_scenario.find("pvp") >= 0: - return VnfControllerPVP(vnf_class) - -def create_collector(collector, collector_class): - """Return a new CollectorController of the given class + return VnfController(deployment_scenario, vnf_class) - Supported collector type strings: - 'cpu' - 'memory': +def create_collector(collector_class, result_dir, test_name): + """Return a new Collector of the given class - :param collector: Collector type string :param collector_class: The collector class to be used. + :param result_dir: Directory with test results + :param test_name: Test to be run :return: A new CollectorController. """ - collector = collector.lower() - if "cpu" in collector or "memory" in collector: - return CollectorController(collector_class) + return collector_class(result_dir, test_name) +def create_loadgen(loadgen_type, loadgen_cfg): + """Return a new ILoadGenerator for the loadgen type. + + The returned load generator has the given loadgen type and loadgen + generator class. + + :param loadgen_type: Name of loadgen type + :param loadgen_class: Reference to load generator class to be used. + :return: A new ILoadGenerator class + """ + loadgen_type = loadgen_type.lower() + if loadgen_type.find("dummy") >= 0: + return DummyLoadGen(loadgen_cfg) + elif loadgen_type.find("stress-ng") >= 0: + return StressNg(loadgen_cfg) + elif loadgen_type.find("stress") >= 0: + return Stress(loadgen_cfg) + +def create_pktfwd(pktfwd_class): + """Return a new packet forwarder controller + + The returned controller is configured with the given + packet forwarder class. + + :param pktfwd_class: Reference to packet forwarder class to be used. + :return: packet forwarder controller + """ + return PktFwdController(pktfwd_class)