Search in sources :

Example 16 with Requisition

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());
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 17 with Requisition

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());
}
Also used : Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Test(org.junit.Test)

Example 18 with Requisition

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;
}
Also used : File(java.io.File) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Before(org.junit.Before)

Example 19 with Requisition

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;
}
Also used : ExecutionException(java.util.concurrent.ExecutionException) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) TimeoutException(java.util.concurrent.TimeoutException)

Example 20 with Requisition

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;
}
Also used : OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) ImportOperationsManager(org.opennms.netmgt.provision.service.operations.ImportOperationsManager) Activity(org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)

Aggregations

Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)70 Test (org.junit.Test)31 RequisitionNode (org.opennms.netmgt.provision.persist.requisition.RequisitionNode)16 ForeignSource (org.opennms.netmgt.provision.persist.foreignsource.ForeignSource)11 RequisitionInterface (org.opennms.netmgt.provision.persist.requisition.RequisitionInterface)11 UrlResource (org.springframework.core.io.UrlResource)10 File (java.io.File)9 OnmsNodeRequisition (org.opennms.netmgt.provision.persist.OnmsNodeRequisition)8 Resource (org.springframework.core.io.Resource)8 IOException (java.io.IOException)6 RequisitionCategory (org.opennms.netmgt.provision.persist.requisition.RequisitionCategory)6 ArrayList (java.util.ArrayList)5 TreeSet (java.util.TreeSet)5 InetAddress (java.net.InetAddress)4 MalformedURLException (java.net.MalformedURLException)4 URL (java.net.URL)4 FileSystemResource (org.springframework.core.io.FileSystemResource)4 InputStream (java.io.InputStream)3 RemoteException (java.rmi.RemoteException)3 Date (java.util.Date)3