use of org.opennms.netmgt.provision.persist.OnmsNodeRequisition in project opennms by OpenNMS.
the class ProvisionerIT method testDnsVisit.
/**
* We have to ignore this test until there is a DNS service available in the test harness
*
* @throws ForeignSourceRepositoryException
* @throws MalformedURLException
*/
@Test(timeout = 300000)
@JUnitDNSServer(port = 9153, zones = { @DNSZone(name = "opennms.com.", v4address = "1.2.3.4", entries = { @DNSEntry(hostname = "www", address = "1.2.3.4") }) })
public void testDnsVisit() throws ForeignSourceRepositoryException, MalformedURLException {
final Requisition requisition = m_foreignSourceRepository.importResourceRequisition(new UrlResource("dns://localhost:9153/opennms.com"));
final CountingVisitor visitor = new CountingVisitor() {
@Override
public void visitNode(final OnmsNodeRequisition req) {
LOG.debug("visitNode: {}/{} {}", req.getForeignSource(), req.getForeignId(), req.getNodeLabel());
m_nodes.add(req);
m_nodeCount++;
}
@Override
public void visitInterface(final OnmsIpInterfaceRequisition req) {
LOG.debug("visitInterface: {}", req.getIpAddr());
m_ifaces.add(req);
m_ifaceCount++;
}
};
requisition.visit(visitor);
verifyDnsImportCounts(visitor);
}
use of org.opennms.netmgt.provision.persist.OnmsNodeRequisition in project opennms by OpenNMS.
the class Requisition method putNode.
/**
* <p>putNode</p>
*
* @param node a {@link org.opennms.netmgt.provision.persist.requisition.RequisitionNode} object.
*/
public void putNode(final RequisitionNode node) {
updateNodeCacheIfNecessary();
if (m_nodeReqs.containsKey(node.getForeignId())) {
final RequisitionNode n = m_nodeReqs.get(node.getForeignId()).getNode();
m_nodes.remove(n);
}
m_nodes.add(node);
m_nodeReqs.put(node.getForeignId(), new OnmsNodeRequisition(getForeignSource(), node));
}
use of org.opennms.netmgt.provision.persist.OnmsNodeRequisition in project opennms by OpenNMS.
the class Requisition method insertNode.
/**
* <p>insertNode</p>
*
* @param node a {@link org.opennms.netmgt.provision.persist.requisition.RequisitionNode} object.
*/
public void insertNode(final RequisitionNode node) {
updateNodeCacheIfNecessary();
if (m_nodeReqs.containsKey(node.getForeignId())) {
final RequisitionNode n = m_nodeReqs.get(node.getForeignId()).getNode();
m_nodes.remove(n);
}
m_nodes.add(0, node);
m_nodeReqs.put(node.getForeignId(), new OnmsNodeRequisition(getForeignSource(), node));
}
use of org.opennms.netmgt.provision.persist.OnmsNodeRequisition in project opennms by OpenNMS.
the class Requisition method visit.
/**
* <p>visit</p>
*
* @param visitor a {@link org.opennms.netmgt.provision.persist.RequisitionVisitor} object.
*/
public void visit(final RequisitionVisitor visitor) {
updateNodeCacheIfNecessary();
if (visitor == null) {
LOG.warn("no visitor specified!");
return;
}
visitor.visitModelImport(this);
for (final OnmsNodeRequisition nodeReq : m_nodeReqs.values()) {
nodeReq.visit(visitor);
}
visitor.completeModelImport(this);
}
use of org.opennms.netmgt.provision.persist.OnmsNodeRequisition in project opennms by OpenNMS.
the class DefaultProvisionService method getRequisitionedNode.
/** {@inheritDoc} */
@Transactional
@Override
public OnmsNode getRequisitionedNode(final String foreignSource, final String foreignId) throws ForeignSourceRepositoryException {
OnmsNodeRequisition nodeReq = null;
try {
nodeReq = m_foreignSourceRepository.getNodeRequisition(foreignSource, foreignId);
} catch (ForeignSourceRepositoryException e) {
// just fall through, nodeReq will be null
}
if (nodeReq == null) {
LOG.warn("nodeReq for node {}:{} cannot be null!", foreignSource, foreignId);
return null;
}
final OnmsNode node = nodeReq.constructOnmsNodeFromRequisition();
// fill in real database categories
final HashSet<OnmsCategory> dbCategories = new HashSet<OnmsCategory>();
for (final OnmsCategory category : node.getCategories()) {
dbCategories.add(createCategoryIfNecessary(category.getName()));
}
node.setCategories(dbCategories);
if (node.getLocation() == null || Strings.isNullOrEmpty(node.getLocation().getLocationName())) {
node.setLocation(m_monitoringLocationDao.getDefaultLocation());
}
// fill in real service types
node.visit(new ServiceTypeFulfiller());
return node;
}
Aggregations