def build_service_map(self): """ Adds all known service definitions to service registry. @todo: May be a bit fragile due to using BaseService.__subclasses__ """ for cls in BaseService.__subclasses__(): assert hasattr( cls, 'name' ), 'Service class must define name value. Service class in error: %s' % cls if cls.name: self.services_by_name[cls.name] = cls self.add_servicedef_entry(cls.name, "base", cls) interfaces = list(implementedBy(cls)) if interfaces: self.add_servicedef_entry(cls.name, "interface", interfaces[0]) if cls.__name__.startswith("Base"): try: client = "%s.%sProcessClient" % (cls.__module__, cls.__name__[4:]) self.add_servicedef_entry(cls.name, "client", named_any(client)) sclient = "%s.%sClient" % (cls.__module__, cls.__name__[4:]) self.add_servicedef_entry(cls.name, "simple_client", named_any(sclient)) except Exception, ex: log.warning("Cannot find client for service %s" % (cls.name))
def load_service_mods(cls, path): import pkgutil import string mod_prefix = string.replace(path, "/", ".") for mod_imp, mod_name, is_pkg in pkgutil.iter_modules([path]): if is_pkg: cls.load_service_mods(path + "/" + mod_name) else: mod_qual = "%s.%s" % (mod_prefix, mod_name) #print "Import", mod_qual try: named_any(mod_qual) except Exception, ex: log.warning("Import module '%s' failed: %s" % (mod_qual, ex))
def load_service_mods(cls, path): import pkgutil import string mod_prefix = string.replace(path, "/", ".") for mod_imp, mod_name, is_pkg in pkgutil.iter_modules([path]): if is_pkg: cls.load_service_mods(path + "/" + mod_name) else: mod_qual = "%s.%s" % (mod_prefix, mod_name) #print "Import", mod_qual try: named_any(mod_qual) except Exception, ex: log.warning("Import module '%s' failed: %s" % (mod_qual, ex))
def initialize_res_lcsms(): """ Initializes resource type lifecycle state machines. """ res_lifecycle = (Config(["res/config/resource_lifecycle.yml"])).data # Initialize the set of available resource lifecycle workflows lcs_workflow_defs.clear() lcsm_defs = res_lifecycle["LifecycleWorkflowDefinitions"] for wf in lcsm_defs: wfname = wf["name"] clsname = wf.get("lcsm_class", None) if clsname: wf_cls = named_any(clsname) lcs_workflow_defs[wfname] = wf_cls(**wf) else: based_on = wf.get("based_on", None) wf_base = lcs_workflow_defs[based_on] lcs_workflow_defs[wfname] = wf_base._clone_with_restrictions(wf) lcs_workflows.clear() # Initialize the set of resource types with lifecycle for res_type, wf_name in res_lifecycle["LifecycleResourceTypes"].iteritems(): lcs_workflows[res_type] = lcs_workflow_defs[wf_name]
def build_service_map(self): """ Adds all known service definitions to service registry. @todo: May be a bit fragile due to using BaseService.__subclasses__ """ for cls in BaseService.__subclasses__(): assert hasattr(cls, 'name'), 'Service class must define name value. Service class in error: %s' % cls if cls.name: self.services_by_name[cls.name] = cls self.add_servicedef_entry(cls.name, "base", cls) interfaces = list(implementedBy(cls)) if interfaces: self.add_servicedef_entry(cls.name, "interface", interfaces[0]) if cls.__name__.startswith("Base"): try: client = "%s.%sProcessClient" % (cls.__module__, cls.__name__[4:]) self.add_servicedef_entry(cls.name, "client", named_any(client)) sclient = "%s.%sClient" % (cls.__module__, cls.__name__[4:]) self.add_servicedef_entry(cls.name, "simple_client", named_any(sclient)) except Exception, ex: log.warning("Cannot find client for service %s" % (cls.name))