cisco-axl 1.1.8 → 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.
@@ -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.
@@ -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
  var fs = require('fs');
3
3
  var path = require('path');
4
4
 
@@ -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,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
  const path = require("path");
3
3
  const fs = require("fs");
4
4
 
@@ -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/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "cisco-axl",
3
- "version": "1.1.8",
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": "^0.45.0",
29
- "strong-soap": "^3.4.3"
28
+ "strong-soap": "^3.5.0"
30
29
  },
31
30
  "devDependencies": {
32
31
  "json-variables": "^10.1.0",
33
- "node-emoji": "^1.11.0"
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
- "10.10.20.1",
7
- "administrator",
8
- "ciscopsdt",
9
- "14.0"
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 = "INTERNAL-PT";
49
- tags.routePartition.description = "Internal directory numbers";
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
  })();