-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaspects.js
More file actions
47 lines (42 loc) · 1.26 KB
/
Copy pathaspects.js
File metadata and controls
47 lines (42 loc) · 1.26 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
const debug = require('debug')('refocus-load-sim:aspects');
const RefocusClient = require('refocus-client');
const conf = require('./config/config');
const rconf = require('./config/refocus');
const rc = new RefocusClient(rconf.refocusUrl, rconf.apiVersion, rconf.token);
function addAspects() {
const roots = Array.apply(null, { length: conf.subjects.roots })
.map(Number.call, Number);
const numPerRoot = Array.apply(null, { length: conf.aspects.numPerRoot })
.map(Number.call, Number);
const aspects = [];
roots.forEach((r) => {
numPerRoot.forEach((a) => {
aspects.push({
name: `${conf.prefix}r${r}_a${a}`,
timeout: conf.aspects.timeout,
valueType: 'NUMERIC',
criticalRange: [90, 100],
warningRange: [80, 90],
infoRange: [70, 80],
okRange: [0, 70],
isPublished: true,
});
});
});
return rc.addAspects(aspects)
.then((added) => {
added.forEach((a) => debug('Added aspect', a.name));
return added;
});
} // addAspects
function deleteAspects(aspects) {
return rc.deleteAspects(aspects)
.then((deleted) => {
deleted.forEach((a) => debug('Deleted aspect', a.name));
return deleted;
});
} // deleteAspects
module.exports = {
addAspects,
deleteAspects,
};