Skip to content

Commit 23726ab

Browse files
Merge remote-tracking branch 'origin/develop'
2 parents 7f19db4 + cd44ada commit 23726ab

File tree

10 files changed

+2150
-12422
lines changed

10 files changed

+2150
-12422
lines changed

README.md

+4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ OpenNMS.js follows [semantic versioning](https://semver.org/).
2222

2323
### Release Notes
2424

25+
#### 2.5.10
26+
27+
OpenNMS.js v2.5.10 contains a bunch of dependency updates, as well as an improvement to the OpenNMS node model for OpenNMS and OPG versions that support it (expected to be part of Horizon 33 and Meridian 2024).
28+
2529
#### 2.5.8
2630

2731
OpenNMS.js v2.5.8 contains even more dependency updates, as well as an improvement to the monitored service model to include additional interface and node-related metadata for OpenNMS versions that support it (expected to be part of Horizon 33 and Meridian 2024).

package-lock.json

+1,765-12,406
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opennms",
3-
"version": "2.5.10-SNAPSHOT",
3+
"version": "2.5.10",
44
"description": "Client API for the OpenNMS network monitoring platform",
55
"main": "dist/opennms.js",
66
"bin": {
@@ -36,31 +36,31 @@
3636
"@types/node": "^16.11.27",
3737
"@types/object-hash": "^3.0.1",
3838
"@types/urijs": "^1.19.17",
39-
"@typescript-eslint/eslint-plugin": "^7.0.1",
40-
"@typescript-eslint/parser": "^7.0.1",
39+
"@typescript-eslint/eslint-plugin": "^8.11.0",
40+
"@typescript-eslint/parser": "^8.17.0",
4141
"babel-loader": "^9.1.0",
4242
"babel-plugin-angularjs-annotate": "^0.10.0",
4343
"babel-plugin-lodash": "^3.3.4",
4444
"babel-plugin-module-resolver": "^5.0.0",
4545
"cache-loader": "^4.1.0",
4646
"chai": "^5.0.0",
4747
"child_process": "^1.0.2",
48-
"eslint": "^8.49.0",
48+
"eslint": "^8.57.0",
4949
"eslint-plugin-import": "^2.28.1",
5050
"eslint-plugin-prefer-arrow": "^1.2.3",
51-
"eslint-plugin-tsdoc": "^0.3.0",
51+
"eslint-plugin-tsdoc": "^0.4.0",
5252
"eslint-webpack-plugin": "^4.0.1",
5353
"husky": "^9.0.3",
5454
"jest": "^29.2.0",
5555
"lodash-webpack-plugin": "^0.11.6",
5656
"parallel-webpack": "^2.6.0",
57-
"rimraf": "^5.0.0",
57+
"rimraf": "^6.0.1",
5858
"standard-changelog": "^5.0.0",
5959
"terser-webpack-plugin": "^5.3.0",
6060
"ts-jest": "^29.0.3",
6161
"ts-node": "^10.4.0",
62-
"typedoc": "^0.26.2",
63-
"typescript": "~5.5.3",
62+
"typedoc": "^0.27.5",
63+
"typescript": "~5.7.2",
6464
"urijs": "^1.19.1",
6565
"webpack": "^5.66.0",
6666
"webpack-cli": "^5.0.0",
@@ -82,20 +82,20 @@
8282
},
8383
"dependencies": {
8484
"@babel/runtime-corejs3": "^7.17.9",
85-
"@xmldom/xmldom": "^0.8.0",
85+
"@xmldom/xmldom": "^0.9.3",
8686
"axios": "^1.1.3",
8787
"btoa": "^1.2.1",
8888
"commander": "^12.0.0",
8989
"core-js": "^3.22.2",
9090
"fs": "^0.0.1-security",
9191
"html-to-formatted-text": "^2.6.0",
92-
"ip-address": "^9.0.5",
92+
"ip-address": "^10.0.1",
9393
"lodash": "^4.17.20",
9494
"moment": "^2.29.1",
9595
"object-hash": "^3.0.0",
96-
"picocolors": "^1.0.0",
97-
"qs": "^6.10.3",
98-
"table": "^6.8.0",
96+
"picocolors": "^1.1.1",
97+
"qs": "^6.13.1",
98+
"table": "^6.9.0",
9999
"version_compare": "^0.0.3",
100100
"x2js": "^3.4.2"
101101
},

src/model/OnmsNode.ts

+4
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ export class OnmsNode implements IHasUrlValue {
3636
/** the time the node was created */
3737
public createTime?: Moment;
3838

39+
/** the ID of the parent node, if any */
40+
public nodeParentId?: number;
41+
3942
/** the parent of this node */
4043
public parent?: OnmsNode;
4144

@@ -117,6 +120,7 @@ export class OnmsNode implements IHasUrlValue {
117120
node.location = data.location;
118121
node.foreignSource = data.foreignSource || undefined;
119122
node.foreignId = data.foreignId || undefined;
123+
node.nodeParentId = data.nodeParentID || undefined;
120124
node.sysContact = data.sysContact;
121125
node.sysDescription = data.sysDescription;
122126
node.sysLocation = data.sysLocation;

test/dao/NodeDAO.spec.ts

+46-3
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {NodeDAO} from '../../src/dao/NodeDAO';
1717

1818
import {MockHTTP19} from '../rest/MockHTTP19';
1919
import {MockHTTP21} from '../rest/MockHTTP21';
20+
import {MockHTTP33} from '../rest/MockHTTP33';
2021

2122
/** @hidden */
2223
// tslint:disable-next-line
@@ -43,9 +44,11 @@ describe('NodeDAO with v1 API', () => {
4344
done();
4445
});
4546
});
47+
4648
it('NodeDAO.get(43, [recurse=false])', () => {
4749
return dao.get(43).then((node) => {
4850
expect(node.id).toEqual(43);
51+
expect(node.nodeParentId).toBeUndefined();
4952
expect(node.categories.length).toEqual(2);
5053
expect(node.categories[0]).toBeInstanceOf(OnmsCategory);
5154
expect(node.foreignSource).toBeUndefined();
@@ -54,9 +57,11 @@ describe('NodeDAO with v1 API', () => {
5457
expect(node.type).toBeInstanceOf(OnmsNodeType);
5558
});
5659
});
60+
5761
it('NodeDAO.get(43, recurse=true)', () => {
5862
return dao.get(43, true).then((node) => {
5963
expect(node.id).toEqual(43);
64+
expect(node.nodeParentId).toBeUndefined();
6065
expect(node.categories.length).toEqual(2);
6166
expect(node.categories[0]).toBeInstanceOf(OnmsCategory);
6267
expect(node.foreignSource).toBeUndefined();
@@ -73,23 +78,26 @@ describe('NodeDAO with v1 API', () => {
7378
expect(snmp.ifOperStatus).toEqual(SnmpStatusTypes['1']);
7479
expect(snmp.ifName).toEqual('br0');
7580
expect(snmp.physAddr).toBeDefined();
76-
expect(snmp.physAddr.toString()).toEqual('40:8D:5C:55:55:A2');
81+
expect(snmp.physAddr?.toString()).toEqual('40:8D:5C:55:55:A2');
7782

7883
expect(node.ipInterfaces.length).toEqual(2);
7984
const ip = node.ipInterfaces[0];
8085
expect(ip.hostname).toEqual('butters.internal.opennms.com');
8186
expect(ip.services.length).toEqual(5);
8287

83-
expect(ip.snmpInterface.toJSON()).toEqual(snmp.toJSON());
88+
expect(ip.snmpInterface?.toJSON()).toEqual(snmp.toJSON());
8489
});
8590
});
91+
8692
it('NodeDAO.find(id=43)', () => {
8793
const filter = new Filter();
8894
filter.withOrRestriction(new Restriction('id', Comparators.EQ, 43));
95+
8996
return dao.find(filter).then((nodes) => {
9097
expect(nodes.length).toEqual(1);
9198
});
9299
});
100+
93101
it('NodeDAO.properties() should reject', () => {
94102
return expect(dao.searchProperties()).rejects.toBeDefined();
95103
});
@@ -109,9 +117,11 @@ describe('NodeDAO with v2 API', () => {
109117
done();
110118
});
111119
});
120+
112121
it('NodeDAO.get(81, [recurse=false])', () => {
113122
return dao.get(81).then((node) => {
114123
expect(node.id).toEqual(81);
124+
expect(node.nodeParentId).toBeUndefined();
115125
expect(node.categories.length).toEqual(1);
116126
expect(node.categories[0]).toBeInstanceOf(OnmsCategory);
117127
expect(node.foreignSource).toEqual('test');
@@ -120,9 +130,11 @@ describe('NodeDAO with v2 API', () => {
120130
expect(node.type).toBeInstanceOf(OnmsNodeType);
121131
});
122132
});
133+
123134
it('NodeDAO.get(81, recurse=true)', () => {
124135
return dao.get(81, true).then((node) => {
125136
expect(node.id).toEqual(81);
137+
expect(node.nodeParentId).toBeUndefined();
126138
expect(node.categories.length).toEqual(1);
127139
expect(node.categories[0]).toBeInstanceOf(OnmsCategory);
128140
expect(node.foreignSource).toEqual('test');
@@ -145,9 +157,10 @@ describe('NodeDAO with v2 API', () => {
145157
expect(ip.services.length).toEqual(3);
146158

147159
expect(ip.snmpInterface).toBeDefined();
148-
expect(ip.snmpInterface.id).toEqual(2018);
160+
expect(ip.snmpInterface?.id).toEqual(2018);
149161
});
150162
});
163+
151164
/* find is currently broken in v2
152165
it('NodeDAO.find(id=81)', () => {
153166
const filter = new Filter();
@@ -161,3 +174,33 @@ describe('NodeDAO with v2 API', () => {
161174
return expect(dao.searchProperties()).rejects.toBeDefined();
162175
});
163176
});
177+
178+
describe('NodeDAO with v2 API, OpenNMS v33', () => {
179+
beforeEach((done) => {
180+
auth = new OnmsAuthConfig(SERVER_USER, SERVER_PASSWORD);
181+
const builder = OnmsServer.newBuilder(SERVER_URL).setName(SERVER_NAME).setAuth(auth);
182+
server = builder.build();
183+
mockHTTP = new MockHTTP33(server);
184+
opennms = new Client(mockHTTP);
185+
dao = new NodeDAO(mockHTTP);
186+
Client.getMetadata(server, mockHTTP).then((metadata) => {
187+
server = builder.setMetadata(metadata).build();
188+
mockHTTP.server = server;
189+
done();
190+
});
191+
});
192+
193+
it('NodeDAO.get(81, [recurse=false])', () => {
194+
return dao.get(81).then((node) => {
195+
expect(node.id).toEqual(81);
196+
expect(node.nodeParentId).toEqual(181);
197+
expect(node.categories.length).toEqual(1);
198+
expect(node.categories[0]).toBeInstanceOf(OnmsCategory);
199+
expect(node.foreignSource).toEqual('test');
200+
expect(node.createTime).toBeInstanceOf(moment);
201+
expect(node.type).toBeDefined();
202+
expect(node.type).toBeInstanceOf(OnmsNodeType);
203+
});
204+
});
205+
});
206+
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"down": true,
3+
"notify": null,
4+
"status": "A",
5+
"source": null,
6+
"qualifier": null,
7+
"lastGood": 1681862554301,
8+
"lastFail": 1693000042923,
9+
"statusLong": "Managed",
10+
"ipInterfaceId": 1,
11+
"serviceType": {
12+
"id": 1,
13+
"name": "DeviceConfig-default"
14+
},
15+
"id": 4
16+
}
+92
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
{
2+
"assetRecord": {
3+
"additionalhardware": null,
4+
"admin": null,
5+
"assetNumber": null,
6+
"autoenable": null,
7+
"building": "test",
8+
"category": "Unspecified",
9+
"circuitId": null,
10+
"comment": null,
11+
"connection": null,
12+
"cpu": null,
13+
"dateInstalled": null,
14+
"department": null,
15+
"description": null,
16+
"displayCategory": null,
17+
"division": null,
18+
"enable": null,
19+
"floor": null,
20+
"hdd1": null,
21+
"hdd2": null,
22+
"hdd3": null,
23+
"hdd4": null,
24+
"hdd5": null,
25+
"hdd6": null,
26+
"id": 1960,
27+
"inputpower": null,
28+
"lastModifiedBy": "",
29+
"lastModifiedDate": 1699799013442,
30+
"latitude": 35.68642,
31+
"lease": null,
32+
"leaseExpires": null,
33+
"longitude": -78.727554,
34+
"maintContractExpiration": null,
35+
"maintContractNumber": null,
36+
"maintcontract": null,
37+
"managedObjectInstance": null,
38+
"managedObjectType": null,
39+
"manufacturer": null,
40+
"modelNumber": null,
41+
"notifyCategory": null,
42+
"numpowersupplies": null,
43+
"operatingSystem": null,
44+
"password": null,
45+
"pollerCategory": null,
46+
"port": null,
47+
"rack": null,
48+
"rackunitheight": null,
49+
"ram": null,
50+
"region": null,
51+
"room": null,
52+
"serialNumber": null,
53+
"slot": null,
54+
"snmpcommunity": null,
55+
"storagectrl": null,
56+
"supportPhone": null,
57+
"thresholdCategory": null,
58+
"username": null,
59+
"vendor": null,
60+
"vendorAssetNumber": null,
61+
"vendorFax": null,
62+
"vendorPhone": null,
63+
"vmwareManagedEntityType": null,
64+
"vmwareManagedObjectId": null,
65+
"vmwareManagementServer": null,
66+
"vmwareState": null,
67+
"vmwareTopologyInfo": null
68+
},
69+
"categories": [
70+
{
71+
"authorizedGroups": [],
72+
"id": 7,
73+
"name": "Monitor_SNMP"
74+
}
75+
],
76+
"createTime": 1699799013442,
77+
"foreignId": "sin.local",
78+
"foreignSource": "test",
79+
"id": 81,
80+
"nodeParentID": 181,
81+
"label": "Sin.local",
82+
"labelSource": "U",
83+
"lastCapsdPoll": 1701532685099,
84+
"location": "Default",
85+
"sysContact": "Administrator <postmaster@example.com>",
86+
"sysDescription": "Darwin With-Teeth.local 24.1.0 Darwin Kernel Version 24.1.0: Mon Nov 4 14:16:27 PDT 2024; root:xnu-3789.70.16~2/RELEASE_M1_PRO M1_PRO",
87+
"sysLocation": "Right here, right now.",
88+
"sysName": "With-Teeth.local",
89+
"sysObjectId": ".1.3.6.1.4.1.8072.3.2.255",
90+
"type": "A"
91+
}
92+
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"down": true,
3+
"notify": null,
4+
"status": "A",
5+
"source": null,
6+
"qualifier": null,
7+
"lastGood": 1681862554301,
8+
"lastFail": 1693000042923,
9+
"statusLong": "Managed",
10+
"ipInterfaceId": 101,
11+
"ipAddress": "192.168.1.119",
12+
"nodeId": 142,
13+
"nodeLabel": "node119",
14+
"serviceType": {
15+
"id": 1,
16+
"name": "DeviceConfig-default"
17+
},
18+
"id": 99
19+
}

0 commit comments

Comments
 (0)