use of org.onosproject.snmp.SnmpController in project onos by opennetworkinglab.
the class LumentumAlarmConsumer method consumeAlarms.
@Override
public List<Alarm> consumeAlarms() {
SnmpController controller = checkNotNull(handler().get(SnmpController.class));
List<Alarm> alarms = new ArrayList<>();
DeviceId deviceId = handler().data().deviceId();
SnmpDevice device = controller.getDevice(deviceId);
try {
snmp = new LumentumSnmpDevice(device.getSnmpHost(), device.getSnmpPort());
} catch (IOException e) {
log.error("Failed to connect to device: ", e);
}
// Gets the alarm table and for each entry get the ID and create the proper alarm.
snmp.get(ALARMS_TABLE_OID).forEach(alarm -> snmp.get(ALARMS_ID_OID).forEach(alarmIdEvent -> {
int alarmId = getAlarmId(alarmIdEvent);
alarms.add(new DefaultAlarm.Builder(AlarmId.alarmId(deviceId, String.valueOf(alarmId)), deviceId, getMessage(alarmId), getSeverity(alarmId), System.currentTimeMillis()).build());
}));
return ImmutableList.copyOf(alarms);
}
use of org.onosproject.snmp.SnmpController in project onos by opennetworkinglab.
the class PolatisSnmpUtility method getDevice.
private static SnmpDevice getDevice(DriverHandler handler) {
SnmpController controller = checkNotNull(handler.get(SnmpController.class));
SnmpDevice device = controller.getDevice(handler.data().deviceId());
return device;
}
Aggregations