Discovering a device

The discovering a device example shows how to discover a device as a network resource in Netcool Configuration Manager - Base.

If you know the VTMOS for a device, creating a Network Resource with that VTMOS and then importing it is the most efficient way to pull the configuration into Netcool Configuration Manager - Base. In cases where you do not know the VTMOS, the Discovery feature can be used.

ApiSession session;
ResourceManager rMgr;
WorkflowManager wMgr;
Date startDate;//execution window start date/time
Date endDate;//execution window end date/time
String hostname;
.
.
.
//it is assumed the session has been established
rMgr = session.resourceManager();
wMgr = session.workflowManager();
.
.
.
//it is assumed the startDate and endDate defining the execution window
//for the work have been set
//a UOW requires some comment describing the work
String comment = "Discover a device";
//instantiate and populate a command
AutoDiscoveryCommand cmd = rMgr.dataFactory().newAutoDiscoveryCommand ();
cmd.setDeviceName(hostname);
//set next flag to false to discover but not import the configuration
cmd.setImportResources(true);
cmd.setRealmKey(realmKey);
cmd.setComment(comment);
cmd.setMaxNumberOfErrors(-1);
cmd.validate();
//now instantiate and populate the Work object to submit
CommandWork work = wMgr.dataFactory().newCommandWork();
work.setCommand(cmd);
work.setExecutionWindowStartTime(startDate);
work.setExecutionWindowEndTime(endDate);
work.validate();
//finally submit the work
WorkKey workKey = wMgr.submit(work, false);