Search in sources :

Example 1 with LifeCycleInstance

use of org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance in project opennms by OpenNMS.

the class CoreImportActivities method scanNodes.

@Activity(lifecycle = "import", phase = "scan", schedulingHint = "import")
public static void scanNodes(final Phase currentPhase, final ImportOperationsManager opsMgr, final RequisitionImport ri) {
    if (ri.isAborted()) {
        info("The import has been aborted, skipping scan phase import.");
        return;
    }
    info("Scheduling nodes for phase {}", currentPhase);
    final Collection<ImportOperation> operations = opsMgr.getOperations();
    for (final ImportOperation op : operations) {
        final LifeCycleInstance nodeScan = currentPhase.createNestedLifeCycle("nodeImport");
        debug("Created lifecycle {} for operation {}", nodeScan, op);
        nodeScan.setAttribute("operation", op);
        nodeScan.setAttribute("requisitionImport", ri);
        nodeScan.trigger();
    }
}
Also used : LifeCycleInstance(org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance) ImportOperation(org.opennms.netmgt.provision.service.operations.ImportOperation) Activity(org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)

Example 2 with LifeCycleInstance

use of org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance in project opennms by OpenNMS.

the class Provisioner method importModelFromResource.

/**
     * <p>importModelFromResource</p>
     *
     * @param resource a {@link org.springframework.core.io.Resource} object.
     * @param rescanExisting TODO
     * @param monitor a {@link org.opennms.netmgt.provision.service.operations.ProvisionMonitor} object.
     * @throws java.lang.Exception if any.
     */
protected void importModelFromResource(final Resource resource, final String rescanExisting, final ProvisionMonitor monitor) throws Exception {
    final LifeCycleInstance doImport = m_lifeCycleRepository.createLifeCycleInstance("import", m_importActivities);
    doImport.setAttribute("resource", resource);
    doImport.setAttribute("rescanExisting", rescanExisting);
    doImport.trigger();
    doImport.waitFor();
    final RequisitionImport ri = doImport.findAttributeByType(RequisitionImport.class);
    if (ri.isAborted()) {
        throw new ModelImportException("Import failed for resource " + resource.toString(), ri.getError());
    }
}
Also used : LifeCycleInstance(org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance) RequisitionImport(org.opennms.netmgt.provision.service.operations.RequisitionImport)

Aggregations

LifeCycleInstance (org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance)2 Activity (org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)1 ImportOperation (org.opennms.netmgt.provision.service.operations.ImportOperation)1 RequisitionImport (org.opennms.netmgt.provision.service.operations.RequisitionImport)1