Search in sources :

Example 1 with Activity

use of org.opennms.netmgt.provision.service.lifecycle.annotations.Activity 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 Activity

use of org.opennms.netmgt.provision.service.lifecycle.annotations.Activity 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)

Example 3 with Activity

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

the class CoreImportActivities method loadSpecFile.

@Activity(lifecycle = "import", phase = "validate", schedulingHint = "import")
public RequisitionImport loadSpecFile(final Resource resource) {
    final RequisitionImport ri = new RequisitionImport();
    info("Loading requisition from resource {}", resource);
    try {
        final Requisition specFile = m_provisionService.loadRequisition(resource);
        ri.setRequisition(specFile);
        debug("Finished loading requisition.");
    } catch (final Throwable t) {
        ri.abort(t);
    }
    return ri;
}
Also used : RequisitionImport(org.opennms.netmgt.provision.service.operations.RequisitionImport) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) Activity(org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)

Example 4 with Activity

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

the class CoreImportActivities method relateNodes.

@Activity(lifecycle = "import", phase = "relate", schedulingHint = "import")
public void relateNodes(final BatchTask currentPhase, final RequisitionImport ri) {
    if (ri.isAborted()) {
        info("The import has been aborted, skipping relate phase.");
        return;
    }
    info("Running relate phase");
    final Requisition requisition = ri.getRequisition();
    RequisitionVisitor visitor = new AbstractRequisitionVisitor() {

        @Override
        public void visitNode(final OnmsNodeRequisition nodeReq) {
            LOG.debug("Scheduling relate of node {}", nodeReq);
            currentPhase.add(parentSetter(m_provisionService, nodeReq, requisition.getForeignSource()));
        }
    };
    requisition.visit(visitor);
    LOG.info("Finished Running relate phase");
}
Also used : AbstractRequisitionVisitor(org.opennms.netmgt.provision.persist.AbstractRequisitionVisitor) RequisitionVisitor(org.opennms.netmgt.provision.persist.RequisitionVisitor) AbstractRequisitionVisitor(org.opennms.netmgt.provision.persist.AbstractRequisitionVisitor) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Requisition(org.opennms.netmgt.provision.persist.requisition.Requisition) OnmsNodeRequisition(org.opennms.netmgt.provision.persist.OnmsNodeRequisition) Activity(org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)

Aggregations

Activity (org.opennms.netmgt.provision.service.lifecycle.annotations.Activity)4 OnmsNodeRequisition (org.opennms.netmgt.provision.persist.OnmsNodeRequisition)3 Requisition (org.opennms.netmgt.provision.persist.requisition.Requisition)3 AbstractRequisitionVisitor (org.opennms.netmgt.provision.persist.AbstractRequisitionVisitor)1 RequisitionVisitor (org.opennms.netmgt.provision.persist.RequisitionVisitor)1 LifeCycleInstance (org.opennms.netmgt.provision.service.lifecycle.LifeCycleInstance)1 ImportOperation (org.opennms.netmgt.provision.service.operations.ImportOperation)1 ImportOperationsManager (org.opennms.netmgt.provision.service.operations.ImportOperationsManager)1 RequisitionImport (org.opennms.netmgt.provision.service.operations.RequisitionImport)1