use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class QueueingForeignSourceRepositoryTest method testRequisition.
@Test
public void testRequisition() throws Exception {
createRequisition();
Requisition r = m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName);
TestVisitor v = new TestVisitor();
r.visit(v);
assertEquals("number of nodes visited", 2, v.getNodeReqs().size());
assertEquals("node name matches", "apknd", v.getNodeReqs().get(0).getNodeLabel());
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class MockForeignSourceRepositoryTest method testRequisition.
@Test
public void testRequisition() throws Exception {
createRequisition();
Requisition r = m_foreignSourceRepository.getRequisition(m_defaultForeignSourceName);
TestVisitor v = new TestVisitor();
r.visit(v);
assertEquals("number of nodes visited", 2, v.getNodeReqs().size());
assertEquals("node name matches", "apknd", v.getNodeReqs().get(0).getNodeLabel());
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class RequisitionFileUtilsTest method createTestRepository.
@Before
public void createTestRepository() throws Exception {
m_requisitionDirectory = Files.createTempDirectory("RequisitionFileUtilsTest");
if (m_requisitionDirectory.toFile().exists()) {
FileUtils.deleteDirectory(m_requisitionDirectory.toFile());
}
final FilesystemForeignSourceRepository fsr = new FilesystemForeignSourceRepository();
m_importDirectory = new File(m_requisitionDirectory.toFile(), "imports").getPath();
m_foreignSourceDirectory = new File(m_requisitionDirectory.toFile(), "foreign-sources").getPath();
fsr.setRequisitionPath(m_importDirectory);
fsr.setForeignSourcePath(m_foreignSourceDirectory);
fsr.afterPropertiesSet();
fsr.save(new Requisition("test"));
m_repository = fsr;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class ShowImport method doExecute.
@Override
protected Object doExecute() throws Exception {
final CompletableFuture<Requisition> future = client.requisition().withRequisitionProviderType(type).withParameters(parse(parameters)).withLocation(location).withTimeToLive(ttlInMs).execute();
while (true) {
try {
try {
Requisition requisition = future.get(1, TimeUnit.SECONDS);
if (xmlOutput) {
return JaxbUtils.marshal(requisition);
} else {
return requisition;
}
} catch (InterruptedException e) {
System.out.println("\nInterrupted.");
} catch (ExecutionException e) {
System.out.printf("\nRequisition retrieval failed with: %s\n", e);
}
break;
} catch (TimeoutException e) {
// pass
}
System.out.print(".");
System.out.flush();
}
return null;
}
use of org.opennms.netmgt.provision.persist.requisition.Requisition in project opennms by OpenNMS.
the class CoreImportActivities method auditNodes.
@Activity(lifecycle = "import", phase = "audit", schedulingHint = "import")
public ImportOperationsManager auditNodes(final RequisitionImport ri, final String rescanExisting) {
if (ri.isAborted()) {
info("The import has been aborted, skipping audit phase import.");
return null;
}
final Requisition specFile = ri.getRequisition();
info("Auditing nodes for requisition {}. The parameter {} was set to {} during import.", specFile, EventConstants.PARM_IMPORT_RESCAN_EXISTING, rescanExisting);
final String foreignSource = specFile.getForeignSource();
final Map<String, Integer> foreignIdsToNodes = m_provisionService.getForeignIdToNodeIdMap(foreignSource);
final ImportOperationsManager opsMgr = new ImportOperationsManager(foreignIdsToNodes, m_provisionService, rescanExisting);
opsMgr.setForeignSource(foreignSource);
opsMgr.auditNodes(specFile);
debug("Finished auditing nodes.");
return opsMgr;
}
Aggregations