Skip to content

Commit

Permalink
HZN-1309: Refactor opennms-server.xml to only reflect Path Outage con…
Browse files Browse the repository at this point in the history
…figurations (#2005)

* HZN-1309: Remove unused serverName and verifyServer

* HZN-1309: Delete unnecessary files

* HZN-1309: Remove unused properties

* HZN-1309: Remove TODOs

* HZN-1309: Cleanup comments

* HZN-1309: Revert deletion of opennms-server.xml and update it accordingly

* HZN-1309: Update schema file

* HZN-1309: Include file in tests

* HZN-1309: Remove LocalServer and put configuration in poller-configuration.xml

* HZN-1309: Remove unused opennms-server.xml references
  • Loading branch information
mvrueden authored and j-white committed Jun 7, 2018
1 parent cc527c3 commit 1ba842b
Show file tree
Hide file tree
Showing 62 changed files with 247 additions and 1,060 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -290,11 +290,6 @@ public abstract class ConfigFileConstants {
*/
public static final int KSC_REPORT_FILE_NAME;

/**
* The opennms server config file
*/
public static final int OPENNMS_SERVER_CONFIG_FILE_NAME;

/**
* The opennms surveillance views config file
*/
Expand Down Expand Up @@ -511,8 +506,6 @@ public abstract class ConfigFileConstants {
KSC_REPORT_FILE_NAME = 46;
SCRIPTD_CONFIG_FILE_NAME = 47;

OPENNMS_SERVER_CONFIG_FILE_NAME = 48;

DHCPD_CONFIG_FILE_NAME = 50;

RRD_CONFIG_FILE_NAME = 51;
Expand Down Expand Up @@ -633,7 +626,6 @@ public abstract class ConfigFileConstants {

FILE_ID_TO_NAME[SCRIPTD_CONFIG_FILE_NAME] = "scriptd-configuration.xml";

FILE_ID_TO_NAME[OPENNMS_SERVER_CONFIG_FILE_NAME] = "opennms-server.xml";
FILE_ID_TO_NAME[DHCPD_CONFIG_FILE_NAME] = "dhcpd-configuration.xml";
FILE_ID_TO_NAME[RRD_CONFIG_FILE_NAME] = "rrd-configuration.properties";
FILE_ID_TO_NAME[JAVA_MAIL_CONFIG_FILE_NAME] = "javamail-configuration.properties";
Expand Down
2 changes: 0 additions & 2 deletions core/upgrade/src/test/resources/etc/opennms-server.xml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@

<bean id="pollerConfigDao" class="org.opennms.netmgt.config.DefaultPollerConfigDao">
<property name="configResource" value="classpath:/org/opennms/netmgt/poller/remote/poller-configuration.xml"/>
<property name="localServer" value="nms1"/>
<property name="verifyServer" value="false"/>
</bean>

<bean id="pollerConfig" factory-bean="pollerConfigDao" factory-method="getPollerConfig"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
*/
public class ReadOnlyPollerConfigManager extends PollerConfigManager {

private ReadOnlyPollerConfigManager(InputStream stream, String localServer, boolean verifyServer) {
super(stream, localServer, verifyServer);
private ReadOnlyPollerConfigManager(InputStream stream) {
super(stream);
}

public static ReadOnlyPollerConfigManager create() throws IOException {
final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.POLLER_CONFIG_FILE_NAME);
try (InputStream is = new FileInputStream(cfgFile)) {
return new ReadOnlyPollerConfigManager(is, null, false);
return new ReadOnlyPollerConfigManager(is);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
<bean id="pollerConfigDao" class="org.opennms.netmgt.config.DefaultPollerConfigDao">
<property name="configResource" value="classpath:/poller-configuration.xml"/>
<property name="localServer" value="nms1"/>
<property name="verifyServer" value="false"/>
</bean>
<bean id="pollerConfig" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@

<bean id="pollerConfigDao" class="org.opennms.netmgt.config.DefaultPollerConfigDao">
<property name="configResource" value="classpath:/poller-configuration.xml"/>
<property name="localServer" value="nms1"/>
<property name="verifyServer" value="false"/>
</bean>

<bean id="pollerConfig" class="org.springframework.beans.factory.config.MethodInvokingFactoryBean">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@
import org.opennms.netmgt.config.rtc.RTCConfiguration;
import org.opennms.netmgt.config.rws.RwsConfiguration;
import org.opennms.netmgt.config.scriptd.ScriptdConfiguration;
import org.opennms.netmgt.config.server.LocalServer;
import org.opennms.netmgt.config.service.ServiceConfiguration;
import org.opennms.netmgt.config.siteStatusViews.SiteStatusViewConfiguration;
import org.opennms.netmgt.config.snmp.SnmpConfig;
Expand Down Expand Up @@ -237,7 +236,6 @@ private static void addFile(final Source source, final String file, final Class<
addFile(Source.CONFIG, "notificationCommands.xml", NotificationCommands.class, true, null);
addFile(Source.CONFIG, "notifications.xml", Notifications.class, true, null);
addFile(Source.CONFIG, "opennms-datasources.xml", DataSourceConfiguration.class, false, null);
addFile(Source.CONFIG, "opennms-server.xml", LocalServer.class, true, null);
addFile(Source.CONFIG, "poll-outages.xml", Outages.class, true, null);
addFile(Source.CONFIG, "poller-configuration.xml", PollerConfiguration.class, true, null);
addFile(Source.CONFIG, "provisiond-configuration.xml", ProvisiondConfiguration.class, false, null);
Expand Down Expand Up @@ -301,7 +299,6 @@ private static void addFile(final Source source, final String file, final Class<
addFile(Source.EXAMPLE, "notificationCommands.xml", NotificationCommands.class, false, null);
addFile(Source.EXAMPLE, "notifications.xml", Notifications.class, false, null);
addFile(Source.EXAMPLE, "old-datacollection-config.xml", DatacollectionConfig.class, false, null);
addFile(Source.EXAMPLE, "opennms-server.xml", LocalServer.class, false, null);
addFile(Source.EXAMPLE, "poll-outages.xml", Outages.class, false, null);
addFile(Source.EXAMPLE, "poller-configuration.xml", PollerConfiguration.class, false, null);
addFile(Source.EXAMPLE, "rancid-configuration.xml", RancidConfiguration.class, false, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ public class RancidAdapterConfigFactory extends RancidAdapterConfigManager {
* Thrown if the specified config file cannot be read
* @param currentVersion a long.
* @param reader a {@link java.io.InputStream} object.
* @param localServer a {@link java.lang.String} object.
* @param verifyServer a boolean.
* @throws java.io.IOException if any.
*/
public RancidAdapterConfigFactory(long currentVersion, InputStream reader, String localServer, boolean verifyServer) throws IOException {
super(reader, localServer, verifyServer);
public RancidAdapterConfigFactory(long currentVersion, InputStream reader) throws IOException {
super(reader);
m_currentVersion = currentVersion;
}

Expand All @@ -98,15 +96,12 @@ public static synchronized void init() throws IOException {
return;
}

OpennmsServerConfigFactory.init();
final OpennmsServerConfigFactory onmsSvrConfig = OpennmsServerConfigFactory.getInstance();

final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.RANCID_CONFIG_FILE_NAME);

LOG.debug("init: config file path: {}", cfgFile.getPath());

final InputStream reader = new FileInputStream(cfgFile);
RancidAdapterConfigFactory config = new RancidAdapterConfigFactory(cfgFile.lastModified(), reader,onmsSvrConfig.getServerName(),onmsSvrConfig.verifyServer());
RancidAdapterConfigFactory config = new RancidAdapterConfigFactory(cfgFile.lastModified(), reader);
reader.close();
setInstance(config);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,17 +82,6 @@ public abstract class RancidAdapterConfigManager implements RancidAdapterConfig
*/
private RancidConfiguration m_config;

/**
* A boolean flag to indicate If a filter rule against the local OpenNMS
* server has to be used.
*/
private static boolean m_verifyServer;

/**
* The name of the local OpenNMS server
*/
private static String m_localServer;

/**
* A mapping of the configured URLs to a list of the specific IPs configured
* in each - so as to avoid file reads
Expand All @@ -115,13 +104,9 @@ public abstract class RancidAdapterConfigManager implements RancidAdapterConfig
*
* @author <a href="mailto:antonio@opennms.org">Antonio Russo</a>
* @param reader a {@link java.io.InputStream} object.
* @param verifyServer a boolean.
* @throws java.io.IOException if any.
* @param serverName a {@link java.lang.String} object.
*/
public RancidAdapterConfigManager(final InputStream reader,final String serverName, final boolean verifyServer) throws IOException {
m_localServer = serverName;
m_verifyServer = verifyServer;
public RancidAdapterConfigManager(final InputStream reader) throws IOException {
reloadXML(reader);
}

Expand All @@ -142,7 +127,7 @@ public Lock getWriteLock() {
/**
* <p>reloadXML</p>
*
* @param reader a {@link java.io.InputStream} object.
* @param is a {@link java.io.InputStream} object.
* @throws java.io.IOException if any.
*/
protected void reloadXML(final InputStream is) throws IOException {
Expand Down Expand Up @@ -228,13 +213,6 @@ private void createPackageIpListMap() {

private List<InetAddress> getIpList(final Package pkg) {
final StringBuilder filterRules = new StringBuilder(pkg.getFilter().getContent());
if (m_verifyServer) {
filterRules.append(" & (serverName == ");
filterRules.append('\"');
filterRules.append(m_localServer);
filterRules.append('\"');
filterRules.append(")");
}
LOG.debug("createPackageIpMap: package is {}. filter rules are {}", pkg.getName(), filterRules);
FilterDaoFactory.getInstance().flushActiveIpAddressListCache();
return FilterDaoFactory.getInstance().getActiveIPAddressList(filterRules.toString());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ public static synchronized void init() throws IOException {
// to reload, reload() will need to be called
return;
}
OpennmsServerConfigFactory.init();

final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.RWS_CONFIG_FILE_NAME);

LOG.debug("init: config file path: {}", cfgFile.getPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
http://www.springframework.org/schema/beans/spring-beans-4.2.xsd">

<bean id="snmpAssetAdapterConfigFactory" class="org.opennms.netmgt.config.SnmpAssetAdapterConfigFactory">
<!-- <constructor-arg type="org.opennms.netmgt.config.OpennmsServerConfigFactory" ref="onmsServerConfig"/> -->
</bean>

<bean id="snmpAssetAdapterConfig" factory-bean="snmpAssetAdapterConfigFactory" factory-method="getInstance"/>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*******************************************************************************
* This file is part of OpenNMS(R).
*
* Copyright (C) 2002-2014 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2014 The OpenNMS Group, Inc.
* Copyright (C) 2018-2018 The OpenNMS Group, Inc.
* OpenNMS(R) is Copyright (C) 1999-2018 The OpenNMS Group, Inc.
*
* OpenNMS(R) is a registered trademark of The OpenNMS Group, Inc.
*
Expand All @@ -26,27 +26,26 @@
* http://www.opennms.com/
*******************************************************************************/

package org.opennms.netmgt.threshd.mock;
package org.opennms.netmgt.config.api;

import java.io.IOException;
import java.io.InputStream;
import java.net.InetAddress;

import org.opennms.netmgt.config.ThreshdConfigManager;
public interface PathOutageConfig {
/**
* Returns true if the path outage feature is enabled. If enabled, the code
* looks for a critical path specification when processing nodeDown events.
* If a critical path exists for the node, it will be tested. If the
* critical path fails to respond, the eventReason parameter on the
* nodeDown event is set to "pathOutage". This parameter will be used by
* notifd to suppress nodeDown notification.
*
* @return a boolean.
*/
boolean isPathOutageEnabled();

public class MockThreshdConfigManager extends ThreshdConfigManager {
int getDefaultCriticalPathTimeout();

public MockThreshdConfigManager(InputStream stream, String localServer, boolean verifyServer) throws IOException {
super(stream, localServer, verifyServer);
}

@Override
public void reloadXML() throws IOException {
// pass
}

@Override
protected void saveXML(String xmlString) throws IOException {
// pass
}
int getDefaultCriticalPathRetries();

InetAddress getDefaultCriticalPathIp();
}
Loading

0 comments on commit 1ba842b

Please sign in to comment.