Skip to content

Commit

Permalink
Merge origin/rc/stable/1.14 into jira/NMS-7083
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus von Rüden committed Oct 29, 2014
2 parents 1069a70 + ef3bdcc commit e53907b
Show file tree
Hide file tree
Showing 25 changed files with 410 additions and 363 deletions.
5 changes: 5 additions & 0 deletions core/snmp/api/pom.xml
Expand Up @@ -37,5 +37,10 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>org.json</groupId>
<artifactId>json</artifactId>
<version>20140107</version>
</dependency>
</dependencies>
</project>
248 changes: 113 additions & 135 deletions core/snmp/api/src/main/java/org/opennms/netmgt/snmp/SnmpAgentConfig.java

Large diffs are not rendered by default.

@@ -1,11 +1,11 @@
package org.opennms.netmgt.snmp;

import org.junit.Assert;
import org.junit.Test;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.junit.Assert;
import org.junit.Test;

public class SnmpAgentConfigTest {

@Test
Expand Down Expand Up @@ -51,6 +51,12 @@ public void testProtocolConfiguration() throws UnknownHostException {
config.setAuthPassPhrase(null);
config.setPrivPassPhrase(null);
config2 = SnmpAgentConfig.parseProtocolConfigurationString(config.toProtocolConfigString());
// config2 will have the default PrivPassphrase and such, so these will *not* actually equal each other
Assert.assertFalse(config.equals(config2));
Assert.assertFalse(config.hashCode() == config2.hashCode());
config2.setAuthPassPhrase(null);
config2.setPrivPassPhrase(null);
// now they should match
Assert.assertEquals(config, config2);
Assert.assertEquals(config.hashCode(), config2.hashCode());

Expand Down
2 changes: 1 addition & 1 deletion dependencies/jrobin/pom.xml
Expand Up @@ -14,7 +14,7 @@
<dependency>
<groupId>org.jrobin</groupId>
<artifactId>jrobin</artifactId>
<version>1.6.0-SNAPSHOT</version>
<version>1.6.0</version>
</dependency>
</dependencies>
<repositories>
Expand Down
Expand Up @@ -170,8 +170,9 @@ public void setRepository(RrdRepository repository) {
/** {@inheritDoc} */
@Override
public void persistNumericAttribute(CollectionAttribute attribute) {
LOG.debug("Persisting {} {}", attribute, (isIgnorePersist() ? ". Ignoring value because of sysUpTime changed." : ""));
String value = isIgnorePersist() ? "U" : attribute.getNumericValue();
boolean persist = isIgnorePersist() && attribute.getType().toLowerCase().startsWith("counter");
LOG.debug("Persisting {} {}", attribute, (persist ? ". Ignoring value because of sysUpTime changed." : ""));
String value = persist ? "U" : attribute.getNumericValue();
m_builder.setAttributeValue(attribute.getAttributeType(), value);
m_builder.setAttributeMetadata(attribute.getMetricIdentifier(), attribute.getName());
}
Expand Down
Expand Up @@ -231,6 +231,18 @@ private void parseArguments(String[] args) throws ParseException {
m_password = "";
}
}

// If we cannot obtain the username/password from the command line, attempt
// to optionally get it from system properties
if (m_username == null) {
m_username = System.getProperty("opennms.poller.server.username");
if (m_username != null) {
m_password = System.getProperty("opennms.poller.server.password");
if (m_password == null) {
m_password = "";
}
}
}
}

private static void usage(Options o) {
Expand Down
Expand Up @@ -58,7 +58,7 @@
@SuppressWarnings("serial")
public class PingWindow extends Window {

private static final double sizePercentage = 0.80; // Window size proportionate to main window
private static final int sizePercentage = 80; // Window size proportionate to main window
protected NativeSelect ipDropdown = null; //Dropdown component for IP Address
protected NativeSelect packetSizeDropdown = null; //Dropdown component for Packet Size
private Label nodeLabel = null; //Label displaying the name of the Node at the top of the window
Expand All @@ -67,8 +67,6 @@ public class PingWindow extends Window {
protected CheckBox numericalDataCheckBox = null; //Checkbox for toggling numeric output
protected Button pingButton; //Button to execute the ping operation
private Embedded resultsBrowser = null; //Browser which displays the ping results
private static final int margin = 40; //Padding around the results browser
private static final int topHeight = 280; //Set height size for everything above the split
private static final String noLabel = "no such label"; //Label given to vertexes that have no real label.
private String pingUrl;

Expand Down Expand Up @@ -207,17 +205,12 @@ public void buttonClick(ClickEvent event) {
public void attach() {
super.attach();

int width = (int) getUI().getPage().getBrowserWindowWidth();
int height = (int) getUI().getPage().getBrowserWindowHeight();
setWidth(sizePercentage, Unit.PERCENTAGE);
setHeight(sizePercentage, Unit.PERCENTAGE);

int windowWidth = (int) (sizePercentage * width), windowHeight = (int) (sizePercentage * height);
setWidth("" + windowWidth + "px");
setHeight("" + windowHeight + "px");
setPositionX((width - windowWidth) / 2);
setPositionY((height - windowHeight) / 2);
center();

resultsBrowser.setWidth("" + (int) (this.getWidth() - margin) + "px"); //Cuts off "close" button from window
resultsBrowser.setHeight("" + (int) (this.getHeight() - topHeight - margin) + "px");
resultsBrowser.setSizeFull();
}

/**
Expand Down Expand Up @@ -264,6 +257,7 @@ protected URL buildURL() {
options.append("address=").append(ipDropdown.getValue())
.append("&timeout=").append(timeoutField.getValue())
.append("&numberOfRequest=").append(requestsField.getValue())
.append("&hideCloseButton=true")
.append("&packetSize=").append(Integer.parseInt(packetSizeDropdown.getValue().toString()) - 8);
if (numericalDataCheckBox.getValue().equals(true)) {
options.append("&numericOutput=true");
Expand Down
106 changes: 69 additions & 37 deletions opennms-assemblies/remote-poller-nsis/remote-poller.nsi
Expand Up @@ -38,10 +38,13 @@ Var ServiceDomain
Var ComputerName

Var JavaHome

Var OnmsWebappProtocol
Var OnmsWebappServer
Var OnmsWebappPort
Var OnmsWebappPath
Var OnmsWebappUsername
Var OnmsWebappPassword

Var POLLER_SERVICE_FILE_NAME
Var POLLER_TRAY_FILE_NAME
Expand All @@ -53,10 +56,14 @@ Var GUI_POLLER_SVC_NAME
Var POLLER_SVC_DISP_NAME
Var POLLER_SVC_DESCRIPTION
Var POLLER_PROPS_FILE

Var DEFAULT_WEBUI_PROTOCOL
Var DEFAULT_WEBUI_HOST
Var DEFAULT_WEBUI_PORT
Var DEFAULT_WEBUI_PATH
Var DEFAULT_WEBUI_USERNAME
Var DEFAULT_WEBUI_PASSWORD

Var KILL_SWITCH_FILE_NAME
Var VBS_KILL_SCRIPT

Expand All @@ -75,15 +82,6 @@ Function .onInit
MessageBox MB_OK|MB_ICONEXCLAMATION "The installer is already running."
Abort

# Same as DEFAULT_WEBUI_PROTOCOL
StrCpy $OnmsWebappProtocol "http"
# Same as DEFAULT_WEBUI_HOST
StrCpy $OnmsWebappServer "<IP Address or Hostname>"
# Same as DEFAULT_WEBUI_PORT
StrCpy $OnmsWebappPort "8980"
# Same as DEFAULT_WEBUI_PATH
StrCpy $OnmsWebappPath "/opennms"

ReadEnvStr $ServiceUser "USERNAME"
ReadEnvStr $ServiceDomain "USERDOMAIN"
ReadEnvStr $ComputerName "COMPUTERNAME"
Expand Down Expand Up @@ -128,16 +126,26 @@ GotJava:
StrCpy $POLLER_SVC_DISP_NAME "${PROJECT_NAME}"
StrCpy $POLLER_SVC_DESCRIPTION "Measures uptime and latency of services from remote locations, sending the data back to an OpenNMS server"
StrCpy $POLLER_PROPS_FILE "$PROFILE\.opennms\remote-poller.properties"
StrCpy $KILL_SWITCH_FILE_NAME "remote-poller.run"
StrCpy $VBS_KILL_SCRIPT "pollkill.vbs"

StrCpy $DEFAULT_WEBUI_PROTOCOL "http"
StrCpy $DEFAULT_WEBUI_HOST "<IP Address or Hostname>"
StrCpy $DEFAULT_WEBUI_PORT "8980"
StrCpy $DEFAULT_WEBUI_PATH "/opennms"
StrCpy $KILL_SWITCH_FILE_NAME "remote-poller.run"
StrCpy $VBS_KILL_SCRIPT "pollkill.vbs"
FunctionEnd
StrCpy $DEFAULT_WEBUI_USERNAME "admin"
StrCpy $DEFAULT_WEBUI_PASSWORD "admin"

StrCpy $OnmsWebappProtocol "$DEFAULT_WEBUI_PROTOCOL"
StrCpy $OnmsWebappServer "$DEFAULT_WEBUI_HOST"
StrCpy $OnmsWebappPort "$DEFAULT_WEBUI_PORT"
StrCpy $OnmsWebappPath "$DEFAULT_WEBUI_PATH"
StrCpy $OnmsWebappUsername "$DEFAULT_WEBUI_USERNAME"
StrCpy $OnmsWebappPassword "$DEFAULT_WEBUI_PASSWORD"

FunctionEnd

# Uninstall init method
Function un.onInit
# First, prevent multiple instances of this installer.
System::Call 'kernel32::CreateMutexA(i 0, i 0, t "onmsRpMutex") i .r1 ?e'
Expand Down Expand Up @@ -169,12 +177,15 @@ Function un.onInit
StrCpy $POLLER_SVC_DISP_NAME "${PROJECT_NAME}"
StrCpy $POLLER_SVC_DESCRIPTION "Measures uptime and latency of services from remote locations, sending the data back to an OpenNMS server"
ReadRegStr $POLLER_PROPS_FILE HKLM "Software\The OpenNMS Group\${PROJECT_NAME}" "PollerPropsFile"
StrCpy $KILL_SWITCH_FILE_NAME "remote-poller.run"

StrCpy $DEFAULT_WEBUI_PROTOCOL "http"
StrCpy $DEFAULT_WEBUI_HOST "<IP Address or Hostname>"
StrCpy $DEFAULT_WEBUI_PORT "8980"
StrCpy $DEFAULT_WEBUI_PATH "/opennms"
StrCpy $KILL_SWITCH_FILE_NAME "remote-poller.run"
StrCpy $DEFAULT_WEBUI_USERNAME "admin"
StrCpy $DEFAULT_WEBUI_PASSWORD "admin"

FunctionEnd


Expand All @@ -192,12 +203,12 @@ PageEx instfiles
CompletedText "Click Next to configure the ${PROJECT_NAME} on your system."
PageExEnd

Page custom onmsSvcUserPage onmsSvcUserPageLeave

Page custom removeOldRegFilePage removeOldRegFilePageLeave

Page custom onmsServerInfoPage onmsServerInfoPageLeave

Page custom onmsSvcUserPage onmsSvcUserPageLeave

Page custom launchGuiPollerPage launchGuiPollerPageLeave

Page custom svcCreationPage svcCreationPageLeave
Expand Down Expand Up @@ -263,12 +274,12 @@ LicenseData resources\agpl-3.0.txt
#----------------------
# Variables used in our custom dialogs
Var Dialog
Var UserLabel
Var UserText
Var PasswordLabel
Var PasswordText
Var PasswordRepLabel
Var PasswordRepText
Var ServiceUserLabel
Var ServiceUserText
Var ServicePasswordLabel
Var ServicePasswordText
Var ServicePasswordRepeatLabel
Var ServicePasswordRepeatText

Var TopLabel
Var ServerLabel
Expand All @@ -277,6 +288,10 @@ Var PortLabel
Var PortText
Var AppPathLabel
Var AppPathText
Var UsernameLabel
Var UsernameText
Var PasswordLabel
Var PasswordText
Var HttpsCheckbox

Var LaunchGuiLabel
Expand Down Expand Up @@ -441,7 +456,19 @@ Function onmsServerInfoPage
${NSD_CreateText} 126u 59u 50u 12u "$OnmsWebappPath"
Pop $AppPathText

${NSD_CreateCheckBox} 0 79u 100% 12u " Use &secure connection (HTTPS)"
${NSD_CreateLabel} 0 80u 125u 12u "Web UI username:"
Pop $UsernameLabel

${NSD_CreateText} 126u 79u 100u 12u "$OnmsWebappUsername"
Pop $UsernameText

${NSD_CreateLabel} 0 100u 125u 12u "Web UI password:"
Pop $PasswordLabel

${NSD_CreatePassword} 126u 99u 100u 12u "$OnmsWebappPassword"
Pop $PasswordText

${NSD_CreateCheckBox} 0 119u 100% 12u " Use &secure connection (HTTPS)"
Pop $HttpsCheckbox
StrCmp $OnmsWebappProtocol "https" SetHttps SetHttp
SetHttps:
Expand Down Expand Up @@ -532,23 +559,23 @@ Function onmsSvcUserPage
Pop $TopLabel

${NSD_CreateLabel} 0 40u 40u 12u "Username:"
Pop $UserLabel
Pop $ServiceUserLabel

${NSD_CreateText} 61u 39u 70u 12u "$ServiceUser"
Pop $UserText
SendMessage $UserText ${EM_SETREADONLY} 1 0
Pop $ServiceUserText
SendMessage $ServiceUserText ${EM_SETREADONLY} 1 0

${NSD_CreateLabel} 0 60u 40u 12u "Password:"
Pop $PasswordLabel
Pop $ServicePasswordLabel

${NSD_CreatePassword} 61u 59u 70u 12u "$ServicePassword"
Pop $PasswordText
Pop $ServicePasswordText

${NSD_CreateLabel} 0 80u 60u 12u "Repeat Password:"
Pop $PasswordRepLabel
Pop $ServicePasswordRepeatLabel

${NSD_CreatePassword} 61u 79u 70u 12u "$ServicePassword"
Pop $PasswordRepText
Pop $ServicePasswordRepeatText

nsDialogs::Show
FunctionEnd
Expand All @@ -557,8 +584,8 @@ Function onmsSvcUserPageLeave
Push $0
Push $1
Push $2
${NSD_GetText} $PasswordText $1
${NSD_GetText} $PasswordRepText $2
${NSD_GetText} $ServicePasswordText $1
${NSD_GetText} $ServicePasswordRepeatText $2
StrCmp $1 $2 PasswordsMatch
MessageBox MB_OK "The password fields must match. Please try again."
Abort
Expand Down Expand Up @@ -704,7 +731,7 @@ Function javaCheckPage
${EndIf}

${NSD_CreateLabel} 0 10u 100% 30u "The installer has identified multiple Java installations on this system, but could not$\r$\ndetermine the best one to use. Please select the Java installation to use for$\r$\n$POLLER_SVC_DISP_NAME."
Pop $UserLabel
Pop $ServiceUserLabel

${NSD_CreateListBox} 0 40u 100% 80u "List of suitable Java installations"
Pop $JavaListBox
Expand Down Expand Up @@ -748,7 +775,7 @@ Function removeOldRegFilePage
Abort
${EndIf}
${NSD_CreateLabel} 0 10u 100% 36u "The remote poller on this system has previously registered with an OpenNMS server. Do you want to keep the existing registratrion or remove it and create a new one? If you remove it, the continuity of data gathered by the poller on this system will be interrupted."
Pop $UserLabel
Pop $ServiceUserLabel
${NSD_CreateRadioButton} 0 50u 100% 12u "&Keep existing registration"
Pop $TEMP1
${NSD_SetState} $TEMP1 ${BST_CHECKED}
Expand Down Expand Up @@ -782,7 +809,7 @@ Function un.OptionsPage
Abort
${EndIf}
${NSD_CreateLabel} 0 10u 100% 30u "Do you want to remove the remote poller registration file? If you remove this file and later reinstall $POLLER_SVC_DISP_NAME on this system, the continuity of data gathered by the poller on this system will be interrupted."
Pop $UserLabel
Pop $ServiceUserLabel
${NSD_CreateCheckBox} 0 50u 100% 12u "Remove remote poller &registration file"
Pop $ShouldRemovePollerProps
nsDialogs::Show
Expand Down Expand Up @@ -912,7 +939,7 @@ FunctionEnd
# Function that sets JAVAWS_VM_ARGS in the service
# user's environment
Function SetJWSUserEnv
WriteRegExpandStr HKCU "Environment" "JAVAWS_VM_ARGS" "-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/remote-poller.run -Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml"
WriteRegExpandStr HKCU "Environment" "JAVAWS_VM_ARGS" "-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/remote-poller.run -Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml -J-Dopennms.poller.server.username=$OnmsWebappUsername -J-Dopennms.poller.server.password=$OnmsWebappPassword "
# Now broadcast a message informing all windows in the system
# of the change to the environment
# This hangs on some systems, disabling as it doesn't have the desired effect anyway
Expand All @@ -928,7 +955,12 @@ Function LaunchGUIPoller
Call GetJWSBaseURL
Pop $1
StrCpy $JnlpUrl "$1/$GUI_POLLER_JNLP"
Exec '"$JWSEXE" -J-Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml -J-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/$KILL_SWITCH_FILE_NAME $JnlpUrl'
Exec '"$JWSEXE" -J-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/$KILL_SWITCH_FILE_NAME -J-Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml -J-Dopennms.poller.server.username=$OnmsWebappUsername -J-Dopennms.poller.server.password=$OnmsWebappPassword $JnlpUrl'
# Not sure if this works yet
#IntCmp $1 0 GuiInstallOk GuiInstallFailed GuiInstallFailed
#GuiInstallFailed:
#MessageBox MB_OK|MB_ICONEXCLAMATION "The GUI installer did not complete successfully. Please check the configuration parameters and try to launch it again."
#GuiInstallOk:
FunctionEnd


Expand All @@ -940,7 +972,7 @@ Function CreateOrUpdatePollerSvc
Call GetJWSBaseURL
Pop $1
StrCpy $JnlpUrl "$1/$HEADLESS_POLLER_JNLP"
StrCpy $ExtraJWSOpts "-J-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/$KILL_SWITCH_FILE_NAME#-J-Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml#"
StrCpy $ExtraJWSOpts "-J-Dopennms.poller.killSwitch.resource=$PROFILEJAVA/.opennms/$KILL_SWITCH_FILE_NAME#-J-Dlog4j.configurationFile=file:///$INSTDIRJAVA/etc/log4j2.xml#-J-Dopennms.poller.server.username=$OnmsWebappUsername#-J-Dopennms.poller.server.password=$OnmsWebappPassword#"

# Check whether the service exists, decide on our verb (install / update) accordingly
Push $POLLER_SVC_NAME
Expand Down

0 comments on commit e53907b

Please sign in to comment.