Beispiel #1
0
 def GetSlivers(self, config, plc):
     """Retrieves GetSlivers at PLC and triggers callbacks defined in modules/plugins"""
     try:
         logger.log("nodemanager: Syncing w/ PLC")
         # retrieve GetSlivers from PLC
         data = plc.GetSlivers()
         # use the magic 'default' slice to retrieve system-wide defaults
         self.getPLCDefaults(data, config)
         # tweak the 'vref' attribute from GetSliceFamily
         self.setSliversVref (data)
         # dump it too, so it can be retrieved later in case of comm. failure
         self.dumpSlivers(data)
         # log it for debug purposes, no matter what verbose is
         logger.log_slivers(data)
         logger.verbose("nodemanager: Sync w/ PLC done")
         last_data=data
     except:
         logger.log_exc("nodemanager: failed in GetSlivers")
         #  XXX So some modules can at least boostrap.
         logger.log("nodemanager:  Can't contact PLC to GetSlivers().  Continuing.")
         data = {}
         # for modules that request it though the 'persistent_data' property
         last_data=self.loadSlivers()
     #  Invoke GetSlivers() functions from the callback modules
     for module in self.loaded_modules:
         logger.verbose('nodemanager: triggering %s.GetSlivers'%module.__name__)
         try:
             callback = getattr(module, 'GetSlivers')
             module_data=data
             if getattr(module,'persistent_data',False):
                 module_data=last_data
             callback(data, config, plc)
         except:
             logger.log_exc("nodemanager: GetSlivers failed to run callback for module %r"%module)
