aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/network_services/traffic_profile/base.py
diff options
context:
space:
mode:
authorRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-01-19 15:46:11 +0000
committerRodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>2018-03-01 10:54:30 +0000
commitd08a8d477fd7b9fb88855b12ee53eafa07e79afa (patch)
tree0331a4104aef22e858aba539b8665c95c7438e94 /yardstick/network_services/traffic_profile/base.py
parentfe8bd59413e3525849f9b75752d657a737b5a0ad (diff)
Import "traffic_profile" modules only once
"traffic_profile" modules should be imported only once. Every time TrafficProfile.get is called, the modules under "yardstick.network_services.traffic_profiles" are loaded [1]. Instead of this, the modules should be registered only once the first time "yardstick.network_services.traffic_profiles.base" is loaded. This will reduce the execution time and will avoid unnecessary calls. [1] https://github.com/opnfv/yardstick/blob/d2c7cc4e9768ed003257a95c92cdb278d516761b/yardstick/network_services/traffic_profile/base.py#L36-L37 JIRA: YARDSTICK-951 Change-Id: Ia3565378ba3a1377fcb0aea8bda50ef8189414fd Signed-off-by: Rodolfo Alonso Hernandez <rodolfo.alonso.hernandez@intel.com>
Diffstat (limited to 'yardstick/network_services/traffic_profile/base.py')
-rw-r--r--yardstick/network_services/traffic_profile/base.py12
1 files changed, 5 insertions, 7 deletions
diff --git a/yardstick/network_services/traffic_profile/base.py b/yardstick/network_services/traffic_profile/base.py
index ad256b444..162bab2bc 100644
--- a/yardstick/network_services/traffic_profile/base.py
+++ b/yardstick/network_services/traffic_profile/base.py
@@ -11,10 +11,9 @@
# 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):
@@ -33,13 +32,12 @@ 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,