Skip to content

Commit

Permalink
Add SNMPv3 support to GUI and REST api
Browse files Browse the repository at this point in the history
backported from master

Squashed commit of the following:

commit 188b046
Author: Alejandro Galue <agalue@opennms.org>
Date:   Fri Aug 15 12:37:19 2014 -0400

    Improving provision.pl to expose the SNMPv3 settings.

commit 30234d6
Author: Matt Brozowski <matt@brozowski.com>
Date:   Thu Aug 14 10:55:35 2014 -0400

    make sure the field names are correct in jsp and smoke-test

commit da735ed
Author: Matt Brozowski <matt@brozowski.com>
Date:   Thu Aug 14 10:39:38 2014 -0400

    fix smoke-tests

commit 7aba31c
Author: Matt Brozowski <matt@brozowski.com>
Date:   Wed Aug 13 18:26:52 2014 -0400

    fix misspelling

commit a0f1323
Author: Matt Brozowski <matt@brozowski.com>
Date:   Wed Aug 13 17:35:06 2014 -0400

    use assertXmlEquals for comparing xml strings

commit 544bfe3
Author: Markus von Rüden <mvr@opennms.com>
Date:   Fri May 3 11:49:14 2013 +0200

    Merge from branch 'feature-snmpv3-config-ui'

    Conflicts:
    	opennms-config/src/test/java/org/opennms/netmgt/config/SnmpEventInfoTest.java
    	opennms-webapp/src/main/webapp/admin/index.jsp
    	smoke-test/src/test/java/org/opennms/smoketest/AdminPageTest.java

commit 0f8466a
Author: Markus von Rüden <mvr@opennms.com>
Date:   Thu Apr 25 11:34:22 2013 +0200

    First implementation of #374 and #155 :SNMPv3 Rest API enhancements

    Conflicts:
    	core/snmp/api/src/main/java/org/opennms/netmgt/snmp/SnmpAgentConfig.java
    	core/snmp/api/src/main/java/org/opennms/netmgt/snmp/SnmpConfiguration.java
    	opennms-config/src/main/java/org/opennms/netmgt/config/SnmpPeerFactory.java
  • Loading branch information
brozow committed Aug 18, 2014
1 parent 54cf46a commit 74fa63a
Show file tree
Hide file tree
Showing 21 changed files with 3,011 additions and 1,604 deletions.
Expand Up @@ -118,18 +118,20 @@ public static SnmpAgentConfig parseProtocolConfigurationString(String protocolCo
agentConfig.setPrivProtocol(value);
} else if ("read-community".equalsIgnoreCase(key)) {
agentConfig.setReadCommunity(value);
} else if ("context-name".equalsIgnoreCase(key)) {
agentConfig.setContextName(value);
} else if ("engine-id".equalsIgnoreCase(key)) {
agentConfig.setEngineId(value);
agentConfig.setEngineId(value);
} else if ("context-engine-id".equalsIgnoreCase(key)) {
agentConfig.setContextEngineId(value);
agentConfig.setContextEngineId(value);
} else if ("context-name".equalsIgnoreCase(key)) {
agentConfig.setContextName(value);
} else if ("enterprise-id".equalsIgnoreCase(key)) {
agentConfig.setEnterpriseId(value);
} else if ("write-community".equalsIgnoreCase(key)) {
agentConfig.setWriteCommunity(value);
} else {
s_logger.warn("Unexpected attribute in protocol configuration string for SnmpAgentConfig: '{}'", attribute);
}
}


return agentConfig;
}

