@itentialopensource/adapter-onap_sdc 0.3.3 → 0.5.0
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/AUTH.md +39 -0
- package/BROKER.md +199 -0
- package/CALLS.md +301 -0
- package/CHANGELOG.md +46 -15
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +3 -148
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +239 -507
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +383 -263
- package/adapterBase.js +855 -409
- package/changelogs/changelog.md +79 -0
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/error.json +12 -0
- package/metadata.json +47 -0
- package/package.json +28 -22
- package/pronghorn.json +691 -88
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +842 -6
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +5265 -0
- package/report/adapter-openapi.yaml +3872 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653173655574.json +120 -0
- package/report/updateReport1691507676774.json +120 -0
- package/report/updateReport1692202676079.json +120 -0
- package/report/updateReport1694462516016.json +120 -0
- package/report/updateReport1698421197587.json +120 -0
- package/sampleProperties.json +156 -3
- package/test/integration/adapterTestBasicGet.js +4 -6
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +158 -104
- package/test/unit/adapterBaseTestUnit.js +393 -310
- package/test/unit/adapterTestUnit.js +918 -164
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/artifactize.js +1 -1
- package/utils/basicGet.js +1 -14
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +179 -0
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +273 -0
- package/utils/modify.js +14 -16
- package/utils/packModificationScript.js +2 -2
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +5 -0
- package/utils/removeHooks.js +20 -0
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +129 -53
- package/utils/tbUtils.js +152 -35
- package/utils/testRunner.js +17 -17
- package/utils/troubleshootingAdapter.js +10 -31
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
/* eslint import/no-dynamic-require: warn */
|
|
4
4
|
/* eslint object-curly-newline: warn */
|
|
5
5
|
/* eslint no-underscore-dangle: warn */
|
|
6
|
+
/* eslint default-param-last: warn */
|
|
6
7
|
/* eslint camelcase: warn */
|
|
7
8
|
|
|
8
9
|
// Set globals
|
|
@@ -82,10 +83,15 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
/**
|
|
85
|
-
* @
|
|
86
|
+
* @iapGetAdapterWorkflowFunctions
|
|
86
87
|
*/
|
|
87
|
-
|
|
88
|
-
let myIgnore = [
|
|
88
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
89
|
+
let myIgnore = [
|
|
90
|
+
'healthCheck',
|
|
91
|
+
'iapGetAdapterWorkflowFunctions',
|
|
92
|
+
'hasEntities',
|
|
93
|
+
'getAuthorization'
|
|
94
|
+
];
|
|
89
95
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
90
96
|
myIgnore = inIgnore;
|
|
91
97
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -96,52 +102,44 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
96
102
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
97
103
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
98
104
|
|
|
99
|
-
return super.
|
|
105
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
100
106
|
}
|
|
101
107
|
|
|
102
108
|
/**
|
|
103
|
-
*
|
|
109
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
104
110
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
105
111
|
* file system.
|
|
106
112
|
*
|
|
107
|
-
* @function
|
|
113
|
+
* @function iapUpdateAdapterConfiguration
|
|
108
114
|
* @param {string} configFile - the name of the file being updated (required)
|
|
109
115
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
110
116
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
111
117
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
112
118
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
119
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
113
120
|
* @param {Callback} callback - The results of the call
|
|
114
121
|
*/
|
|
115
|
-
|
|
116
|
-
const
|
|
122
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
123
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
124
|
+
const origin = `${this.id}-${meth}`;
|
|
117
125
|
log.trace(origin);
|
|
118
|
-
super.updateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
119
|
-
}
|
|
120
126
|
|
|
121
|
-
|
|
122
|
-
* See if the API path provided is found in this adapter
|
|
123
|
-
*
|
|
124
|
-
* @function findPath
|
|
125
|
-
* @param {string} apiPath - the api path to check on
|
|
126
|
-
* @param {Callback} callback - The results of the call
|
|
127
|
-
*/
|
|
128
|
-
findPath(apiPath, callback) {
|
|
129
|
-
const origin = `${this.id}-adapter-findPath`;
|
|
130
|
-
log.trace(origin);
|
|
131
|
-
super.findPath(apiPath, callback);
|
|
127
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
132
128
|
}
|
|
133
129
|
|
|
134
130
|
/**
|
|
135
131
|
* @summary Suspends adapter
|
|
136
132
|
*
|
|
137
|
-
* @function
|
|
133
|
+
* @function iapSuspendAdapter
|
|
138
134
|
* @param {Callback} callback - callback function
|
|
139
135
|
*/
|
|
140
|
-
|
|
141
|
-
const
|
|
136
|
+
iapSuspendAdapter(mode, callback) {
|
|
137
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
138
|
+
const origin = `${this.id}-${meth}`;
|
|
142
139
|
log.trace(origin);
|
|
140
|
+
|
|
143
141
|
try {
|
|
144
|
-
return super.
|
|
142
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
145
143
|
} catch (error) {
|
|
146
144
|
log.error(`${origin}: ${error}`);
|
|
147
145
|
return callback(null, error);
|
|
@@ -151,14 +149,16 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
151
149
|
/**
|
|
152
150
|
* @summary Unsuspends adapter
|
|
153
151
|
*
|
|
154
|
-
* @function
|
|
152
|
+
* @function iapUnsuspendAdapter
|
|
155
153
|
* @param {Callback} callback - callback function
|
|
156
154
|
*/
|
|
157
|
-
|
|
158
|
-
const
|
|
155
|
+
iapUnsuspendAdapter(callback) {
|
|
156
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
157
|
+
const origin = `${this.id}-${meth}`;
|
|
159
158
|
log.trace(origin);
|
|
159
|
+
|
|
160
160
|
try {
|
|
161
|
-
return super.
|
|
161
|
+
return super.iapUnsuspendAdapter(callback);
|
|
162
162
|
} catch (error) {
|
|
163
163
|
log.error(`${origin}: ${error}`);
|
|
164
164
|
return callback(null, error);
|
|
@@ -166,31 +166,51 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
166
166
|
}
|
|
167
167
|
|
|
168
168
|
/**
|
|
169
|
-
* @summary Get the
|
|
169
|
+
* @summary Get the Adapter Queue
|
|
170
170
|
*
|
|
171
|
-
* @function
|
|
171
|
+
* @function iapGetAdapterQueue
|
|
172
172
|
* @param {Callback} callback - callback function
|
|
173
173
|
*/
|
|
174
|
-
|
|
175
|
-
const
|
|
174
|
+
iapGetAdapterQueue(callback) {
|
|
175
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
176
|
+
const origin = `${this.id}-${meth}`;
|
|
177
|
+
log.trace(origin);
|
|
178
|
+
|
|
179
|
+
return super.iapGetAdapterQueue(callback);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/* SCRIPT CALLS */
|
|
183
|
+
/**
|
|
184
|
+
* See if the API path provided is found in this adapter
|
|
185
|
+
*
|
|
186
|
+
* @function iapFindAdapterPath
|
|
187
|
+
* @param {string} apiPath - the api path to check on
|
|
188
|
+
* @param {Callback} callback - The results of the call
|
|
189
|
+
*/
|
|
190
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
191
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
192
|
+
const origin = `${this.id}-${meth}`;
|
|
176
193
|
log.trace(origin);
|
|
177
|
-
|
|
194
|
+
|
|
195
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
178
196
|
}
|
|
179
197
|
|
|
180
198
|
/**
|
|
181
199
|
* @summary Runs troubleshoot scripts for adapter
|
|
182
200
|
*
|
|
183
|
-
* @function
|
|
201
|
+
* @function iapTroubleshootAdapter
|
|
184
202
|
* @param {Object} props - the connection, healthcheck and authentication properties
|
|
185
203
|
*
|
|
186
204
|
* @param {boolean} persistFlag - whether the adapter properties should be updated
|
|
187
205
|
* @param {Callback} callback - The results of the call
|
|
188
206
|
*/
|
|
189
|
-
|
|
190
|
-
const
|
|
207
|
+
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
208
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
209
|
+
const origin = `${this.id}-${meth}`;
|
|
191
210
|
log.trace(origin);
|
|
211
|
+
|
|
192
212
|
try {
|
|
193
|
-
return super.
|
|
213
|
+
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
194
214
|
} catch (error) {
|
|
195
215
|
log.error(`${origin}: ${error}`);
|
|
196
216
|
return callback(null, error);
|
|
@@ -200,15 +220,17 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
200
220
|
/**
|
|
201
221
|
* @summary runs healthcheck script for adapter
|
|
202
222
|
*
|
|
203
|
-
* @function
|
|
223
|
+
* @function iapRunAdapterHealthcheck
|
|
204
224
|
* @param {Adapter} adapter - adapter instance to troubleshoot
|
|
205
225
|
* @param {Callback} callback - callback function
|
|
206
226
|
*/
|
|
207
|
-
|
|
208
|
-
const
|
|
227
|
+
iapRunAdapterHealthcheck(callback) {
|
|
228
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
229
|
+
const origin = `${this.id}-${meth}`;
|
|
209
230
|
log.trace(origin);
|
|
231
|
+
|
|
210
232
|
try {
|
|
211
|
-
return super.
|
|
233
|
+
return super.iapRunAdapterHealthcheck(this, callback);
|
|
212
234
|
} catch (error) {
|
|
213
235
|
log.error(`${origin}: ${error}`);
|
|
214
236
|
return callback(null, error);
|
|
@@ -218,14 +240,16 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
218
240
|
/**
|
|
219
241
|
* @summary runs connectivity check script for adapter
|
|
220
242
|
*
|
|
221
|
-
* @function
|
|
243
|
+
* @function iapRunAdapterConnectivity
|
|
222
244
|
* @param {Callback} callback - callback function
|
|
223
245
|
*/
|
|
224
|
-
|
|
225
|
-
const
|
|
246
|
+
iapRunAdapterConnectivity(callback) {
|
|
247
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
248
|
+
const origin = `${this.id}-${meth}`;
|
|
226
249
|
log.trace(origin);
|
|
250
|
+
|
|
227
251
|
try {
|
|
228
|
-
return super.
|
|
252
|
+
return super.iapRunAdapterConnectivity(callback);
|
|
229
253
|
} catch (error) {
|
|
230
254
|
log.error(`${origin}: ${error}`);
|
|
231
255
|
return callback(null, error);
|
|
@@ -235,14 +259,16 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
235
259
|
/**
|
|
236
260
|
* @summary runs basicGet script for adapter
|
|
237
261
|
*
|
|
238
|
-
* @function
|
|
262
|
+
* @function iapRunAdapterBasicGet
|
|
239
263
|
* @param {Callback} callback - callback function
|
|
240
264
|
*/
|
|
241
|
-
|
|
242
|
-
const
|
|
265
|
+
iapRunAdapterBasicGet(callback) {
|
|
266
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
267
|
+
const origin = `${this.id}-${meth}`;
|
|
243
268
|
log.trace(origin);
|
|
269
|
+
|
|
244
270
|
try {
|
|
245
|
-
return super.
|
|
271
|
+
return super.iapRunAdapterBasicGet(callback);
|
|
246
272
|
} catch (error) {
|
|
247
273
|
log.error(`${origin}: ${error}`);
|
|
248
274
|
return callback(null, error);
|
|
@@ -250,171 +276,275 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
250
276
|
}
|
|
251
277
|
|
|
252
278
|
/**
|
|
253
|
-
* @summary
|
|
279
|
+
* @summary moves entites into Mongo DB
|
|
254
280
|
*
|
|
255
|
-
* @function
|
|
256
|
-
* @param {
|
|
257
|
-
*
|
|
281
|
+
* @function iapMoveAdapterEntitiesToDB
|
|
282
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
283
|
+
* or the error
|
|
284
|
+
*/
|
|
285
|
+
iapMoveAdapterEntitiesToDB(callback) {
|
|
286
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
287
|
+
const origin = `${this.id}-${meth}`;
|
|
288
|
+
log.trace(origin);
|
|
289
|
+
|
|
290
|
+
try {
|
|
291
|
+
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
292
|
+
} catch (err) {
|
|
293
|
+
log.error(`${origin}: ${err}`);
|
|
294
|
+
return callback(null, err);
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* @summary Deactivate adapter tasks
|
|
300
|
+
*
|
|
301
|
+
* @function iapDeactivateTasks
|
|
302
|
+
*
|
|
303
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
304
|
+
* @param {Callback} callback
|
|
305
|
+
*/
|
|
306
|
+
iapDeactivateTasks(tasks, callback) {
|
|
307
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
308
|
+
const origin = `${this.id}-${meth}`;
|
|
309
|
+
log.trace(origin);
|
|
310
|
+
|
|
311
|
+
try {
|
|
312
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
313
|
+
} catch (err) {
|
|
314
|
+
log.error(`${origin}: ${err}`);
|
|
315
|
+
return callback(null, err);
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/**
|
|
320
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
321
|
+
*
|
|
322
|
+
* @function iapActivateTasks
|
|
323
|
+
*
|
|
324
|
+
* @param {Array} tasks - List of tasks to activate
|
|
325
|
+
* @param {Callback} callback
|
|
326
|
+
*/
|
|
327
|
+
iapActivateTasks(tasks, callback) {
|
|
328
|
+
const meth = 'adapter-iapActivateTasks';
|
|
329
|
+
const origin = `${this.id}-${meth}`;
|
|
330
|
+
log.trace(origin);
|
|
331
|
+
|
|
332
|
+
try {
|
|
333
|
+
return super.iapActivateTasks(tasks, callback);
|
|
334
|
+
} catch (err) {
|
|
335
|
+
log.error(`${origin}: ${err}`);
|
|
336
|
+
return callback(null, err);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
/* CACHE CALLS */
|
|
341
|
+
/**
|
|
342
|
+
* @summary Populate the cache for the given entities
|
|
343
|
+
*
|
|
344
|
+
* @function iapPopulateEntityCache
|
|
345
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
346
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
347
|
+
*
|
|
348
|
+
* @returns status of the populate
|
|
349
|
+
*/
|
|
350
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
351
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
352
|
+
const origin = `${this.id}-${meth}`;
|
|
353
|
+
log.trace(origin);
|
|
354
|
+
|
|
355
|
+
try {
|
|
356
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
357
|
+
} catch (err) {
|
|
358
|
+
log.error(`${origin}: ${err}`);
|
|
359
|
+
return callback(null, err);
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* @summary Retrieves data from cache for specified entity type
|
|
258
365
|
*
|
|
259
|
-
* @
|
|
260
|
-
*
|
|
366
|
+
* @function iapRetrieveEntitiesCache
|
|
367
|
+
* @param {String} entityType - entity of which to retrieve
|
|
368
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
369
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
261
370
|
*/
|
|
262
|
-
|
|
263
|
-
const
|
|
371
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
372
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
373
|
+
const origin = `${this.id}-${meth}`;
|
|
264
374
|
log.trace(origin);
|
|
265
375
|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
376
|
+
try {
|
|
377
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
378
|
+
} catch (err) {
|
|
379
|
+
log.error(`${origin}: ${err}`);
|
|
380
|
+
return callback(null, err);
|
|
381
|
+
}
|
|
269
382
|
}
|
|
270
383
|
|
|
384
|
+
/* BROKER CALLS */
|
|
271
385
|
/**
|
|
272
|
-
* @summary
|
|
273
|
-
* whether the adapter supports type, action and specific entity
|
|
386
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
274
387
|
*
|
|
275
|
-
* @function
|
|
388
|
+
* @function hasEntities
|
|
276
389
|
* @param {String} entityType - the entity type to check for
|
|
277
|
-
* @param {
|
|
278
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
390
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
279
391
|
*
|
|
280
|
-
* @param {Callback} callback -
|
|
281
|
-
*
|
|
392
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
393
|
+
* value is true or false
|
|
282
394
|
*/
|
|
283
|
-
|
|
284
|
-
const meth = '
|
|
395
|
+
hasEntities(entityType, entityList, callback) {
|
|
396
|
+
const meth = 'adapter-hasEntities';
|
|
285
397
|
const origin = `${this.id}-${meth}`;
|
|
286
398
|
log.trace(origin);
|
|
287
399
|
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
400
|
+
try {
|
|
401
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
402
|
+
} catch (err) {
|
|
403
|
+
log.error(`${origin}: ${err}`);
|
|
404
|
+
return callback(null, err);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
295
407
|
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
return this.requestHandlerInst.verifyCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
310
|
-
if (verror) {
|
|
311
|
-
return callback(null, verror);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return this.capabilityResults(vcapable, callback);
|
|
315
|
-
});
|
|
316
|
-
});
|
|
317
|
-
}
|
|
318
|
-
default: {
|
|
319
|
-
// unsupported entity type
|
|
320
|
-
const result = [false];
|
|
321
|
-
|
|
322
|
-
// put false in array for all entities
|
|
323
|
-
if (Array.isArray(entityId)) {
|
|
324
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
325
|
-
result.push(false);
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
return callback(result);
|
|
330
|
-
}
|
|
331
|
-
}
|
|
332
|
-
}
|
|
408
|
+
/**
|
|
409
|
+
* @summary Get Appliance that match the deviceName
|
|
410
|
+
*
|
|
411
|
+
* @function getDevice
|
|
412
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
413
|
+
*
|
|
414
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
415
|
+
* (appliance) or the error
|
|
416
|
+
*/
|
|
417
|
+
getDevice(deviceName, callback) {
|
|
418
|
+
const meth = 'adapter-getDevice';
|
|
419
|
+
const origin = `${this.id}-${meth}`;
|
|
420
|
+
log.trace(origin);
|
|
333
421
|
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
422
|
+
try {
|
|
423
|
+
return super.getDevice(deviceName, callback);
|
|
424
|
+
} catch (err) {
|
|
425
|
+
log.error(`${origin}: ${err}`);
|
|
426
|
+
return callback(null, err);
|
|
337
427
|
}
|
|
428
|
+
}
|
|
338
429
|
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
430
|
+
/**
|
|
431
|
+
* @summary Get Appliances that match the filter
|
|
432
|
+
*
|
|
433
|
+
* @function getDevicesFiltered
|
|
434
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
435
|
+
*
|
|
436
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
437
|
+
* (appliances) or the error
|
|
438
|
+
*/
|
|
439
|
+
getDevicesFiltered(options, callback) {
|
|
440
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
441
|
+
const origin = `${this.id}-${meth}`;
|
|
442
|
+
log.trace(origin);
|
|
346
443
|
|
|
347
|
-
|
|
348
|
-
|
|
444
|
+
try {
|
|
445
|
+
return super.getDevicesFiltered(options, callback);
|
|
446
|
+
} catch (err) {
|
|
447
|
+
log.error(`${origin}: ${err}`);
|
|
448
|
+
return callback(null, err);
|
|
349
449
|
}
|
|
450
|
+
}
|
|
350
451
|
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
if (verror) {
|
|
365
|
-
return callback(null, verror);
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
// is the entity in the list?
|
|
369
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
370
|
-
const res = [];
|
|
371
|
-
|
|
372
|
-
// not found
|
|
373
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
374
|
-
if (vcapable) {
|
|
375
|
-
res.push(isEntity[i]);
|
|
376
|
-
} else {
|
|
377
|
-
res.push(false);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
return callback(res);
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
}
|
|
385
|
-
default: {
|
|
386
|
-
// unsupported entity type
|
|
387
|
-
const result = [false];
|
|
388
|
-
|
|
389
|
-
// put false in array for all entities
|
|
390
|
-
if (Array.isArray(entityId)) {
|
|
391
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
392
|
-
result.push(false);
|
|
393
|
-
}
|
|
394
|
-
}
|
|
452
|
+
/**
|
|
453
|
+
* @summary Gets the status for the provided appliance
|
|
454
|
+
*
|
|
455
|
+
* @function isAlive
|
|
456
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
457
|
+
*
|
|
458
|
+
* @param {configCallback} callback - callback function to return the result
|
|
459
|
+
* (appliance isAlive) or the error
|
|
460
|
+
*/
|
|
461
|
+
isAlive(deviceName, callback) {
|
|
462
|
+
const meth = 'adapter-isAlive';
|
|
463
|
+
const origin = `${this.id}-${meth}`;
|
|
464
|
+
log.trace(origin);
|
|
395
465
|
|
|
396
|
-
|
|
397
|
-
|
|
466
|
+
try {
|
|
467
|
+
return super.isAlive(deviceName, callback);
|
|
468
|
+
} catch (err) {
|
|
469
|
+
log.error(`${origin}: ${err}`);
|
|
470
|
+
return callback(null, err);
|
|
398
471
|
}
|
|
399
472
|
}
|
|
400
473
|
|
|
401
474
|
/**
|
|
402
|
-
* @summary
|
|
475
|
+
* @summary Gets a config for the provided Appliance
|
|
403
476
|
*
|
|
404
|
-
* @function
|
|
477
|
+
* @function getConfig
|
|
478
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
479
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
405
480
|
*
|
|
481
|
+
* @param {configCallback} callback - callback function to return the result
|
|
482
|
+
* (appliance config) or the error
|
|
406
483
|
*/
|
|
407
|
-
|
|
408
|
-
const
|
|
484
|
+
getConfig(deviceName, format, callback) {
|
|
485
|
+
const meth = 'adapter-getConfig';
|
|
486
|
+
const origin = `${this.id}-${meth}`;
|
|
409
487
|
log.trace(origin);
|
|
410
488
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
489
|
+
try {
|
|
490
|
+
return super.getConfig(deviceName, format, callback);
|
|
491
|
+
} catch (err) {
|
|
492
|
+
log.error(`${origin}: ${err}`);
|
|
493
|
+
return callback(null, err);
|
|
494
|
+
}
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
/**
|
|
498
|
+
* @summary Gets the device count from the system
|
|
499
|
+
*
|
|
500
|
+
* @function iapGetDeviceCount
|
|
501
|
+
*
|
|
502
|
+
* @param {getCallback} callback - callback function to return the result
|
|
503
|
+
* (count) or the error
|
|
504
|
+
*/
|
|
505
|
+
iapGetDeviceCount(callback) {
|
|
506
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
507
|
+
const origin = `${this.id}-${meth}`;
|
|
508
|
+
log.trace(origin);
|
|
509
|
+
|
|
510
|
+
try {
|
|
511
|
+
return super.iapGetDeviceCount(callback);
|
|
512
|
+
} catch (err) {
|
|
513
|
+
log.error(`${origin}: ${err}`);
|
|
514
|
+
return callback(null, err);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
519
|
+
/**
|
|
520
|
+
* Makes the requested generic call
|
|
521
|
+
*
|
|
522
|
+
* @function iapExpandedGenericAdapterRequest
|
|
523
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
524
|
+
* Can be a stringified Object.
|
|
525
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
526
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
527
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
528
|
+
* Can be a stringified Object.
|
|
529
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
530
|
+
* Can be a stringified Object.
|
|
531
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
532
|
+
* Can be a stringified Object.
|
|
533
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
534
|
+
* Can be a stringified Object.
|
|
535
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
536
|
+
* or the error
|
|
537
|
+
*/
|
|
538
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
539
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
540
|
+
const origin = `${this.id}-${meth}`;
|
|
541
|
+
log.trace(origin);
|
|
542
|
+
|
|
543
|
+
try {
|
|
544
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
545
|
+
} catch (err) {
|
|
546
|
+
log.error(`${origin}: ${err}`);
|
|
547
|
+
return callback(null, err);
|
|
418
548
|
}
|
|
419
549
|
}
|
|
420
550
|
|
|
@@ -438,94 +568,84 @@ class OnapSdc extends AdapterBaseCl {
|
|
|
438
568
|
const origin = `${this.id}-${meth}`;
|
|
439
569
|
log.trace(origin);
|
|
440
570
|
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
571
|
+
try {
|
|
572
|
+
return super.genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
573
|
+
} catch (err) {
|
|
574
|
+
log.error(`${origin}: ${err}`);
|
|
575
|
+
return callback(null, err);
|
|
445
576
|
}
|
|
577
|
+
}
|
|
446
578
|
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
579
|
+
/**
|
|
580
|
+
* Makes the requested generic call with no base path or version
|
|
581
|
+
*
|
|
582
|
+
* @function genericAdapterRequestNoBasePath
|
|
583
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
584
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
585
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
586
|
+
* Can be a stringified Object.
|
|
587
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
588
|
+
* Can be a stringified Object.
|
|
589
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
590
|
+
* Can be a stringified Object.
|
|
591
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
592
|
+
* or the error
|
|
593
|
+
*/
|
|
594
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
595
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
596
|
+
const origin = `${this.id}-${meth}`;
|
|
597
|
+
log.trace(origin);
|
|
458
598
|
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
599
|
+
try {
|
|
600
|
+
return super.genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback);
|
|
601
|
+
} catch (err) {
|
|
602
|
+
log.error(`${origin}: ${err}`);
|
|
603
|
+
return callback(null, err);
|
|
464
604
|
}
|
|
465
|
-
|
|
466
|
-
const queryParamsAvailable = queryData;
|
|
467
|
-
const queryParams = {};
|
|
468
|
-
const bodyVars = requestBody;
|
|
605
|
+
}
|
|
469
606
|
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
607
|
+
/* INVENTORY CALLS */
|
|
608
|
+
/**
|
|
609
|
+
* @summary run the adapter lint script to return the results.
|
|
610
|
+
*
|
|
611
|
+
* @function iapRunAdapterLint
|
|
612
|
+
* @param {Callback} callback - callback function
|
|
613
|
+
*/
|
|
614
|
+
iapRunAdapterLint(callback) {
|
|
615
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
616
|
+
const origin = `${this.id}-${meth}`;
|
|
617
|
+
log.trace(origin);
|
|
477
618
|
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
payload: bodyVars,
|
|
481
|
-
uriPathVars: pathVars,
|
|
482
|
-
uriQuery: queryParams,
|
|
483
|
-
uriOptions: {}
|
|
484
|
-
};
|
|
485
|
-
// add headers if provided
|
|
486
|
-
if (addlHeaders) {
|
|
487
|
-
reqObj.addlHeaders = addlHeaders;
|
|
488
|
-
}
|
|
489
|
-
|
|
490
|
-
// determine the call and return flag
|
|
491
|
-
let action = 'getGenerics';
|
|
492
|
-
let returnF = true;
|
|
493
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
494
|
-
action = 'createGeneric';
|
|
495
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
496
|
-
action = 'updateGeneric';
|
|
497
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
498
|
-
action = 'patchGeneric';
|
|
499
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
500
|
-
action = 'deleteGeneric';
|
|
501
|
-
returnF = false;
|
|
502
|
-
}
|
|
619
|
+
return super.iapRunAdapterLint(callback);
|
|
620
|
+
}
|
|
503
621
|
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
516
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
517
|
-
return callback(null, errorObj);
|
|
518
|
-
}
|
|
622
|
+
/**
|
|
623
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
624
|
+
* can not run integration as there can be implications with that.
|
|
625
|
+
*
|
|
626
|
+
* @function iapRunAdapterTests
|
|
627
|
+
* @param {Callback} callback - callback function
|
|
628
|
+
*/
|
|
629
|
+
iapRunAdapterTests(callback) {
|
|
630
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
631
|
+
const origin = `${this.id}-${meth}`;
|
|
632
|
+
log.trace(origin);
|
|
519
633
|
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
634
|
+
return super.iapRunAdapterTests(callback);
|
|
635
|
+
}
|
|
636
|
+
|
|
637
|
+
/**
|
|
638
|
+
* @summary provide inventory information abbout the adapter
|
|
639
|
+
*
|
|
640
|
+
* @function iapGetAdapterInventory
|
|
641
|
+
* @param {Callback} callback - callback function
|
|
642
|
+
*/
|
|
643
|
+
iapGetAdapterInventory(callback) {
|
|
644
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
645
|
+
const origin = `${this.id}-${meth}`;
|
|
646
|
+
log.trace(origin);
|
|
647
|
+
|
|
648
|
+
return super.iapGetAdapterInventory(callback);
|
|
529
649
|
}
|
|
530
650
|
|
|
531
651
|
/**
|