1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
10 """ Scenario base class
13 import yardstick.common.utils as utils
16 class Scenario(object):
19 ''' default impl for scenario setup '''
23 ''' catcher for not implemented run methods in subclasses '''
24 raise RuntimeError("run method not implemented")
27 ''' default impl for scenario teardown '''
32 '''return a list of known runner type (class) names'''
34 for scenario in utils.itersubclasses(Scenario):
35 scenarios.append(scenario)
39 def get_cls(scenario_type):
40 '''return class of specified type'''
41 for scenario in utils.itersubclasses(Scenario):
42 if scenario_type == scenario.__scenario_type__:
45 raise RuntimeError("No such scenario type %s" % scenario_type)
48 def get(scenario_type):
49 """Returns instance of a scenario runner for execution type.
51 for scenario in utils.itersubclasses(Scenario):
52 if scenario_type == scenario.__scenario_type__:
53 return scenario.__module__ + "." + scenario.__name__
55 raise RuntimeError("No such scenario type %s" % scenario_type)