Beispiel #1
0
    def _launch(self, configuration, Configuration, Interface, Transmission,
                Features):
        """ _launch create the bocore object and wait for it's return.
        At return Bocore objet will answer a set of classes, and a
        status tellling this function if this agent must be rebooter, reconfigured or stopped

        @type  configuration: class instance that load, check and store the Configuration
        @param configuration: the configuration object

        @type  Configuration: a subclass of the Configuration class 
        @param Configuration: Class that load, check and store the Configuration

        @type  Interface: a subclass of the Interface class 
        @param Interface: Class that manage the reception of order, its run function is the listening loop

        @type  Features: a list of subclass of the Feature class 
        @param Features: list of Class that process the order

        @type  Transmission: a subclass of the Transmission class 
        @param Transmission: Class that manage the connexion of other agent and transmit the orders to them

        @return nothing
        
        """

        #known object in a structure, that structure will be uses as return type par Bocore.run()
        original_bokor_struct = {
            'configuration_object': configuration,
            'Configuration': Configuration,
            'Interface': Interface,
            'interface_object': None,
            'Transmission': Transmission,
            'transmission_object': None,
            'Features': Features,
            'feature_object_list': [],
            'status': 'init',  #no bject instantiated exept configuration
        }
        # we keep original and use bokor_struct
        logging.info("original structure for agent : %s" %
                     (str(original_bokor_struct)))
        bokor_struct = original_bokor_struct.copy()
        self.bocore = None

        # main loop
        while True:
            # creating only if needed
            if not self.bocore:
                logging.info("building bocore object")
                self.bocore = Bocore(configuration, Configuration, Interface,
                                     Transmission, Features)
            #running agent
            bokor_struct = self.bocore.run()
            #shall we quit ?
            if bokor_struct['status'] in ['quit'] or self.force_quit:
                self.bocore.destroy()
                break
            #shall we destroy Bocore ?
            # clodrebbot : destroy all then recreate
            if bokor_struct['status'] in ['coldreboot']:
                self.bocore.destroy()
                self.bocore = None

            sleep(15)
        return