Skip to content
Release: Australia · Updated: 2026-03-12 · Official documentation · View source

IPAddressFixup- Global

The IPAddressFixup script include provides methods that ensure that no other device has the same IP address, after a device has been successfully discovered. If any duplicates are found, the IP address field is cleared.

Use with any server-side Discovery script to validate IP addresses.

Parent Topic:Server API reference

IPAddressFixup - dedupe(String tableName, String ip)

Removes duplicates of the specified IP address in the specified table.

After a device has been successfully discovered, you can use the dedupe() method to remove the duplicate IP addresses for that device.

NameTypeDescription
tableNameStringTable to check for duplicates.
ipStringIP address to check for.
TypeDescription
void 

The following example shows how to use dedupe() in a background script to remove duplicate IP addresses for the specified IP address within the cmdb_ci_hardware table.

var grDiscovery=new GlideRecord("discovery_device_history");
grDiscovery.addQuery('sys_id','<sys id of the record>'); // sys_id of the device discovery_device_history
grDiscovery.query();
if(grDiscovery.next())
  {
    var fx=new IPAddressFixup(grDiscovery.cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference 
    fx.dedupe('cmdb_ci_hardware','192.161.1.1'); // Pass the IP address and table which removes duplicates of the specified IP address in the specified table.
  }

The following example shows how to use dedupe() in a business rule to remove duplicate IP addresses for the specified IP address within the cmdb_ci_hardware table.

(function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
  {
    var ipf = new IPAddressFixup(cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    ipf.dedupe('cmdb_ci_hardware','168.128.1.1'); // Removes duplicates of the specified IP address in the specified table.
  }
})(current, previous);

IPAddressFixup - dedupeAll()

Removes all duplicate IP addresses from the tables.

NameTypeDescription
None  
TypeDescription
void 

The following example shows how to use dedupeAll() in a background script to remove all duplicate IP addresses.

var grDiscovery=new GlideRecord("discovery_device_history"); 
grDiscovery.addQuery('sys_id','<sys id of the record>'); // sys_id of the device discovery_device_history
grDiscovery.query();
if(grDiscovery.next())
{
  var fx=new IPAddressFixup(grDiscovery.cmdb_ci); // Call script include IPAddressFixup and pass cmdb reference
  fx.dedupeAll(); //Removes all duplicate IP addresses from the tables.
}

The following example shows how to use dedupeAll() in a business rule to remove all duplicate IP addresses.

(function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
{
  var ipf = new IPAddressFixup(cmdb_ci); //call script include IPAddressFixup and pass cmdb reference
  ipf.dedupeAll(); //Removes all duplicate IP addresses from the tables.
})(current, previous);

IPAddressFixup - fix()

Removes all duplicate IP addresses and ensures that the parent ip_address record is set to one of the network interface card's (NIC) IP addresses.

After a device has been successfully discovered, you can use the dedupe() method to remove the duplicate IP addresses for that device and set the parent ip_address record value.

NameTypeDescription
None  
TypeDescription
void 

The following example shows how to use fix() in a background script to remove duplicate IP addresses and set the parent IP address.

var grDiscovery=new GlideRecord("discovery_device_history"); 
grDiscovery.addQuery('sys_id','<sys id of the the record>'); // sys_id of the device discovery_device_history
grDiscovery.query();
if(grDiscovery.next())
  {
    var fx=new IPAddressFixup(grDiscovery.cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    fx.fix(); // Remove all duplicate IP addresses and ensure that the parent ip_address record is set to one of the NIC's IP addresses.
  }

The following example shows how to use fix() in a business rule to remove duplicate IP addresses and set the parent IP address.

(function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
  {
    var ipf = new IPAddressFixup(cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    ipf.fix(); /// Remove all duplicate IP addresses and ensure that the parent ip_address record is set to one of the NIC's IP addresses.
  }
})(current, previous);

IPAddressFixup - getParentIP()

Returns the parent IP address for the current device.

NameTypeDescription
None  
TypeDescription
StringParent IP address

The following example shows how to use getParentIP() in a background script to obtain the parent IP address.

var grDiscovery=new GlideRecord("discovery_device_history"); // current.cmdb_ci can be used in case of Business rule on discovery_device_history table
grDiscovery.addQuery('sys_id','<sys id of the the record>'); // sys_id of the device discovery_device_history
grDiscovery.query();
if(grDiscovery.next())
  {
    var fx=new IPAddressFixup(grDiscovery.cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    gs.info(fx.getParentIP()); // Display the parent IP address of the device 
  }

Output:

172.21.12.11

The following example shows how to use getParentIP() in a business rule to obtain the parent IP address.

((function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
  {
    var ipf = new IPAddressFixup(cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    gs.log(ipf.getParentIP()); // Log the parent IP address of the device. Located in the system logs table 
  }
})(current, previous);

IPAddressFixup - setParentIP(String ip)

Sets the parent IP address field for the current CI.

NameTypeDescription
ipStringParent IP address for the current CI.
TypeDescription
void 

The following example shows how to use setParentIP() in a background script to store the parent IP address.

var grDiscover=new GlideRecord("discovery_device_history"); 
grDiscover.addQuery('sys_id','a14e43b31bb4051070cb96c6b04bcb23'); // sys_id of the device in discovery_device_history table. Put your own sys_id here.
grDiscover.query();
if(grDiscover.next())
  {
    var fx=new IPAddressFixup(grDiscover.cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference.
    fx.setParentIP('197.111.1.1'); // Pass IP address to set as new IP on current mentioned CI.
  }

The following example shows how to use setParentIP() in a business rule to store the parent IP address.

((function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
  {
    var ipf = new IPAddressFixup(cmdb_ci); // Instantiate IPAddressFixup - pass cmdb reference
    fx.setParentIP('195.11.1.1'); // Set the new IP address of the CI 
  }
})(current, previous);

IPAddressFixup - syncIP()

Ensures that the parent ip_address record is set to one of the NIC's IP addresses, or leaves it alone if there were no NICs.

NameTypeDescription
None  
TypeDescription
void 

This shows an example of using the syncIP() method in a background script.

var grDevHistory=new GlideRecord("discovery_device_history");
grDevHistory.addQuery('sys_id','a14e43b31bb4051070cb96c6b04bcb23'); // Sys_id of the device in discovery_device_history table. Put your own sys_id here.
grDevHistory.query();
if(grDevHistory.next())
  {
    var fx=new IPAddressFixup(grDevHistory.cmdb_ci); // Call the script include IPAddressFixup and pass cmdb reference
    fx.syncIP(); // Ensures that the parent ip_address record is set to one of the NIC's IP addresses, or leaves it alone if there were no NICs.
  }

This shows an example of using the syncIP() method in a business rule.

(function executeRule(current, previous /*null when async*/) {

var cmdb_ci = current.cmdb_ci + '';
if (cmdb_ci) 
  {
    var ipf = new IPAddressFixup(cmdb_ci); // Call script include IPAddressFixup and pass cmdb reference
    ipf.syncIP(); // Ensures that the parent ip_address record is set to one of the NIC's IP addresses, or leaves it alone if there were no NICs.
  }
})(current, previous);