Ejemplo n.º 1
0
    def initialise(self):
        # get class for persistence and initialise
        self.backEnd = \
            getClassFromString(self.config.storageBackend)(self.kernel, self.config)

        self.get = self.backEnd.get
        self.set = self.backEnd.set
        self.getmulti = self.backEnd.getmulti
        self.delete = self.backEnd.delete

        # create the callable
        self.iface = BackPackIO(self)
Ejemplo n.º 2
0
    def launchService(self, serviceName, runconfig=None):
        """ Start the process of launching a service which will require
the following steps:
    
    1. Locate the profile, extract the psclimits and launch parameters
    3. Create a service launch sequencer with the profile and start it
 """
        self.logger.info("Mapping launch request for service %s" % serviceName)
        # 1. locate and load the profile
        pqcn = "%s.%s.%s" % (serviceName.lower(), serviceName.lower(), serviceName)
        cls = getClassFromString(pqcn, reload=True)
        self.__service = cls(serviceName, None, None)
        self.__service.loadConfig(self.kernel.settings.servicepath, runconfig)
        # 2. Start the sequencer
        ServiceLaunchSequencer(self.kernel, serviceName, self.__service.profile).start()
Ejemplo n.º 3
0
    def loadService(self, runtimeConfig = None):
        """ Loading a service happens as follows:
    - Load service class
    - Validate its signature cookie ???
    - Load configs: Here the configuration files are read and 
internals are organised. This is generally NOT overidden by the
service writer who instead provides the startup() method to do logical
business level initialisation.

Raises ServiceConfigurationError if the name is invalid.
        """        
        try:
            pqcn = "%s.%s.%s" % (self.name.lower(), self.name.lower(), self.name)
            cls = getClassFromString(pqcn)
            self.__service = cls(self.name, self.dispatcher, logging.getLogger(self.name))
            self.__service.initSupportServices()
            self.__service.loadConfig(self.servicepath, runtimeConfig)
        except Exception, ex:
            raise ServiceConfigurationError("Could not find class for service %s" % self.name, ex)
Ejemplo n.º 4
0
 def test_getClassFromString(self):
     c = 'peloton.kernel.PelotonKernel'
     cls = getClassFromString(c)
     from peloton.kernel import PelotonKernel as MatchClass
     self.assertEquals(cls, MatchClass)
     self.assertRaises(Exception, getClassFromString, 'peloton.kernel.Bogus')