Exemplo n.º 1
0
 def get_resultchecker_cls(type):
     '''return resultchecker instance of specified type'''
     resultchecker_type = type
     for checker_cls in utils.itersubclasses(BaseResultChecker):
         if resultchecker_type == checker_cls.__result_checker__type__:
             return checker_cls
     raise RuntimeError("No such runner_type %s" % resultchecker_type)
Exemplo n.º 2
0
    def get_monitor_cls(monitor_type):
        '''return monitor class of specified type'''

        for monitor in utils.itersubclasses(BaseMonitor):
            if monitor_type == monitor.__monitor_type__:
                return monitor
        raise RuntimeError("No such monitor_type %s" % monitor_type)
Exemplo n.º 3
0
 def get_attacker_cls(attacker_cfg):
     """return attacker instance of specified type"""
     attacker_type = attacker_cfg['fault_type']
     for attacker_cls in utils.itersubclasses(BaseAttacker):
         if attacker_type == attacker_cls.__attacker_type__:
             return attacker_cls
     raise RuntimeError("No such runner_type: %s" % attacker_type)
 def get_operation_cls(type):
     """return operation instance of specified type"""
     operation_type = type
     for operation_cls in utils.itersubclasses(BaseOperation):
         if operation_type == operation_cls.__operation__type__:
             return operation_cls
     raise RuntimeError("No such runner_type %s" % operation_type)
Exemplo n.º 5
0
    def get_monitor_cls(monitor_type):
        """return monitor class of specified type"""

        for monitor in utils.itersubclasses(BaseMonitor):
            if monitor_type == monitor.__monitor_type__:
                return monitor
        raise RuntimeError("No such monitor_type: %s" % monitor_type)
Exemplo n.º 6
0
    def get_cls(scenario_type):
        '''return class of specified type'''
        for scenario in utils.itersubclasses(Scenario):
            if scenario_type == scenario.__scenario_type__:
                return scenario

        raise RuntimeError("No such scenario type %s" % scenario_type)
Exemplo n.º 7
0
 def get_attacker_cls(attacker_cfg):
     '''return attacker instance of specified type'''
     attacker_type = attacker_cfg['fault_type']
     for attacker_cls in utils.itersubclasses(BaseAttacker):
         if attacker_type == attacker_cls.__attacker_type__:
             return attacker_cls
     raise RuntimeError("No such runner_type %s" % attacker_type)
Exemplo n.º 8
0
 def get_operation_cls(type):
     '''return operation instance of specified type'''
     operation_type = type
     for operation_cls in utils.itersubclasses(BaseOperation):
         if operation_type == operation_cls.__operation__type__:
             return operation_cls
     raise RuntimeError("No such runner_type %s" % operation_type)
Exemplo n.º 9
0
 def get_resultchecker_cls(type):
     '''return resultchecker instance of specified type'''
     resultchecker_type = type
     for checker_cls in utils.itersubclasses(BaseResultChecker):
         if resultchecker_type == checker_cls.__result_checker__type__:
             return checker_cls
     raise RuntimeError("No such runner_type %s" % resultchecker_type)
Exemplo n.º 10
0
    def get_cls(scenario_type):
        """return class of specified type"""
        for scenario in utils.itersubclasses(Scenario):
            if scenario_type == scenario.__scenario_type__:
                return scenario

        raise RuntimeError("No such scenario type %s" % scenario_type)
Exemplo n.º 11
0
    def get(scenario_type):
        """Returns instance of a scenario runner for execution type.
        """
        for scenario in utils.itersubclasses(Scenario):
            if scenario_type == scenario.__scenario_type__:
                return scenario.__module__ + "." + scenario.__name__

        raise RuntimeError("No such scenario type %s" % scenario_type)
Exemplo n.º 12
0
    def get(scenario_type):
        """Returns instance of a scenario runner for execution type.
        """
        for scenario in utils.itersubclasses(Scenario):
            if scenario_type == scenario.__scenario_type__:
                return scenario.__module__ + "." + scenario.__name__

        raise RuntimeError("No such scenario type %s" % scenario_type)
Exemplo n.º 13
0
    def get(tp_config):
        """Get the traffic profile instance for the given traffic type

        :param tp_config: loaded YAML file
        :return:
        """
        profile_class = tp_config["traffic_profile"]["traffic_type"]
        try:
            return next(c for c in utils.itersubclasses(TrafficProfile)
                        if c.__name__ == profile_class)(tp_config)
        except StopIteration:
            raise exceptions.TrafficProfileNotImplemented(
                profile_class=profile_class)
