add package scenarios with module base
[yardstick.git] / yardstick / benchmark / scenarios / base.py
1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 #
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 ##############################################################################
9
10 """ Scenario base class
11 """
12
13 import yardstick.common.utils as utils
14
15
16 class Scenario(object):
17
18     def run(self, args):
19         pass
20
21     @staticmethod
22     def get(scenario_type):
23         """Returns instance of a scenario runner for execution type.
24         """
25         for scenario in utils.itersubclasses(Scenario):
26             if scenario_type == scenario.__scenario_type__:
27                 return scenario.__module__ + "." + scenario.__name__
28
29         raise RuntimeError("No such scenario type %s" % scenario_type)