X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=core%2Fcomponent_factory.py;h=bd9a1019859925357703566804367c66bb5e41d6;hb=485ac777fd9cded7c145917bfcbe701276f3c855;hp=7f453bd216fbf742072760884860e47dc6acfacf;hpb=8363f8c6387449186b5656af5a5fc44bedc906b1;p=vswitchperf.git diff --git a/core/component_factory.py b/core/component_factory.py index 7f453bd2..bd9a1019 100644 --- a/core/component_factory.py +++ b/core/component_factory.py @@ -1,4 +1,4 @@ -# Copyright 2015-2016 Intel Corporation. +# Copyright 2015-2017 Intel Corporation. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -16,6 +16,7 @@ """ from core.traffic_controller_rfc2544 import TrafficControllerRFC2544 +from core.traffic_controller_rfc2889 import TrafficControllerRFC2889 from core.vswitch_controller_clean import VswitchControllerClean from core.vswitch_controller_p2p import VswitchControllerP2P from core.vswitch_controller_pxp import VswitchControllerPXP @@ -23,9 +24,6 @@ from core.vswitch_controller_op2p import VswitchControllerOP2P from core.vswitch_controller_ptunp import VswitchControllerPtunP 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__(): @@ -45,9 +43,12 @@ def create_traffic(traffic_type, trafficgen_class): :param traffic_type: Name of traffic type :param trafficgen_class: Reference to traffic generator class to be used. - :return: A new ITrafficController + :return: A new TrafficController """ - return TrafficControllerRFC2544(trafficgen_class) + if traffic_type.lower().startswith('rfc2889'): + return TrafficControllerRFC2889(trafficgen_class) + else: + return TrafficControllerRFC2544(trafficgen_class) def create_vswitch(deployment_scenario, vswitch_class, traffic, @@ -64,6 +65,7 @@ def create_vswitch(deployment_scenario, vswitch_class, traffic, :param tunnel_operation encapsulation/decapsulation or None :return: IVSwitchController for the deployment_scenario """ + # pylint: disable=too-many-return-statements deployment_scenario = deployment_scenario.lower() if deployment_scenario.startswith("p2p"): return VswitchControllerP2P(vswitch_class, traffic) @@ -83,7 +85,7 @@ def create_vswitch(deployment_scenario, vswitch_class, traffic, raise RuntimeError("Unknown deployment scenario '{}'.".format(deployment_scenario)) -def create_vnf(deployment_scenario, vnf_class): +def create_vnf(deployment_scenario, vnf_class, extra_vnfs): """Return a new VnfController for the deployment_scenario. The returned controller is configured with the given VNF class. @@ -92,9 +94,13 @@ def create_vnf(deployment_scenario, vnf_class): :param deployment_scenario: The deployment scenario name :param vswitch_class: Reference to vSwitch class to be used. + :param extra_vnfs: The number of VNFs not involved in given + deployment scenario. It will be used to correctly expand + configuration values and initialize shared dirs. This parameter + is used in case, that additional VNFs are executed by TestSteps. :return: VnfController for the deployment_scenario """ - return VnfController(deployment_scenario, vnf_class) + return VnfController(deployment_scenario, vnf_class, extra_vnfs) def create_collector(collector_class, result_dir, test_name): """Return a new Collector of the given class @@ -106,23 +112,17 @@ def create_collector(collector_class, result_dir, test_name): """ return collector_class(result_dir, test_name) -def create_loadgen(loadgen_type, loadgen_cfg): - """Return a new ILoadGenerator for the loadgen type. +def create_loadgen(loadgen_class, loadgen_cfg): + """Return a new ILoadGenerator for the loadgen class. - The returned load generator has the given loadgen type and loadgen - generator class. + The returned load generator is of given loadgen generator class. - :param loadgen_type: Name of loadgen type - :param loadgen_class: Reference to load generator class to be used. + :param loadgen_class: Name to load generator class to be used. + :param loadgen_cfg: Configuration for the loadgen :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) + # pylint: disable=too-many-function-args + return loadgen_class(loadgen_cfg) def create_pktfwd(deployment, pktfwd_class): """Return a new packet forwarder controller