Search in sources :

Example 1 with PathElement

use of org.opennms.netmgt.model.PathElement in project opennms by OpenNMS.

the class NodeDaoIT method testSaveWithPathElement.

@Test
@Transactional
public void testSaveWithPathElement() {
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "MyFirstNode");
    PathElement p = new PathElement("192.168.7.7", "ICMP");
    node.setPathElement(p);
    getNodeDao().save(node);
    getNodeDao().flush();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) PathElement(org.opennms.netmgt.model.PathElement) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 2 with PathElement

use of org.opennms.netmgt.model.PathElement in project opennms by OpenNMS.

the class NodeDaoIT method testSaveWithNullPathElement.

@Test
@Transactional
public void testSaveWithNullPathElement() {
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "MyFirstNode");
    PathElement p = new PathElement("192.168.7.7", "ICMP");
    node.setPathElement(p);
    getNodeDao().save(node);
    OnmsNode myNode = getNodeDao().get(node.getId());
    assertNotNull(myNode);
    myNode.setPathElement(null);
    getNodeDao().save(myNode);
    getNodeDao().flush();
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) PathElement(org.opennms.netmgt.model.PathElement) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 3 with PathElement

use of org.opennms.netmgt.model.PathElement in project opennms by OpenNMS.

the class NodeDaoIT method testCreate.

@Test
@Transactional
public void testCreate() throws InterruptedException {
    OnmsNode node = new OnmsNode(m_locationDao.getDefaultLocation(), "MyFirstNode");
    node.getAssetRecord().setDisplayCategory("MyCategory");
    PathElement p = new PathElement("192.168.7.7", "ICMP");
    node.setPathElement(p);
    getNodeDao().save(node);
    System.out.println("BEFORE GET");
    Collection<OnmsNode> nodes = getNodeDao().findAll();
    assertEquals(7, nodes.size());
    System.out.println("AFTER GETNODES");
    for (OnmsNode retrieved : nodes) {
        System.out.println("category for " + retrieved.getId() + " = " + retrieved.getAssetRecord().getDisplayCategory());
        if (node.getId().intValue() == 5) {
            assertEquals("MyFirstNode", retrieved.getLabel());
            assertEquals("MyCategory", retrieved.getAssetRecord().getDisplayCategory());
            assertEquals("192.168.7.7", retrieved.getPathElement().getIpAddress());
        }
    }
    System.out.println("AFTER Loop");
}
Also used : OnmsNode(org.opennms.netmgt.model.OnmsNode) PathElement(org.opennms.netmgt.model.PathElement) Test(org.junit.Test) Transactional(org.springframework.transaction.annotation.Transactional)

Example 4 with PathElement

use of org.opennms.netmgt.model.PathElement in project opennms by OpenNMS.

the class DefaultProvisionService method setPathDependency.

private void setPathDependency(final OnmsNode node, final OnmsNode parent) {
    if (node == null)
        return;
    OnmsIpInterface critIface = null;
    if (parent != null) {
        critIface = parent.getCriticalInterface();
    }
    LOG.info("Setting criticalInterface of node: {} to: {}", node, critIface);
    node.setPathElement(critIface == null ? null : new PathElement(str(critIface.getIpAddress()), "ICMP"));
}
Also used : OnmsIpInterface(org.opennms.netmgt.model.OnmsIpInterface) PathElement(org.opennms.netmgt.model.PathElement)

Aggregations

PathElement (org.opennms.netmgt.model.PathElement)4 Test (org.junit.Test)3 OnmsNode (org.opennms.netmgt.model.OnmsNode)3 Transactional (org.springframework.transaction.annotation.Transactional)3 OnmsIpInterface (org.opennms.netmgt.model.OnmsIpInterface)1