Automating Work with the Address Commander JDK 

Published on 25 Sep 2013

Scenario

As a service provider, you may lease IP space to many organizations. Address Commander lets you easily keep track of which organization has leased what space by assigning an “entity” — or an owner — to each subnet. If one of your customers changes the name of their business, no problem! Simply change the name of the entity and you will still be able to keep track of their address space.

However, suppose that you have two customers, each with a large amount of address space. When one customer purchases the other, they appropriate all of their leases. In this scenario, you can’t simply change the entity’s name, as two entities can’t have the same name.

What you really want is to be able to change the owner of all the subnets owned by the defunct entity. If there are a lot of subnets, this could create a few hours of tedious (and potentially error-prone) work in the Web Management Console.

Solution

One straightforward solution is to create code in the Address Commander JDK to automate this task. The complete Java code is provided below:

import com.incognito.GenericObjectPackage.OperatorType;
import com.incognito.baseJDK.IncIterator;
import com.incognito.baseJDK.IncognitoException;
import com.incognito.baseJDK.SearchCriteria;
import com.incognito.resCmdr.ipms.DB_IDS;
import com.incognito.umsJDK.Entity;
import com.incognito.umsJDK.UMSService;

public static void main(String[] args) throws IncognitoException

{
    UMSService ums = new UMSService();
    ums.login(userName, password, UMSHost, UMSIORAccessorPort);
    IPMSService ipms = new IPMSService();
    ipms.connectFirstEnabled(ums);

    Entity purchasedEnt = ums.getEntity("PurchasedCompanyName");
    Entity newOwnerEnt = ums.getEntity("NewCompanyName");

    SearchCriteria subnetsWithOwner = new SearchCriteria();
    subnetsWithOwner.addStatement(DB_IDS.IPMS_BFL_OWNERENTITYID, OperatorType.Equal, purchasedEnt.getID());

    BlockCollection blocksWithOwner = ipms.searchBlocks(subnetsWithOwner);
IncIterator blockItr = blocksWithOwner.iterator();
while(blockItr.hasNext())
    {
      Block block = (Block) blockItr.next();
      block.changeOwnerEntityID(newOwnerEnt.getID());
    }

    ipms.disconnect();

    ums.logout();
}

This code takes minutes to write and executes in seconds. This kind of powerful and easy manipulation of your data is a great feature of Address Commander.  Click here to find out more about Address Commander and download the product fact sheet.