Skip to content

Commit 2cf18dd

Browse files
author
Jesse White
committed
Restructure.
1 parent 5b92002 commit 2cf18dd

File tree

24 files changed

+88
-1
lines changed

24 files changed

+88
-1
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.swp

2-events-out-amqp/.README.md.swp

-12 KB
Binary file not shown.

2-events-out-scriptd/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jython*.jar

2-events-out-scriptd/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Demo
2+
3+
## Add Jython to the classpath
4+
5+
wget http://search.maven.org/remotecontent?filepath=org/python/jython-standalone/2.7.0/jython-standalone-2.7.0.jar -O jython-standalone-2.7.0.jar
6+
7+
## Copy over the configuration
8+
9+
cp -R scriptd-configuration.xml my_python_module $OPENNMS_HOME/etc/
10+
11+
## Restart scriptd
12+
13+
$OPENNMS_HOME/bin/send-event.pl -p "daemonName scriptd" uei.opennms.org/internal/reloadDaemonConfig
14+
15+
## Fire up a web server on port 8080
16+
17+
python -m SimpleHTTPServer 8080
18+
19+
## Trigger an event
20+
21+
./1-send-event.sh
22+

2-events-out-scriptd/my_python_module/__init__.py

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import urllib2
2+
import json
3+
4+
class EventForwarder:
5+
def __init__(self, bsf):
6+
self.event = bsf.lookupBean("event")
7+
self.log = bsf.lookupBean("log")
8+
9+
def post(self):
10+
event_as_json = json.dumps({'uei':self.event.uei, 'logmsg':self.event.logmsg.content})
11+
req = urllib2.Request("http://localhost:8080/events", event_as_json, {'Content-Type': 'application/json'})
12+
f = urllib2.urlopen(req)
13+
response = f.read()
14+
self.log.debug("Response: " + response)
15+
f.close()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?xml version="1.0"?>
2+
<scriptd-configuration>
3+
<engine language="python" className="org.apache.bsf.engines.jython.JythonEngine" extensions="py"/>
4+
<event-script language="python">
5+
<uei name="uei.opennms.org/internal/authentication/failure"/>import os
6+
from my_python_module.utils import EventForwarder
7+
ef = EventForwarder(bsf)
8+
ef.post()</event-script>
9+
</scriptd-configuration>
File renamed without changes.
File renamed without changes.
File renamed without changes.

5-inventory-in/README.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Demo
2+
3+
Patch provision.pl with:
4+
5+
```
6+
$post->content($twig->sprint);
7+
print "Posting to '" . $url_root . $base . '/' . $path . "':\n" . $twig->sprint . "\n\n";
8+
my $response = $BROWSER->request($post);
9+
```
10+
11+
```
12+
my $put = HTTP::Request->new(PUT => $url_root . $base . '/' . $path . (defined $args and $args ne '' ? '?' . $args : ''));
13+
print "PUT to '" . $url_root . $base . '/' . $path . "'\n";
14+
my $response = $BROWSER->request($put);
15+
```
16+
17+
Create a new requisition:
18+
19+
```
20+
./bin/provision.pl requisition add test
21+
```
22+
23+
Add a node to the requisition:
24+
25+
```
26+
./bin/provision.pl node add test test-node-foreign-id test-node-label
27+
```
28+
29+
Add an interface to the node:
30+
31+
```
32+
./bin/provision.pl interface add test test-node-foreign-id 127.0.0.2
33+
```
34+
35+
Add a category to the node:
36+
37+
```
38+
./bin/provision.pl category add test test-node-foreign-id ouce2018
39+
```
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
#!/bin/sh
22
curl -s -u admin:admin -H "Accept: application/json" \
3-
"http://localhost:8980/opennms/api/v2/nodes?_s=node.label==*host" \
3+
"http://localhost:8980/opennms/api/v2/nodes?_s=node.label==test*" \
44
| jq ".node[] | {label: .label, id: .id}"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)