Exemplo n.º 14
0
    def get(tp_config):
        """Get the traffic profile instance for the given traffic type

        :param tp_config: loaded YAML file
        :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)
                        if c.__name__ == profile_class)(tp_config)
        except StopIteration:
            raise RuntimeError("No implementation for %s", profile_class)
Exemplo n.º 15
0
    def test_itersubclasses(self):
        class A(object):
            pass

        class B(A):
            pass

        class C(A):
            pass

        class D(C):
            pass

        self.assertEqual([B, C, D], list(utils.itersubclasses(A)))
Exemplo n.º 16
0
def _iter_scenario_classes(scenario_type=None):
    """Generator over all 'Scenario' subclasses

    This function will iterate over all 'Scenario' subclasses defined in this
    project and will load any class introduced by any installed plugin project,
    defined in 'entry_points' section, under 'yardstick.scenarios' subsection.
    """
    extension.ExtensionManager(namespace='yardstick.scenarios',
                               invoke_on_load=False)
    for scenario in utils.itersubclasses(Scenario):
        if not scenario_type:
            yield scenario
        elif getattr(scenario, '__scenario_type__', None) == scenario_type:
            yield scenario
Exemplo n.º 17
0
    def get_vnf_impl(cls, vnf_model):
        """ Find the implementing class from vnf_model["vnf"]["name"] field

        :param vnf_model: dictionary containing a parsed vnfd
        :return: subclass of GenericVNF
        """
        import_modules_from_package(
            "yardstick.network_services.vnf_generic.vnf")
        expected_name = vnf_model['id']
        impl = (c for c in itersubclasses(GenericVNF)
                if c.__name__ == expected_name)
        try:
            return next(impl)
        except StopIteration:
            raise IncorrectConfig("No implementation for %s", expected_name)
Exemplo n.º 18
0
    def get_context_impl(self, nfvi_type):
        """ Find the implementing class from vnf_model["vnf"]["name"] field

        :param vnf_model: dictionary containing a parsed vnfd
        :return: subclass of GenericVNF
        """
        import_modules_from_package("yardstick.benchmark.contexts")
        expected_name = nfvi_type
        impl = [
            c for c in itersubclasses(StandaloneContext)
            if c.__name__ == expected_name
        ]
        try:
            return next(iter(impl))
        except StopIteration:
            raise ValueError("No implementation for %s", expected_name)
Exemplo n.º 19
0
 def get_types():
     """return a list of known runner type (class) names"""
     scenarios = []
     for scenario in utils.itersubclasses(Scenario):
         scenarios.append(scenario)
     return scenarios
Exemplo n.º 20
0
def get_resource(resource_name):
    name = ''.join(resource_name.split('_'))
    return next((r for r in utils.itersubclasses(ApiResource)
                 if r.__name__.lower() == name))
Exemplo n.º 21
0
 def get_types():
     """return a list of known runner type (class) names"""
     types = []
     for runner in utils.itersubclasses(Runner):
         types.append(runner)
     return types
Exemplo n.º 22
0
 def get_cls(runner_type):
     """return class of specified type"""
     for runner in utils.itersubclasses(Runner):
         if runner_type == runner.__execution_type__:
             return runner
     raise RuntimeError("No such runner_type %s" % runner_type)
Exemplo n.º 23
0
 def impl():
     for name, class_ in ((c.__name__, c)
                          for c in itersubclasses(GenericVNF)):
         if name == expected_name:
             yield class_
         classes_found.append(name)
Exemplo n.º 24
0
 def get_cls(context_type):
     '''Return class of specified type.'''
     for context in utils.itersubclasses(Context):
         if context_type == context.__context_type__:
             return context
     raise RuntimeError("No such context_type %s" % context_type)
Exemplo n.º 25
0
 def get_cls(dispatcher_type):
     '''Return class of specified type.'''
     for dispatcher in utils.itersubclasses(Base):
         if dispatcher_type == dispatcher.__dispatcher_type__:
             return dispatcher
     raise RuntimeError("No such dispatcher_type %s" % dispatcher_type)
Exemplo n.º 26
0
Arquivo: base.py Projeto: kkltcjk/1026
 def get_cls(context_type):
     '''Return class of specified type.'''
     for context in utils.itersubclasses(Context):
         if context_type == context.__context_type__:
             return context
     raise RuntimeError("No such context_type %s" % context_type)
Exemplo n.º 27
0
 def get_types():
     """return a list of known runner type (class) names"""
     types = []
     for runner in utils.itersubclasses(Runner):
         types.append(runner)
     return types
Exemplo n.º 28
0
 def get_cls(dispatcher_type):
     '''Return class of specified type.'''
     for dispatcher in utils.itersubclasses(Base):
         if dispatcher_type == dispatcher.__dispatcher_type__:
             return dispatcher
     raise RuntimeError("No such dispatcher_type %s" % dispatcher_type)
Exemplo n.º 29
0
 def get_types():
     '''return a list of known runner type (class) names'''
     scenarios = []
     for scenario in utils.itersubclasses(Scenario):
         scenarios.append(scenario)
     return scenarios
Exemplo n.º 30
0
 def get_cls(runner_type):
     """return class of specified type"""
     for runner in utils.itersubclasses(Runner):
         if runner_type == runner.__execution_type__:
             return runner
     raise RuntimeError("No such runner_type %s" % runner_type)