use of org.opennms.core.network.IPAddress in project opennms by OpenNMS.
the class AlarmChangeNotificationClient method jsonAlarmToEventBuilder.
private EventBuilder jsonAlarmToEventBuilder(JSONObject jsonObject, EventBuilder eb) {
// copy generic alarm details as paramaters
String alarmId = (jsonObject.get("alarmid") == null) ? null : jsonObject.get("alarmid").toString();
String severity = (jsonObject.get("severity") == null) ? null : jsonObject.get("severity").toString();
String logmsg = (jsonObject.get("logmsg") == null) ? null : jsonObject.get("logmsg").toString();
String eventuei = (jsonObject.get("eventuei") == null) ? null : jsonObject.get("eventuei").toString();
String reductionkey = (jsonObject.get("reductionkey") == null) ? null : jsonObject.get("reductionkey").toString();
String clearkey = (jsonObject.get("clearkey") == null) ? null : jsonObject.get("clearkey").toString();
String alarmtype = (jsonObject.get("alarmtype") == null) ? null : jsonObject.get("alarmtype").toString();
String alarmacktime = (jsonObject.get("alarmacktime") == null) ? null : jsonObject.get("alarmacktime").toString();
String alarmackuser = (jsonObject.get("alarmackuser") == null) ? null : jsonObject.get("alarmackuser").toString();
String suppressedtime = (jsonObject.get("suppressedtime") == null) ? null : jsonObject.get("suppressedtime").toString();
String suppresseduntil = (jsonObject.get("suppresseduntil") == null) ? null : jsonObject.get("suppresseduntil").toString();
String suppresseduser = (jsonObject.get("suppresseduser") == null) ? null : jsonObject.get("suppresseduser").toString();
// Node / service identity - copy into event corresponding event fields
String nodeid = (jsonObject.get("nodeid") == null) ? null : jsonObject.get("nodeid").toString();
String ipaddr = (jsonObject.get("ipaddr") == null) ? null : jsonObject.get("ipaddr").toString();
String ifindex = (jsonObject.get("ifindex") == null) ? null : jsonObject.get("ifindex").toString();
String applicationdn = (jsonObject.get("applicationdn") == null) ? null : jsonObject.get("applicationdn").toString();
String serviceid = (jsonObject.get("serviceid") == null) ? null : jsonObject.get("serviceid").toString();
String systemid = (jsonObject.get("systemid") == null) ? null : jsonObject.get("systemid").toString();
eb.addParam(AlarmChangeEventConstants.ALARMID_PARAM, alarmId);
eb.addParam(AlarmChangeEventConstants.ALARM_SEVERITY_PARAM, severity);
eb.addParam(AlarmChangeEventConstants.LOGMSG_PARAM, logmsg);
eb.addParam(AlarmChangeEventConstants.CLEARKEY_PARAM, clearkey);
eb.addParam(AlarmChangeEventConstants.ALARMTYPE_PARAM, alarmtype);
eb.addParam(AlarmChangeEventConstants.ALARM_ACK_TIME_PARAM, alarmacktime);
eb.addParam(AlarmChangeEventConstants.ALARM_ACK_USER_PARAM, alarmackuser);
eb.addParam(AlarmChangeEventConstants.SUPPRESSEDTIME_PARAM, suppressedtime);
eb.addParam(AlarmChangeEventConstants.SUPPRESSEDUNTIL_PARAM, suppresseduntil);
eb.addParam(AlarmChangeEventConstants.SUPPRESSEDUSER_PARAM, suppresseduser);
eb.addParam(AlarmChangeEventConstants.EVENTUEI_PARAM, eventuei);
eb.addParam(AlarmChangeEventConstants.REDUCTIONKEY_PARAM, reductionkey);
if (nodeid != null)
eb.setNodeid(Long.parseLong(nodeid));
if (ipaddr != null)
try {
IPAddress ipaddress = new IPAddress(ipaddr);
eb.setInterface(ipaddress.toInetAddress());
} catch (Exception e) {
LOG.error("cannot parse json object ipaddr=" + ipaddr, e);
}
if (ifindex != null)
eb.setIfIndex(Integer.parseInt(ifindex));
eb.addParam(AlarmChangeEventConstants.APPLICATIONDN_PARAM, applicationdn);
eb.addParam(AlarmChangeEventConstants.SERVICEID_PARAM, serviceid);
eb.addParam(AlarmChangeEventConstants.SYSTEMID_PARAM, systemid);
return eb;
}
use of org.opennms.core.network.IPAddress in project opennms by OpenNMS.
the class Package method hasIncludeRange.
public boolean hasIncludeRange(final String addr) {
if (getIncludeRanges().size() == 0 && getSpecifics().size() == 0) {
return true;
}
final IPAddress ipAddr = new IPAddress(addr);
for (final IncludeRange rng : getIncludeRanges()) {
final IPAddress begin = rng.getBeginAsAddress();
final IPAddress end = rng.getEndAsAddress();
if (ipAddr.isGreaterThanOrEqualTo(begin) && ipAddr.isLessThanOrEqualTo(end)) {
return true;
}
}
return false;
}
Aggregations