@itentialopensource/adapter-nokia_altiplano 0.1.1 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -1
- package/adapterBase.js +22 -0
- package/entities/.generic/action.json +5 -5
- package/entities/.system/action.json +7 -3
- package/entities/.system/schemaTokenResp.json +1 -1
- package/entities/Intent/action.json +74 -29
- package/package.json +11 -7
- package/propertiesSchema.json +1 -1
- package/refs?service=git-upload-pack +0 -0
- package/test/unit/adapterBaseTestUnit.js +1 -1
- package/test/unit/adapterTestUnit.js +6 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +0 -0
- package/utils/basicGet.js +5 -1
- package/utils/entitiesToDB.js +224 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +11 -5
- package/utils/tbUtils.js +20 -3
- package/utils/troubleshootingAdapter.js +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## 0.1.3 [10-24-2021]
|
|
3
|
+
|
|
4
|
+
* Fix the registry url
|
|
5
|
+
|
|
6
|
+
See merge request itentialopensource/adapters/controller-orchestrator/adapter-nokia_altiplano!2
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## 0.1.2 [10-24-2021]
|
|
11
|
+
|
|
12
|
+
* change paths and add headers
|
|
13
|
+
|
|
14
|
+
See merge request itentialopensource/adapters/controller-orchestrator/adapter-nokia_altiplano!1
|
|
15
|
+
|
|
16
|
+
---
|
|
17
|
+
|
|
2
18
|
## 0.1.1 [07-29-2021]
|
|
3
19
|
|
|
4
20
|
* Bug fixes and performance improvements
|
|
@@ -6,4 +22,3 @@
|
|
|
6
22
|
See commit bff31d3
|
|
7
23
|
|
|
8
24
|
---
|
|
9
|
-
|
package/adapterBase.js
CHANGED
|
@@ -22,6 +22,7 @@ const AjvCl = require('ajv');
|
|
|
22
22
|
const PropUtilCl = require('@itentialopensource/adapter-utils').PropertyUtility;
|
|
23
23
|
const RequestHandlerCl = require('@itentialopensource/adapter-utils').RequestHandler;
|
|
24
24
|
|
|
25
|
+
const entitiesToDB = require(path.join(__dirname, 'utils/entitiesToDB'));
|
|
25
26
|
const troubleshootingAdapter = require(path.join(__dirname, 'utils/troubleshootingAdapter'));
|
|
26
27
|
const tbUtils = require(path.join(__dirname, 'utils/tbUtils'));
|
|
27
28
|
|
|
@@ -1001,6 +1002,27 @@ class AdapterBase extends EventEmitterCl {
|
|
|
1001
1002
|
return [];
|
|
1002
1003
|
}
|
|
1003
1004
|
}
|
|
1005
|
+
|
|
1006
|
+
/**
|
|
1007
|
+
* @summary moves entities to mongo database
|
|
1008
|
+
*
|
|
1009
|
+
* @function moveEntitiesToDB
|
|
1010
|
+
*
|
|
1011
|
+
* @return {Callback} - containing the response from the mongo transaction
|
|
1012
|
+
*/
|
|
1013
|
+
moveEntitiesToDB(callback) {
|
|
1014
|
+
const meth = 'adapterBase-moveEntitiesToDB';
|
|
1015
|
+
const origin = `${this.id}-${meth}`;
|
|
1016
|
+
log.trace(origin);
|
|
1017
|
+
|
|
1018
|
+
try {
|
|
1019
|
+
return callback(entitiesToDB.moveEntitiesToDB(__dirname, { pronghornProps: this.allProps, id: this.id }), null);
|
|
1020
|
+
} catch (err) {
|
|
1021
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, err);
|
|
1022
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
1023
|
+
return callback(null, errorObj);
|
|
1024
|
+
}
|
|
1025
|
+
}
|
|
1004
1026
|
}
|
|
1005
1027
|
|
|
1006
1028
|
module.exports = AdapterBase;
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "getGenerics",
|
|
5
5
|
"protocol": "REST",
|
|
6
6
|
"method": "GET",
|
|
7
|
-
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
|
|
7
|
+
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
|
8
8
|
"requestSchema": "schema.json",
|
|
9
9
|
"responseSchema": "schema.json",
|
|
10
10
|
"timeout": 0,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"name": "createGeneric",
|
|
26
26
|
"protocol": "REST",
|
|
27
27
|
"method": "POST",
|
|
28
|
-
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
|
|
28
|
+
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
|
29
29
|
"requestSchema": "schema.json",
|
|
30
30
|
"responseSchema": "schema.json",
|
|
31
31
|
"timeout": 0,
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"name": "updateGeneric",
|
|
47
47
|
"protocol": "REST",
|
|
48
48
|
"method": "PUT",
|
|
49
|
-
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
|
|
49
|
+
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
|
50
50
|
"requestSchema": "schema.json",
|
|
51
51
|
"responseSchema": "schema.json",
|
|
52
52
|
"timeout": 0,
|
|
@@ -67,7 +67,7 @@
|
|
|
67
67
|
"name": "patchGeneric",
|
|
68
68
|
"protocol": "REST",
|
|
69
69
|
"method": "PATCH",
|
|
70
|
-
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
|
|
70
|
+
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
|
71
71
|
"requestSchema": "schema.json",
|
|
72
72
|
"responseSchema": "schema.json",
|
|
73
73
|
"timeout": 0,
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"name": "deleteGeneric",
|
|
89
89
|
"protocol": "REST",
|
|
90
90
|
"method": "DELETE",
|
|
91
|
-
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}?{query}",
|
|
91
|
+
"entitypath": "{base_path}/{version}/{pathv1}/{pathv2}/{pathv3}/{pathv4}/{pathv5}/{pathv6}/{pathv7}/{pathv8}/{pathv9}/{pathv10}/{pathv11}/{pathv12}/{pathv13}/{pathv14}/{pathv15}/{pathv16}/{pathv17}/{pathv18}/{pathv19}/{pathv20}?{query}",
|
|
92
92
|
"requestSchema": "schema.json",
|
|
93
93
|
"responseSchema": "schema.json",
|
|
94
94
|
"timeout": 0,
|
|
@@ -9,9 +9,13 @@
|
|
|
9
9
|
"responseSchema": "schemaTokenResp.json",
|
|
10
10
|
"timeout": 0,
|
|
11
11
|
"sendEmpty": false,
|
|
12
|
-
"requestDatatype": "",
|
|
13
|
-
"responseDatatype": "",
|
|
14
|
-
"headers": {
|
|
12
|
+
"requestDatatype": "JSON",
|
|
13
|
+
"responseDatatype": "JSON",
|
|
14
|
+
"headers": {
|
|
15
|
+
"Authorization": "Basic {b64}{username}:{password}{/b64}",
|
|
16
|
+
"Content-Type": "",
|
|
17
|
+
"Accept": "*/*"
|
|
18
|
+
},
|
|
15
19
|
"sso": {
|
|
16
20
|
"protocol": "",
|
|
17
21
|
"host": "",
|
|
@@ -11,7 +11,10 @@
|
|
|
11
11
|
"sendEmpty": false,
|
|
12
12
|
"requestDatatype": "JSON",
|
|
13
13
|
"responseDatatype": "JSON",
|
|
14
|
-
"headers": {
|
|
14
|
+
"headers": {
|
|
15
|
+
"Content-Type": "application/yang-data+json",
|
|
16
|
+
"Accept": "application/yang-data+json"
|
|
17
|
+
},
|
|
15
18
|
"responseObjects": [
|
|
16
19
|
{
|
|
17
20
|
"type": "default",
|
|
@@ -24,14 +27,17 @@
|
|
|
24
27
|
"name": "dependentsSummaryForDevice",
|
|
25
28
|
"protocol": "REST",
|
|
26
29
|
"method": "POST",
|
|
27
|
-
"entitypath": "{base_path}/{version}/
|
|
30
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1}/dependents-summary?{query}",
|
|
28
31
|
"requestSchema": "schema.json",
|
|
29
32
|
"responseSchema": "schema.json",
|
|
30
33
|
"timeout": 0,
|
|
31
34
|
"sendEmpty": false,
|
|
32
35
|
"requestDatatype": "JSON",
|
|
33
36
|
"responseDatatype": "JSON",
|
|
34
|
-
"headers": {
|
|
37
|
+
"headers": {
|
|
38
|
+
"Content-Type": "application/yang-data+json",
|
|
39
|
+
"Accept": "application/yang-data+json"
|
|
40
|
+
},
|
|
35
41
|
"responseObjects": [
|
|
36
42
|
{
|
|
37
43
|
"type": "default",
|
|
@@ -44,14 +50,17 @@
|
|
|
44
50
|
"name": "getuplinkConnectionConfiguration",
|
|
45
51
|
"protocol": "REST",
|
|
46
52
|
"method": "POST",
|
|
47
|
-
"entitypath": "{base_path}/{version}/
|
|
53
|
+
"entitypath": "{base_path}/{version}/restconf/operations/ibn:search-intents?{query}",
|
|
48
54
|
"requestSchema": "schema.json",
|
|
49
55
|
"responseSchema": "schema.json",
|
|
50
56
|
"timeout": 0,
|
|
51
57
|
"sendEmpty": false,
|
|
52
58
|
"requestDatatype": "JSON",
|
|
53
59
|
"responseDatatype": "JSON",
|
|
54
|
-
"headers": {
|
|
60
|
+
"headers": {
|
|
61
|
+
"Content-Type": "application/yang-data+json",
|
|
62
|
+
"Accept": "application/yang-data+json"
|
|
63
|
+
},
|
|
55
64
|
"responseObjects": [
|
|
56
65
|
{
|
|
57
66
|
"type": "default",
|
|
@@ -64,14 +73,17 @@
|
|
|
64
73
|
"name": "dependentsSummaryFiber",
|
|
65
74
|
"protocol": "REST",
|
|
66
75
|
"method": "POST",
|
|
67
|
-
"entitypath": "{base_path}/{version}/
|
|
76
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},fiber/dependents-summary?{query}",
|
|
68
77
|
"requestSchema": "schema.json",
|
|
69
78
|
"responseSchema": "schema.json",
|
|
70
79
|
"timeout": 0,
|
|
71
80
|
"sendEmpty": false,
|
|
72
81
|
"requestDatatype": "JSON",
|
|
73
82
|
"responseDatatype": "JSON",
|
|
74
|
-
"headers": {
|
|
83
|
+
"headers": {
|
|
84
|
+
"Content-Type": "application/yang-data+json",
|
|
85
|
+
"Accept": "application/yang-data+json"
|
|
86
|
+
},
|
|
75
87
|
"responseObjects": [
|
|
76
88
|
{
|
|
77
89
|
"type": "default",
|
|
@@ -84,14 +96,17 @@
|
|
|
84
96
|
"name": "createOnt",
|
|
85
97
|
"protocol": "REST",
|
|
86
98
|
"method": "POST",
|
|
87
|
-
"entitypath": "{base_path}/{version}/
|
|
99
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn?{query}",
|
|
88
100
|
"requestSchema": "schema.json",
|
|
89
101
|
"responseSchema": "schema.json",
|
|
90
102
|
"timeout": 0,
|
|
91
103
|
"sendEmpty": false,
|
|
92
104
|
"requestDatatype": "JSON",
|
|
93
105
|
"responseDatatype": "JSON",
|
|
94
|
-
"headers": {
|
|
106
|
+
"headers": {
|
|
107
|
+
"Content-Type": "application/yang-data+json",
|
|
108
|
+
"Accept": "application/yang-data+json"
|
|
109
|
+
},
|
|
95
110
|
"responseObjects": [
|
|
96
111
|
{
|
|
97
112
|
"type": "default",
|
|
@@ -104,7 +119,7 @@
|
|
|
104
119
|
"name": "getOnt",
|
|
105
120
|
"protocol": "REST",
|
|
106
121
|
"method": "GET",
|
|
107
|
-
"entitypath": "{base_path}/{version}/
|
|
122
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},ont?{query}",
|
|
108
123
|
"requestSchema": "schema.json",
|
|
109
124
|
"responseSchema": "schema.json",
|
|
110
125
|
"timeout": 0,
|
|
@@ -112,7 +127,10 @@
|
|
|
112
127
|
"sendGetBody": false,
|
|
113
128
|
"requestDatatype": "JSON",
|
|
114
129
|
"responseDatatype": "JSON",
|
|
115
|
-
"headers": {
|
|
130
|
+
"headers": {
|
|
131
|
+
"Content-Type": "application/yang-data+json",
|
|
132
|
+
"Accept": "application/yang-data+json"
|
|
133
|
+
},
|
|
116
134
|
"responseObjects": [
|
|
117
135
|
{
|
|
118
136
|
"type": "default",
|
|
@@ -125,14 +143,17 @@
|
|
|
125
143
|
"name": "lockOnt",
|
|
126
144
|
"protocol": "REST",
|
|
127
145
|
"method": "PATCH",
|
|
128
|
-
"entitypath": "{base_path}/{version}/
|
|
146
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},ont?{query}",
|
|
129
147
|
"requestSchema": "schema.json",
|
|
130
148
|
"responseSchema": "schema.json",
|
|
131
149
|
"timeout": 0,
|
|
132
150
|
"sendEmpty": false,
|
|
133
151
|
"requestDatatype": "JSON",
|
|
134
152
|
"responseDatatype": "JSON",
|
|
135
|
-
"headers": {
|
|
153
|
+
"headers": {
|
|
154
|
+
"Content-Type": "application/yang-data+json",
|
|
155
|
+
"Accept": "application/yang-data+json"
|
|
156
|
+
},
|
|
136
157
|
"responseObjects": [
|
|
137
158
|
{
|
|
138
159
|
"type": "default",
|
|
@@ -145,14 +166,17 @@
|
|
|
145
166
|
"name": "deleteOnt",
|
|
146
167
|
"protocol": "REST",
|
|
147
168
|
"method": "DELETE",
|
|
148
|
-
"entitypath": "{base_path}/{version}/
|
|
169
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},ont?{query}",
|
|
149
170
|
"requestSchema": "schema.json",
|
|
150
171
|
"responseSchema": "schema.json",
|
|
151
172
|
"timeout": 0,
|
|
152
173
|
"sendEmpty": false,
|
|
153
174
|
"requestDatatype": "JSON",
|
|
154
175
|
"responseDatatype": "JSON",
|
|
155
|
-
"headers": {
|
|
176
|
+
"headers": {
|
|
177
|
+
"Content-Type": "application/yang-data+json",
|
|
178
|
+
"Accept": "application/yang-data+json"
|
|
179
|
+
},
|
|
156
180
|
"responseObjects": [
|
|
157
181
|
{
|
|
158
182
|
"type": "default",
|
|
@@ -165,14 +189,17 @@
|
|
|
165
189
|
"name": "synchronizeOnt",
|
|
166
190
|
"protocol": "REST",
|
|
167
191
|
"method": "POST",
|
|
168
|
-
"entitypath": "{base_path}/{version}/
|
|
192
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},ont/synchronize?{query}",
|
|
169
193
|
"requestSchema": "schema.json",
|
|
170
194
|
"responseSchema": "schema.json",
|
|
171
195
|
"timeout": 0,
|
|
172
196
|
"sendEmpty": false,
|
|
173
197
|
"requestDatatype": "JSON",
|
|
174
198
|
"responseDatatype": "JSON",
|
|
175
|
-
"headers": {
|
|
199
|
+
"headers": {
|
|
200
|
+
"Content-Type": "application/yang-data+json",
|
|
201
|
+
"Accept": "application/yang-data+json"
|
|
202
|
+
},
|
|
176
203
|
"responseObjects": [
|
|
177
204
|
{
|
|
178
205
|
"type": "default",
|
|
@@ -185,14 +212,17 @@
|
|
|
185
212
|
"name": "auditOnt",
|
|
186
213
|
"protocol": "REST",
|
|
187
214
|
"method": "POST",
|
|
188
|
-
"entitypath": "{base_path}/{version}/
|
|
215
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},ont/audit?{query}",
|
|
189
216
|
"requestSchema": "schema.json",
|
|
190
217
|
"responseSchema": "schema.json",
|
|
191
218
|
"timeout": 0,
|
|
192
219
|
"sendEmpty": false,
|
|
193
220
|
"requestDatatype": "JSON",
|
|
194
221
|
"responseDatatype": "JSON",
|
|
195
|
-
"headers": {
|
|
222
|
+
"headers": {
|
|
223
|
+
"Content-Type": "application/yang-data+json",
|
|
224
|
+
"Accept": "application/yang-data+json"
|
|
225
|
+
},
|
|
196
226
|
"responseObjects": [
|
|
197
227
|
{
|
|
198
228
|
"type": "default",
|
|
@@ -205,14 +235,17 @@
|
|
|
205
235
|
"name": "synchronizel2User",
|
|
206
236
|
"protocol": "REST",
|
|
207
237
|
"method": "POST",
|
|
208
|
-
"entitypath": "{base_path}/{version}/
|
|
238
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},l2-user/synchronize?{query}",
|
|
209
239
|
"requestSchema": "schema.json",
|
|
210
240
|
"responseSchema": "schema.json",
|
|
211
241
|
"timeout": 0,
|
|
212
242
|
"sendEmpty": false,
|
|
213
243
|
"requestDatatype": "JSON",
|
|
214
244
|
"responseDatatype": "JSON",
|
|
215
|
-
"headers": {
|
|
245
|
+
"headers": {
|
|
246
|
+
"Content-Type": "application/yang-data+json",
|
|
247
|
+
"Accept": "application/yang-data+json"
|
|
248
|
+
},
|
|
216
249
|
"responseObjects": [
|
|
217
250
|
{
|
|
218
251
|
"type": "default",
|
|
@@ -225,7 +258,7 @@
|
|
|
225
258
|
"name": "getl2User",
|
|
226
259
|
"protocol": "REST",
|
|
227
260
|
"method": "GET",
|
|
228
|
-
"entitypath": "{base_path}/{version}/
|
|
261
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},l2-user?{query}",
|
|
229
262
|
"requestSchema": "schema.json",
|
|
230
263
|
"responseSchema": "schema.json",
|
|
231
264
|
"timeout": 0,
|
|
@@ -233,7 +266,10 @@
|
|
|
233
266
|
"sendGetBody": false,
|
|
234
267
|
"requestDatatype": "JSON",
|
|
235
268
|
"responseDatatype": "JSON",
|
|
236
|
-
"headers": {
|
|
269
|
+
"headers": {
|
|
270
|
+
"Content-Type": "application/yang-data+json",
|
|
271
|
+
"Accept": "application/yang-data+json"
|
|
272
|
+
},
|
|
237
273
|
"responseObjects": [
|
|
238
274
|
{
|
|
239
275
|
"type": "default",
|
|
@@ -246,14 +282,17 @@
|
|
|
246
282
|
"name": "modifyl2User",
|
|
247
283
|
"protocol": "REST",
|
|
248
284
|
"method": "PATCH",
|
|
249
|
-
"entitypath": "{base_path}/{version}/
|
|
285
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},l2-user?{query}",
|
|
250
286
|
"requestSchema": "schema.json",
|
|
251
287
|
"responseSchema": "schema.json",
|
|
252
288
|
"timeout": 0,
|
|
253
289
|
"sendEmpty": false,
|
|
254
290
|
"requestDatatype": "JSON",
|
|
255
291
|
"responseDatatype": "JSON",
|
|
256
|
-
"headers": {
|
|
292
|
+
"headers": {
|
|
293
|
+
"Content-Type": "application/yang-data+json",
|
|
294
|
+
"Accept": "application/yang-data+json"
|
|
295
|
+
},
|
|
257
296
|
"responseObjects": [
|
|
258
297
|
{
|
|
259
298
|
"type": "default",
|
|
@@ -266,14 +305,17 @@
|
|
|
266
305
|
"name": "deletel2User",
|
|
267
306
|
"protocol": "REST",
|
|
268
307
|
"method": "DELETE",
|
|
269
|
-
"entitypath": "{base_path}/{version}/
|
|
308
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},l2-user?{query}",
|
|
270
309
|
"requestSchema": "schema.json",
|
|
271
310
|
"responseSchema": "schema.json",
|
|
272
311
|
"timeout": 0,
|
|
273
312
|
"sendEmpty": false,
|
|
274
313
|
"requestDatatype": "JSON",
|
|
275
314
|
"responseDatatype": "JSON",
|
|
276
|
-
"headers": {
|
|
315
|
+
"headers": {
|
|
316
|
+
"Content-Type": "application/yang-data+json",
|
|
317
|
+
"Accept": "application/yang-data+json"
|
|
318
|
+
},
|
|
277
319
|
"responseObjects": [
|
|
278
320
|
{
|
|
279
321
|
"type": "default",
|
|
@@ -286,14 +328,17 @@
|
|
|
286
328
|
"name": "auditl2User",
|
|
287
329
|
"protocol": "REST",
|
|
288
330
|
"method": "POST",
|
|
289
|
-
"entitypath": "{base_path}/{version}/
|
|
331
|
+
"entitypath": "{base_path}/{version}/restconf/data/ibn:ibn/{pathv1},l2-user/audit?{query}",
|
|
290
332
|
"requestSchema": "schema.json",
|
|
291
333
|
"responseSchema": "schema.json",
|
|
292
334
|
"timeout": 0,
|
|
293
335
|
"sendEmpty": false,
|
|
294
336
|
"requestDatatype": "JSON",
|
|
295
337
|
"responseDatatype": "JSON",
|
|
296
|
-
"headers": {
|
|
338
|
+
"headers": {
|
|
339
|
+
"Content-Type": "application/yang-data+json",
|
|
340
|
+
"Accept": "application/yang-data+json"
|
|
341
|
+
},
|
|
297
342
|
"responseObjects": [
|
|
298
343
|
{
|
|
299
344
|
"type": "default",
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itentialopensource/adapter-nokia_altiplano",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "This adapter integrates with system described as: Nokia Altiplano.",
|
|
5
5
|
"main": "adapter.js",
|
|
6
|
-
"wizardVersion": "2.44.
|
|
7
|
-
"engineVersion": "1.59.
|
|
6
|
+
"wizardVersion": "2.44.7",
|
|
7
|
+
"engineVersion": "1.59.46",
|
|
8
8
|
"adapterType": "http",
|
|
9
9
|
"scripts": {
|
|
10
10
|
"artifactize": "npm i && node utils/packModificationScript.js",
|
|
11
|
-
"preinstall": "node utils/setup.js",
|
|
11
|
+
"preinstall": "node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions",
|
|
12
12
|
"lint": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js",
|
|
13
13
|
"lint:errors": "node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet",
|
|
14
14
|
"test:baseunit": "mocha test/unit/adapterBaseTestUnit.js --LOG=error",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"test:integration": "mocha test/integration/adapterTestIntegration.js --LOG=error",
|
|
17
17
|
"test:cover": "nyc --reporter html --reporter text mocha --reporter dot test/*",
|
|
18
18
|
"test": "npm run test:baseunit && npm run test:unit && npm run test:integration",
|
|
19
|
-
"adapter:install": "node utils/tbScript.js install",
|
|
19
|
+
"adapter:install": "npm i && node utils/tbScript.js install",
|
|
20
20
|
"adapter:checkMigrate": "node utils/checkMigrate.js",
|
|
21
21
|
"adapter:findPath": "node utils/findPath.js",
|
|
22
22
|
"adapter:migrate": "node utils/modify.js -m",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"healthcheck": "node utils/tbScript.js healthcheck",
|
|
27
27
|
"basicget": "node utils/tbScript.js basicget",
|
|
28
28
|
"connectivity": "node utils/tbScript.js connectivity",
|
|
29
|
-
"deploy": "npm publish --registry=
|
|
29
|
+
"deploy": "npm publish --registry=https://registry.npmjs.org --access=public",
|
|
30
30
|
"build": "npm run deploy"
|
|
31
31
|
},
|
|
32
32
|
"keywords": [
|
|
@@ -54,13 +54,14 @@
|
|
|
54
54
|
"author": "Itential",
|
|
55
55
|
"homepage": "https://gitlab.com/itentialopensource/adapters/controller-orchestrator/adapter-nokia_altiplano#readme",
|
|
56
56
|
"dependencies": {
|
|
57
|
-
"@itentialopensource/adapter-utils": "^4.44.
|
|
57
|
+
"@itentialopensource/adapter-utils": "^4.44.8",
|
|
58
58
|
"ajv": "^6.12.0",
|
|
59
59
|
"axios": "^0.21.0",
|
|
60
60
|
"commander": "^2.20.0",
|
|
61
61
|
"fs-extra": "^8.1.0",
|
|
62
62
|
"mocha": "^9.0.1",
|
|
63
63
|
"mocha-param": "^2.0.1",
|
|
64
|
+
"mongodb": "^4.1.0",
|
|
64
65
|
"network-diagnostics": "^0.5.3",
|
|
65
66
|
"nyc": "^15.1.0",
|
|
66
67
|
"readline-sync": "^1.4.10",
|
|
@@ -76,5 +77,8 @@
|
|
|
76
77
|
"package-json-validator": "^0.6.3",
|
|
77
78
|
"testdouble": "^3.16.1"
|
|
78
79
|
},
|
|
80
|
+
"resolutions": {
|
|
81
|
+
"minimist": "^1.2.5"
|
|
82
|
+
},
|
|
79
83
|
"private": false
|
|
80
84
|
}
|
package/propertiesSchema.json
CHANGED
|
Binary file
|
|
@@ -317,7 +317,7 @@ describe('[unit] Adapter Base Test', () => {
|
|
|
317
317
|
});
|
|
318
318
|
it('should return a list of functions', (done) => {
|
|
319
319
|
const returnedFunctions = ['addEntityCache', 'capabilityResults', 'checkActionFiles', 'checkProperties', 'connect', 'encryptProperty',
|
|
320
|
-
'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck',
|
|
320
|
+
'entityInList', 'findPath', 'getAllCapabilities', 'getAllFunctions', 'getQueue', 'getWorkflowFunctions', 'healthCheck', 'moveEntitiesToDB',
|
|
321
321
|
'refreshProperties', 'runBasicGet', 'runConnectivity', 'runHealthcheck', 'suspend', 'troubleshoot', 'unsuspend', 'updateAdapterConfiguration', 'addListener',
|
|
322
322
|
'emit', 'eventNames', 'getMaxListeners', 'listenerCount', 'listeners', 'off', 'on', 'once', 'prependListener',
|
|
323
323
|
'prependOnceListener', 'rawListeners', 'removeAllListeners', 'removeListener', 'setMaxListeners'];
|
|
@@ -356,6 +356,7 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
|
|
|
356
356
|
assert.notEqual(undefined, packageDotJson.scripts);
|
|
357
357
|
assert.notEqual(null, packageDotJson.scripts);
|
|
358
358
|
assert.notEqual('', packageDotJson.scripts);
|
|
359
|
+
assert.equal('node utils/setup.js && npm install --package-lock-only --ignore-scripts && npx npm-force-resolutions', packageDotJson.scripts.preinstall);
|
|
359
360
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js', packageDotJson.scripts.lint);
|
|
360
361
|
assert.equal('node --max_old_space_size=4096 ./node_modules/eslint/bin/eslint.js . --ext .json --ext .js --quiet', packageDotJson.scripts['lint:errors']);
|
|
361
362
|
assert.equal('mocha test/unit/adapterBaseTestUnit.js --LOG=error', packageDotJson.scripts['test:baseunit']);
|
|
@@ -363,6 +364,8 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
|
|
|
363
364
|
assert.equal('mocha test/integration/adapterTestIntegration.js --LOG=error', packageDotJson.scripts['test:integration']);
|
|
364
365
|
assert.equal('nyc --reporter html --reporter text mocha --reporter dot test/*', packageDotJson.scripts['test:cover']);
|
|
365
366
|
assert.equal('npm run test:baseunit && npm run test:unit && npm run test:integration', packageDotJson.scripts.test);
|
|
367
|
+
assert.equal('npm publish --registry=https://registry.npmjs.org --access=public', packageDotJson.scripts.deploy);
|
|
368
|
+
assert.equal('npm run deploy', packageDotJson.scripts.build);
|
|
366
369
|
done();
|
|
367
370
|
} catch (error) {
|
|
368
371
|
log.error(`Test Failure: ${error}`);
|
|
@@ -375,6 +378,9 @@ describe('[unit] Nokia_altiplano Adapter Test', () => {
|
|
|
375
378
|
assert.notEqual(undefined, packageDotJson.repository);
|
|
376
379
|
assert.notEqual(null, packageDotJson.repository);
|
|
377
380
|
assert.notEqual('', packageDotJson.repository);
|
|
381
|
+
assert.equal('git', packageDotJson.repository.type);
|
|
382
|
+
assert.equal('git@gitlab.com:itentialopensource/adapters/', packageDotJson.repository.url.substring(0, 43));
|
|
383
|
+
assert.equal('https://gitlab.com/itentialopensource/adapters/', packageDotJson.homepage.substring(0, 47));
|
|
378
384
|
done();
|
|
379
385
|
} catch (error) {
|
|
380
386
|
log.error(`Test Failure: ${error}`);
|
package/utils/addAuth.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/* eslint-disable no-plusplus */
|
|
2
|
+
/* eslint global-require: warn */
|
|
3
|
+
/* eslint import/no-dynamic-require: warn */
|
|
4
|
+
|
|
5
|
+
const rls = require('readline-sync');
|
|
6
|
+
const path = require('path');
|
|
7
|
+
const fs = require('fs');
|
|
8
|
+
|
|
9
|
+
function getQuestions(props, obj) {
|
|
10
|
+
const questions = props.map((p) => `${p}: ${(obj[p] !== undefined) ? `(${obj[p]})` : ''} `);
|
|
11
|
+
return questions;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
// function outputs each property for user to edit/confirm
|
|
15
|
+
// props are the fields that need to be changed depending on what the user selects
|
|
16
|
+
// obj is the JSON object that's being updated
|
|
17
|
+
function confirm(props, obj) {
|
|
18
|
+
// create array of questions
|
|
19
|
+
const updatedObj = obj;
|
|
20
|
+
getQuestions(props, obj).forEach((q) => {
|
|
21
|
+
const answer = rls.question(q);
|
|
22
|
+
// only update the field if the answer is NOT and empty string
|
|
23
|
+
if (answer) {
|
|
24
|
+
updatedObj[q.split(':')[0].trim()] = answer;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
return updatedObj;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const updateBasicAuth = (auth) => {
|
|
31
|
+
const propsToUpdate = ['username', 'password', 'auth_field', 'auth_field_format'];
|
|
32
|
+
return confirm(propsToUpdate, auth);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const updateStaticTokenAuth = (auth) => {
|
|
36
|
+
const propsToUpdate = ['token', 'auth_field', 'auth_field_format'];
|
|
37
|
+
return confirm(propsToUpdate, auth);
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
function updateTokenSchemas(user, pw, token) {
|
|
41
|
+
let schemaPath = path.join(__dirname, '..', 'entities/.system/schemaTokenReq.json');
|
|
42
|
+
const reqSchema = require(schemaPath);
|
|
43
|
+
reqSchema.properties.username.external_name = user;
|
|
44
|
+
reqSchema.properties.password.external_name = pw;
|
|
45
|
+
fs.writeFileSync(schemaPath, JSON.stringify(reqSchema, null, 2));
|
|
46
|
+
schemaPath = path.join(__dirname, '..', 'entities/.system/schemaTokenResp.json');
|
|
47
|
+
const respSchema = require(schemaPath);
|
|
48
|
+
respSchema.properties.token.external_name = token;
|
|
49
|
+
fs.writeFileSync(schemaPath, JSON.stringify(respSchema, null, 2));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function updateRequestToken(auth) {
|
|
53
|
+
const propsToUpdate = [
|
|
54
|
+
'username',
|
|
55
|
+
'password',
|
|
56
|
+
'auth_field',
|
|
57
|
+
'auth_field_format',
|
|
58
|
+
'token_user_field',
|
|
59
|
+
'token_password_field',
|
|
60
|
+
'token_result_field',
|
|
61
|
+
'token_URI_path'
|
|
62
|
+
];
|
|
63
|
+
const newAuth = confirm(propsToUpdate, auth);
|
|
64
|
+
updateTokenSchemas(newAuth.token_user_field, newAuth.token_password_field, newAuth.token_result_field);
|
|
65
|
+
|
|
66
|
+
return newAuth;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// prompt users to pick an auth method from the list above
|
|
70
|
+
const addAuthInfo = (props) => {
|
|
71
|
+
const authOptions = [
|
|
72
|
+
'basic user_password',
|
|
73
|
+
'static_token',
|
|
74
|
+
'request_token',
|
|
75
|
+
'no_authentication'
|
|
76
|
+
];
|
|
77
|
+
const newProps = confirm(['host', 'port', 'base_path'], props);
|
|
78
|
+
|
|
79
|
+
const newAuthMethod = authOptions[rls.keyInSelect(authOptions, 'Which authentication method?')];
|
|
80
|
+
newProps.authentication.auth_method = newAuthMethod;
|
|
81
|
+
|
|
82
|
+
if (newAuthMethod === 'basic user_password') {
|
|
83
|
+
newProps.authentication = updateBasicAuth(newProps.authentication);
|
|
84
|
+
} else if (newAuthMethod === 'static_token') {
|
|
85
|
+
newProps.authentication = updateStaticTokenAuth(newProps.authentication);
|
|
86
|
+
} else if (newAuthMethod === 'request_token') {
|
|
87
|
+
newProps.authentication = updateRequestToken(newProps.authentication);
|
|
88
|
+
}
|
|
89
|
+
console.log('Connectivity and authentication properties have been configured');
|
|
90
|
+
console.log('If you want to make changes, rerun this script to reinstall the adapter');
|
|
91
|
+
return newProps;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
module.exports = { addAuthInfo };
|
package/utils/artifactize.js
CHANGED
|
File without changes
|
package/utils/basicGet.js
CHANGED
|
@@ -4,9 +4,13 @@
|
|
|
4
4
|
/* eslint import/no-extraneous-dependencies: warn */
|
|
5
5
|
/* eslint global-require: warn */
|
|
6
6
|
/* eslint import/no-unresolved: warn */
|
|
7
|
+
/* eslint import/no-dynamic-require: warn */
|
|
7
8
|
|
|
9
|
+
const path = require('path');
|
|
8
10
|
const winston = require('winston');
|
|
9
11
|
|
|
12
|
+
const utils = require(path.join(__dirname, 'tbUtils'));
|
|
13
|
+
|
|
10
14
|
const logLevel = 'none';
|
|
11
15
|
const myCustomLevels = {
|
|
12
16
|
levels: {
|
|
@@ -53,7 +57,7 @@ const basicGet = {
|
|
|
53
57
|
*/
|
|
54
58
|
connect: async function connect(properties) {
|
|
55
59
|
// Connect to Mongo
|
|
56
|
-
const { MongoDBConnection } = require('@itential/database');
|
|
60
|
+
const { MongoDBConnection } = require(path.join(utils.getDirname(), '../../../', '@itential/database'));
|
|
57
61
|
const connection = new MongoDBConnection(properties.mongoProps);
|
|
58
62
|
const database = await connection.connect(true);
|
|
59
63
|
return database;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
/* @copyright Itential, LLC 2021 */
|
|
2
|
+
|
|
3
|
+
// Set globals
|
|
4
|
+
/* global log */
|
|
5
|
+
|
|
6
|
+
/* eslint import/no-dynamic-require: warn */
|
|
7
|
+
/* eslint global-require: warn */
|
|
8
|
+
/* eslint no-unused-vars: warn */
|
|
9
|
+
/* eslint import/no-unresolved: warn */
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* This script is used to read through an adapter's entities files
|
|
13
|
+
* and then creates documents and enters them into the IAP mongodb
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
const fs = require('fs');
|
|
17
|
+
const { MongoClient } = require('mongodb');
|
|
18
|
+
const path = require('path');
|
|
19
|
+
// const { argv } = require('process');
|
|
20
|
+
// const { string } = require('yargs');
|
|
21
|
+
|
|
22
|
+
// get the pronghorn database information
|
|
23
|
+
const getPronghornProps = async (iapDir) => {
|
|
24
|
+
log.trace('Retrieving properties.json file...');
|
|
25
|
+
const rawProps = require(path.join(iapDir, 'properties.json'));
|
|
26
|
+
log.trace('Decrypting properties...');
|
|
27
|
+
const { PropertyEncryption } = require('@itential/itential-utils');
|
|
28
|
+
const propertyEncryption = new PropertyEncryption();
|
|
29
|
+
const pronghornProps = await propertyEncryption.decryptProps(rawProps);
|
|
30
|
+
log.trace('Found properties.\n');
|
|
31
|
+
return pronghornProps;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Function used to take a file path to a entity directory and build
|
|
36
|
+
* a document that corresponds to the entity files.
|
|
37
|
+
*/
|
|
38
|
+
const buildDoc = (pathstring) => {
|
|
39
|
+
let files = fs.readdirSync(pathstring);
|
|
40
|
+
|
|
41
|
+
// load the mockdatafiles
|
|
42
|
+
const mockdatafiles = {};
|
|
43
|
+
if (files.includes('mockdatafiles') && fs.lstatSync(`${pathstring}/mockdatafiles`).isDirectory()) {
|
|
44
|
+
fs.readdirSync(`${pathstring}/mockdatafiles`).forEach((file) => {
|
|
45
|
+
if (file.split('.').pop() === 'json') {
|
|
46
|
+
const mockpath = `${pathstring}/mockdatafiles/${file}`;
|
|
47
|
+
const data = JSON.parse(fs.readFileSync(mockpath));
|
|
48
|
+
mockdatafiles[mockpath.split('/').pop()] = data;
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// load the action data
|
|
54
|
+
let actions;
|
|
55
|
+
if (files.includes('action.json')) {
|
|
56
|
+
actions = JSON.parse(fs.readFileSync(`${pathstring}/action.json`));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
// Load schema.json and other schemas in remaining json files
|
|
60
|
+
files = files.filter((f) => (f !== 'action.json') && f.endsWith('.json'));
|
|
61
|
+
const schema = [];
|
|
62
|
+
files.forEach((file) => {
|
|
63
|
+
const data = JSON.parse(fs.readFileSync(`${pathstring}/${file}`));
|
|
64
|
+
schema.push({
|
|
65
|
+
name: file,
|
|
66
|
+
schema: data
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
// return the data
|
|
71
|
+
return {
|
|
72
|
+
actions: actions.actions,
|
|
73
|
+
schema,
|
|
74
|
+
mockdatafiles
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Function used to get the database from the options or a provided directory
|
|
80
|
+
*/
|
|
81
|
+
const optionsHandler = (options) => {
|
|
82
|
+
// if the database properties were provided in the options - return them
|
|
83
|
+
if (options.pronghornProps) {
|
|
84
|
+
if (typeof options.pronghornProps === 'string') {
|
|
85
|
+
return JSON.parse(options.pronghornProps);
|
|
86
|
+
}
|
|
87
|
+
return new Promise((resolve, reject) => resolve(options.pronghornProps));
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// if the directory was provided, get the pronghorn props from the directory
|
|
91
|
+
if (options.iapDir) {
|
|
92
|
+
return getPronghornProps(options.iapDir);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// if nothing was provided, error
|
|
96
|
+
return new Promise((resolve, reject) => reject(new Error('Neither pronghornProps nor iapDir defined in options!')));
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Function used to put the adapter configuration into the provided database
|
|
101
|
+
*/
|
|
102
|
+
const moveEntitiesToDB = (targetPath, options) => {
|
|
103
|
+
// set local variables
|
|
104
|
+
let myOpts = options;
|
|
105
|
+
let myPath = targetPath;
|
|
106
|
+
|
|
107
|
+
// if we got a string parse into a JSON object
|
|
108
|
+
if (typeof myOpts === 'string') {
|
|
109
|
+
myOpts = JSON.parse(myOpts);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// if there is no target collection - set the collection to the default
|
|
113
|
+
if (!myOpts.targetCollection) {
|
|
114
|
+
myOpts.targetCollection = 'adapter_configs';
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// if there is no id error since we need an id for the entities
|
|
118
|
+
if (!myOpts.id) {
|
|
119
|
+
throw new Error('Adapter ID required!');
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
// get the pronghorn database properties
|
|
123
|
+
optionsHandler(options).then((currentProps) => {
|
|
124
|
+
let mongoUrl;
|
|
125
|
+
let dbName;
|
|
126
|
+
|
|
127
|
+
// find the mongo properties so we can connect
|
|
128
|
+
if (currentProps.mongoProps) {
|
|
129
|
+
mongoUrl = currentProps.mongoProps.url;
|
|
130
|
+
dbName = currentProps.mongoProps.db;
|
|
131
|
+
} else if (currentProps.mongo) {
|
|
132
|
+
if (currentProps.mongo.url) {
|
|
133
|
+
mongoUrl = currentProps.mongo.url;
|
|
134
|
+
} else {
|
|
135
|
+
mongoUrl = `mongodb://${currentProps.mongo.host}:${currentProps.mongo.port}`;
|
|
136
|
+
}
|
|
137
|
+
dbName = currentProps.mongo.database;
|
|
138
|
+
} else {
|
|
139
|
+
throw new Error('Mongo properties are not specified in adapter preferences!');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Check valid filepath provided
|
|
143
|
+
if (!myPath) {
|
|
144
|
+
// if no path use the current directory without the utils
|
|
145
|
+
myPath = path.join(__dirname, '../');
|
|
146
|
+
} else if (myPath.slice(-1) === '/') {
|
|
147
|
+
myPath = myPath.slice(0, -1);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// verify set the entity path
|
|
151
|
+
const entitiesPath = `${myPath}/entities`;
|
|
152
|
+
if (!fs.existsSync(entitiesPath)) {
|
|
153
|
+
throw new Error(`Entities path does not exist in filesystem: ${entitiesPath}`);
|
|
154
|
+
} else {
|
|
155
|
+
log.trace('Target found on filesystem');
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
// Get adapter details
|
|
159
|
+
if (!fs.existsSync(`${myPath}/pronghorn.json`)) {
|
|
160
|
+
throw new Error(`pronghorn.json does not exist in path: ${myPath}`);
|
|
161
|
+
} else {
|
|
162
|
+
log.trace('pronghorn.json found on filesystem');
|
|
163
|
+
}
|
|
164
|
+
const adapterData = JSON.parse(fs.readFileSync(`${myPath}/pronghorn.json`));
|
|
165
|
+
|
|
166
|
+
// Load files from the filesystem
|
|
167
|
+
const docs = [];
|
|
168
|
+
const entities = fs.readdirSync(entitiesPath);
|
|
169
|
+
entities.forEach((entity) => {
|
|
170
|
+
const entityPath = `${entitiesPath}/${entity}`;
|
|
171
|
+
const isDir = fs.lstatSync(entitiesPath).isDirectory();
|
|
172
|
+
|
|
173
|
+
// Build doc for entity
|
|
174
|
+
if (isDir) {
|
|
175
|
+
let doc = buildDoc(entityPath);
|
|
176
|
+
doc = {
|
|
177
|
+
id: myOpts.id,
|
|
178
|
+
type: adapterData.id,
|
|
179
|
+
entity,
|
|
180
|
+
...doc
|
|
181
|
+
};
|
|
182
|
+
docs.push(doc);
|
|
183
|
+
}
|
|
184
|
+
});
|
|
185
|
+
|
|
186
|
+
// Upload documents to db collection
|
|
187
|
+
MongoClient.connect(mongoUrl, (err, db) => {
|
|
188
|
+
if (err) {
|
|
189
|
+
log.error(JSON.stringify(err));
|
|
190
|
+
throw err;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
// get the proper collection
|
|
194
|
+
const collection = db.db(dbName).collection(myOpts.targetCollection);
|
|
195
|
+
// insert the documents into the collection
|
|
196
|
+
collection.insertMany(docs, { checkKeys: false }, (error, res) => {
|
|
197
|
+
if (error) {
|
|
198
|
+
log.error(JSON.stringify(error));
|
|
199
|
+
throw error;
|
|
200
|
+
}
|
|
201
|
+
// log the insertion, close the database and return
|
|
202
|
+
log.debug(`Inserted ${docs.length} documents to ${dbName}.${myOpts.targetCollection} with response ${JSON.stringify(res)}`);
|
|
203
|
+
db.close();
|
|
204
|
+
return res;
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
});
|
|
208
|
+
};
|
|
209
|
+
|
|
210
|
+
// const args = process.argv.slice(2);
|
|
211
|
+
|
|
212
|
+
// throw new SyntaxError(args[0]);
|
|
213
|
+
|
|
214
|
+
// if (args.length === 0) {
|
|
215
|
+
// console.error('ERROR: target path not specified!');
|
|
216
|
+
// } else if (args[0] === 'help') {
|
|
217
|
+
// log.trace('node ./entitiesToDB <target path> <options object: {iapDir: string, pronghornProps: string, targetCollection: string}>');
|
|
218
|
+
// } else if (args.length === 1) {
|
|
219
|
+
// console.error('ERROR: IAP directory not specified');
|
|
220
|
+
// } else {
|
|
221
|
+
// moveEntitiesToDB(args[0], args[1]);
|
|
222
|
+
// }
|
|
223
|
+
|
|
224
|
+
module.exports = { moveEntitiesToDB };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* This script will uninstall pre-commit or pre-push hooks in case there's ever a need to
|
|
5
|
+
* commit/push something that has issues
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const precommitPath = '.git/hooks/pre-commit';
|
|
9
|
+
const prepushPath = '.git/hooks/pre-push';
|
|
10
|
+
fs.unlink(precommitPath, (err) => {
|
|
11
|
+
if (err && err.code !== 'ENOENT') {
|
|
12
|
+
console.log(`${err.message}`);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
fs.unlink(prepushPath, (err) => {
|
|
17
|
+
if (err && err.code !== 'ENOENT') {
|
|
18
|
+
console.log(`${err.message}`);
|
|
19
|
+
}
|
|
20
|
+
});
|
package/utils/tbScript.js
CHANGED
|
@@ -15,13 +15,18 @@ const basicGet = require('./basicGet');
|
|
|
15
15
|
const { name } = require('../package.json');
|
|
16
16
|
const sampleProperties = require('../sampleProperties.json');
|
|
17
17
|
const adapterPronghorn = require('../pronghorn.json');
|
|
18
|
+
const { addAuthInfo } = require('./addAuth');
|
|
18
19
|
|
|
19
20
|
const { troubleshoot, getAdapterConfig, offline } = require('./troubleshootingAdapter');
|
|
20
21
|
|
|
21
22
|
const main = async (command) => {
|
|
22
|
-
const
|
|
23
|
+
const dirname = utils.getDirname();
|
|
24
|
+
const iapDir = path.join(dirname, '../../../../');
|
|
23
25
|
if (!utils.withinIAP(iapDir)) {
|
|
24
|
-
if (command === '
|
|
26
|
+
if (command === 'install') {
|
|
27
|
+
console.log('Not currently in IAP directory - installation not possible');
|
|
28
|
+
process.exit(0);
|
|
29
|
+
} else if (command === 'connectivity') {
|
|
25
30
|
const { host } = sampleProperties.properties;
|
|
26
31
|
console.log(`perform networking diagnositics to ${host}`);
|
|
27
32
|
await utils.runConnectivity(host);
|
|
@@ -74,14 +79,16 @@ const main = async (command) => {
|
|
|
74
79
|
process.exit(0);
|
|
75
80
|
}
|
|
76
81
|
} else {
|
|
77
|
-
utils.verifyInstallationDir(
|
|
78
|
-
utils.npmInstall();
|
|
82
|
+
utils.verifyInstallationDir(dirname, name);
|
|
79
83
|
utils.runTest();
|
|
80
84
|
if (rls.keyInYN(`Do you want to install ${name} to IAP?`)) {
|
|
81
85
|
console.log('Creating database entries...');
|
|
82
86
|
const adapter = utils.createAdapter(
|
|
83
87
|
pronghornProps, profileItem, sampleProperties, adapterPronghorn
|
|
84
88
|
);
|
|
89
|
+
|
|
90
|
+
adapter.properties.properties = await addAuthInfo(adapter.properties.properties);
|
|
91
|
+
|
|
85
92
|
await database.collection(utils.SERVICE_CONFIGS_COLLECTION).insertOne(adapter);
|
|
86
93
|
profileItem.services.push(adapter.name);
|
|
87
94
|
const update = { $set: { services: profileItem.services } };
|
|
@@ -154,7 +161,6 @@ program.parse(process.argv);
|
|
|
154
161
|
if (process.argv.length < 3) {
|
|
155
162
|
main();
|
|
156
163
|
}
|
|
157
|
-
|
|
158
164
|
const allowedParams = ['install', 'healthcheck', 'basicget', 'connectivity'];
|
|
159
165
|
if (process.argv.length === 3 && !allowedParams.includes(process.argv[2])) {
|
|
160
166
|
console.log(`unknown parameter ${process.argv[2]}`);
|
package/utils/tbUtils.js
CHANGED
|
@@ -178,7 +178,7 @@ module.exports = {
|
|
|
178
178
|
const pathArray = dirname.split(path.sep);
|
|
179
179
|
const expectedPath = `node_modules/${name}`;
|
|
180
180
|
const currentPath = pathArray.slice(pathArray.length - 4, pathArray.length - 1).join('/');
|
|
181
|
-
if (
|
|
181
|
+
if (currentPath.trim() !== expectedPath.trim()) {
|
|
182
182
|
throw new Error(`adapter should be installed under ${expectedPath}`);
|
|
183
183
|
}
|
|
184
184
|
|
|
@@ -304,8 +304,9 @@ module.exports = {
|
|
|
304
304
|
* @param {Object} adapterPronghorn - ./pronghorn.json in adapter dir
|
|
305
305
|
* @param {Object} sampleProperties - './sampleProperties.json' in adapter dir
|
|
306
306
|
*/
|
|
307
|
-
createAdapter: (pronghornProps, profileItem, sampleProperties, adapterPronghorn)
|
|
308
|
-
const
|
|
307
|
+
createAdapter: function createAdapter(pronghornProps, profileItem, sampleProperties, adapterPronghorn) {
|
|
308
|
+
const dirname = this.getDirname();
|
|
309
|
+
const packagePath = `${dirname.split('node_modules')[0]}package.json`;
|
|
309
310
|
const info = JSON.parse(fs.readFileSync(packagePath));
|
|
310
311
|
const version = parseInt(info.version.split('.')[0], 10);
|
|
311
312
|
|
|
@@ -385,5 +386,21 @@ module.exports = {
|
|
|
385
386
|
} catch (error) {
|
|
386
387
|
return false;
|
|
387
388
|
}
|
|
389
|
+
},
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* @summary Used to determine the proper dirname to return in case adapter reference is
|
|
393
|
+
* symlinked withink IAP
|
|
394
|
+
* @returns the symlinked path (using pwd command) of the adapter in case properties.json
|
|
395
|
+
* is not found in the original path
|
|
396
|
+
* @function getDirname
|
|
397
|
+
*/
|
|
398
|
+
getDirname: function getDirname() {
|
|
399
|
+
if (this.withinIAP(path.join(__dirname, '../../../../'))) {
|
|
400
|
+
return __dirname;
|
|
401
|
+
}
|
|
402
|
+
const { stdout } = this.systemSync('pwd', true);
|
|
403
|
+
return path.join(stdout, 'utils');
|
|
388
404
|
}
|
|
405
|
+
|
|
389
406
|
};
|
|
@@ -121,16 +121,16 @@ const getPronghornProps = (iapDir) => {
|
|
|
121
121
|
console.log('Retrieving properties.json file...');
|
|
122
122
|
const rawProps = require(path.join(iapDir, 'properties.json'));
|
|
123
123
|
console.log('Decrypting properties...');
|
|
124
|
-
const { Discovery } = require('
|
|
124
|
+
const { Discovery } = require(path.join(iapDir, 'node_modules/@itential/itential-utils'));
|
|
125
125
|
const discovery = new Discovery();
|
|
126
|
-
const pronghornProps = utils.decryptProperties(rawProps,
|
|
126
|
+
const pronghornProps = utils.decryptProperties(rawProps, utils.getDirname(), discovery);
|
|
127
127
|
console.log('Found properties.\n');
|
|
128
128
|
return pronghornProps;
|
|
129
129
|
};
|
|
130
130
|
|
|
131
131
|
// get database connection and existing adapter config
|
|
132
132
|
const getAdapterConfig = async () => {
|
|
133
|
-
const iapDir = path.join(
|
|
133
|
+
const iapDir = path.join(utils.getDirname(), '../../../../');
|
|
134
134
|
const pronghornProps = getPronghornProps(iapDir);
|
|
135
135
|
console.log('Connecting to Database...');
|
|
136
136
|
const database = await basicGet.connect(pronghornProps);
|