Ejemplo n.º 1
0
    def test_dispatch_snmp_validation_alert(self):
        validator = snmp_validator.SNMPValidator()
        storage = fakes.FAKE_STOTRAGE
        alert = {
            'storage_id': storage['id'],
            'storage_name': storage['name'],
            'vendor': storage['vendor'],
            'model': storage['model'],
            'serial_number': storage['serial_number'],
            'alert_id': constants.SNMP_CONNECTION_FAILED_ALERT_ID,
            'sequence_number': 0,
            'alert_name': 'SNMP connect failed',
            'category': constants.Category.FAULT,
            'severity': constants.Severity.MAJOR,
            'type': constants.EventType.COMMUNICATIONS_ALARM,
            'location': 'NetworkEntity=%s' % storage['name'],
            'description': "SNMP connection to the storage failed. "
                           "SNMP traps from storage will not be received.",
            'recovery_advice': "1. The network connection is abnormal. "
                               "2. SNMP authentication parameters "
                               "are invalid.",
            'occur_time': mock.ANY,
        }

        validator._dispatch_snmp_validation_alert(
            context, storage, constants.Category.FAULT)
        base_exporter.AlertExporterManager(). \
            dispatch.assert_called_once_with(context, alert)
Ejemplo n.º 2
0
 def __init__(self, service_name=None, *args, **kwargs):
     self.mib_view_controller = kwargs.get('mib_view_controller')
     self.snmp_engine = kwargs.get('snmp_engine')
     self.trap_receiver_address = kwargs.get('trap_receiver_address')
     self.trap_receiver_port = kwargs.get('trap_receiver_port')
     self.alert_processor = alert_processor.AlertProcessor()
     self.snmp_validator = snmp_validator.SNMPValidator()
     self.alert_rpc_api = rpcapi.AlertAPI()
     super(TrapReceiver, self).__init__(host=kwargs.get('host'))
Ejemplo n.º 3
0
    def test_validate(self, mock_validate_connectivity):
        validator = snmp_validator.SNMPValidator()

        mock_validate_connectivity.return_value = fakes.fake_v3_alert_source()
        v3_alert_source_without_engine_id = fakes.fake_v3_alert_source()
        v3_alert_source_without_engine_id.pop('engine_id')
        validator.validate(context, v3_alert_source_without_engine_id)
        self.assertEqual(db.alert_source_update.call_count, 1)

        mock_validate_connectivity.return_value = fakes.fake_v3_alert_source()
        validator.validate(context, fakes.fake_v3_alert_source())
        self.assertEqual(db.alert_source_update.call_count, 1)
Ejemplo n.º 4
0
    def test_handle_validation_result(self):
        validator = snmp_validator.SNMPValidator()

        validator._handle_validation_result(context, fakes.FAKE_STOTRAGE['id'],
                                            constants.Category.FAULT)
        snmp_validator.SNMPValidator._dispatch_snmp_validation_alert \
            .assert_called_with(context,
                                fakes.FAKE_STOTRAGE,
                                constants.Category.FAULT)

        validator._handle_validation_result(context, fakes.FAKE_STOTRAGE['id'],
                                            constants.Category.RECOVERY)
        snmp_validator.SNMPValidator._dispatch_snmp_validation_alert \
            .assert_called_with(context,
                                fakes.FAKE_STOTRAGE,
                                constants.Category.RECOVERY)