cisco-perfmon 1.3.0 → 1.3.2
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/main.js +20 -3
- package/package.json +2 -1
package/main.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// fetch-retry can also wrap Node.js's native fetch API implementation:
|
|
2
|
+
const fetch = require('fetch-retry')(global.fetch);
|
|
1
3
|
const util = require("util");
|
|
2
4
|
const parseString = require("xml2js").parseString;
|
|
3
5
|
const stripPrefix = require("xml2js").processors.stripPrefix;
|
|
@@ -98,12 +100,15 @@ var XML_REMOVE_COUNTER_ENVELOPE = `<soapenv:Envelope xmlns:soapenv="http://schem
|
|
|
98
100
|
class perfMonService {
|
|
99
101
|
constructor(host, username, password, options) {
|
|
100
102
|
this._OPTIONS = {
|
|
103
|
+
retries: 5,
|
|
104
|
+
retryDelay: 800,
|
|
105
|
+
retryOn: [503],
|
|
101
106
|
method: "POST",
|
|
102
107
|
headers: {
|
|
103
108
|
Authorization: "Basic " + Buffer.from(username + ":" + password).toString("base64"),
|
|
104
109
|
"Content-Type": "text/xml;charset=UTF-8",
|
|
105
110
|
Connection: "keep-alive",
|
|
106
|
-
}
|
|
111
|
+
}
|
|
107
112
|
};
|
|
108
113
|
|
|
109
114
|
// Adds additional headers if they are provided. Useful for adding cookies for SSO sessions
|
|
@@ -205,8 +210,20 @@ class perfMonService {
|
|
|
205
210
|
reject(promiseResults);
|
|
206
211
|
}
|
|
207
212
|
} else {
|
|
208
|
-
|
|
209
|
-
|
|
213
|
+
// Error checking. If the response contains a fault, we return the fault.
|
|
214
|
+
if (keyExists(output, "Fault")) {
|
|
215
|
+
if (output.Body.Fault.faultcode.includes("RateControl")) {
|
|
216
|
+
promiseResults.Results = { faultcode: "RateControl", faultstring: output.Body.Fault.faultstring };
|
|
217
|
+
} else if (output.Body.Fault.faultcode.includes("generalException")) {
|
|
218
|
+
promiseResults.Results = { faultcode: "generalException", faultstring: output.Body.Fault.faultstring };
|
|
219
|
+
} else {
|
|
220
|
+
promiseResults.Results = { faultcode: output.Body.Fault.faultcode, faultstring: output.Body.Fault.faultstring };
|
|
221
|
+
}
|
|
222
|
+
resolve(promiseResults);
|
|
223
|
+
} else {
|
|
224
|
+
// Error unknown. Return the response status instead.
|
|
225
|
+
reject(response.status);
|
|
226
|
+
}
|
|
210
227
|
}
|
|
211
228
|
} catch (e) {
|
|
212
229
|
promiseResults.Results = e;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cisco-perfmon",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.2",
|
|
4
4
|
"description": "A library to pull Perfmon data from Cisco VOS applications via SOAP",
|
|
5
5
|
"main": "main.js",
|
|
6
6
|
"scripts": {
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/sieteunoseis/cisco-perfmon#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
+
"fetch-retry": "^6.0.0",
|
|
28
29
|
"util": "*",
|
|
29
30
|
"xml2js": "*"
|
|
30
31
|
},
|