def callback_for_alert(self, event, *args, **kwargs): log.debug("caught an OMSDeviceStatusEvent: %s", event) # self._notify_driver_event(OMSEventDriverEvent(event['description'])) log.info('Platform agent %r published OMSDeviceStatusEvent : %s, time: %s', self._platform_id, event, time.time())
def _configure(self, driver_config): """ Nothing special done here, only calls super.configure(driver_config) @param driver_config with required 'oms_uri' entry. """ PlatformDriver._configure(self, driver_config) self.nodeCfg = NodeConfiguration() self._platform_id = driver_config['node_id'] self.nodeCfg.openNode( self._platform_id, driver_config['driver_config_file']['node_cfg_file']) self.nms_source = self.nodeCfg.node_meta_data['nms_source'] self.oms_sample_rate = self.nodeCfg.node_meta_data['oms_sample_rate'] self.read_only_mode = self.nodeCfg.node_meta_data['read_only_mode'] log.info("READ ONLY MODE: %s" % self.read_only_mode) self.nodeCfg.Print() self._construct_resource_schema()
def _delete_scheduler(self): """ Remove the autosample schedule. """ try: self._remove_scheduler(ScheduledJob.ACQUIRE_SAMPLE) except KeyError: log.info('Failed to remove scheduled job for ACQUIRE_SAMPLE')
def callback_for_alert(self, event, *args, **kwargs): log.debug("caught an OMSDeviceStatusEvent: %s", event) # self._notify_driver_event(OMSEventDriverEvent(event['description'])) log.info( 'Platform agent %r published OMSDeviceStatusEvent : %s, time: %s', self._platform_id, event, time.time())
def _disconnect(self, recursion=None): log.info("%r: _disconnect...", self._platform_id) CIOMSClientFactory.destroy_instance(self._rsn_oms) self._rsn_oms = None log.debug("%r: CIOMSClient instance destroyed", self._platform_id) self._delete_scheduler() self._scheduler = None
def _delete_scheduler(self): """ Remove the autosample schedule. """ try: self._scheduler.unschedule_job(self._job) except KeyError: log.info('Failed to remove scheduled job for ACQUIRE_SAMPLE') self._scheduler.shutdown()
def _delete_scheduler(self): """ Remove the autosample schedule. """ try: self._scheduler.unschedule_job(self._job) self._scheduler.shutdown() # self._scheduler.remove_scheduler(self._job) except KeyError: log.info('Failed to remove scheduled job for ACQUIRE_SAMPLE')
def _set_params(self, *args, **kwargs): if len(args) < 1: raise InstrumentParameterException("Set command requires a parameter dict.") params = args[0] if not isinstance(params, dict): raise InstrumentParameterException("Set parameters not a dict.") self._param_dict = ProtocolParameterDict() for param in params: log.info("Creating new parameter: %s", param) self._param_dict.add(param, "", None, None) self._param_dict.set_value(param, params[param])
def _set_params(self, *args, **kwargs): if len(args) < 1: raise InstrumentParameterException( 'Set command requires a parameter dict.') params = args[0] if not isinstance(params, dict): raise InstrumentParameterException('Set parameters not a dict.') self._param_dict = ProtocolParameterDict() for param in params: log.info('Creating new parameter: %s', param) self._param_dict.add(param, '', None, None) self._param_dict.set_value(param, params[param])
def _handler_connected_connection_lost(self, *args, **kwargs): """ The device connection was lost. Stop comms, destroy protocol FSM and revert to disconnected state. @returns: (next_state, result) tuple, (DriverConnectionState.DISCONNECTED, None). """ for connection in self._connection.values(): connection.stop_comms() self._destroy_protocol() # Send async agent state change event. log.info("_handler_connected_connection_lost: sending LOST_CONNECTION " "event, moving to DISCONNECTED state.") self._driver_event(DriverAsyncEvent.AGENT_EVENT, ResourceAgentEvent.LOST_CONNECTION) return DriverConnectionState.UNCONFIGURED, None
def _connect(self, recursion=None): """ Creates an CIOMSClient instance, does a ping to verify connection, and starts event dispatch. """ log.info("%r: _connect...", self._platform_id) # create CIOMSClient: oms_uri = self._driver_config['oms_uri'] log.debug("%r: creating CIOMSClient instance with oms_uri=%r", self._platform_id, oms_uri) self._rsn_oms = CIOMSClientFactory.create_instance(oms_uri) log.debug("%r: CIOMSClient instance created: %s", self._platform_id, self._rsn_oms) # ping to verify connection: self._ping() self._build_scheduler() # then start calling it every X seconds
def _configure(self, driver_config): """ Nothing special done here, only calls super.configure(driver_config) @param driver_config with required 'oms_uri' entry. """ PlatformDriver._configure(self, driver_config) self.node_config = NodeConfiguration(driver_config["driver_config_file"]["node_cfg_file"]) self._platform_id = self.node_config.platform_id self.nms_source = self.node_config.node_meta_data["nms_source"] self.oms_sample_rate = self.node_config.node_meta_data["oms_sample_rate"] self.read_only_mode = self.node_config.node_meta_data["read_only_mode"] log.info("READ ONLY MODE: %s" % self.read_only_mode) self._construct_resource_schema()
def event_callback(event): log.info("driver job triggered, raise event: %s" % event) self._fsm.on_event(event)