Search in sources :

Example 1 with RequisitionMonitoredServiceCollection

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);
}
Also used : RequisitionCategoryCollection(org.opennms.netmgt.provision.persist.requisition.RequisitionCategoryCollection) RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionMonitoredServiceCollection(org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredServiceCollection) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) RequisitionCategory(org.opennms.netmgt.provision.persist.requisition.RequisitionCategory) RequisitionInterfaceCollection(org.opennms.netmgt.provision.persist.requisition.RequisitionInterfaceCollection) InetAddress(java.net.InetAddress) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) RequisitionMonitoredService(org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)

Aggregations

InetAddress (java.net.InetAddress)1 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)1 RequisitionCategory (org.opennms.netmgt.provision.persist.requisition.RequisitionCategory)1 RequisitionCategoryCollection (org.opennms.netmgt.provision.persist.requisition.RequisitionCategoryCollection)1 RequisitionInterface (org.opennms.netmgt.provision.persist.requisition.RequisitionInterface)1 RequisitionInterfaceCollection (org.opennms.netmgt.provision.persist.requisition.RequisitionInterfaceCollection)1 RequisitionMonitoredService (org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)1 RequisitionMonitoredServiceCollection (org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredServiceCollection)1 RequisitionNode (org.opennms.netmgt.provision.persist.requisition.RequisitionNode)1