Skip to content

Commit

Permalink
Merge branch 'release/1.1.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Neumann authored and Markus Neumann committed Apr 28, 2015
2 parents c9dc845 + bddf716 commit 5f71517
Show file tree
Hide file tree
Showing 24 changed files with 159 additions and 64 deletions.
2 changes: 1 addition & 1 deletion opennms-pris-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-parent</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-api</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion opennms-pris-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-parent</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-dist</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions opennms-pris-docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-parent</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-docs</artifactId>
Expand Down Expand Up @@ -71,7 +71,7 @@
<headerFooter>true</headerFooter>
<sourceDirectory>${asciidoc.source.directory}</sourceDirectory>
<outputDirectory>${asciidoc.output.directory}</outputDirectory>
<imagesDir>./</imagesDir>
<imagesDir>images</imagesDir>
<attributes>
<docVersion>${project.version}</docVersion>
</attributes>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import org.opennms.netmgt.model.PrimaryType
import org.opennms.pris.model.*

/**
Expand All @@ -12,7 +11,8 @@ import org.opennms.pris.model.*
*/

// Name of the requisition. XML file name should be the same, e.g. $OPENNMS_HOME/etc/imports/pending/myGroovySource.xml
Requisition requisition = new Requisition(instance)
Requisition requisition = new Requisition()
requisition.setForeignSource(instance)

