示例#1
0
    def _send_ifdata_json_msg(self,
                              sensor_type,
                              resource_id,
                              resource_type,
                              state,
                              severity,
                              event=""):
        """A resuable method for transmitting IFDataMsg to RMQ and IEM logging"""
        ifDataMsg = IFdataMsg(self._node_sensor.host_id,
                              self._node_sensor.local_time,
                              self._node_sensor.if_data, resource_id,
                              resource_type, self.site_id, self.node_id,
                              self.cluster_id, self.rack_id, state, severity,
                              event)
        # Add in uuid if it was present in the json request
        if self._uuid is not None:
            ifDataMsg.set_uuid(self._uuid)
        jsonMsg = ifDataMsg.getJson()
        self.if_sensor_data = jsonMsg
        self.os_sensor_type[sensor_type] = self.if_sensor_data

        # Send the event to logging msg handler to send IEM message to journald
        #internal_json_msg=json.dumps({
        #                        'actuator_request_type': {
        #                            'logging': {
        #                                'log_level': 'LOG_WARNING',
        #                                'log_type': 'IEM',
        #                                'log_msg': '{}'.format(jsonMsg)}}})
        #self._write_internal_msgQ(LoggingMsgHandler.name(), internal_json_msg)

        # Transmit it out over rabbitMQ channel
        self._write_internal_msgQ(RabbitMQegressProcessor.name(), jsonMsg)
示例#2
0
    def _send_ifdata_json_msg(self,
                              resource_id,
                              resource_type,
                              state,
                              event=""):
        """A resuable method for transmitting IFDataMsg to RMQ and IEM logging"""
        ifDataMsg = IFdataMsg(self._node_sensor.host_id,
                              self._node_sensor.local_time,
                              self._node_sensor.if_data, resource_id,
                              resource_type, state,
                              self.severity_reader.map_severity(state), event)
        # Add in uuid if it was present in the json request
        if self._uuid is not None:
            ifDataMsg.set_uuid(self._uuid)
        jsonMsg = ifDataMsg.getJson()
        self.if_sensor_data = jsonMsg
        self.os_sensor_type["nw"] = self.if_sensor_data

        # Transmit it to message processor
        self._write_internal_msgQ(EgressProcessor.name(), jsonMsg)
        self.persist_state_data('nw', 'NW_SENSOR_DATA')
示例#3
0
    def _send_ifdata_json_msg(self,
                              sensor_type,
                              resource_id,
                              resource_type,
                              state,
                              severity,
                              event=""):
        """A resuable method for transmitting IFDataMsg to RMQ and IEM logging"""
        ifDataMsg = IFdataMsg(self._node_sensor.host_id,
                              self._node_sensor.local_time,
                              self._node_sensor.if_data, resource_id,
                              resource_type, self.site_id, self.node_id,
                              self.cluster_id, self.rack_id, state, severity,
                              event)
        # Add in uuid if it was present in the json request
        if self._uuid is not None:
            ifDataMsg.set_uuid(self._uuid)
        jsonMsg = ifDataMsg.getJson()
        self.if_sensor_data = jsonMsg
        self.os_sensor_type[sensor_type] = self.if_sensor_data

        # Send the event to logging msg handler to send IEM message to journald
        #internal_json_msg=json.dumps({
        #                        'actuator_request_type': {
        #                            'logging': {
        #                                'log_level': 'LOG_WARNING',
        #                                'log_type': 'IEM',
        #                                'log_msg': '{}'.format(jsonMsg)}}})
        #self._write_internal_msgQ(LoggingMsgHandler.name(), internal_json_msg)

        # Transmit it to message processor
        self._write_internal_msgQ(EgressProcessor.name(), jsonMsg)
        persistent_nw_data = {
            'prev_nw_status': self.prev_nw_status,
            'prev_cable_cnxns': self.prev_cable_cnxns,
            'interface_fault_state': self.interface_fault_state
        }
        store.put(persistent_nw_data, self.NW_SENSOR_DATA_PATH)