Search in sources :

Example 11 with RequisitionInterface

use of org.opennms.netmgt.provision.persist.requisition.RequisitionInterface in project opennms by OpenNMS.

the class DefaultProvisionService method createUpdateRequistion.

private boolean createUpdateRequistion(final String addrString, final OnmsNode node, final String locationName, String m_foreignSource) {
    LOG.debug("Creating/Updating requistion {} for newSuspect {}...", m_foreignSource, addrString);
    try {
        Requisition r = null;
        if (m_foreignSource != null) {
            r = m_foreignSourceRepository.getRequisition(m_foreignSource);
            if (r == null) {
                r = new Requisition(m_foreignSource);
            }
        }
        r.updateDateStamp();
        RequisitionNode rn = new RequisitionNode();
        RequisitionInterface iface = new RequisitionInterface();
        iface.setDescr("disc-if");
        iface.setIpAddr(addrString);
        iface.setManaged(true);
        iface.setSnmpPrimary(PrimaryType.PRIMARY);
        iface.setStatus(Integer.valueOf(1));
        RequisitionInterfaceCollection ric = new RequisitionInterfaceCollection();
        ric.add(iface);
        rn.setInterfaces(ric.getObjects());
        rn.setBuilding(m_foreignSource);
        rn.setForeignId(node.getForeignId());
        rn.setNodeLabel(node.getLabel());
        rn.setLocation(locationName);
        r.putNode(rn);
        m_foreignSourceRepository.save(r);
        m_foreignSourceRepository.flush();
    } catch (ForeignSourceRepositoryException e) {
        LOG.error("Couldn't create/update requistion for newSuspect " + addrString, e);
        return false;
    }
    LOG.debug("Created/Updated requistion {} for newSuspect {}.", m_foreignSource, addrString);
    return true;
}
Also used : RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) ForeignSourceRepositoryException(org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException) RequisitionInterfaceCollection(org.opennms.netmgt.provision.persist.requisition.RequisitionInterfaceCollection) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition)

Example 12 with RequisitionInterface

use of org.opennms.netmgt.provision.persist.requisition.RequisitionInterface in project opennms by OpenNMS.

the class RequisitionBuilder method withContainer.

public RequisitionBuilder withContainer(final ContainerAlias alias, final String... services) {
    // We're assuming that the Minion container is on the same
    // host as the service containers
    final ContainerInfo containerInfo = minionSystem.getContainerInfo(alias);
    final String containerIpAddr = containerInfo.networkSettings().ipAddress();
    RequisitionNode node = new RequisitionNode();
    node.setNodeLabel(alias.toString());
    node.setForeignId(alias.toString());
    RequisitionInterface iface = new RequisitionInterface();
    iface.setSnmpPrimary(PrimaryType.PRIMARY);
    iface.setIpAddr(containerIpAddr);
    for (String svcName : services) {
        RequisitionMonitoredService svc = new RequisitionMonitoredService();
        svc.setServiceName(svcName);
        iface.putMonitoredService(svc);
    }
    node.putInterface(iface);
    requisition.putNode(node);
    return this;
}
Also used : RequisitionNode(org.opennms.netmgt.provision.persist.requisition.RequisitionNode) RequisitionInterface(org.opennms.netmgt.provision.persist.requisition.RequisitionInterface) ContainerInfo(com.spotify.docker.client.messages.ContainerInfo) RequisitionMonitoredService(org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)

Aggregations

RequisitionInterface (org.opennms.netmgt.provision.persist.requisition.RequisitionInterface)12 RequisitionNode (org.opennms.netmgt.provision.persist.requisition.RequisitionNode)12 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)8 RequisitionMonitoredService (org.opennms.netmgt.provision.persist.requisition.RequisitionMonitoredService)5 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 RequisitionCategory (org.opennms.netmgt.provision.persist.requisition.RequisitionCategory)3 RestClient (org.opennms.smoketest.utils.RestClient)3 InetAddress (java.net.InetAddress)2 InetSocketAddress (java.net.InetSocketAddress)2 Date (java.util.Date)2 CriteriaBuilder (org.opennms.core.criteria.CriteriaBuilder)2 OnmsNode (org.opennms.netmgt.model.OnmsNode)2 RequisitionAsset (org.opennms.netmgt.provision.persist.requisition.RequisitionAsset)2 RequisitionInterfaceCollection (org.opennms.netmgt.provision.persist.requisition.RequisitionInterfaceCollection)2 ContainerInfo (com.spotify.docker.client.messages.ContainerInfo)1 HostRuntimeInfo (com.vmware.vim25.HostRuntimeInfo)1 HostSystemPowerState (com.vmware.vim25.HostSystemPowerState)1 VirtualMachinePowerState (com.vmware.vim25.VirtualMachinePowerState)1 VirtualMachineRuntimeInfo (com.vmware.vim25.VirtualMachineRuntimeInfo)1