@itentialopensource/adapter-openstack_glance 0.1.1 → 0.2.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 +18 -13
- package/CALLS.md +59 -23
- package/CHANGELOG.md +8 -1
- package/CONTRIBUTING.md +1 -160
- package/ENHANCE.md +2 -2
- package/README.md +32 -23
- package/SYSTEMINFO.md +18 -6
- package/adapter.js +170 -369
- package/adapterBase.js +541 -877
- package/changelogs/CHANGELOG.md +9 -0
- package/metadata.json +53 -0
- package/package.json +24 -26
- package/pronghorn.json +474 -142
- package/propertiesSchema.json +431 -34
- package/refs?service=git-upload-pack +0 -0
- package/report/adapter-openapi.json +1367 -0
- package/report/adapter-openapi.yaml +1169 -0
- package/report/adapterInfo.json +8 -8
- package/report/updateReport1691507378592.json +120 -0
- package/report/updateReport1692202413995.json +120 -0
- package/report/updateReport1694460469489.json +120 -0
- package/report/updateReport1698420436235.json +120 -0
- package/sampleProperties.json +63 -2
- package/test/integration/adapterTestBasicGet.js +2 -4
- package/test/integration/adapterTestConnectivity.js +91 -42
- package/test/integration/adapterTestIntegration.js +130 -2
- package/test/unit/adapterBaseTestUnit.js +389 -317
- package/test/unit/adapterTestUnit.js +303 -112
- package/utils/adapterInfo.js +1 -1
- package/utils/addAuth.js +1 -1
- package/utils/artifactize.js +1 -1
- package/utils/checkMigrate.js +1 -1
- package/utils/entitiesToDB.js +2 -2
- package/utils/findPath.js +1 -1
- package/utils/methodDocumentor.js +71 -23
- package/utils/modify.js +13 -15
- package/utils/packModificationScript.js +1 -1
- package/utils/taskMover.js +309 -0
- package/utils/tbScript.js +89 -34
- package/utils/tbUtils.js +41 -21
- package/utils/testRunner.js +1 -1
- package/utils/troubleshootingAdapter.js +9 -6
- package/workflows/README.md +0 -3
package/adapter.js
CHANGED
|
@@ -121,10 +121,8 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
121
121
|
let myIgnore = [
|
|
122
122
|
'healthCheck',
|
|
123
123
|
'iapGetAdapterWorkflowFunctions',
|
|
124
|
-
'
|
|
125
|
-
'
|
|
126
|
-
'iapUpdateAdapterEntityCache',
|
|
127
|
-
'hasEntities'
|
|
124
|
+
'hasEntities',
|
|
125
|
+
'getAuthorization'
|
|
128
126
|
];
|
|
129
127
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
130
128
|
myIgnore = inIgnore;
|
|
@@ -150,29 +148,15 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
150
148
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
151
149
|
* @param {string} type - the type of entity file to change, (action, schema, mock) (optional)
|
|
152
150
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
151
|
+
* @param {boolean} replace - true to replace entire mock data, false to merge/append
|
|
153
152
|
* @param {Callback} callback - The results of the call
|
|
154
153
|
*/
|
|
155
|
-
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
154
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback) {
|
|
156
155
|
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
157
156
|
const origin = `${this.id}-${meth}`;
|
|
158
157
|
log.trace(origin);
|
|
159
158
|
|
|
160
|
-
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* See if the API path provided is found in this adapter
|
|
165
|
-
*
|
|
166
|
-
* @function iapFindAdapterPath
|
|
167
|
-
* @param {string} apiPath - the api path to check on
|
|
168
|
-
* @param {Callback} callback - The results of the call
|
|
169
|
-
*/
|
|
170
|
-
iapFindAdapterPath(apiPath, callback) {
|
|
171
|
-
const meth = 'adapter-iapFindAdapterPath';
|
|
172
|
-
const origin = `${this.id}-${meth}`;
|
|
173
|
-
log.trace(origin);
|
|
174
|
-
|
|
175
|
-
super.iapFindAdapterPath(apiPath, callback);
|
|
159
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, replace, callback);
|
|
176
160
|
}
|
|
177
161
|
|
|
178
162
|
/**
|
|
@@ -214,7 +198,7 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
214
198
|
}
|
|
215
199
|
|
|
216
200
|
/**
|
|
217
|
-
* @summary Get the
|
|
201
|
+
* @summary Get the Adapter Queue
|
|
218
202
|
*
|
|
219
203
|
* @function iapGetAdapterQueue
|
|
220
204
|
* @param {Callback} callback - callback function
|
|
@@ -227,6 +211,22 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
227
211
|
return super.iapGetAdapterQueue(callback);
|
|
228
212
|
}
|
|
229
213
|
|
|
214
|
+
/* SCRIPT CALLS */
|
|
215
|
+
/**
|
|
216
|
+
* See if the API path provided is found in this adapter
|
|
217
|
+
*
|
|
218
|
+
* @function iapFindAdapterPath
|
|
219
|
+
* @param {string} apiPath - the api path to check on
|
|
220
|
+
* @param {Callback} callback - The results of the call
|
|
221
|
+
*/
|
|
222
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
223
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
224
|
+
const origin = `${this.id}-${meth}`;
|
|
225
|
+
log.trace(origin);
|
|
226
|
+
|
|
227
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
228
|
+
}
|
|
229
|
+
|
|
230
230
|
/**
|
|
231
231
|
* @summary Runs troubleshoot scripts for adapter
|
|
232
232
|
*
|
|
@@ -327,176 +327,93 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
327
327
|
}
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
/* BROKER CALLS */
|
|
331
330
|
/**
|
|
332
|
-
* @summary
|
|
331
|
+
* @summary Deactivate adapter tasks
|
|
333
332
|
*
|
|
334
|
-
* @function
|
|
335
|
-
* @param {String} entityType - the entity type to check for
|
|
336
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
333
|
+
* @function iapDeactivateTasks
|
|
337
334
|
*
|
|
338
|
-
* @param {
|
|
339
|
-
*
|
|
335
|
+
* @param {Array} tasks - List of tasks to deactivate
|
|
336
|
+
* @param {Callback} callback
|
|
340
337
|
*/
|
|
341
|
-
|
|
342
|
-
const
|
|
338
|
+
iapDeactivateTasks(tasks, callback) {
|
|
339
|
+
const meth = 'adapter-iapDeactivateTasks';
|
|
340
|
+
const origin = `${this.id}-${meth}`;
|
|
343
341
|
log.trace(origin);
|
|
344
342
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
343
|
+
try {
|
|
344
|
+
return super.iapDeactivateTasks(tasks, callback);
|
|
345
|
+
} catch (err) {
|
|
346
|
+
log.error(`${origin}: ${err}`);
|
|
347
|
+
return callback(null, err);
|
|
348
|
+
}
|
|
348
349
|
}
|
|
349
350
|
|
|
350
351
|
/**
|
|
351
|
-
* @summary
|
|
352
|
-
* whether the adapter supports type, action and specific entity
|
|
352
|
+
* @summary Activate adapter tasks that have previously been deactivated
|
|
353
353
|
*
|
|
354
|
-
* @function
|
|
355
|
-
* @param {String} entityType - the entity type to check for
|
|
356
|
-
* @param {String} actionType - the action type to check for
|
|
357
|
-
* @param {String/Array} entityId - the specific entity we are looking for
|
|
354
|
+
* @function iapActivateTasks
|
|
358
355
|
*
|
|
359
|
-
* @param {
|
|
360
|
-
*
|
|
356
|
+
* @param {Array} tasks - List of tasks to activate
|
|
357
|
+
* @param {Callback} callback
|
|
361
358
|
*/
|
|
362
|
-
|
|
363
|
-
const meth = '
|
|
359
|
+
iapActivateTasks(tasks, callback) {
|
|
360
|
+
const meth = 'adapter-iapActivateTasks';
|
|
364
361
|
const origin = `${this.id}-${meth}`;
|
|
365
362
|
log.trace(origin);
|
|
366
363
|
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
return callback(null, error);
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// if the cache needs to be updated, update and try again
|
|
376
|
-
if (results && results[0] === 'needupdate') {
|
|
377
|
-
switch (entityType) {
|
|
378
|
-
case 'template_entity': {
|
|
379
|
-
// if the cache is invalid, update the cache
|
|
380
|
-
return this.getEntities(null, null, null, null, (data, err) => {
|
|
381
|
-
if (err) {
|
|
382
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Could not update entity: $VARIABLE$, cache', [entityType], null, null, null);
|
|
383
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
384
|
-
return callback(null, errorObj);
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
// need to check the cache again since it has been updated
|
|
388
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
389
|
-
if (verror) {
|
|
390
|
-
return callback(null, verror);
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
return this.capabilityResults(vcapable, callback);
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
default: {
|
|
398
|
-
// unsupported entity type
|
|
399
|
-
const result = [false];
|
|
400
|
-
|
|
401
|
-
// put false in array for all entities
|
|
402
|
-
if (Array.isArray(entityId)) {
|
|
403
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
404
|
-
result.push(false);
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return callback(result);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
// return the results
|
|
414
|
-
return this.capabilityResults(results, callback);
|
|
415
|
-
});
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
// if no entity id
|
|
419
|
-
if (!entityId) {
|
|
420
|
-
// need to check the cache again since it has been updated
|
|
421
|
-
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
422
|
-
if (verror) {
|
|
423
|
-
return callback(null, verror);
|
|
424
|
-
}
|
|
425
|
-
|
|
426
|
-
return this.capabilityResults(vcapable, callback);
|
|
427
|
-
});
|
|
364
|
+
try {
|
|
365
|
+
return super.iapActivateTasks(tasks, callback);
|
|
366
|
+
} catch (err) {
|
|
367
|
+
log.error(`${origin}: ${err}`);
|
|
368
|
+
return callback(null, err);
|
|
428
369
|
}
|
|
370
|
+
}
|
|
429
371
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return callback(null, verror);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
// is the entity in the list?
|
|
448
|
-
const isEntity = this.entityInList(entityId, data.response, callback);
|
|
449
|
-
const res = [];
|
|
450
|
-
|
|
451
|
-
// not found
|
|
452
|
-
for (let i = 0; i < isEntity.length; i += 1) {
|
|
453
|
-
if (vcapable) {
|
|
454
|
-
res.push(isEntity[i]);
|
|
455
|
-
} else {
|
|
456
|
-
res.push(false);
|
|
457
|
-
}
|
|
458
|
-
}
|
|
459
|
-
|
|
460
|
-
return callback(res);
|
|
461
|
-
});
|
|
462
|
-
});
|
|
463
|
-
}
|
|
464
|
-
default: {
|
|
465
|
-
// unsupported entity type
|
|
466
|
-
const result = [false];
|
|
467
|
-
|
|
468
|
-
// put false in array for all entities
|
|
469
|
-
if (Array.isArray(entityId)) {
|
|
470
|
-
for (let e = 1; e < entityId.length; e += 1) {
|
|
471
|
-
result.push(false);
|
|
472
|
-
}
|
|
473
|
-
}
|
|
372
|
+
/* CACHE CALLS */
|
|
373
|
+
/**
|
|
374
|
+
* @summary Populate the cache for the given entities
|
|
375
|
+
*
|
|
376
|
+
* @function iapPopulateEntityCache
|
|
377
|
+
* @param {String/Array of Strings} entityType - the entity type(s) to populate
|
|
378
|
+
* @param {Callback} callback - whether the cache was updated or not for each entity type
|
|
379
|
+
*
|
|
380
|
+
* @returns status of the populate
|
|
381
|
+
*/
|
|
382
|
+
iapPopulateEntityCache(entityTypes, callback) {
|
|
383
|
+
const meth = 'adapter-iapPopulateEntityCache';
|
|
384
|
+
const origin = `${this.id}-${meth}`;
|
|
385
|
+
log.trace(origin);
|
|
474
386
|
|
|
475
|
-
|
|
476
|
-
|
|
387
|
+
try {
|
|
388
|
+
return super.iapPopulateEntityCache(entityTypes, callback);
|
|
389
|
+
} catch (err) {
|
|
390
|
+
log.error(`${origin}: ${err}`);
|
|
391
|
+
return callback(null, err);
|
|
477
392
|
}
|
|
478
393
|
}
|
|
479
394
|
|
|
480
395
|
/**
|
|
481
|
-
* @summary
|
|
482
|
-
*
|
|
483
|
-
* @function iapUpdateAdapterEntityCache
|
|
396
|
+
* @summary Retrieves data from cache for specified entity type
|
|
484
397
|
*
|
|
398
|
+
* @function iapRetrieveEntitiesCache
|
|
399
|
+
* @param {String} entityType - entity of which to retrieve
|
|
400
|
+
* @param {Object} options - settings of which data to return and how to return it
|
|
401
|
+
* @param {Callback} callback - the data if it was retrieved
|
|
485
402
|
*/
|
|
486
|
-
|
|
487
|
-
const
|
|
403
|
+
iapRetrieveEntitiesCache(entityType, options, callback) {
|
|
404
|
+
const meth = 'adapter-iapCheckEiapRetrieveEntitiesCachentityCached';
|
|
405
|
+
const origin = `${this.id}-${meth}`;
|
|
488
406
|
log.trace(origin);
|
|
489
407
|
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
}
|
|
496
|
-
});
|
|
408
|
+
try {
|
|
409
|
+
return super.iapRetrieveEntitiesCache(entityType, options, callback);
|
|
410
|
+
} catch (err) {
|
|
411
|
+
log.error(`${origin}: ${err}`);
|
|
412
|
+
return callback(null, err);
|
|
497
413
|
}
|
|
498
414
|
}
|
|
499
415
|
|
|
416
|
+
/* BROKER CALLS */
|
|
500
417
|
/**
|
|
501
418
|
* @summary Determines if this adapter supports any in a list of entities
|
|
502
419
|
*
|
|
@@ -634,9 +551,13 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
634
551
|
/**
|
|
635
552
|
* Makes the requested generic call
|
|
636
553
|
*
|
|
637
|
-
* @function
|
|
638
|
-
* @param {
|
|
639
|
-
*
|
|
554
|
+
* @function iapExpandedGenericAdapterRequest
|
|
555
|
+
* @param {Object} metadata - metadata for the call (optional).
|
|
556
|
+
* Can be a stringified Object.
|
|
557
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (optional)
|
|
558
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (optional)
|
|
559
|
+
* @param {Object} pathVars - the parameters to be put within the url path (optional).
|
|
560
|
+
* Can be a stringified Object.
|
|
640
561
|
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
641
562
|
* Can be a stringified Object.
|
|
642
563
|
* @param {Object} requestBody - the body to add to the request (optional).
|
|
@@ -646,75 +567,17 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
646
567
|
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
647
568
|
* or the error
|
|
648
569
|
*/
|
|
649
|
-
|
|
650
|
-
const meth = 'adapter-
|
|
570
|
+
iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback) {
|
|
571
|
+
const meth = 'adapter-iapExpandedGenericAdapterRequest';
|
|
651
572
|
const origin = `${this.id}-${meth}`;
|
|
652
573
|
log.trace(origin);
|
|
653
574
|
|
|
654
|
-
if (
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return callback(null, errorObj);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
661
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
662
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
663
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
664
|
-
return callback(null, errorObj);
|
|
665
|
-
}
|
|
666
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
667
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
668
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
669
|
-
return callback(null, errorObj);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
673
|
-
// remove any leading / and split the uripath into path variables
|
|
674
|
-
let myPath = uriPath;
|
|
675
|
-
while (myPath.indexOf('/') === 0) {
|
|
676
|
-
myPath = myPath.substring(1);
|
|
677
|
-
}
|
|
678
|
-
const pathVars = myPath.split('/');
|
|
679
|
-
const queryParamsAvailable = queryData;
|
|
680
|
-
const queryParams = {};
|
|
681
|
-
const bodyVars = requestBody;
|
|
682
|
-
|
|
683
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
684
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
685
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
686
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
687
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
688
|
-
}
|
|
689
|
-
});
|
|
690
|
-
|
|
691
|
-
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
692
|
-
const reqObj = {
|
|
693
|
-
payload: bodyVars,
|
|
694
|
-
uriPathVars: pathVars,
|
|
695
|
-
uriQuery: queryParams,
|
|
696
|
-
uriOptions: {}
|
|
697
|
-
};
|
|
698
|
-
// add headers if provided
|
|
699
|
-
if (addlHeaders) {
|
|
700
|
-
reqObj.addlHeaders = addlHeaders;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
// determine the call and return flag
|
|
704
|
-
let action = 'getGenerics';
|
|
705
|
-
let returnF = true;
|
|
706
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
707
|
-
action = 'createGeneric';
|
|
708
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
709
|
-
action = 'updateGeneric';
|
|
710
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
711
|
-
action = 'patchGeneric';
|
|
712
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
713
|
-
action = 'deleteGeneric';
|
|
714
|
-
returnF = false;
|
|
575
|
+
if (metadata === undefined || metadata === null || metadata === '') {
|
|
576
|
+
// eslint-disable-next-line no-param-reassign
|
|
577
|
+
metadata = {};
|
|
715
578
|
}
|
|
716
|
-
|
|
717
|
-
|
|
579
|
+
// eslint-disable-next-line no-param-reassign
|
|
580
|
+
metadata.authData = {
|
|
718
581
|
auth: {
|
|
719
582
|
identity: {
|
|
720
583
|
methods: [
|
|
@@ -741,7 +604,8 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
741
604
|
}
|
|
742
605
|
};
|
|
743
606
|
|
|
744
|
-
|
|
607
|
+
// eslint-disable-next-line no-param-reassign
|
|
608
|
+
metadata.callProperties = {
|
|
745
609
|
ssl: {
|
|
746
610
|
enabled: true,
|
|
747
611
|
accept_invalid_cert: true
|
|
@@ -749,29 +613,38 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
749
613
|
};
|
|
750
614
|
|
|
751
615
|
try {
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
759
|
-
return callback(null, irReturnError);
|
|
760
|
-
}
|
|
761
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
762
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequest'], null, null, null);
|
|
763
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
764
|
-
return callback(null, errorObj);
|
|
765
|
-
}
|
|
616
|
+
return super.iapExpandedGenericAdapterRequest(metadata, uriPath, restMethod, pathVars, queryData, requestBody, addlHeaders, callback);
|
|
617
|
+
} catch (err) {
|
|
618
|
+
log.error(`${origin}: ${err}`);
|
|
619
|
+
return callback(null, err);
|
|
620
|
+
}
|
|
621
|
+
}
|
|
766
622
|
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
623
|
+
/**
|
|
624
|
+
* Makes the requested generic call
|
|
625
|
+
*
|
|
626
|
+
* @function genericAdapterRequest
|
|
627
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
628
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
629
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
630
|
+
* Can be a stringified Object.
|
|
631
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
632
|
+
* Can be a stringified Object.
|
|
633
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
634
|
+
* Can be a stringified Object.
|
|
635
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
636
|
+
* or the error
|
|
637
|
+
*/
|
|
638
|
+
genericAdapterRequest(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
639
|
+
const meth = 'adapter-genericAdapterRequest';
|
|
640
|
+
const origin = `${this.id}-${meth}`;
|
|
641
|
+
log.trace(origin);
|
|
642
|
+
|
|
643
|
+
try {
|
|
644
|
+
return this.iapExpandedGenericAdapterRequest(null, uriPath, restMethod, null, queryData, requestBody, addlHeaders, callback);
|
|
645
|
+
} catch (err) {
|
|
646
|
+
log.error(`${origin}: ${err}`);
|
|
647
|
+
return callback(null, err);
|
|
775
648
|
}
|
|
776
649
|
}
|
|
777
650
|
|
|
@@ -795,128 +668,56 @@ class OpenstackGlance extends AdapterBaseCl {
|
|
|
795
668
|
const origin = `${this.id}-${meth}`;
|
|
796
669
|
log.trace(origin);
|
|
797
670
|
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
805
|
-
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
806
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
807
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
808
|
-
return callback(null, errorObj);
|
|
809
|
-
}
|
|
810
|
-
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
811
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
812
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
813
|
-
return callback(null, errorObj);
|
|
814
|
-
}
|
|
815
|
-
|
|
816
|
-
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
817
|
-
// remove any leading / and split the uripath into path variables
|
|
818
|
-
let myPath = uriPath;
|
|
819
|
-
while (myPath.indexOf('/') === 0) {
|
|
820
|
-
myPath = myPath.substring(1);
|
|
671
|
+
try {
|
|
672
|
+
return this.iapExpandedGenericAdapterRequest(null, uriPath, restMethod, null, queryData, requestBody, addlHeaders, callback);
|
|
673
|
+
} catch (err) {
|
|
674
|
+
log.error(`${origin}: ${err}`);
|
|
675
|
+
return callback(null, err);
|
|
821
676
|
}
|
|
822
|
-
|
|
823
|
-
const queryParamsAvailable = queryData;
|
|
824
|
-
const queryParams = {};
|
|
825
|
-
const bodyVars = requestBody;
|
|
826
|
-
|
|
827
|
-
// loop in template. long callback arg name to avoid identifier conflicts
|
|
828
|
-
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
829
|
-
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
830
|
-
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
831
|
-
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
832
|
-
}
|
|
833
|
-
});
|
|
677
|
+
}
|
|
834
678
|
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
679
|
+
/* INVENTORY CALLS */
|
|
680
|
+
/**
|
|
681
|
+
* @summary run the adapter lint script to return the results.
|
|
682
|
+
*
|
|
683
|
+
* @function iapRunAdapterLint
|
|
684
|
+
* @param {Callback} callback - callback function
|
|
685
|
+
*/
|
|
686
|
+
iapRunAdapterLint(callback) {
|
|
687
|
+
const meth = 'adapter-iapRunAdapterLint';
|
|
688
|
+
const origin = `${this.id}-${meth}`;
|
|
689
|
+
log.trace(origin);
|
|
846
690
|
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
let returnF = true;
|
|
850
|
-
if (restMethod.toUpperCase() === 'POST') {
|
|
851
|
-
action = 'createGenericNoBase';
|
|
852
|
-
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
853
|
-
action = 'updateGenericNoBase';
|
|
854
|
-
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
855
|
-
action = 'patchGenericNoBase';
|
|
856
|
-
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
857
|
-
action = 'deleteGenericNoBase';
|
|
858
|
-
returnF = false;
|
|
859
|
-
}
|
|
691
|
+
return super.iapRunAdapterLint(callback);
|
|
692
|
+
}
|
|
860
693
|
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
},
|
|
873
|
-
password: this.allProps.authentication.password
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
|
-
},
|
|
877
|
-
scope: {
|
|
878
|
-
project: {
|
|
879
|
-
name: this.allProps.authentication.os_project_name,
|
|
880
|
-
domain: {
|
|
881
|
-
name: this.allProps.authentication.os_project_domain_name
|
|
882
|
-
}
|
|
883
|
-
}
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
};
|
|
694
|
+
/**
|
|
695
|
+
* @summary run the adapter test scripts (baseunit and unit) to return the results.
|
|
696
|
+
* can not run integration as there can be implications with that.
|
|
697
|
+
*
|
|
698
|
+
* @function iapRunAdapterTests
|
|
699
|
+
* @param {Callback} callback - callback function
|
|
700
|
+
*/
|
|
701
|
+
iapRunAdapterTests(callback) {
|
|
702
|
+
const meth = 'adapter-iapRunAdapterTests';
|
|
703
|
+
const origin = `${this.id}-${meth}`;
|
|
704
|
+
log.trace(origin);
|
|
887
705
|
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
enabled: true,
|
|
891
|
-
accept_invalid_cert: true
|
|
892
|
-
}
|
|
893
|
-
};
|
|
706
|
+
return super.iapRunAdapterTests(callback);
|
|
707
|
+
}
|
|
894
708
|
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
906
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
907
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
908
|
-
return callback(null, errorObj);
|
|
909
|
-
}
|
|
709
|
+
/**
|
|
710
|
+
* @summary provide inventory information abbout the adapter
|
|
711
|
+
*
|
|
712
|
+
* @function iapGetAdapterInventory
|
|
713
|
+
* @param {Callback} callback - callback function
|
|
714
|
+
*/
|
|
715
|
+
iapGetAdapterInventory(callback) {
|
|
716
|
+
const meth = 'adapter-iapGetAdapterInventory';
|
|
717
|
+
const origin = `${this.id}-${meth}`;
|
|
718
|
+
log.trace(origin);
|
|
910
719
|
|
|
911
|
-
|
|
912
|
-
// return the response
|
|
913
|
-
return callback(irReturnData, null);
|
|
914
|
-
});
|
|
915
|
-
} catch (ex) {
|
|
916
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
917
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
918
|
-
return callback(null, errorObj);
|
|
919
|
-
}
|
|
720
|
+
return super.iapGetAdapterInventory(callback);
|
|
920
721
|
}
|
|
921
722
|
|
|
922
723
|
/**
|