Beispiel #2
0
    def GetSlivers(self, config, plc):
        """Retrieves GetSlivers at PLC and triggers callbacks defined in modules/plugins"""

        try:
            logger.log("nodemanager: Syncing w/ PLC")
            # retrieve GetSlivers from PLC
            data = plc.GetSlivers()
            # use the magic 'default' slice to retrieve system-wide defaults
            self.getPLCDefaults(data, config)
            # tweak the 'vref' attribute from GetSliceFamily
            self.setSliversVref(data)
            # dump it too, so it can be retrieved later in case of comm. failure
            self.dumpSlivers(data)
            # log it for debug purposes, no matter what verbose is
            logger.log_slivers(data)
            logger.verbose("nodemanager: Sync w/ PLC done")
            last_data = data
        except:
            logger.log_exc("nodemanager: failed in GetSlivers")
            #  XXX So some modules can at least boostrap.
            logger.log(
                "nodemanager:  Can't contact PLC to GetSlivers().  Continuing."
            )
            data = {}
            # for modules that request it though the 'persistent_data' property
            last_data = self.loadSlivers()
        logger.log("*************************************************")
        #logger.log("we should provide these information to PEARL TEAM")
        logger.log_map({}, "******************************************")
        #wangyang,get slice map from date fetched from myplc
        slicemap = self.getslicemap(data)
        #logger.log_map(slicemap,"slicemap")
        #wangyang,get slice map from db
        slicemapdb = self.loadmap(slicemap)
        #logger.log_map(slicemapdb,"slicedb")
        #wangyang,compare two files
        slicemapdb = self.handlemap(slicemap, slicemapdb)
        #logger.log_map(slicemapdb,"dbafter compare")
        #wangyang,update to router
        slicemapdb = self.updatetoRouter(slicemapdb)
        #logger.log_map(slicemapdb,"db after update")
        #wangyang,update to router
        self.savemap(slicemapdb)
        #wangyang,write into txt
        logger.log_map(slicemapdb, "write to db")
        '''
        for sliver in last_data['slivers']:
            logger.log("sliceid is %s"%sliver['slice_id'])
            if sliver['slice_id'] > 4:
                logfile = '/var/log/slice/slice.'+sliver['name']
                #logger.logslice("slicename: %s"%sliver['name'],logfile)    
                logger.logslice("sliceid: %s"%sliver['slice_id'],logfile)
                vmid=self.createslver(sliver['slice_id']) 
                logger.log("vmid is %s"%vmid)
                logger.logmap(sliver['slice_id'],vmid)
                
                #logger.logslice("keys: %s"%sliver['keys'],logfile)
                '''
        logger.log("*************************************************")
        #  Invoke GetSlivers() functions from the callback modules
        for module in self.loaded_modules:
            logger.verbose('nodemanager: triggering %s.GetSlivers' %
                           module.__name__)
            try:
                callback = getattr(module, 'GetSlivers')
                module_data = data
                if getattr(module, 'persistent_data', False):
                    module_data = last_data
                callback(data, config, plc)
            except:
                logger.log_exc(
                    "nodemanager: GetSlivers failed to run callback for module %r"
                    % module)
 def GetSlivers(self, config, plc):
     """Retrieves GetSlivers at PLC and triggers callbacks defined in modules/plugins"""
     
     try:
         logger.log("nodemanager: Syncing w/ PLC")
         # retrieve GetSlivers from PLC
         data = plc.GetSlivers()
         # use the magic 'default' slice to retrieve system-wide defaults
         self.getPLCDefaults(data, config)
         # tweak the 'vref' attribute from GetSliceFamily
         self.setSliversVref (data)
         # dump it too, so it can be retrieved later in case of comm. failure
         self.dumpSlivers(data)
         # log it for debug purposes, no matter what verbose is
         logger.log_slivers(data)
         logger.verbose("nodemanager: Sync w/ PLC done")
         last_data=data
     except:
         logger.log_exc("nodemanager: failed in GetSlivers")
         #  XXX So some modules can at least boostrap.
         logger.log("nodemanager:  Can't contact PLC to GetSlivers().  Continuing.")
         data = {}
         # for modules that request it though the 'persistent_data' property
         last_data=self.loadSlivers()
     logger.log("*************************************************")
     #logger.log("we should provide these information to PEARL TEAM")
     logger.log_map({},"******************************************")
     #wangyang,get slice map from date fetched from myplc
     slicemap = self.getslicemap(data)
     #logger.log_map(slicemap,"slicemap")
     #wangyang,get slice map from db
     slicemapdb = self.loadmap(slicemap)
     #logger.log_map(slicemapdb,"slicedb")
     #wangyang,compare two files
     slicemapdb = self.handlemap(slicemap,slicemapdb)
     #logger.log_map(slicemapdb,"dbafter compare")
     #wangyang,update to router 
     slicemapdb = self.updatetoRouter(slicemapdb)
     #logger.log_map(slicemapdb,"db after update")
     #wangyang,update to router
     self.savemap(slicemapdb)
     #wangyang,write into txt
     logger.log_map(slicemapdb,"write to db")
     '''
     for sliver in last_data['slivers']:
         logger.log("sliceid is %s"%sliver['slice_id'])
         if sliver['slice_id'] > 4:
             logfile = '/var/log/slice/slice.'+sliver['name']
             #logger.logslice("slicename: %s"%sliver['name'],logfile)    
             logger.logslice("sliceid: %s"%sliver['slice_id'],logfile)
             vmid=self.createslver(sliver['slice_id']) 
             logger.log("vmid is %s"%vmid)
             logger.logmap(sliver['slice_id'],vmid)
             
             #logger.logslice("keys: %s"%sliver['keys'],logfile)
             '''
     logger.log("*************************************************")
     #  Invoke GetSlivers() functions from the callback modules
     for module in self.loaded_modules:
         logger.verbose('nodemanager: triggering %s.GetSlivers'%module.__name__)
         try:
             callback = getattr(module, 'GetSlivers')
             module_data=data
             if getattr(module,'persistent_data',False):
                 module_data=last_data
             callback(data, config, plc)
         except:
             logger.log_exc("nodemanager: GetSlivers failed to run callback for module %r"%module)