1 from sfa.util.sfalogging import logger
2 from sfa.util.config import Config
5 # a bundle is the combination of
6 # (*) an api that reacts on the incoming requests to trigger the API methods
7 # (*) a manager that implements the function of the service,
8 # either aggregate, registry, or slicemgr
9 # (*) a driver that controls the underlying testbed
12 # The Generic class is a utility that uses the configuration to figure out
13 # which combination of these pieces need to be put together
15 # this extra indirection is needed to adapt to the current naming scheme
16 # where we have 'pl' and 'plc' and components and the like, that does not
17 # yet follow a sensible scheme
19 # needs refinements to cache more efficiently, esp. wrt the config
23 def __init__ (self, config):
27 # example flavour='pl' -> sfa.generic.pl.pl()
29 def the_flavour (flavour=None, config=None):
30 if config is None: config=Config()
31 if flavour is None: flavour=config.SFA_GENERIC_FLAVOUR
32 flavour = flavour.lower()
33 #mixed = flavour.capitalize()
34 module_path="sfa.generic.%s"%flavour
35 classname="%s"%flavour
36 logger.info("Generic.the_flavour with flavour=%s"%flavour)
38 module = __import__ (module_path, globals(), locals(), [classname])
39 return getattr(module, classname)(config)
41 logger.log_exc("Cannot locate generic instance with flavour=%s"%flavour)
44 # how to build an API object
45 # default is to use api_class but can be redefined
46 def make_api (self, *args, **kwds):
47 return self.api_class()(*args, **kwds)