cisco-axl 1.1.7 → 1.1.9
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/examples/change_phone_model/changePhoneModel.js +1 -1
- package/examples/copy_phone/copyPhone.js +1 -1
- package/examples/copy_sip_trunk/copySipTrunk.js +1 -1
- package/examples/sql/sqlQuery.js +1 -1
- package/examples/templates/add_phone_update_line/addPhoneUpdateLine.js +1 -1
- package/examples/templates/save_search_as_template/saveSearch.js +1 -1
- package/examples/templates/update_phone_update_line/updatePhoneUpdateLine.js +1 -1
- package/index.js +24 -16
- package/package.json +7 -6
- package/test/tests.js +85 -7
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const axlService = require("../../index");
|
|
1
|
+
const axlService = require("../../index"); // Change this to require("cisco-axl") when using outside this package
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Ever wanted to change a phone model, but keep the existing one in CUCM? This script will attempt to migrate a phone to the new model.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const axlService = require("../../index");
|
|
1
|
+
const axlService = require("../../index"); // Change this to require("cisco-axl") when using outside this package
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Example of how to copy a phone. This is similar to the Super Copy function in CUCM. Just an example of how to do it via AXL.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const axlService = require("../../index");
|
|
1
|
+
const axlService = require("../../index"); // Change this to require("cisco-axl") when using outside this package
|
|
2
2
|
|
|
3
3
|
/*
|
|
4
4
|
Example of how to copy a SIP Trunk. Cisco doesn't have a Super Copy option for this, but we can do it via AXL.
|
package/examples/sql/sqlQuery.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
const axlService = require("../../../index"); // Change this to require("cisco-axl") when using outside this package
|
|
1
2
|
const { jVar } = require("json-variables");
|
|
2
|
-
const axlService = require("../../../index");
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
This script using json-variables (https://codsen.com/os/json-variables) to add a new phone from a template.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
const axlService = require("../../../index"); // Change this to require("cisco-axl") when using outside this package
|
|
1
2
|
const { jVar } = require("json-variables");
|
|
2
|
-
const axlService = require("../../../index");
|
|
3
3
|
|
|
4
4
|
/*
|
|
5
5
|
Every wanted to change an exsiting phone from one user to another user? This script will help you do that as well as updating all the display,
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const soap = require("strong-soap").soap;
|
|
2
2
|
const WSDL = soap.WSDL;
|
|
3
|
-
const path = require(
|
|
3
|
+
const path = require("path");
|
|
4
4
|
const wsdlOptions = {
|
|
5
5
|
attributesKey: "attributes",
|
|
6
6
|
valueKey: "value",
|
|
@@ -102,14 +102,26 @@ class axlService {
|
|
|
102
102
|
var options = this._OPTIONS;
|
|
103
103
|
|
|
104
104
|
var clean = opts?.clean ? opts.clean : false;
|
|
105
|
-
var dataContainerIdentifierTails = opts?.dataContainerIdentifierTails
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
var dataContainerIdentifierTails = opts?.dataContainerIdentifierTails
|
|
106
|
+
? opts.dataContainerIdentifierTails
|
|
107
|
+
: "_data";
|
|
108
|
+
var removeAttributes = opts?.removeAttributes
|
|
109
|
+
? opts.removeAttributes
|
|
110
|
+
: false;
|
|
111
|
+
|
|
108
112
|
// Let's remove empty top level strings. Also filter out json-variables
|
|
109
|
-
Object.keys(tags).forEach(
|
|
113
|
+
Object.keys(tags).forEach(
|
|
114
|
+
(k) =>
|
|
115
|
+
(tags[k] == "" || k.includes(dataContainerIdentifierTails)) &&
|
|
116
|
+
delete tags[k]
|
|
117
|
+
);
|
|
110
118
|
|
|
111
119
|
return new Promise((resolve, reject) => {
|
|
112
120
|
soap.createClient(options.url, wsdlOptions, function (err, client) {
|
|
121
|
+
var customRequestHeader = { connection: "keep-alive" };
|
|
122
|
+
if (err) {
|
|
123
|
+
reject(err);
|
|
124
|
+
}
|
|
113
125
|
client.setSecurity(
|
|
114
126
|
new soap.BasicAuthSecurity(options.username, options.password)
|
|
115
127
|
);
|
|
@@ -123,10 +135,7 @@ class axlService {
|
|
|
123
135
|
|
|
124
136
|
axlFunc(
|
|
125
137
|
tags,
|
|
126
|
-
function (
|
|
127
|
-
err,
|
|
128
|
-
result,
|
|
129
|
-
) {
|
|
138
|
+
function (err, result) {
|
|
130
139
|
if (err) {
|
|
131
140
|
reject(err);
|
|
132
141
|
}
|
|
@@ -135,15 +144,16 @@ class axlService {
|
|
|
135
144
|
if (clean) {
|
|
136
145
|
cleanObj(output);
|
|
137
146
|
}
|
|
138
|
-
if(removeAttributes){
|
|
147
|
+
if (removeAttributes) {
|
|
139
148
|
cleanAttributes(output);
|
|
140
149
|
}
|
|
141
150
|
resolve(output);
|
|
142
|
-
|
|
143
151
|
} else {
|
|
144
|
-
reject(
|
|
152
|
+
reject("No return results");
|
|
145
153
|
}
|
|
146
|
-
}
|
|
154
|
+
},
|
|
155
|
+
null,
|
|
156
|
+
customRequestHeader
|
|
147
157
|
);
|
|
148
158
|
});
|
|
149
159
|
});
|
|
@@ -195,9 +205,7 @@ const cleanAttributes = (object) => {
|
|
|
195
205
|
if (v && typeof v === "object") {
|
|
196
206
|
cleanAttributes(v);
|
|
197
207
|
}
|
|
198
|
-
if (
|
|
199
|
-
(v && typeof v === "object" && 'attributes' in object)
|
|
200
|
-
) {
|
|
208
|
+
if (v && typeof v === "object" && "attributes" in object) {
|
|
201
209
|
if (Array.isArray(object)) {
|
|
202
210
|
object.splice(k, 1);
|
|
203
211
|
} else {
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cisco-axl",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"description": "A library to make Cisco AXL a lot easier",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 node ./test/tests.js"
|
|
7
|
+
"test": "NODE_OPTIONS=--experimental-vm-modules NODE_NO_WARNINGS=1 NODE_TLS_REJECT_UNAUTHORIZED=0 NODE_ENV=test node ./test/tests.js"
|
|
8
8
|
},
|
|
9
9
|
"repository": {
|
|
10
10
|
"type": "git",
|
|
@@ -25,11 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"homepage": "https://github.com/sieteunoseis/cisco-axl#readme",
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"soap": "^
|
|
29
|
-
"strong-soap": "^3.4.0"
|
|
28
|
+
"strong-soap": "^3.5.0"
|
|
30
29
|
},
|
|
31
30
|
"devDependencies": {
|
|
32
31
|
"json-variables": "^10.1.0",
|
|
33
|
-
"node-emoji": "
|
|
32
|
+
"node-emoji": "*",
|
|
33
|
+
"dotenv": "*",
|
|
34
|
+
"envalid": "^7.3.1"
|
|
34
35
|
}
|
|
35
|
-
}
|
|
36
|
+
}
|
package/test/tests.js
CHANGED
|
@@ -1,12 +1,34 @@
|
|
|
1
1
|
const axlService = require("../index");
|
|
2
2
|
const emoji = require("node-emoji");
|
|
3
|
+
const { cleanEnv, str, host } = require("envalid");
|
|
4
|
+
var path = require('path');
|
|
5
|
+
|
|
6
|
+
// If not production load the local env file
|
|
7
|
+
if(process.env.NODE_ENV === "development"){
|
|
8
|
+
require('dotenv').config({ path: path.join(__dirname, '..', 'env', 'development.env') })
|
|
9
|
+
}else if(process.env.NODE_ENV === "test"){
|
|
10
|
+
require('dotenv').config({ path: path.join(__dirname, '..', 'env', 'test.env') })
|
|
11
|
+
}else if(process.env.NODE_ENV === "staging"){
|
|
12
|
+
require('dotenv').config({ path: path.join(__dirname, '..', 'env', 'staging.env') })
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const env = cleanEnv(process.env, {
|
|
16
|
+
NODE_ENV: str({
|
|
17
|
+
choices: ["development", "test", "production", "staging"],
|
|
18
|
+
desc: "Node environment",
|
|
19
|
+
}),
|
|
20
|
+
CUCM_HOSTNAME: host({ desc: "Cisco CUCM Hostname or IP Address." }),
|
|
21
|
+
CUCM_USERNAME: str({ desc: "Cisco CUCM AXL Username." }),
|
|
22
|
+
CUCM_PASSWORD: str({ desc: "Cisco CUCM AXL Password." }),
|
|
23
|
+
CUCM_VERSION: str({ desc: "Cisco CUCM Version. i.e. 12.5, or 14.0." }),
|
|
24
|
+
});
|
|
3
25
|
|
|
4
26
|
// Set up new AXL service
|
|
5
27
|
let service = new axlService(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
28
|
+
env.CUCM_HOSTNAME,
|
|
29
|
+
env.CUCM_USERNAME,
|
|
30
|
+
env.CUCM_PASSWORD,
|
|
31
|
+
env.CUCM_VERSION
|
|
10
32
|
);
|
|
11
33
|
|
|
12
34
|
var check = emoji.get("heavy_check_mark");
|
|
@@ -36,7 +58,6 @@ var finished = emoji.get("raised_hand");
|
|
|
36
58
|
);
|
|
37
59
|
|
|
38
60
|
var operation = "addRoutePartition";
|
|
39
|
-
|
|
40
61
|
console.log(
|
|
41
62
|
`${next} We'll need to get what tags to pass to the SOAP client first.`
|
|
42
63
|
);
|
|
@@ -45,8 +66,8 @@ var finished = emoji.get("raised_hand");
|
|
|
45
66
|
console.log(
|
|
46
67
|
`${sparkles} Magnificent, let's update the name and description fields.`
|
|
47
68
|
);
|
|
48
|
-
tags.routePartition.name = "
|
|
49
|
-
tags.routePartition.description = "
|
|
69
|
+
tags.routePartition.name = "TEST-PARTITION-PT";
|
|
70
|
+
tags.routePartition.description = "Partition for testing purposes. Created by AXL.";
|
|
50
71
|
console.log(computer, tags);
|
|
51
72
|
console.log(
|
|
52
73
|
`${next} Now we will attempt to add the new partition. Function should return an UUID to represent the new partition.`
|
|
@@ -91,5 +112,62 @@ var finished = emoji.get("raised_hand");
|
|
|
91
112
|
.catch((error) => {
|
|
92
113
|
console.log(skull, "Adding a new partition failed", error);
|
|
93
114
|
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
var operation = "removeRoutePartition";
|
|
118
|
+
console.log(
|
|
119
|
+
`${skull} Now let's remove the partition we just created. We'll need to get what tags to pass to the SOAP client first.`
|
|
120
|
+
);
|
|
121
|
+
var tags = await service.getOperationTags(operation);
|
|
122
|
+
console.log(computer, tags);
|
|
123
|
+
console.log(
|
|
124
|
+
`${sparkles} Magnificent, let's update the name of the partition we wanted to remove.`
|
|
125
|
+
);
|
|
126
|
+
tags.name = "TEST-PARTITION-PT";
|
|
127
|
+
console.log(computer, tags);
|
|
128
|
+
console.log(
|
|
129
|
+
`${next} Now we will attempt to delete the partition. Function should return an UUID.`
|
|
130
|
+
);
|
|
131
|
+
await service
|
|
132
|
+
.executeOperation(operation, tags)
|
|
133
|
+
.then(async (results) => {
|
|
134
|
+
console.log(computer, results);
|
|
135
|
+
console.log(
|
|
136
|
+
`${cat} Awesome, let's get a list of all the partitions on our cluster now. First we'll get the tags needed for this call.`
|
|
137
|
+
);
|
|
138
|
+
|
|
139
|
+
operation = "listRoutePartition";
|
|
140
|
+
tags = await service.getOperationTags(operation);
|
|
141
|
+
console.log(computer, tags);
|
|
142
|
+
|
|
143
|
+
console.log(
|
|
144
|
+
`${spy} We want to list all partitions, so we'll be searching for a wildcard (%%) in the name and description fields.`
|
|
145
|
+
);
|
|
146
|
+
tags.searchCriteria.name = "%%";
|
|
147
|
+
tags.searchCriteria.description = "%%";
|
|
148
|
+
console.log(computer, tags);
|
|
149
|
+
console.log(
|
|
150
|
+
`${sparkles} Astounding, now that we've updated our tags, we'll send the AXL request via SOAP.`
|
|
151
|
+
);
|
|
152
|
+
|
|
153
|
+
await service
|
|
154
|
+
.executeOperation(operation, tags)
|
|
155
|
+
.then((results) => {
|
|
156
|
+
console.log(
|
|
157
|
+
`${list} Here are an updated list of all the partitions on our cluster (Notice our partition we created in an earlier step is missing):`
|
|
158
|
+
);
|
|
159
|
+
results.routePartition.map((str) => {
|
|
160
|
+
var outString = `${check} ${str.name}`;
|
|
161
|
+
console.log(outString);
|
|
162
|
+
});
|
|
163
|
+
})
|
|
164
|
+
.catch((error) => {
|
|
165
|
+
console.log(skull, error);
|
|
166
|
+
});
|
|
167
|
+
})
|
|
168
|
+
.catch((error) => {
|
|
169
|
+
console.log(skull, "Deleteing partition failed", error);
|
|
170
|
+
});
|
|
171
|
+
|
|
94
172
|
console.log(finished, "Test all finished. Thanks!");
|
|
95
173
|
})();
|