-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathprox_tools.js
55 lines (55 loc) · 1.85 KB
/
prox_tools.js
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
49
50
51
52
53
54
55
/**
* @fileoverview Collection of functions that deal with connecting to/controlling a server running Proxmox
* @author Donald Elrod
* @version 1.0.0
*/
var proxmox = require('proxmox');
/**
* Collection of functions that deal with connecting to/controlling a server running Proxmox
* @exports prox_tools
*/
module.exports = {
/**
* Processes the activation of the Proxmox module
* @param {*} modules the modules object from server.js, contains all objects/details for modules to work properly
* @param {*} type the Netgear object loaded from the modules.json file (this is obtained during the initial forEach loop in the processModules function in server.js)
*/
processProxmox: function (modules, type) {
try {
modules.prox = proxmox(type.details.user, type.details.password, type.details.ip);
console.log('Proxmox api enabled');
} catch(err) {
console.log(err);
}
},
getClusterStatus: async function(prox) {
return new Promise(function(resolve, reject) {
prox.getClusterStatus(function(err, response){
if(err) {
console.log(err);
reject(err);
}
else {
data = JSON.parse(response);
console.log(data);
resolve(data);
}
});
});
},
getNodes: async function(prox) {
return new Promise(function(resolve, reject) {
prox.getNodes(function(err, response){
if(err) {
console.log(err);
reject(err);
}
else {
data = JSON.parse(response);
console.log(data);
resolve(data);
}
});
});
}
};