Search in sources :

Example 1 with DeviceAlarmConfig

use of org.onosproject.alarm.DeviceAlarmConfig in project onos by opennetworkinglab.

the class SnmpAlarmProvider method getAlarmTranslator.

private DeviceAlarmConfig getAlarmTranslator(SnmpDevice device) {
    Driver deviceDriver = driverService.getDriver(device.deviceId());
    if (deviceDriver != null && deviceDriver.hasBehaviour(DeviceAlarmConfig.class)) {
        DriverData driverData = new DefaultDriverData(deviceDriver, device.deviceId());
        DeviceAlarmConfig alarmTranslator = deviceDriver.createBehaviour(driverData, DeviceAlarmConfig.class);
        alarmTranslator.setHandler(new DefaultDriverHandler(driverData));
        return alarmTranslator;
    } else {
        log.warn("Device does not support alarm {}", device.deviceId());
    }
    return null;
}
Also used : DefaultDriverData(org.onosproject.net.driver.DefaultDriverData) DriverData(org.onosproject.net.driver.DriverData) DefaultDriverHandler(org.onosproject.net.driver.DefaultDriverHandler) Driver(org.onosproject.net.driver.Driver) DeviceAlarmConfig(org.onosproject.alarm.DeviceAlarmConfig) DefaultDriverData(org.onosproject.net.driver.DefaultDriverData)

Example 2 with DeviceAlarmConfig

use of org.onosproject.alarm.DeviceAlarmConfig in project onos by opennetworkinglab.

the class SnmpAlarmProvider method requestTraps.

private boolean requestTraps(DeviceId deviceId) {
    SnmpDevice device = controller.getDevice(deviceId);
    DeviceAlarmConfig alarmTranslator = getAlarmTranslator(device);
    if (alarmTranslator != null) {
        return alarmTranslator.configureDevice(localIp, device.getNotificationPort(), device.getNotificationProtocol());
    } else {
        log.warn("Device {} does not support alarms.", deviceId);
        return false;
    }
}
Also used : SnmpDevice(org.onosproject.snmp.SnmpDevice) DeviceAlarmConfig(org.onosproject.alarm.DeviceAlarmConfig)

Aggregations

DeviceAlarmConfig (org.onosproject.alarm.DeviceAlarmConfig)2 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)1 DefaultDriverHandler (org.onosproject.net.driver.DefaultDriverHandler)1 Driver (org.onosproject.net.driver.Driver)1 DriverData (org.onosproject.net.driver.DriverData)1 SnmpDevice (org.onosproject.snmp.SnmpDevice)1