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();
}
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();
}
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");
}
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"));
}
Aggregations