1 # Copyright 2013: Mirantis Inc.
4 # Licensed under the Apache License, Version 2.0 (the "License"); you may
5 # not use this file except in compliance with the License. You may obtain
6 # a copy of the License at
8 # http://www.apache.org/licenses/LICENSE-2.0
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13 # License for the specific language governing permissions and limitations
16 # yardstick comment: this is a modified copy of
17 # rally/rally/benchmark/scenarios/base.py
19 """ Scenario base class
22 from __future__ import absolute_import
23 import yardstick.common.utils as utils
26 class Scenario(object):
29 """ default impl for scenario setup """
33 """ catcher for not implemented run methods in subclasses """
34 raise RuntimeError("run method not implemented")
37 """ default impl for scenario teardown """
42 """return a list of known runner type (class) names"""
44 for scenario in utils.itersubclasses(Scenario):
45 scenarios.append(scenario)
49 def get_cls(scenario_type):
50 """return class of specified type"""
51 for scenario in utils.itersubclasses(Scenario):
52 if scenario_type == scenario.__scenario_type__:
55 raise RuntimeError("No such scenario type %s" % scenario_type)
58 def get(scenario_type):
59 """Returns instance of a scenario runner for execution type.
61 for scenario in utils.itersubclasses(Scenario):
62 if scenario_type == scenario.__scenario_type__:
63 return scenario.__module__ + "." + scenario.__name__
65 raise RuntimeError("No such scenario type %s" % scenario_type)