@itentialopensource/adapter-dna_center 0.5.7 → 0.6.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 +44 -26
- package/CODE_OF_CONDUCT.md +12 -17
- package/CONTRIBUTING.md +88 -74
- package/ENHANCE.md +14 -14
- package/PROPERTIES.md +483 -89
- package/README.md +131 -51
- package/SUMMARY.md +2 -2
- package/SYSTEMINFO.md +11 -0
- package/TROUBLESHOOT.md +4 -3
- package/adapter.js +66 -394
- package/adapterBase.js +648 -165
- package/entities/.system/schemaTokenReq.json +2 -6
- package/package.json +5 -3
- package/pronghorn.json +642 -642
- package/propertiesSchema.json +62 -8
- package/refs?service=git-upload-pack +0 -0
- package/report/adapterInfo.json +10 -0
- package/report/updateReport1653138367120.json +120 -0
- package/sampleProperties.json +90 -1
- package/test/integration/adapterTestBasicGet.js +1 -1
- package/test/integration/adapterTestIntegration.js +24 -107
- package/test/unit/adapterBaseTestUnit.js +4 -2
- package/test/unit/adapterTestUnit.js +32 -126
- package/utils/adapterInfo.js +206 -0
- package/utils/entitiesToDB.js +12 -57
- package/utils/pre-commit.sh +3 -0
- package/utils/tbScript.js +35 -20
- package/utils/tbUtils.js +44 -39
- package/utils/testRunner.js +16 -16
package/adapter.js
CHANGED
|
@@ -85,7 +85,15 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
85
85
|
* @iapGetAdapterWorkflowFunctions
|
|
86
86
|
*/
|
|
87
87
|
iapGetAdapterWorkflowFunctions(inIgnore) {
|
|
88
|
-
let myIgnore = [
|
|
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') {
|
|
@@ -113,8 +121,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
113
121
|
* @param {Callback} callback - The results of the call
|
|
114
122
|
*/
|
|
115
123
|
iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback) {
|
|
116
|
-
const
|
|
124
|
+
const meth = 'adapter-iapUpdateAdapterConfiguration';
|
|
125
|
+
const origin = `${this.id}-${meth}`;
|
|
117
126
|
log.trace(origin);
|
|
127
|
+
|
|
118
128
|
super.iapUpdateAdapterConfiguration(configFile, changes, entity, type, action, callback);
|
|
119
129
|
}
|
|
120
130
|
|
|
@@ -126,8 +136,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
126
136
|
* @param {Callback} callback - The results of the call
|
|
127
137
|
*/
|
|
128
138
|
iapFindAdapterPath(apiPath, callback) {
|
|
129
|
-
const
|
|
139
|
+
const meth = 'adapter-iapFindAdapterPath';
|
|
140
|
+
const origin = `${this.id}-${meth}`;
|
|
130
141
|
log.trace(origin);
|
|
142
|
+
|
|
131
143
|
super.iapFindAdapterPath(apiPath, callback);
|
|
132
144
|
}
|
|
133
145
|
|
|
@@ -138,8 +150,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
138
150
|
* @param {Callback} callback - callback function
|
|
139
151
|
*/
|
|
140
152
|
iapSuspendAdapter(mode, callback) {
|
|
141
|
-
const
|
|
153
|
+
const meth = 'adapter-iapSuspendAdapter';
|
|
154
|
+
const origin = `${this.id}-${meth}`;
|
|
142
155
|
log.trace(origin);
|
|
156
|
+
|
|
143
157
|
try {
|
|
144
158
|
return super.iapSuspendAdapter(mode, callback);
|
|
145
159
|
} catch (error) {
|
|
@@ -155,8 +169,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
155
169
|
* @param {Callback} callback - callback function
|
|
156
170
|
*/
|
|
157
171
|
iapUnsuspendAdapter(callback) {
|
|
158
|
-
const
|
|
172
|
+
const meth = 'adapter-iapUnsuspendAdapter';
|
|
173
|
+
const origin = `${this.id}-${meth}`;
|
|
159
174
|
log.trace(origin);
|
|
175
|
+
|
|
160
176
|
try {
|
|
161
177
|
return super.iapUnsuspendAdapter(callback);
|
|
162
178
|
} catch (error) {
|
|
@@ -172,8 +188,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
172
188
|
* @param {Callback} callback - callback function
|
|
173
189
|
*/
|
|
174
190
|
iapGetAdapterQueue(callback) {
|
|
175
|
-
const
|
|
191
|
+
const meth = 'adapter-iapGetAdapterQueue';
|
|
192
|
+
const origin = `${this.id}-${meth}`;
|
|
176
193
|
log.trace(origin);
|
|
194
|
+
|
|
177
195
|
return super.iapGetAdapterQueue(callback);
|
|
178
196
|
}
|
|
179
197
|
|
|
@@ -187,8 +205,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
187
205
|
* @param {Callback} callback - The results of the call
|
|
188
206
|
*/
|
|
189
207
|
iapTroubleshootAdapter(props, persistFlag, callback) {
|
|
190
|
-
const
|
|
208
|
+
const meth = 'adapter-iapTroubleshootAdapter';
|
|
209
|
+
const origin = `${this.id}-${meth}`;
|
|
191
210
|
log.trace(origin);
|
|
211
|
+
|
|
192
212
|
try {
|
|
193
213
|
return super.iapTroubleshootAdapter(props, persistFlag, this, callback);
|
|
194
214
|
} catch (error) {
|
|
@@ -205,8 +225,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
205
225
|
* @param {Callback} callback - callback function
|
|
206
226
|
*/
|
|
207
227
|
iapRunAdapterHealthcheck(callback) {
|
|
208
|
-
const
|
|
228
|
+
const meth = 'adapter-iapRunAdapterHealthcheck';
|
|
229
|
+
const origin = `${this.id}-${meth}`;
|
|
209
230
|
log.trace(origin);
|
|
231
|
+
|
|
210
232
|
try {
|
|
211
233
|
return super.iapRunAdapterHealthcheck(this, callback);
|
|
212
234
|
} catch (error) {
|
|
@@ -222,8 +244,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
222
244
|
* @param {Callback} callback - callback function
|
|
223
245
|
*/
|
|
224
246
|
iapRunAdapterConnectivity(callback) {
|
|
225
|
-
const
|
|
247
|
+
const meth = 'adapter-iapRunAdapterConnectivity';
|
|
248
|
+
const origin = `${this.id}-${meth}`;
|
|
226
249
|
log.trace(origin);
|
|
250
|
+
|
|
227
251
|
try {
|
|
228
252
|
return super.iapRunAdapterConnectivity(callback);
|
|
229
253
|
} catch (error) {
|
|
@@ -239,8 +263,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
239
263
|
* @param {Callback} callback - callback function
|
|
240
264
|
*/
|
|
241
265
|
iapRunAdapterBasicGet(callback) {
|
|
242
|
-
const
|
|
266
|
+
const meth = 'adapter-iapRunAdapterBasicGet';
|
|
267
|
+
const origin = `${this.id}-${meth}`;
|
|
243
268
|
log.trace(origin);
|
|
269
|
+
|
|
244
270
|
try {
|
|
245
271
|
return super.iapRunAdapterBasicGet(callback);
|
|
246
272
|
} catch (error) {
|
|
@@ -257,8 +283,10 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
257
283
|
* or the error
|
|
258
284
|
*/
|
|
259
285
|
iapMoveAdapterEntitiesToDB(callback) {
|
|
260
|
-
const
|
|
286
|
+
const meth = 'adapter-iapMoveAdapterEntitiesToDB';
|
|
287
|
+
const origin = `${this.id}-${meth}`;
|
|
261
288
|
log.trace(origin);
|
|
289
|
+
|
|
262
290
|
try {
|
|
263
291
|
return super.iapMoveAdapterEntitiesToDB(callback);
|
|
264
292
|
} catch (err) {
|
|
@@ -448,56 +476,18 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
448
476
|
* value is true or false
|
|
449
477
|
*/
|
|
450
478
|
hasEntities(entityType, entityList, callback) {
|
|
451
|
-
const
|
|
479
|
+
const meth = 'adapter-hasEntities';
|
|
480
|
+
const origin = `${this.id}-${meth}`;
|
|
452
481
|
log.trace(origin);
|
|
453
482
|
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
483
|
+
try {
|
|
484
|
+
return super.hasEntities(entityType, entityList, callback);
|
|
485
|
+
} catch (err) {
|
|
486
|
+
log.error(`${origin}: ${err}`);
|
|
487
|
+
return callback(null, err);
|
|
459
488
|
}
|
|
460
489
|
}
|
|
461
490
|
|
|
462
|
-
/**
|
|
463
|
-
* @summary Helper method for hasEntities for the specific device case
|
|
464
|
-
*
|
|
465
|
-
* @param {Array} deviceList - array of unique device identifiers
|
|
466
|
-
* @param {Callback} callback - A map where the device is the key and the
|
|
467
|
-
* value is true or false
|
|
468
|
-
*/
|
|
469
|
-
hasDevices(deviceList, callback) {
|
|
470
|
-
const origin = `${this.id}-adapter-hasDevices`;
|
|
471
|
-
log.trace(origin);
|
|
472
|
-
|
|
473
|
-
const findings = deviceList.reduce((map, device) => {
|
|
474
|
-
// eslint-disable-next-line no-param-reassign
|
|
475
|
-
map[device] = false;
|
|
476
|
-
log.debug(`In reduce: ${JSON.stringify(map)}`);
|
|
477
|
-
return map;
|
|
478
|
-
}, {});
|
|
479
|
-
const apiCalls = deviceList.map((device) => new Promise((resolve) => {
|
|
480
|
-
this.getDevice(device, (result, error) => {
|
|
481
|
-
if (error) {
|
|
482
|
-
log.debug(`In map error: ${JSON.stringify(device)}`);
|
|
483
|
-
return resolve({ name: device, found: false });
|
|
484
|
-
}
|
|
485
|
-
log.debug(`In map: ${JSON.stringify(device)}`);
|
|
486
|
-
return resolve({ name: device, found: true });
|
|
487
|
-
});
|
|
488
|
-
}));
|
|
489
|
-
Promise.all(apiCalls).then((results) => {
|
|
490
|
-
results.forEach((device) => {
|
|
491
|
-
findings[device.name] = device.found;
|
|
492
|
-
});
|
|
493
|
-
log.debug(`FINDINGS: ${JSON.stringify(findings)}`);
|
|
494
|
-
return callback(findings);
|
|
495
|
-
}).catch((errors) => {
|
|
496
|
-
log.error('Unable to do device lookup.');
|
|
497
|
-
return callback(null, { code: 503, message: 'Unable to do device lookup.', error: errors });
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
|
|
501
491
|
/**
|
|
502
492
|
* @summary Get Appliance that match the deviceName
|
|
503
493
|
*
|
|
@@ -512,75 +502,11 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
512
502
|
const origin = `${this.id}-${meth}`;
|
|
513
503
|
log.trace(origin);
|
|
514
504
|
|
|
515
|
-
// make sure we are set up for device broker getDevice
|
|
516
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevice || this.allProps.devicebroker.getDevice.length === 0 || !this.allProps.devicebroker.getDevice[0].path) {
|
|
517
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevice.path'], null, null, null);
|
|
518
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
519
|
-
return callback(null, errorObj);
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
/* HERE IS WHERE YOU VALIDATE DATA */
|
|
523
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
524
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
525
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
526
|
-
return callback(null, errorObj);
|
|
527
|
-
}
|
|
528
|
-
|
|
529
505
|
try {
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
name: deviceName
|
|
535
|
-
}
|
|
536
|
-
};
|
|
537
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
538
|
-
// if we received an error or their is no response on the results return an error
|
|
539
|
-
if (ferr) {
|
|
540
|
-
return callback(null, ferr);
|
|
541
|
-
}
|
|
542
|
-
if (devs.list.length < 1) {
|
|
543
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
544
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
545
|
-
return callback(null, errorObj);
|
|
546
|
-
}
|
|
547
|
-
|
|
548
|
-
const callPromises = [];
|
|
549
|
-
for (let i = 0; i < this.allProps.devicebroker.getDevice.length; i += 1) {
|
|
550
|
-
// Perform component calls here.
|
|
551
|
-
callPromises.push(
|
|
552
|
-
new Promise((resolve, reject) => {
|
|
553
|
-
this.iapMakeBrokerCall('getDevice', this.allProps.devicebroker.getDevice[i], devs.list[0], null, (callRet, callErr) => {
|
|
554
|
-
// return an error
|
|
555
|
-
if (callErr) {
|
|
556
|
-
reject(callErr);
|
|
557
|
-
} else {
|
|
558
|
-
// return the data
|
|
559
|
-
resolve(callRet);
|
|
560
|
-
}
|
|
561
|
-
});
|
|
562
|
-
})
|
|
563
|
-
);
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// return an array of repsonses
|
|
567
|
-
return Promise.all(callPromises).then((results) => {
|
|
568
|
-
let myResult = {};
|
|
569
|
-
results.forEach((result) => {
|
|
570
|
-
myResult = { ...myResult, ...result };
|
|
571
|
-
});
|
|
572
|
-
|
|
573
|
-
return callback(myResult, null);
|
|
574
|
-
})
|
|
575
|
-
.catch((error) => {
|
|
576
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
577
|
-
return callback(null, error);
|
|
578
|
-
});
|
|
579
|
-
});
|
|
580
|
-
} catch (ex) {
|
|
581
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
582
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
583
|
-
return callback(null, errorObj);
|
|
506
|
+
return super.getDevice(deviceName, callback);
|
|
507
|
+
} catch (err) {
|
|
508
|
+
log.error(`${origin}: ${err}`);
|
|
509
|
+
return callback(null, err);
|
|
584
510
|
}
|
|
585
511
|
}
|
|
586
512
|
|
|
@@ -598,88 +524,11 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
598
524
|
const origin = `${this.id}-${meth}`;
|
|
599
525
|
log.trace(origin);
|
|
600
526
|
|
|
601
|
-
// make sure we are set up for device broker getDevicesFiltered
|
|
602
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getDevicesFiltered || this.allProps.devicebroker.getDevicesFiltered.length === 0 || !this.allProps.devicebroker.getDevicesFiltered[0].path) {
|
|
603
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getDevicesFiltered.path'], null, null, null);
|
|
604
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
605
|
-
return callback(null, errorObj);
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
// verify the required fields have been provided
|
|
609
|
-
if (options === undefined || options === null || options === '' || options.length === 0) {
|
|
610
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['options'], null, null, null);
|
|
611
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
612
|
-
return callback(null, errorObj);
|
|
613
|
-
}
|
|
614
|
-
log.debug(`Device Filter Options: ${JSON.stringify(options)}`);
|
|
615
|
-
|
|
616
527
|
try {
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
// set up the filter of Device Names
|
|
622
|
-
let filterName = [];
|
|
623
|
-
if (options && options.filter && options.filter.name) {
|
|
624
|
-
// when this hack is removed, remove the lint ignore above
|
|
625
|
-
if (Array.isArray(options.filter.name)) {
|
|
626
|
-
// eslint-disable-next-line prefer-destructuring
|
|
627
|
-
filterName = options.filter.name;
|
|
628
|
-
} else {
|
|
629
|
-
filterName = [options.filter.name];
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
// TODO - get sort and order working
|
|
634
|
-
/*
|
|
635
|
-
if (options && options.sort) {
|
|
636
|
-
reqObj.uriOptions.sort = JSON.stringify(options.sort);
|
|
637
|
-
}
|
|
638
|
-
if (options && options.order) {
|
|
639
|
-
reqObj.uriOptions.order = options.order;
|
|
640
|
-
}
|
|
641
|
-
*/
|
|
642
|
-
const callPromises = [];
|
|
643
|
-
for (let i = 0; i < this.allProps.devicebroker.getDevicesFiltered.length; i += 1) {
|
|
644
|
-
// Perform component calls here.
|
|
645
|
-
callPromises.push(
|
|
646
|
-
new Promise((resolve, reject) => {
|
|
647
|
-
this.iapMakeBrokerCall('getDevicesFiltered', this.allProps.devicebroker.getDevicesFiltered[i], {}, filterName, (callRet, callErr) => {
|
|
648
|
-
// return an error
|
|
649
|
-
if (callErr) {
|
|
650
|
-
reject(callErr);
|
|
651
|
-
} else {
|
|
652
|
-
// return the data
|
|
653
|
-
resolve(callRet);
|
|
654
|
-
}
|
|
655
|
-
});
|
|
656
|
-
})
|
|
657
|
-
);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
// return an array of repsonses
|
|
661
|
-
return Promise.all(callPromises).then((results) => {
|
|
662
|
-
let myResult = [];
|
|
663
|
-
results.forEach((result) => {
|
|
664
|
-
if (Array.isArray(result)) {
|
|
665
|
-
myResult = [...myResult, ...result];
|
|
666
|
-
} else if (Object.keys(result).length > 0) {
|
|
667
|
-
myResult.push(result);
|
|
668
|
-
}
|
|
669
|
-
});
|
|
670
|
-
|
|
671
|
-
log.debug(`${origin}: Found #${myResult.length} devices.`);
|
|
672
|
-
log.debug(`Devices: ${JSON.stringify(myResult)}`);
|
|
673
|
-
return callback({ total: myResult.length, list: myResult });
|
|
674
|
-
})
|
|
675
|
-
.catch((error) => {
|
|
676
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
677
|
-
return callback(null, error);
|
|
678
|
-
});
|
|
679
|
-
} catch (ex) {
|
|
680
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
681
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
682
|
-
return callback(null, errorObj);
|
|
528
|
+
return super.getDevicesFiltered(options, callback);
|
|
529
|
+
} catch (err) {
|
|
530
|
+
log.error(`${origin}: ${err}`);
|
|
531
|
+
return callback(null, err);
|
|
683
532
|
}
|
|
684
533
|
}
|
|
685
534
|
|
|
@@ -697,79 +546,11 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
697
546
|
const origin = `${this.id}-${meth}`;
|
|
698
547
|
log.trace(origin);
|
|
699
548
|
|
|
700
|
-
// make sure we are set up for device broker isAlive
|
|
701
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.isAlive || this.allProps.devicebroker.isAlive.length === 0 || !this.allProps.devicebroker.isAlive[0].path) {
|
|
702
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.isAlive.path'], null, null, null);
|
|
703
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
704
|
-
return callback(null, errorObj);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
// verify the required fields have been provided
|
|
708
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
709
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
710
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
711
|
-
return callback(null, errorObj);
|
|
712
|
-
}
|
|
713
|
-
|
|
714
549
|
try {
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
name: deviceName
|
|
720
|
-
}
|
|
721
|
-
};
|
|
722
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
723
|
-
// if we received an error or their is no response on the results return an error
|
|
724
|
-
if (ferr) {
|
|
725
|
-
return callback(null, ferr);
|
|
726
|
-
}
|
|
727
|
-
if (devs.list.length < 1) {
|
|
728
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
729
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
730
|
-
return callback(null, errorObj);
|
|
731
|
-
}
|
|
732
|
-
|
|
733
|
-
const callPromises = [];
|
|
734
|
-
for (let i = 0; i < this.allProps.devicebroker.isAlive.length; i += 1) {
|
|
735
|
-
// Perform component calls here.
|
|
736
|
-
callPromises.push(
|
|
737
|
-
new Promise((resolve, reject) => {
|
|
738
|
-
this.iapMakeBrokerCall('isAlive', this.allProps.devicebroker.isAlive[i], devs.list[0], null, (callRet, callErr) => {
|
|
739
|
-
// return an error
|
|
740
|
-
if (callErr) {
|
|
741
|
-
reject(callErr);
|
|
742
|
-
} else {
|
|
743
|
-
// return the data
|
|
744
|
-
resolve(callRet);
|
|
745
|
-
}
|
|
746
|
-
});
|
|
747
|
-
})
|
|
748
|
-
);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
|
-
// return an array of repsonses
|
|
752
|
-
return Promise.all(callPromises).then((results) => {
|
|
753
|
-
let myResult = {};
|
|
754
|
-
results.forEach((result) => {
|
|
755
|
-
myResult = { ...myResult, ...result };
|
|
756
|
-
});
|
|
757
|
-
|
|
758
|
-
let response = true;
|
|
759
|
-
if (myResult.isAlive !== null && myResult.isAlive !== undefined && myResult.isAlive === false) {
|
|
760
|
-
response = false;
|
|
761
|
-
}
|
|
762
|
-
return callback(response);
|
|
763
|
-
})
|
|
764
|
-
.catch((error) => {
|
|
765
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
766
|
-
return callback(null, error);
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
} catch (ex) {
|
|
770
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
771
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
772
|
-
return callback(null, errorObj);
|
|
550
|
+
return super.isAlive(deviceName, callback);
|
|
551
|
+
} catch (err) {
|
|
552
|
+
log.error(`${origin}: ${err}`);
|
|
553
|
+
return callback(null, err);
|
|
773
554
|
}
|
|
774
555
|
}
|
|
775
556
|
|
|
@@ -788,79 +569,11 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
788
569
|
const origin = `${this.id}-${meth}`;
|
|
789
570
|
log.trace(origin);
|
|
790
571
|
|
|
791
|
-
// make sure we are set up for device broker getConfig
|
|
792
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getConfig || this.allProps.devicebroker.getConfig.length === 0 || !this.allProps.devicebroker.getConfig[0].path) {
|
|
793
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getConfig.path'], null, null, null);
|
|
794
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
795
|
-
return callback(null, errorObj);
|
|
796
|
-
}
|
|
797
|
-
|
|
798
|
-
// verify the required fields have been provided
|
|
799
|
-
if (deviceName === undefined || deviceName === null || deviceName === '' || deviceName.length === 0) {
|
|
800
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Data', ['deviceName'], null, null, null);
|
|
801
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
802
|
-
return callback(null, errorObj);
|
|
803
|
-
}
|
|
804
|
-
|
|
805
572
|
try {
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
name: deviceName
|
|
811
|
-
}
|
|
812
|
-
};
|
|
813
|
-
return this.getDevicesFiltered(opts, (devs, ferr) => {
|
|
814
|
-
// if we received an error or their is no response on the results return an error
|
|
815
|
-
if (ferr) {
|
|
816
|
-
return callback(null, ferr);
|
|
817
|
-
}
|
|
818
|
-
if (devs.list.length < 1) {
|
|
819
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, `Did Not Find Device ${deviceName}`, [], null, null, null);
|
|
820
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
821
|
-
return callback(null, errorObj);
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
const callPromises = [];
|
|
825
|
-
for (let i = 0; i < this.allProps.devicebroker.getConfig.length; i += 1) {
|
|
826
|
-
// Perform component calls here.
|
|
827
|
-
callPromises.push(
|
|
828
|
-
new Promise((resolve, reject) => {
|
|
829
|
-
this.iapMakeBrokerCall('getConfig', this.allProps.devicebroker.getConfig[i], devs.list[0], null, (callRet, callErr) => {
|
|
830
|
-
// return an error
|
|
831
|
-
if (callErr) {
|
|
832
|
-
reject(callErr);
|
|
833
|
-
} else {
|
|
834
|
-
// return the data
|
|
835
|
-
resolve(callRet);
|
|
836
|
-
}
|
|
837
|
-
});
|
|
838
|
-
})
|
|
839
|
-
);
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
// return an array of repsonses
|
|
843
|
-
return Promise.all(callPromises).then((results) => {
|
|
844
|
-
let myResult = {};
|
|
845
|
-
results.forEach((result) => {
|
|
846
|
-
myResult = { ...myResult, ...result };
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
// return the result
|
|
850
|
-
const newResponse = {
|
|
851
|
-
response: JSON.stringify(myResult, null, 2)
|
|
852
|
-
};
|
|
853
|
-
return callback(newResponse, null);
|
|
854
|
-
})
|
|
855
|
-
.catch((error) => {
|
|
856
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
857
|
-
return callback(null, error);
|
|
858
|
-
});
|
|
859
|
-
});
|
|
860
|
-
} catch (ex) {
|
|
861
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
862
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
863
|
-
return callback(null, errorObj);
|
|
573
|
+
return super.getConfig(deviceName, format, callback);
|
|
574
|
+
} catch (err) {
|
|
575
|
+
log.error(`${origin}: ${err}`);
|
|
576
|
+
return callback(null, err);
|
|
864
577
|
}
|
|
865
578
|
}
|
|
866
579
|
|
|
@@ -877,52 +590,11 @@ class DnaCenter extends AdapterBaseCl {
|
|
|
877
590
|
const origin = `${this.id}-${meth}`;
|
|
878
591
|
log.trace(origin);
|
|
879
592
|
|
|
880
|
-
// make sure we are set up for device broker getCount
|
|
881
|
-
if (!this.allProps.devicebroker || !this.allProps.devicebroker.getCount || this.allProps.devicebroker.getCount.length === 0 || !this.allProps.devicebroker.getCount[0].path) {
|
|
882
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Missing Properties', ['devicebroker.getCount.path'], null, null, null);
|
|
883
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
884
|
-
return callback(null, errorObj);
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
// verify the required fields have been provided
|
|
888
|
-
|
|
889
593
|
try {
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
new Promise((resolve, reject) => {
|
|
895
|
-
this.iapMakeBrokerCall('getCount', this.allProps.devicebroker.getCount[i], null, null, (callRet, callErr) => {
|
|
896
|
-
// return an error
|
|
897
|
-
if (callErr) {
|
|
898
|
-
reject(callErr);
|
|
899
|
-
} else {
|
|
900
|
-
// return the data
|
|
901
|
-
resolve(callRet);
|
|
902
|
-
}
|
|
903
|
-
});
|
|
904
|
-
})
|
|
905
|
-
);
|
|
906
|
-
}
|
|
907
|
-
|
|
908
|
-
// return an array of repsonses
|
|
909
|
-
return Promise.all(callPromises).then((results) => {
|
|
910
|
-
let myResult = {};
|
|
911
|
-
results.forEach((result) => {
|
|
912
|
-
myResult = { ...myResult, ...result };
|
|
913
|
-
});
|
|
914
|
-
|
|
915
|
-
// return the result
|
|
916
|
-
return callback({ count: myResult.length });
|
|
917
|
-
})
|
|
918
|
-
.catch((error) => {
|
|
919
|
-
log.debug(`Caught ${JSON.stringify(error)}`);
|
|
920
|
-
return callback(null, error);
|
|
921
|
-
});
|
|
922
|
-
} catch (ex) {
|
|
923
|
-
const errorObj = this.requestHandlerInst.formatErrorObject(this.id, meth, 'Caught Exception', null, null, null, ex);
|
|
924
|
-
log.error(`${origin}: ${errorObj.IAPerror.displayString}`);
|
|
925
|
-
return callback(null, errorObj);
|
|
594
|
+
return super.iapGetDeviceCount(callback);
|
|
595
|
+
} catch (err) {
|
|
596
|
+
log.error(`${origin}: ${err}`);
|
|
597
|
+
return callback(null, err);
|
|
926
598
|
}
|
|
927
599
|
}
|
|
928
600
|
|