-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathcontrolConstructService.js
More file actions
48 lines (43 loc) · 1.37 KB
/
Copy pathcontrolConstructService.js
File metadata and controls
48 lines (43 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
const { readRecords } = require('./elasticService');
const individualServices = require('../../../IndividualServicesService');
const RandExp = require('randexp');
async function getCachedControlConstruct(mountName) {
// retrieval from local cache
let cachedControlConstruct = await readRecords(mountName);
return cachedControlConstruct;
}
async function getLiveControlConstruct(mountName) {
// live fetch from device
try{
let url = "/core-model-1-4:network-control-domain=live/control-construct=" + mountName;
let user = "CacheQualityMeasurementProcess";
let originator = "MicroWaveDeviceInventory";
let xCorrelator = getRandomXCorrelator();
let traceIndicator = "1";
let customerJourney = "CacheQualityMeasurementProcess";
let liveControlConstruct = await individualServices.getLiveControlConstruct(url,
user,
originator,
xCorrelator,
traceIndicator,
customerJourney,
mountName);
return liveControlConstruct;
}catch(error){
console.log(error);
}
}
function getRandomXCorrelator() {
let randomXCorrelatorString;
try {
randomXCorrelatorString = new RandExp(/^[0-9A-Fa-f]{8}(?:-[0-9A-Fa-f]{4}){3}-[0-9A-Fa-f]{12}$/).gen();
} catch (error) {
console.log("error");
console.log(error);
}
return randomXCorrelatorString;
}
module.exports = {
getCachedControlConstruct,
getLiveControlConstruct
};