use of org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredServiceCollection in project opennms by OpenNMS.
the class CsvRequisitionParser method createOrUpdateRequistion.
private static void createOrUpdateRequistion(RequisitionData rd) throws UnknownHostException {
Requisition r = null;
RequisitionNode rn = new RequisitionNode();
String foreignSource = rd.getForeignSource();
r = m_fsr.getRequisition(foreignSource);
if (r == null) {
r = new Requisition(foreignSource);
}
System.err.println("Creating/Updating requistion: " + foreignSource);
r.updateDateStamp();
RequisitionMonitoredServiceCollection services = new RequisitionMonitoredServiceCollection();
for (String svc : m_serviceList) {
services.add(new RequisitionMonitoredService(svc));
}
RequisitionInterface iface = new RequisitionInterface();
iface.setDescr("mgmt-if");
iface.setIpAddr(rd.getPrimaryIp());
iface.setManaged(true);
iface.setSnmpPrimary(PrimaryType.PRIMARY);
iface.setStatus(Integer.valueOf(1));
iface.setMonitoredServices(services.getObjects());
RequisitionInterfaceCollection ric = new RequisitionInterfaceCollection();
ric.add(iface);
//add categories requisition level categories
RequisitionCategoryCollection rcc = new RequisitionCategoryCollection();
if (m_categoryList != null && m_categoryList.size() > 0) {
for (String cat : m_categoryList) {
rcc.add(new RequisitionCategory(cat));
}
}
//add categories already on the node to the requisition
if (rd.getCategories() != null) {
for (String cat : rd.getCategories()) {
rcc.add(new RequisitionCategory(cat));
}
}
rn.setBuilding(foreignSource);
if (rcc.size() >= 1) {
rn.setCategories(rcc.getObjects());
}
rn.setForeignId(rd.getForeignId());
rn.setInterfaces(ric.getObjects());
String nodeLabel = rd.getNodeLabel();
if (m_resolveIps) {
InetAddress addr = InetAddress.getByName(rd.getPrimaryIp());
nodeLabel = addr.getCanonicalHostName();
}
rn.setNodeLabel(nodeLabel);
//r.insertNode(rn);
r.putNode(rn);
m_fsr.save(r);
}
Aggregations