@Test public void testGetServiceConfigInvalidPkg() { try { m_provisioner.getServiceConfiguration("invalid", "ICMP"); fail("Expected exception"); } catch (IllegalArgumentException e) { } }
public Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId) { if (pkgName == null) { throw new NullPointerException("pkgName is null"); } if (serviceId == null) { throw new NullPointerException("serviceId is null"); } final Package pkg = m_pollerConfig.getPackage(pkgName); if (pkg == null) { throw new IllegalArgumentException(pkgName+" is not a valid poller package name"); } final Service svc = m_pollerConfig.getServiceInPackage(serviceId, pkg); if (svc == null) { throw new IllegalArgumentException("Could not find service "+serviceId+" in package "+pkgName); } final Map<String, Object> m = new HashMap<String, Object>(); m.put("serviceid", serviceId); m.put("interval", Integer.valueOf((int)svc.getInterval())); for(int i = 0; i < svc.getParameterCount(); i++) { final Parameter param = svc.getParameter(i); String key = param.getKey(); final String valStr = param.getValue(); Object val = valStr; if ("retry".equals(key)) { key = "retries"; val = Integer.decode(valStr); } else if ("timeout".equals(key)) { val = Integer.decode(valStr); } else if ("port".equals(key)) { val = Integer.decode(valStr); } else if ("response".equals(key)) { val = valStr; } else if ("response text".equals(key)) { key = "response_text"; } else if ("response-text".equals(key)) { key = "response_text"; } else if ("host-name".equals(key)) { key = "hostname"; } else if ("host name".equals(key)) { key = "hostname"; } else if ("user-agent".equals(key)) { key = "agent"; } else if ("basic-authentication".equals(key)) { int colon = valStr.indexOf(':'); if (colon < 0) { continue; } final String user = valStr.substring(0, colon); final String passwd = valStr.substring(colon+1); m.put("user", user); m.put("password", passwd); continue; } m.put(key, val); } for(int i = 0; i < pkg.getDowntimeCount(); i++) { final Downtime dt = pkg.getDowntime(i); final String suffix = (i == 0 ? "" : ""+i); if ((dt.hasEnd()) || (dt.getDelete() != null && !"false".equals(dt.getDelete()))) { m.put("downtime_interval"+suffix, Integer.valueOf((int)dt.getInterval())); int duration = (!dt.hasEnd() ? Integer.MAX_VALUE : (int)(dt.getEnd() - dt.getBegin())); m.put("downtime_duration"+suffix, Integer.valueOf(duration)); } } return m; }
OpenNMSProvisioner implements Provisioner { public Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId) { if (pkgName == null) { throw new NullPointerException("pkgName is null"); } if (serviceId == null) { throw new NullPointerException("serviceId is null"); } final Package pkg = m_pollerConfig.getPackage(pkgName); if (pkg == null) { throw new IllegalArgumentException(pkgName+" is not a valid poller package name"); } final Service svc = m_pollerConfig.getServiceInPackage(serviceId, pkg); if (svc == null) { throw new IllegalArgumentException("Could not find service "+serviceId+" in package "+pkgName); } final Map<String, Object> m = new HashMap<String, Object>(); m.put("serviceid", serviceId); m.put("interval", Integer.valueOf((int)svc.getInterval())); for(int i = 0; i < svc.getParameterCount(); i++) { final Parameter param = svc.getParameter(i); String key = param.getKey(); final String valStr = param.getValue(); Object val = valStr; if ("retry".equals(key)) { key = "retries"; val = Integer.decode(valStr); } else if ("timeout".equals(key)) { val = Integer.decode(valStr); } else if ("port".equals(key)) { val = Integer.decode(valStr); } else if ("response".equals(key)) { val = valStr; } else if ("response text".equals(key)) { key = "response_text"; } else if ("response-text".equals(key)) { key = "response_text"; } else if ("host-name".equals(key)) { key = "hostname"; } else if ("host name".equals(key)) { key = "hostname"; } else if ("user-agent".equals(key)) { key = "agent"; } else if ("basic-authentication".equals(key)) { int colon = valStr.indexOf(':'); if (colon < 0) { continue; } final String user = valStr.substring(0, colon); final String passwd = valStr.substring(colon+1); m.put("user", user); m.put("password", passwd); continue; } m.put(key, val); } for(int i = 0; i < pkg.getDowntimeCount(); i++) { final Downtime dt = pkg.getDowntime(i); final String suffix = (i == 0 ? "" : ""+i); if ((dt.hasEnd()) || (dt.getDelete() != null && !"false".equals(dt.getDelete()))) { m.put("downtime_interval"+suffix, Integer.valueOf((int)dt.getInterval())); int duration = (!dt.hasEnd() ? Integer.MAX_VALUE : (int)(dt.getEnd() - dt.getBegin())); m.put("downtime_duration"+suffix, Integer.valueOf(duration)); } } return m; } }
OpenNMSProvisioner implements Provisioner { public Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId) { if (pkgName == null) { throw new NullPointerException("pkgName is null"); } if (serviceId == null) { throw new NullPointerException("serviceId is null"); } final Package pkg = m_pollerConfig.getPackage(pkgName); if (pkg == null) { throw new IllegalArgumentException(pkgName+" is not a valid poller package name"); } final Service svc = m_pollerConfig.getServiceInPackage(serviceId, pkg); if (svc == null) { throw new IllegalArgumentException("Could not find service "+serviceId+" in package "+pkgName); } final Map<String, Object> m = new HashMap<String, Object>(); m.put("serviceid", serviceId); m.put("interval", Integer.valueOf((int)svc.getInterval())); for(int i = 0; i < svc.getParameterCount(); i++) { final Parameter param = svc.getParameter(i); String key = param.getKey(); final String valStr = param.getValue(); Object val = valStr; if ("retry".equals(key)) { key = "retries"; val = Integer.decode(valStr); } else if ("timeout".equals(key)) { val = Integer.decode(valStr); } else if ("port".equals(key)) { val = Integer.decode(valStr); } else if ("response".equals(key)) { val = valStr; } else if ("response text".equals(key)) { key = "response_text"; } else if ("response-text".equals(key)) { key = "response_text"; } else if ("host-name".equals(key)) { key = "hostname"; } else if ("host name".equals(key)) { key = "hostname"; } else if ("user-agent".equals(key)) { key = "agent"; } else if ("basic-authentication".equals(key)) { int colon = valStr.indexOf(':'); if (colon < 0) { continue; } final String user = valStr.substring(0, colon); final String passwd = valStr.substring(colon+1); m.put("user", user); m.put("password", passwd); continue; } m.put(key, val); } for(int i = 0; i < pkg.getDowntimeCount(); i++) { final Downtime dt = pkg.getDowntime(i); final String suffix = (i == 0 ? "" : ""+i); if ((dt.hasEnd()) || (dt.getDelete() != null && !"false".equals(dt.getDelete()))) { m.put("downtime_interval"+suffix, Integer.valueOf((int)dt.getInterval())); int duration = (!dt.hasEnd() ? Integer.MAX_VALUE : (int)(dt.getEnd() - dt.getBegin())); m.put("downtime_duration"+suffix, Integer.valueOf(duration)); } } return m; }  }
OpenNMSProvisioner implements Provisioner { public Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId) { if (pkgName == null) { throw new NullPointerException("pkgName is null"); } if (serviceId == null) { throw new NullPointerException("serviceId is null"); } final Package pkg = m_pollerConfig.getPackage(pkgName); if (pkg == null) { throw new IllegalArgumentException(pkgName+" is not a valid poller package name"); } final Service svc = m_pollerConfig.getServiceInPackage(serviceId, pkg); if (svc == null) { throw new IllegalArgumentException("Could not find service "+serviceId+" in package "+pkgName); } final Map<String, Object> m = new HashMap<String, Object>(); m.put("serviceid", serviceId); m.put("interval", Integer.valueOf((int)svc.getInterval())); for(int i = 0; i < svc.getParameterCount(); i++) { final Parameter param = svc.getParameter(i); String key = param.getKey(); final String valStr = param.getValue(); Object val = valStr; if ("retry".equals(key)) { key = "retries"; val = Integer.decode(valStr); } else if ("timeout".equals(key)) { val = Integer.decode(valStr); } else if ("port".equals(key)) { val = Integer.decode(valStr); } else if ("response".equals(key)) { val = valStr; } else if ("response text".equals(key)) { key = "response_text"; } else if ("response-text".equals(key)) { key = "response_text"; } else if ("host-name".equals(key)) { key = "hostname"; } else if ("host name".equals(key)) { key = "hostname"; } else if ("user-agent".equals(key)) { key = "agent"; } else if ("basic-authentication".equals(key)) { int colon = valStr.indexOf(':'); if (colon < 0) { continue; } final String user = valStr.substring(0, colon); final String passwd = valStr.substring(colon+1); m.put("user", user); m.put("password", passwd); continue; } m.put(key, val); } for(int i = 0; i < pkg.getDowntimeCount(); i++) { final Downtime dt = pkg.getDowntime(i); final String suffix = (i == 0 ? "" : ""+i); if ((dt.hasEnd()) || (dt.getDelete() != null && !"false".equals(dt.getDelete()))) { m.put("downtime_interval"+suffix, Integer.valueOf((int)dt.getInterval())); int duration = (!dt.hasEnd() ? Integer.MAX_VALUE : (int)(dt.getEnd() - dt.getBegin())); m.put("downtime_duration"+suffix, Integer.valueOf(duration)); } } return m; }  boolean addServiceICMP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration); Parameter findParamterWithKey(final Service svc, final String key); boolean addServiceDNS(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final int port, final String lookup); boolean addServiceTCP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final int port, final String banner); boolean addServiceHTTP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String hostName, final int port, final String response, final String responseText, final String url, final String user, final String passwd, final String agent); boolean addServiceHTTPS(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String hostName, final int port, final String response, final String responseText, final String url, final String user, final String passwd, final String agent); boolean addServiceDatabase(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String user, final String password, final String driver, final String url); Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId); void setCapsdConfig(final CapsdConfig capsdConfig); void setPollerConfig(final PollerConfig pollerConfig); void setEventManager(final EventIpcManager eventManager); void setCapsdDbSyncer(final CapsdDbSyncer capsdDbSyncer); }
OpenNMSProvisioner implements Provisioner { public Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId) { if (pkgName == null) { throw new NullPointerException("pkgName is null"); } if (serviceId == null) { throw new NullPointerException("serviceId is null"); } final Package pkg = m_pollerConfig.getPackage(pkgName); if (pkg == null) { throw new IllegalArgumentException(pkgName+" is not a valid poller package name"); } final Service svc = m_pollerConfig.getServiceInPackage(serviceId, pkg); if (svc == null) { throw new IllegalArgumentException("Could not find service "+serviceId+" in package "+pkgName); } final Map<String, Object> m = new HashMap<String, Object>(); m.put("serviceid", serviceId); m.put("interval", Integer.valueOf((int)svc.getInterval())); for(int i = 0; i < svc.getParameterCount(); i++) { final Parameter param = svc.getParameter(i); String key = param.getKey(); final String valStr = param.getValue(); Object val = valStr; if ("retry".equals(key)) { key = "retries"; val = Integer.decode(valStr); } else if ("timeout".equals(key)) { val = Integer.decode(valStr); } else if ("port".equals(key)) { val = Integer.decode(valStr); } else if ("response".equals(key)) { val = valStr; } else if ("response text".equals(key)) { key = "response_text"; } else if ("response-text".equals(key)) { key = "response_text"; } else if ("host-name".equals(key)) { key = "hostname"; } else if ("host name".equals(key)) { key = "hostname"; } else if ("user-agent".equals(key)) { key = "agent"; } else if ("basic-authentication".equals(key)) { int colon = valStr.indexOf(':'); if (colon < 0) { continue; } final String user = valStr.substring(0, colon); final String passwd = valStr.substring(colon+1); m.put("user", user); m.put("password", passwd); continue; } m.put(key, val); } for(int i = 0; i < pkg.getDowntimeCount(); i++) { final Downtime dt = pkg.getDowntime(i); final String suffix = (i == 0 ? "" : ""+i); if ((dt.hasEnd()) || (dt.getDelete() != null && !"false".equals(dt.getDelete()))) { m.put("downtime_interval"+suffix, Integer.valueOf((int)dt.getInterval())); int duration = (!dt.hasEnd() ? Integer.MAX_VALUE : (int)(dt.getEnd() - dt.getBegin())); m.put("downtime_duration"+suffix, Integer.valueOf(duration)); } } return m; }  boolean addServiceICMP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration); Parameter findParamterWithKey(final Service svc, final String key); boolean addServiceDNS(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final int port, final String lookup); boolean addServiceTCP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final int port, final String banner); boolean addServiceHTTP(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String hostName, final int port, final String response, final String responseText, final String url, final String user, final String passwd, final String agent); boolean addServiceHTTPS(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String hostName, final int port, final String response, final String responseText, final String url, final String user, final String passwd, final String agent); boolean addServiceDatabase(final String serviceId, final int retry, final int timeout, final int interval, final int downTimeInterval, final int downTimeDuration, final String user, final String password, final String driver, final String url); Map<String, Object> getServiceConfiguration(final String pkgName, final String serviceId); void setCapsdConfig(final CapsdConfig capsdConfig); void setPollerConfig(final PollerConfig pollerConfig); void setEventManager(final EventIpcManager eventManager); void setCapsdDbSyncer(final CapsdDbSyncer capsdDbSyncer);  }