forked from CiscoDevNet/ise-servicenow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathISE_Network_Adapter (Business Rule).json
52 lines (48 loc) · 2.3 KB
/
ISE_Network_Adapter (Business Rule).json
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
(function executeRule(current, previous /*null when async*/ ) {
try {
// Add your code here
var strInventoried = "false";
var si = new global.ISE_Helper();
var GUIDendpoint = "";
if (!current.correlation_id) {
var getOBJviaMAC = si.fnGetGUIDviaMAC(current.mac_address.toString());
if (getOBJviaMAC !== 'error') {
GUIDendpoint = si.fnParseGUID(getOBJviaMAC);
current.correlation_id = GUIDendpoint;
} else {
// gs.info('DEBUGfile: error finding endpoint in ISE');
}
} else {
GUIDendpoint = current.correlation_id.toString();
}
var strSerial = current.cmdb_ci.serial_number.toString();
var strSerialSource = "ServiceNow";
// if ((current.cmdb_ci.serial_number.toString().length > 0) && (current.cmdb_ci.department.toString().length > 0) && (current.cmdb_ci.u_room.toString().length > 0)) {
if (current.cmdb_ci.install_status.toString() === '1') {
strInventoried = "true";
} else {
strInventoried = "false";
}
var strInventoryDisplay = null;
if(strInventoried==="true") {
strInventoryDisplay = "PASS";
} else {
strInventoryDisplay = "FAIL (Internet access may be blocked)";
}
// gs.addInfoMessage("Attempting to update details to ISE with: " + strSerial + "," + strInventoried + "," + strSerialSource);
// gs.info('DEBUGfile');
var PUTResponse = si.fnPUTEndpointDetails(GUIDendpoint, strSerial, strSerialSource, strInventoried);
if(typeof PUTResponse==="undefined") {
gs.addErrorMessage("Error retrieving ISE details for device " + current.mac_address + ".");
} else {
gs.addInfoMessage("Refreshed ISE. Inventory status: " + strInventoryDisplay + " with MAC address " + current.mac_address);
// gs.addInfoMessage(PUTResponse);
if(current.mac_address==='AC:DE:48:00:11:22') {
gs.addInfoMessage(PUTResponse);
}
}
current.u_correlation_last_check = gs.now().toString();
} catch (err) {
//gs.addErrorMessage("Error retrieving ISE details for device " + current.mac_address + ".");
}
})(current, previous);