@itentialopensource/adapter-vmware_vcenter 0.5.5 → 0.8.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 +169 -0
- package/CHANGELOG.md +85 -54
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +69 -0
- package/PROPERTIES.md +641 -0
- package/README.md +225 -502
- package/SUMMARY.md +9 -0
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +47 -0
- package/adapter.js +430 -57
- package/adapterBase.js +1021 -245
- package/entities/.generic/action.json +110 -5
- package/entities/.generic/schema.json +6 -1
- package/entities/Vmtemplatelibraryitems/action.json +25 -0
- package/entities/Vmtemplatelibraryitems/schema.json +19 -0
- package/error.json +12 -0
- package/package.json +20 -13
- package/pronghorn.json +686 -378
- package/propertiesDecorators.json +14 -0
- package/propertiesSchema.json +436 -0
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1643047821981.json +95 -0
- package/report/updateReport1652715810150.json +120 -0
- package/sampleProperties.json +94 -2
- package/test/integration/adapterTestBasicGet.js +2 -2
- package/test/integration/adapterTestIntegration.js +62 -103
- package/test/unit/adapterBaseTestUnit.js +35 -27
- package/test/unit/adapterTestUnit.js +586 -142
- package/utils/adapterInfo.js +206 -0
- package/utils/addAuth.js +94 -0
- package/utils/basicGet.js +1 -14
- package/utils/entitiesToDB.js +179 -0
- package/utils/modify.js +1 -1
- package/utils/packModificationScript.js +1 -1
- package/utils/patches2bundledDeps.js +90 -0
- package/utils/pre-commit.sh +3 -0
- package/utils/removeHooks.js +20 -0
- package/utils/tbScript.js +43 -22
- package/utils/tbUtils.js +126 -29
- package/utils/testRunner.js +16 -16
- package/utils/troubleshootingAdapter.js +2 -26
package/adapter.js
CHANGED
|
@@ -82,10 +82,18 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
/**
|
|
85
|
-
* @
|
|
85
|
+
* @iapGetAdapterWorkflowFunctions
|
|
86
86
|
*/
|
|
87
|
-
|
|
88
|
-
let myIgnore = [
|
|
87
|
+
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
88
|
+
let myIgnore = [
|
|
89
|
+
'healthCheck',
|
|
90
|
+
'iapGetAdapterWorkflowFunctions',
|
|
91
|
+
'iapHasAdapterEntity',
|
|
92
|
+
'iapVerifyAdapterCapability',
|
|
93
|
+
'iapUpdateAdapterEntityCache',
|
|
94
|
+
'hasEntities',
|
|
95
|
+
'getAuthorization'
|
|
96
|
+
];
|
|
89
97
|
if (!inIgnore && Array.isArray(inIgnore)) {
|
|
90
98
|
myIgnore = inIgnore;
|
|
91
99
|
} else if (!inIgnore && typeof inIgnore === 'string') {
|
|
@@ -96,15 +104,15 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
96
104
|
// you can add specific methods that you do not want to be workflow functions to ignore like below
|
|
97
105
|
// myIgnore.push('myMethodNotInWorkflow');
|
|
98
106
|
|
|
99
|
-
return super.
|
|
107
|
+
return super.iapGetAdapterWorkflowFunctions(myIgnore);
|
|
100
108
|
}
|
|
101
109
|
|
|
102
110
|
/**
|
|
103
|
-
*
|
|
111
|
+
* iapUpdateAdapterConfiguration is used to update any of the adapter configuration files. This
|
|
104
112
|
* allows customers to make changes to adapter configuration without having to be on the
|
|
105
113
|
* file system.
|
|
106
114
|
*
|
|
107
|
-
* @function
|
|
115
|
+
* @function iapUpdateAdapterConfiguration
|
|
108
116
|
* @param {string} configFile - the name of the file being updated (required)
|
|
109
117
|
* @param {Object} changes - an object containing all of the changes = formatted like the configuration file (required)
|
|
110
118
|
* @param {string} entity - the entity to be changed, if an action, schema or mock data file (optional)
|
|
@@ -112,36 +120,42 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
112
120
|
* @param {string} action - the action to be changed, if an action, schema or mock data file (optional)
|
|
113
121
|
* @param {Callback} callback - The results of the call
|
|
114
122
|
*/
|
|
115
|
-
|
|
116
|
-
const
|
|
123
|
+
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
124
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
125
|
+
const origin = `${this.id}-${meth}`;
|
|
117
126
|
log.trace(origin);
|
|
118
|
-
|
|
127
|
+
|
|
128
|
+
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
119
129
|
}
|
|
120
130
|
|
|
121
131
|
/**
|
|
122
132
|
* See if the API path provided is found in this adapter
|
|
123
133
|
*
|
|
124
|
-
* @function
|
|
134
|
+
* @function iapFindAdapterPath
|
|
125
135
|
* @param {string} apiPath - the api path to check on
|
|
126
136
|
* @param {Callback} callback - The results of the call
|
|
127
137
|
*/
|
|
128
|
-
|
|
129
|
-
const
|
|
138
|
+
iapFindAdapterPath(apiPath, callback) {
|
|
139
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
140
|
+
const origin = `${this.id}-${meth}`;
|
|
130
141
|
log.trace(origin);
|
|
131
|
-
|
|
142
|
+
|
|
143
|
+
super.iapFindAdapterPath(apiPath, callback);
|
|
132
144
|
}
|
|
133
145
|
|
|
134
146
|
/**
|
|
135
147
|
* @summary Suspends adapter
|
|
136
148
|
*
|
|
137
|
-
* @function
|
|
149
|
+
* @function iapSuspendAdapter
|
|
138
150
|
* @param {Callback} callback - callback function
|
|
139
151
|
*/
|
|
140
|
-
|
|
141
|
-
const
|
|
152
|
+
iapSuspendAdapter(mode, callback) {
|
|
153
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
142
155
|
log.trace(origin);
|
|
156
|
+
|
|
143
157
|
try {
|
|
144
|
-
return super.
|
|
158
|
+
return super.iapSuspendAdapter(mode, callback);
|
|
145
159
|
} catch (error) {
|
|
146
160
|
log.error(`${origin}: ${error}`);
|
|
147
161
|
return callback(null, error);
|
|
@@ -151,14 +165,16 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
151
165
|
/**
|
|
152
166
|
* @summary Unsuspends adapter
|
|
153
167
|
*
|
|
154
|
-
* @function
|
|
168
|
+
* @function iapUnsuspendAdapter
|
|
155
169
|
* @param {Callback} callback - callback function
|
|
156
170
|
*/
|
|
157
|
-
|
|
158
|
-
const
|
|
171
|
+
iapUnsuspendAdapter(callback) {
|
|
172
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
159
174
|
log.trace(origin);
|
|
175
|
+
|
|
160
176
|
try {
|
|
161
|
-
return super.
|
|
177
|
+
return super.iapUnsuspendAdapter(callback);
|
|
162
178
|
} catch (error) {
|
|
163
179
|
log.error(`${origin}: ${error}`);
|
|
164
180
|
return callback(null, error);
|
|
@@ -168,29 +184,33 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
168
184
|
/**
|
|
169
185
|
* @summary Get the Adaoter Queue
|
|
170
186
|
*
|
|
171
|
-
* @function
|
|
187
|
+
* @function iapGetAdapterQueue
|
|
172
188
|
* @param {Callback} callback - callback function
|
|
173
189
|
*/
|
|
174
|
-
|
|
175
|
-
const
|
|
190
|
+
iapGetAdapterQueue(callback) {
|
|
191
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
192
|
+
const origin = `${this.id}-${meth}`;
|
|
176
193
|
log.trace(origin);
|
|
177
|
-
|
|
194
|
+
|
|
195
|
+
return super.iapGetAdapterQueue(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 VmwareVCenter 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 VmwareVCenter 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,44 +259,67 @@ class VmwareVCenter 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);
|
|
249
275
|
}
|
|
250
276
|
}
|
|
251
277
|
|
|
278
|
+
/**
|
|
279
|
+
* @summary moves entites into Mongo DB
|
|
280
|
+
*
|
|
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
|
+
/* BROKER CALLS */
|
|
252
299
|
/**
|
|
253
300
|
* @summary Determines if this adapter supports the specific entity
|
|
254
301
|
*
|
|
255
|
-
* @function
|
|
302
|
+
* @function iapHasAdapterEntity
|
|
256
303
|
* @param {String} entityType - the entity type to check for
|
|
257
304
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
258
305
|
*
|
|
259
306
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
260
307
|
* desired capability or an error
|
|
261
308
|
*/
|
|
262
|
-
|
|
263
|
-
const origin = `${this.id}-adapter-
|
|
309
|
+
iapHasAdapterEntity(entityType, entityId, callback) {
|
|
310
|
+
const origin = `${this.id}-adapter-iapHasAdapterEntity`;
|
|
264
311
|
log.trace(origin);
|
|
265
312
|
|
|
266
313
|
// Make the call -
|
|
267
|
-
//
|
|
268
|
-
return this.
|
|
314
|
+
// iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
315
|
+
return this.iapVerifyAdapterCapability(entityType, null, entityId, callback);
|
|
269
316
|
}
|
|
270
317
|
|
|
271
318
|
/**
|
|
272
319
|
* @summary Provides a way for the adapter to tell north bound integrations
|
|
273
320
|
* whether the adapter supports type, action and specific entity
|
|
274
321
|
*
|
|
275
|
-
* @function
|
|
322
|
+
* @function iapVerifyAdapterCapability
|
|
276
323
|
* @param {String} entityType - the entity type to check for
|
|
277
324
|
* @param {String} actionType - the action type to check for
|
|
278
325
|
* @param {String/Array} entityId - the specific entity we are looking for
|
|
@@ -280,15 +327,15 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
280
327
|
* @param {Callback} callback - An array of whether the adapter can has the
|
|
281
328
|
* desired capability or an error
|
|
282
329
|
*/
|
|
283
|
-
|
|
284
|
-
const meth = 'adapterBase-
|
|
330
|
+
iapVerifyAdapterCapability(entityType, actionType, entityId, callback) {
|
|
331
|
+
const meth = 'adapterBase-iapVerifyAdapterCapability';
|
|
285
332
|
const origin = `${this.id}-${meth}`;
|
|
286
333
|
log.trace(origin);
|
|
287
334
|
|
|
288
335
|
// if caching
|
|
289
336
|
if (this.caching) {
|
|
290
|
-
// Make the call -
|
|
291
|
-
return this.requestHandlerInst.
|
|
337
|
+
// Make the call - iapVerifyAdapterCapability(entityType, actionType, entityId, callback)
|
|
338
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (results, error) => {
|
|
292
339
|
if (error) {
|
|
293
340
|
return callback(null, error);
|
|
294
341
|
}
|
|
@@ -306,7 +353,7 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
306
353
|
}
|
|
307
354
|
|
|
308
355
|
// need to check the cache again since it has been updated
|
|
309
|
-
return this.requestHandlerInst.
|
|
356
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, entityId, (vcapable, verror) => {
|
|
310
357
|
if (verror) {
|
|
311
358
|
return callback(null, verror);
|
|
312
359
|
}
|
|
@@ -339,7 +386,7 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
339
386
|
// if no entity id
|
|
340
387
|
if (!entityId) {
|
|
341
388
|
// need to check the cache again since it has been updated
|
|
342
|
-
return this.requestHandlerInst.
|
|
389
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
343
390
|
if (verror) {
|
|
344
391
|
return callback(null, verror);
|
|
345
392
|
}
|
|
@@ -360,7 +407,7 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
360
407
|
}
|
|
361
408
|
|
|
362
409
|
// need to check the cache again since it has been updated
|
|
363
|
-
return this.requestHandlerInst.
|
|
410
|
+
return this.requestHandlerInst.iapVerifyAdapterCapability(entityType, actionType, null, (vcapable, verror) => {
|
|
364
411
|
if (verror) {
|
|
365
412
|
return callback(null, verror);
|
|
366
413
|
}
|
|
@@ -401,11 +448,11 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
401
448
|
/**
|
|
402
449
|
* @summary Updates the cache for all entities by call the get All entity method
|
|
403
450
|
*
|
|
404
|
-
* @function
|
|
451
|
+
* @function iapUpdateAdapterEntityCache
|
|
405
452
|
*
|
|
406
453
|
*/
|
|
407
|
-
|
|
408
|
-
const origin = `${this.id}-adapter-
|
|
454
|
+
iapUpdateAdapterEntityCache() {
|
|
455
|
+
const origin = `${this.id}-adapter-iapUpdateAdapterEntityCache`;
|
|
409
456
|
log.trace(origin);
|
|
410
457
|
|
|
411
458
|
if (this.caching) {
|
|
@@ -418,6 +465,140 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
418
465
|
}
|
|
419
466
|
}
|
|
420
467
|
|
|
468
|
+
/**
|
|
469
|
+
* @summary Determines if this adapter supports any in a list of entities
|
|
470
|
+
*
|
|
471
|
+
* @function hasEntities
|
|
472
|
+
* @param {String} entityType - the entity type to check for
|
|
473
|
+
* @param {Array} entityList - the list of entities we are looking for
|
|
474
|
+
*
|
|
475
|
+
* @param {Callback} callback - A map where the entity is the key and the
|
|
476
|
+
* value is true or false
|
|
477
|
+
*/
|
|
478
|
+
hasEntities(entityType, entityList, callback) {
|
|
479
|
+
const meth = 'adapter-hasEntities';
|
|
480
|
+
const origin = `${this.id}-${meth}`;
|
|
481
|
+
log.trace(origin);
|
|
482
|
+
|
|
483
|
+
try {
|
|
484
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
485
|
+
} catch (err) {
|
|
486
|
+
log.error(`${origin}: ${err}`);
|
|
487
|
+
return callback(null, err);
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
|
|
491
|
+
/**
|
|
492
|
+
* @summary Get Appliance that match the deviceName
|
|
493
|
+
*
|
|
494
|
+
* @function getDevice
|
|
495
|
+
* @param {String} deviceName - the deviceName to find (required)
|
|
496
|
+
*
|
|
497
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
498
|
+
* (appliance) or the error
|
|
499
|
+
*/
|
|
500
|
+
getDevice(deviceName, callback) {
|
|
501
|
+
const meth = 'adapter-getDevice';
|
|
502
|
+
const origin = `${this.id}-${meth}`;
|
|
503
|
+
log.trace(origin);
|
|
504
|
+
|
|
505
|
+
try {
|
|
506
|
+
return super.getDevice(deviceName, callback);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
log.error(`${origin}: ${err}`);
|
|
509
|
+
return callback(null, err);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
/**
|
|
514
|
+
* @summary Get Appliances that match the filter
|
|
515
|
+
*
|
|
516
|
+
* @function getDevicesFiltered
|
|
517
|
+
* @param {Object} options - the data to use to filter the appliances (optional)
|
|
518
|
+
*
|
|
519
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
520
|
+
* (appliances) or the error
|
|
521
|
+
*/
|
|
522
|
+
getDevicesFiltered(options, callback) {
|
|
523
|
+
const meth = 'adapter-getDevicesFiltered';
|
|
524
|
+
const origin = `${this.id}-${meth}`;
|
|
525
|
+
log.trace(origin);
|
|
526
|
+
|
|
527
|
+
try {
|
|
528
|
+
return super.getDevicesFiltered(options, callback);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
log.error(`${origin}: ${err}`);
|
|
531
|
+
return callback(null, err);
|
|
532
|
+
}
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* @summary Gets the status for the provided appliance
|
|
537
|
+
*
|
|
538
|
+
* @function isAlive
|
|
539
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
540
|
+
*
|
|
541
|
+
* @param {configCallback} callback - callback function to return the result
|
|
542
|
+
* (appliance isAlive) or the error
|
|
543
|
+
*/
|
|
544
|
+
isAlive(deviceName, callback) {
|
|
545
|
+
const meth = 'adapter-isAlive';
|
|
546
|
+
const origin = `${this.id}-${meth}`;
|
|
547
|
+
log.trace(origin);
|
|
548
|
+
|
|
549
|
+
try {
|
|
550
|
+
return super.isAlive(deviceName, callback);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
log.error(`${origin}: ${err}`);
|
|
553
|
+
return callback(null, err);
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/**
|
|
558
|
+
* @summary Gets a config for the provided Appliance
|
|
559
|
+
*
|
|
560
|
+
* @function getConfig
|
|
561
|
+
* @param {String} deviceName - the deviceName of the appliance. (required)
|
|
562
|
+
* @param {String} format - the desired format of the config. (optional)
|
|
563
|
+
*
|
|
564
|
+
* @param {configCallback} callback - callback function to return the result
|
|
565
|
+
* (appliance config) or the error
|
|
566
|
+
*/
|
|
567
|
+
getConfig(deviceName, format, callback) {
|
|
568
|
+
const meth = 'adapter-getConfig';
|
|
569
|
+
const origin = `${this.id}-${meth}`;
|
|
570
|
+
log.trace(origin);
|
|
571
|
+
|
|
572
|
+
try {
|
|
573
|
+
return super.getConfig(deviceName, format, callback);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
log.error(`${origin}: ${err}`);
|
|
576
|
+
return callback(null, err);
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/**
|
|
581
|
+
* @summary Gets the device count from the system
|
|
582
|
+
*
|
|
583
|
+
* @function iapGetDeviceCount
|
|
584
|
+
*
|
|
585
|
+
* @param {getCallback} callback - callback function to return the result
|
|
586
|
+
* (count) or the error
|
|
587
|
+
*/
|
|
588
|
+
iapGetDeviceCount(callback) {
|
|
589
|
+
const meth = 'adapter-iapGetDeviceCount';
|
|
590
|
+
const origin = `${this.id}-${meth}`;
|
|
591
|
+
log.trace(origin);
|
|
592
|
+
|
|
593
|
+
try {
|
|
594
|
+
return super.iapGetDeviceCount(callback);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
log.error(`${origin}: ${err}`);
|
|
597
|
+
return callback(null, err);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
/* GENERIC ADAPTER REQUEST - allows extension of adapter without new calls being added */
|
|
421
602
|
/**
|
|
422
603
|
* Makes the requested generic call
|
|
423
604
|
*
|
|
@@ -528,6 +709,116 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
528
709
|
}
|
|
529
710
|
}
|
|
530
711
|
|
|
712
|
+
/**
|
|
713
|
+
* Makes the requested generic call with no base path or version
|
|
714
|
+
*
|
|
715
|
+
* @function genericAdapterRequestNoBasePath
|
|
716
|
+
* @param {String} uriPath - the path of the api call - do not include the host, port, base path or version (required)
|
|
717
|
+
* @param {String} restMethod - the rest method (GET, POST, PUT, PATCH, DELETE) (required)
|
|
718
|
+
* @param {Object} queryData - the parameters to be put on the url (optional).
|
|
719
|
+
* Can be a stringified Object.
|
|
720
|
+
* @param {Object} requestBody - the body to add to the request (optional).
|
|
721
|
+
* Can be a stringified Object.
|
|
722
|
+
* @param {Object} addlHeaders - additional headers to be put on the call (optional).
|
|
723
|
+
* Can be a stringified Object.
|
|
724
|
+
* @param {getCallback} callback - a callback function to return the result (Generics)
|
|
725
|
+
* or the error
|
|
726
|
+
*/
|
|
727
|
+
genericAdapterRequestNoBasePath(uriPath, restMethod, queryData, requestBody, addlHeaders, callback) {
|
|
728
|
+
const meth = 'adapter-genericAdapterRequestNoBasePath';
|
|
729
|
+
const origin = `${this.id}-${meth}`;
|
|
730
|
+
log.trace(origin);
|
|
731
|
+
|
|
732
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
733
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
734
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
735
|
+
return callback(null, errorObj);
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
739
|
+
if (uriPath === undefined || uriPath === null || uriPath === '') {
|
|
740
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['uriPath'], null, null, null);
|
|
741
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
742
|
+
return callback(null, errorObj);
|
|
743
|
+
}
|
|
744
|
+
if (restMethod === undefined || restMethod === null || restMethod === '') {
|
|
745
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['restMethod'], null, null, null);
|
|
746
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
747
|
+
return callback(null, errorObj);
|
|
748
|
+
}
|
|
749
|
+
|
|
750
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
751
|
+
// remove any leading / and split the uripath into path variables
|
|
752
|
+
let myPath = uriPath;
|
|
753
|
+
while (myPath.indexOf('/') === 0) {
|
|
754
|
+
myPath = myPath.substring(1);
|
|
755
|
+
}
|
|
756
|
+
const pathVars = myPath.split('/');
|
|
757
|
+
const queryParamsAvailable = queryData;
|
|
758
|
+
const queryParams = {};
|
|
759
|
+
const bodyVars = requestBody;
|
|
760
|
+
|
|
761
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
762
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
763
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
764
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
765
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
766
|
+
}
|
|
767
|
+
});
|
|
768
|
+
|
|
769
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
770
|
+
const reqObj = {
|
|
771
|
+
payload: bodyVars,
|
|
772
|
+
uriPathVars: pathVars,
|
|
773
|
+
uriQuery: queryParams,
|
|
774
|
+
uriOptions: {}
|
|
775
|
+
};
|
|
776
|
+
// add headers if provided
|
|
777
|
+
if (addlHeaders) {
|
|
778
|
+
reqObj.addlHeaders = addlHeaders;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// determine the call and return flag
|
|
782
|
+
let action = 'getGenericsNoBase';
|
|
783
|
+
let returnF = true;
|
|
784
|
+
if (restMethod.toUpperCase() === 'POST') {
|
|
785
|
+
action = 'createGenericNoBase';
|
|
786
|
+
} else if (restMethod.toUpperCase() === 'PUT') {
|
|
787
|
+
action = 'updateGenericNoBase';
|
|
788
|
+
} else if (restMethod.toUpperCase() === 'PATCH') {
|
|
789
|
+
action = 'patchGenericNoBase';
|
|
790
|
+
} else if (restMethod.toUpperCase() === 'DELETE') {
|
|
791
|
+
action = 'deleteGenericNoBase';
|
|
792
|
+
returnF = false;
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
try {
|
|
796
|
+
// Make the call -
|
|
797
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
798
|
+
return this.requestHandlerInst.identifyRequest('.generic', action, reqObj, returnF, (irReturnData, irReturnError) => {
|
|
799
|
+
// if we received an error or their is no response on the results
|
|
800
|
+
// return an error
|
|
801
|
+
if (irReturnError) {
|
|
802
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
803
|
+
return callback(null, irReturnError);
|
|
804
|
+
}
|
|
805
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
806
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['genericAdapterRequestNoBasePath'], null, null, null);
|
|
807
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
808
|
+
return callback(null, errorObj);
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
812
|
+
// return the response
|
|
813
|
+
return callback(irReturnData, null);
|
|
814
|
+
});
|
|
815
|
+
} catch (ex) {
|
|
816
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
817
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
818
|
+
return callback(null, errorObj);
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
531
822
|
/**
|
|
532
823
|
* @callback healthCallback
|
|
533
824
|
* @param {Object} result - the result of the get request (contains an id and a status)
|
|
@@ -7881,6 +8172,88 @@ class VmwareVCenter extends AdapterBaseCl {
|
|
|
7881
8172
|
return callback(null, errorObj);
|
|
7882
8173
|
}
|
|
7883
8174
|
}
|
|
8175
|
+
|
|
8176
|
+
/**
|
|
8177
|
+
* @summary Creates a Virtual Machine from the template.
|
|
8178
|
+
*
|
|
8179
|
+
* @function postVcentervmtemplatedeploy
|
|
8180
|
+
* @param {string} item - The identifier of the library item having the ISO image to mount on the virtual machine.
|
|
8181
|
+
* @param {object} requestBody - Specs of the Virtual Machine.
|
|
8182
|
+
* @param {getCallback} callback - a callback function to return the result
|
|
8183
|
+
*/
|
|
8184
|
+
/* YOU CAN CHANGE THE PARAMETERS YOU TAKE IN HERE AND IN THE pronghorn.json FILE */
|
|
8185
|
+
postVcentervmtemplatedeploy(item, requestBody, callback) {
|
|
8186
|
+
const meth = 'adapter-postVcentervmtemplatedeploy';
|
|
8187
|
+
const origin = `${this.id}-${meth}`;
|
|
8188
|
+
log.trace(origin);
|
|
8189
|
+
|
|
8190
|
+
if (this.suspended && this.suspendMode === 'error') {
|
|
8191
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'AD.600', [], null, null, null);
|
|
8192
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8193
|
+
return callback(null, errorObj);
|
|
8194
|
+
}
|
|
8195
|
+
|
|
8196
|
+
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
8197
|
+
if (item === undefined || item === null || item === '') {
|
|
8198
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['item'], null, null, null);
|
|
8199
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8200
|
+
return callback(null, errorObj);
|
|
8201
|
+
}
|
|
8202
|
+
if (requestBody === undefined || requestBody === null || requestBody === '') {
|
|
8203
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['requestBody'], null, null, null);
|
|
8204
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8205
|
+
return callback(null, errorObj);
|
|
8206
|
+
}
|
|
8207
|
+
|
|
8208
|
+
/* HERE IS WHERE YOU SET THE DATA TO PASS INTO REQUEST */
|
|
8209
|
+
const queryParamsAvailable = {};
|
|
8210
|
+
const queryParams = {};
|
|
8211
|
+
const pathVars = [item];
|
|
8212
|
+
const bodyVars = requestBody;
|
|
8213
|
+
|
|
8214
|
+
// loop in template. long callback arg name to avoid identifier conflicts
|
|
8215
|
+
Object.keys(queryParamsAvailable).forEach((thisKeyInQueryParamsAvailable) => {
|
|
8216
|
+
if (queryParamsAvailable[thisKeyInQueryParamsAvailable] !== undefined && queryParamsAvailable[thisKeyInQueryParamsAvailable] !== null
|
|
8217
|
+
&& queryParamsAvailable[thisKeyInQueryParamsAvailable] !== '') {
|
|
8218
|
+
queryParams[thisKeyInQueryParamsAvailable] = queryParamsAvailable[thisKeyInQueryParamsAvailable];
|
|
8219
|
+
}
|
|
8220
|
+
});
|
|
8221
|
+
|
|
8222
|
+
// set up the request object - payload, uriPathVars, uriQuery, uriOptions, addlHeaders
|
|
8223
|
+
const reqObj = {
|
|
8224
|
+
payload: bodyVars,
|
|
8225
|
+
uriPathVars: pathVars,
|
|
8226
|
+
uriQuery: queryParams,
|
|
8227
|
+
uriOptions: {}
|
|
8228
|
+
};
|
|
8229
|
+
reqObj.uriOptions.action = 'deploy';
|
|
8230
|
+
|
|
8231
|
+
try {
|
|
8232
|
+
// Make the call -
|
|
8233
|
+
// identifyRequest(entity, action, requestObj, returnDataFlag, callback)
|
|
8234
|
+
return this.requestHandlerInst.identifyRequest('Vmtemplatelibraryitems', 'postVcentervmtemplatedeploy', reqObj, true, (irReturnData, irReturnError) => {
|
|
8235
|
+
// if we received an error or their is no response on the results
|
|
8236
|
+
// return an error
|
|
8237
|
+
if (irReturnError) {
|
|
8238
|
+
/* HERE IS WHERE YOU CAN ALTER THE ERROR MESSAGE */
|
|
8239
|
+
return callback(null, irReturnError);
|
|
8240
|
+
}
|
|
8241
|
+
if (!Object.hasOwnProperty.call(irReturnData, 'response')) {
|
|
8242
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Invalid Response', ['postVcentervmtemplatedeploy'], null, null, null);
|
|
8243
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8244
|
+
return callback(null, errorObj);
|
|
8245
|
+
}
|
|
8246
|
+
|
|
8247
|
+
/* HERE IS WHERE YOU CAN ALTER THE RETURN DATA */
|
|
8248
|
+
// return the response
|
|
8249
|
+
return callback(irReturnData, null);
|
|
8250
|
+
});
|
|
8251
|
+
} catch (ex) {
|
|
8252
|
+
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
8253
|
+
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
8254
|
+
return callback(null, errorObj);
|
|
8255
|
+
}
|
|
8256
|
+
}
|
|
7884
8257
|
}
|
|
7885
8258
|
|
|
7886
8259
|
module.exports = VmwareVCenter;
|