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();
}
}
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;
}
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;
}
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");
}
Aggregations