config.getInt("count").times {
logger.info("Adding node: {}", it)
Expand Down Expand Up @@ -44,12 +44,12 @@ config.getInt("count").times {
interfaceList.add(requisitionInterface)

// Assign services to monitor to interface
monitoredServiceList.add(new RequisitionMonitoredService("ICMP"))
monitoredServiceList.add(new RequisitionMonitoredService("SNMP"))
monitoredServiceList.add(new RequisitionMonitoredService("HTTP"))
monitoredServiceList.add(new RequisitionMonitoredService(null, "ICMP"))
monitoredServiceList.add(new RequisitionMonitoredService(null, "SNMP"))
monitoredServiceList.add(new RequisitionMonitoredService(null, "HTTP"))

// Assign services for monitoring to IP interface
requisitionInterface.setMonitoredServices(monitoredServiceList)
requisitionInterface.getMonitoredServices().addAll(monitoredServiceList)

// Set Asset information
assetCity.setName("city")
Expand All @@ -64,11 +64,11 @@ config.getInt("count").times {
assetList.add(assetCountry)

// Assign Interfaces and assets to the node
requisitionNode.setInterfaces(interfaceList)
requisitionNode.setAssets(assetList)
requisitionNode.getInterfaces().addAll(interfaceList)
requisitionNode.getAssets().addAll(assetList)

// Put new node into requisition
requisition.putNode(requisitionNode)
requisition.getNodes().add(requisitionNode)
}

return requisition
10 changes: 6 additions & 4 deletions opennms-pris-docs/src/asciidoc/doc-guidelines.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Allow GitHub image rendering
:imagesdir: images

[[doc-guidelines]]
== Documentation guidelines
Expand Down Expand Up @@ -213,23 +215,23 @@ To include an image file, make sure it resides in the 'images/' directory relati

[source]
----
image::images/opennms-logo.png[]
image::opennms-logo.png[]
----

Which is rendered as:

image::images/opennms-logo.png[]
image::opennms-logo.png[]

[source]
----
.example.odp
image::images/example.png[example.odp]
image::example.png[example.odp]
----

Which is rendered as:

.example.odp
image::images/example.png[example.odp]
image::example.png[example.odp]

=== Attributes

Expand Down
5 changes: 4 additions & 1 deletion opennms-pris-docs/src/asciidoc/introduction.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// Allow GitHub image rendering
:imagesdir: images

[[introduction]]
== Introduction
If you have a large network and discovery doesn't help, it helps to find a source of truth for starting to fill your management system.
Expand All @@ -21,7 +24,7 @@ The _PRIS_ components are shown in <<pris_overview>>.
=== Overview

.OpenNMS PRIS overview
image::images/pris-overview.png[OpenNMS PRIS overview]
image::pris-overview.png[OpenNMS PRIS overview]

The components from left to right are described as followed:

Expand Down
8 changes: 5 additions & 3 deletions opennms-pris-docs/src/asciidoc/quickstart.adoc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Allow GitHub image rendering
:imagesdir: images

[[quickstart-example]]
== Quickstart example
Expand All @@ -6,7 +8,7 @@ The first requisition has a worksheet containing all routers and the second work
This example can be found in `examples/source/xlsExample`.

.Worksheet with Router
image::images/myRouter.png[myRouter.png]
image::myRouter.png[myRouter.png]

In line 5, 6 and 7 there is a router defined with more than one IP interface.
All three interfaces will be manually provisioned.
Expand All @@ -16,7 +18,7 @@ For all other IP interfaces you can use the OpenNMS Provisiond mechanism scannin
The server will also be categorized in _Backbone_ and _Office_.

.Worksheet with Server
image::images/myServer.png[myServer.png]
image::myServer.png[myServer.png]

The _OpenNMS_ requisition should be provided via _HTTP_ and we use _OpenNMS Provisiond_ to synchronize it on a regular basis.
We build the following file structure:
Expand Down Expand Up @@ -76,7 +78,7 @@ All changes will be applied from the next request against the server.
With the given configuration you see the result of the OpenNMS requisitions with the URL http://localhost:8000/requisitions/myRouter and http://localhost:8000/requisitions/myServer which can be used in _OpenNMS Provisiond_.

.Output of _PRIS_ server for both configured requisitions
image::images/requisitions-http.png[requisitions-http.png]
image::requisitions-http.png[requisitions-http.png]

To get the requisition provided from _PRIS_ automatically into OpenNMS you can configure Provisiond with a schedule.
Create following to entries in `provisiond-configuration.xml` and they will automatically be synchronized every night at 0h:0m:0s and 1h:0m:0s.
Expand Down
19 changes: 11 additions & 8 deletions opennms-pris-docs/src/asciidoc/source/source.jdbc.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@ The following column-headers will be mapped from the result set to the OpenNMS r

[options="header",cols="1,^1,10"]
|========================
| Column Header | Required | Description
| `Foreign_Id` | * | will be interpreted as `foreignId` on the node
| `IP_Address` | | will be interpreted as an IP address for a new IP interface on the node
| `MgmtType` | | is interpreted as `snmp-primary` flag and controls how the interface can be used to communicate with the SNMP agent. Valid are `P` (Primary), `S` (Secondary) and `N` (None).
| `InterfaceStatus` | | will be interpreted as Interface Status. Value has to be an integer. Use `1` for monitored and `3` for not monitored.
| `Node_Label` | | will be interpreted as node label for the node identified by the `Foreign_Id`
| `Cat` | | will be interpreted as a surveillance category for the node identified by the `Foreign_Id`
| `Svc` | | will be interpreted as a service on the interface of the node identified by the `Foreign_Id` and `IP_Address` field
| Column Header | Required | Description
| `Foreign_Id` | * | will be interpreted as `foreignId` on the node
| `Parent_Foreign_Id` | | defines the `foreignId` for the parent node. Used for `path outages`.
| `Parent_Foreign_Source` | | defines the `foreignSource` for the parent node. Used for `path outages`.
| `Parent_Node_Label` | | defines the `nodeLabel` of the parent node. Used for `path outages`.
| `IP_Address` | | will be interpreted as an IP address for a new IP interface on the node
| `MgmtType` | | is interpreted as `snmp-primary` flag and controls how the interface can be used to communicate with the SNMP agent. Valid are `P` (Primary), `S` (Secondary) and `N` (None).
| `InterfaceStatus` | | will be interpreted as Interface Status. Value has to be an integer. Use `1` for monitored and `3` for not monitored.
| `Node_Label` | | will be interpreted as node label for the node identified by the `Foreign_Id`
| `Cat` | | will be interpreted as a surveillance category for the node identified by the `Foreign_Id`
| `Svc` | | will be interpreted as a service on the interface of the node identified by the `Foreign_Id` and `IP_Address` field
|========================

This source also supports all asset fields by using `Asset_` as a prefix followed by the `asset-field-name`.
Expand Down
19 changes: 11 additions & 8 deletions opennms-pris-docs/src/asciidoc/source/source.xls.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ These `column names` have to start with certain prefixes to be recognized.

[options="header",cols="1,^1,10"]
|========================
| Prefixes | Required | Description
| `Node_` | * | will be interpreted as node label. It is also used as `foreignId` if no `ID_` header is present.
| `IP_` | * | will be interpreted as an IP address as a new interface on the node.
| `MgmtType_` | * | is interpreted as `snmp-primary` flag and controls how the interface can be used to communicate with the SNMP agent. Valid are `P` (Primary), `S` (Secondary) and `N` (None).
| `ID_` | | will be interpreted as `foreignId` for the node. If no `foreignId` is definded the `Node_` value is used as `foreignId`.
| `InterfaceStatus` | | will be interpreted as interface status. Use `1` for monitored and `3` for not monitored.
| `cat_` | | will be interpreted as a surveillance category. Multiple comma-separated categories can be provided. It can be used multiple times per sheet.
| `svc_` | | will be interpreted as a service on the interface of the node. Multiple comma-separated services can be provided. It can be used multiple times per sheet.
| Prefixes | Required | Description
| `Node_` | * | will be interpreted as node label. It is also used as `foreignId` if no `ID_` header is present.
| `IP_` | * | will be interpreted as an IP address as a new interface on the node.
| `MgmtType_` | * | is interpreted as `snmp-primary` flag and controls how the interface can be used to communicate with the SNMP agent. Valid are `P` (Primary), `S` (Secondary) and `N` (None).
| `ID_` | | will be interpreted as `foreignId` for the node. If no `foreignId` is definded the `Node_` value is used as `foreignId`.
| `Parent_Foreign_Id` | | defines the `foreignId` for the parent node. Used for `path outages`.
| `Parent_Foreign_Source` | | defines the `foreignSource` for the parent node. Used for `path outages`.
| `Parent_Node_Label` | | defines the `nodeLabel` of the parent node. Used for `path outages`.
| `InterfaceStatus` | | will be interpreted as interface status. Use `1` for monitored and `3` for not monitored.
| `cat_` | | will be interpreted as a surveillance category. Multiple comma-separated categories can be provided. It can be used multiple times per sheet.
| `svc_` | | will be interpreted as a service on the interface of the node. Multiple comma-separated services can be provided. It can be used multiple times per sheet.
|========================

This source also supports all asset-fields by using `Asset_` as a prefix followed by the `asset-field-name`.
Expand Down
8 changes: 7 additions & 1 deletion opennms-pris-main/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-parent</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-main</artifactId>
Expand Down Expand Up @@ -34,6 +34,12 @@
<artifactId>jetty-server</artifactId>
</dependency>

<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-rewrite</artifactId>
</dependency>


<!-- Configuration -->
<dependency>
<groupId>commons-configuration</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
package org.opennms.pris.driver;

import java.net.InetSocketAddress;
import org.eclipse.jetty.rewrite.handler.RedirectPatternRule;
import org.eclipse.jetty.rewrite.handler.RewriteHandler;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.handler.ContextHandler;
import org.eclipse.jetty.server.handler.ContextHandlerCollection;
Expand All @@ -47,6 +49,8 @@ public class HttpServerDriver implements Driver {

private static final Logger LOGGER = LoggerFactory.getLogger(HttpServerDriver.class);

private final String DOCU_PATH = "/documentation";

public static final class Factory implements Driver.Factory {

@Override
Expand All @@ -66,24 +70,40 @@ private HttpServerDriver(final Configuration config) {
public void run() throws Exception {
// Create an embedded jetty instance
final Server server = new Server(new InetSocketAddress(this.config.getString("host", "127.0.0.1"),
this.config.getInt("port", 8686)));

this.config.getInt("port", 8000)));

ContextHandlerCollection contextHandlerCollection = new ContextHandlerCollection();

// custom handling for requisitions
RequisitionProviderHandler requisitionProviderHandler = new RequisitionProviderHandler();
ContextHandler contextHandlerRequisitions = new ContextHandler("/requisitions");
contextHandlerRequisitions.setHandler(requisitionProviderHandler);
contextHandlerCollection.addHandler(contextHandlerRequisitions);

// provide the documentation
ResourceHandler docuResourceHandler = new ResourceHandler();
docuResourceHandler.setDirectoriesListed(true);
docuResourceHandler.setWelcomeFiles(new String[]{"index.html"});
docuResourceHandler.setResourceBase("./documentation/");
ContextHandler contextHandlerDocu = new ContextHandler("/documentation");
ContextHandler contextHandlerDocu = new ContextHandler(DOCU_PATH);
contextHandlerDocu.setHandler(docuResourceHandler);
contextHandlerCollection.addHandler(contextHandlerDocu);

// redirecting http://ip:port/ to the docu
RewriteHandler redirector = new RewriteHandler();
redirector.setRewriteRequestURI(true);
redirector.setRewritePathInfo(false);

RedirectPatternRule rootToDocuRedirectRule = new RedirectPatternRule();
rootToDocuRedirectRule.setPattern("/*");
rootToDocuRedirectRule.setLocation(DOCU_PATH);
redirector.addRule(rootToDocuRedirectRule);

ContextHandler rootContext = new ContextHandler("/");
rootContext.setHandler(redirector);
contextHandlerCollection.addHandler(rootContext);

server.setHandler(contextHandlerCollection);

server.start();
Expand Down
2 changes: 1 addition & 1 deletion opennms-pris-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-parent</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-model</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion opennms-pris-plugins/opennms-pris-plugins-defaults/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-plugins</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-plugins-defaults</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion opennms-pris-plugins/opennms-pris-plugins-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<parent>
<groupId>org.opennms</groupId>
<artifactId>opennms-pris-plugins</artifactId>
<version>1.1.2</version>
<version>1.1.3</version>
</parent>

<artifactId>opennms-pris-plugins-jdbc</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ public class JdbcSource implements Source {
private static final String COLUMN_FOREIGN_ID = "Foreign_Id";
private static final String INTERFACE_TYPE_PRIMARY = "P";
private static final String INTERFACE_TYPE_SECONDARY = "S";
private static final String COLUMN_PARENT_NODE_LABEL = "Parent_Node_Label";
private static final String COLUMN_PARENT_FOREIGN_ID = "Parent_Foreign_Id";
private static final String COLUMN_PARENT_FOREIGN_SOURCE = "Parent_Foreign_Source";

public JdbcSource(final InstanceConfiguration config) {
this.config = config;
Expand Down Expand Up @@ -108,6 +111,21 @@ public Object dump() {
node.setNodeLabel(nodeLabel);
}

String parentNodeLabel = getString(resultSet, COLUMN_PARENT_NODE_LABEL);
if (parentNodeLabel != null) {
node.setParentNodeLabel(parentNodeLabel);
}

String parentForeignId = getString(resultSet, COLUMN_PARENT_FOREIGN_ID);
if (parentForeignId != null) {
node.setParentForeignId(parentForeignId);
}

String parentForeignSource = getString(resultSet, COLUMN_PARENT_FOREIGN_SOURCE);
if (parentForeignSource != null) {
node.setParentForeignSource(parentForeignSource);
}

String ipAddress = getString(resultSet, COLUMN_IP_ADDRESS);

if (ipAddress != null) {
Expand Down
Loading

0 comments on commit 5f71517

Please sign in to comment.