Expand All @@ -143,45 +145,49 @@ public String toProtocolConfigString() {
buff.append(",max-repetitions=" + getMaxRepetitions());
buff.append(",max-request-size=" + getMaxRequestSize());
buff.append(",version=" + versionToString(getVersion()));
if (getVersion() == VERSION3) {
if (isVersion3()) {
buff.append(",security-level=" + getSecurityLevel());
buff.append(",security-name=" + getSecurityName());
buff.append(",auth-passphrase=" + getAuthPassPhrase());
buff.append(",auth-protocol=" + getAuthProtocol());
buff.append(",priv-passprhase=" + getPrivPassPhrase());
buff.append(",priv-passphrase=" + getPrivPassPhrase());
buff.append(",priv-protocol=" + getPrivProtocol());
if (getContextName() != null) buff.append(",context-name=" + getContextName());
if (getEngineId() != null) buff.append(",engine-id=" + getEngineId());
if (getContextEngineId() != null) buff.append(",context-engine-id=" + getContextEngineId());
buff.append(",engine-id=" + getEngineId());
buff.append(",context-engine-id=" + getContextEngineId());
buff.append(",context-name=" + getContextName());
buff.append(",enterprise-id=" + getEnterpriseId());
} else {
buff.append(",read-community=" + getReadCommunity());
buff.append(",write-community=" + getWriteCommunity());
}
return buff.toString();

}

public String toString() {
StringBuffer buff = new StringBuffer("AgentConfig[");
buff.append("Address: " + (m_address == null? null : InetAddressUtils.str(m_address)));
buff.append(", ProxyForAddress: " + (m_proxyFor == null? null : InetAddressUtils.str(m_proxyFor)));
StringBuffer buff = new StringBuffer("SnmpAgentConfig[");
buff.append("Address: " + InetAddressUtils.str(m_address));
buff.append(", ProxyForAddress: " + InetAddressUtils.str(m_proxyFor));
buff.append(", Port: " + getPort());
buff.append(", Community: " + getReadCommunity());
buff.append(", Timeout: " + getTimeout());
buff.append(", Retries: " + getRetries());
buff.append(", MaxVarsPerPdu: " + getMaxVarsPerPdu());
buff.append(", MaxRepetitions: " + getMaxRepetitions());
buff.append(", Max request size: " + getMaxRequestSize());
buff.append(", MaxRequestSize: " + getMaxRequestSize());
buff.append(", Version: " + versionToString(getVersion()));
if (getVersion() == VERSION3) {
buff.append(", Security level: " + getSecurityLevel());
buff.append(", Security name: " + getSecurityName());
buff.append(", auth-passphrase: " + getAuthPassPhrase());
buff.append(", auth-protocol: " + getAuthProtocol());
buff.append(", priv-passprhase: " + getPrivPassPhrase());
buff.append(", priv-protocol: " + getPrivProtocol());
buff.append(", Context name: " + getContextName());
buff.append(", Engine ID: " + getEngineId());
buff.append(", Context Engine ID: " + getContextEngineId());
if (isVersion3()) {
buff.append(", SecurityLevel: " + getSecurityLevel());
buff.append(", SecurityName: " + getSecurityName());
buff.append(", AuthPassPhrase: " + getAuthPassPhrase());
buff.append(", AuthProtocol: " + getAuthProtocol());
buff.append(", PrivPassprhase: " + getPrivPassPhrase());
buff.append(", PrivProtocol: " + getPrivProtocol());
buff.append(", EngineId: " + getEngineId());
buff.append(", ContextEngineId: " + getContextEngineId());
buff.append(", ContextName: " + getContextName());
buff.append(", EnterpriseId:" + getEnterpriseId());
} else {
buff.append(", ReadCommunity: " + getReadCommunity());
buff.append(", WriteCommunity: " + getWriteCommunity());
}
buff.append("]");
return buff.toString();
Expand Down
Expand Up @@ -37,7 +37,7 @@
*/
@XmlRootElement(name="snmpConfiguration")
public class SnmpConfiguration {
public static final int DEFAULT_TIMEOUT = 3000;
public static final int DEFAULT_PORT = 161;
public static final int VERSION1 = 1;
Expand Down Expand Up @@ -102,9 +102,10 @@ public class SnmpConfiguration {
private String m_authProtocol;
private String m_privProtocol;
private String m_privPassPhrase;
private String m_contextName;
private String m_engineId;
private String m_contextEngineId;
private String m_contextName;
private String m_enterpriseId;

public SnmpConfiguration() {
this(DEFAULTS);
Expand All @@ -126,9 +127,10 @@ public SnmpConfiguration(SnmpConfiguration config) {
setTimeout(config.getTimeout());
setVersion(config.getVersion());
setWriteCommunity(config.getWriteCommunity());
setEnterpriseId(config.getEnterpriseId());
setContextName(config.getContextName());
setEngineId(config.getEngineId());
setContextEngineId(config.getContextEngineId());
setEngineId(config.getEngineId());
}
}

Expand Down Expand Up @@ -287,28 +289,39 @@ public final void setPrivPassPhrase(String privPassPhrase) {
m_privPassPhrase = privPassPhrase;
}

public final String getContextName() {
return m_contextName;
public final String getEngineId() {
return m_engineId;
}

public final void setContextName(String contextName) {
m_contextName = contextName;
public final void setEngineId(final String engineId) {
m_engineId = engineId;
}

public final String getEngineId() {
return m_engineId;
public final String getContextEngineId() {
return m_contextEngineId;
}

public final void setEngineId(String engineId) {
m_engineId = engineId;
public final void setContextEngineId(final String contextEngineId) {
m_contextEngineId = contextEngineId;
}

public final String getContextEngineId() {
return m_contextEngineId;
public final String getContextName() {
return m_contextName;
}

public final void setContextEngineId(String contextEngineId) {
m_contextEngineId = contextEngineId;
public void setContextName(final String contextName) {
m_contextName = contextName;
}

public final String getEnterpriseId() {
return m_enterpriseId;
}

public void setEnterpriseId(final String enterpriseId) {
m_enterpriseId = enterpriseId;
}

public boolean isVersion3() {
return getVersion() == VERSION3;
}

}
44 changes: 42 additions & 2 deletions opennms-base-assembly/src/main/filtered/bin/provision.pl
Expand Up @@ -538,16 +538,56 @@ sub cmd_asset {
Valid options are:
=over 8
=over 4
=item * version: v1 or v2c
=item * version: v1 or v2c or v3
=item * port: the port of the SNMP agent
=item * timeout: the timeout, in milliseconds
=item * retries: the number of retries before giving up
=item * max-repetitions: maximum repetitions (defaults to 2)
=item * max-vars-per-pdu: maximum variables per PDU (defaults to 10)
=back
SNMPv3 options:
=over 4
=item * security-name: the USM name
=item * security-level: 1, 2, 3
=over 4
=item * 1: noAuthNoPriv (default)
=item * 2: authNoPriv
=item * 3: authPriv
=back
=item * priv-protocol: DES, AES, AES192, AES256
=item * priv-pass-phrase: the password for privacy protocol
=item * auth-protocol: MD5, SHA
=item * auth-pass-phrase: the password for the authentication protocol
=item * engine-id: the unique engine ID of the SNMP agent
=item * context-engine-id: the context ending ID
=item * context-name: the context name
=item * enterprise-id: the enterprise ID
=back
=back
Expand Down

0 comments on commit 74fa63a

Please sign in to comment.