@Test @Transactional @JUnitHttpServer(port=7081,basicAuth=true) @Ignore public void testAdd() throws Exception { OnmsNode n = m_nodeDao.findByForeignId("rancid", "1"); m_adapter.addNode(n.getId()); m_adapter.processPendingOperationForNode(m_addOperation); Thread.sleep(3000); }
@Override public void processPendingOperationForNode(final AdapterOperation op) throws ProvisioningAdapterException { log().debug("processPendingOperationForNode: " + op.getType() + " for node: " + op.getNodeId() ); if (op.getType() == AdapterOperationType.ADD) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.UPDATE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.DELETE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.CONFIG_CHANGE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); return null; } }); } }
RancidProvisioningAdapter extends SimpleQueuedProvisioningAdapter implements InitializingBean { @Override public void processPendingOperationForNode(final AdapterOperation op) throws ProvisioningAdapterException { log().debug("processPendingOperationForNode: " + op.getType() + " for node: " + op.getNodeId() ); if (op.getType() == AdapterOperationType.ADD) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.UPDATE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.DELETE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.CONFIG_CHANGE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); return null; } }); } } }
RancidProvisioningAdapter extends SimpleQueuedProvisioningAdapter implements InitializingBean { @Override public void processPendingOperationForNode(final AdapterOperation op) throws ProvisioningAdapterException { log().debug("processPendingOperationForNode: " + op.getType() + " for node: " + op.getNodeId() ); if (op.getType() == AdapterOperationType.ADD) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.UPDATE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.DELETE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.CONFIG_CHANGE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); return null; } }); } }  }
RancidProvisioningAdapter extends SimpleQueuedProvisioningAdapter implements InitializingBean { @Override public void processPendingOperationForNode(final AdapterOperation op) throws ProvisioningAdapterException { log().debug("processPendingOperationForNode: " + op.getType() + " for node: " + op.getNodeId() ); if (op.getType() == AdapterOperationType.ADD) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.UPDATE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.DELETE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.CONFIG_CHANGE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); return null; } }); } }  TransactionTemplate getTemplate(); void setTemplate(TransactionTemplate template); @Override void afterPropertiesSet(); void doAdd(int nodeId, ConnectionProperties cp, boolean retry); void doUpdate(int nodeId, ConnectionProperties cp, boolean retry); void doDelete(int nodeId,ConnectionProperties cp, boolean retry); void doNodeConfigChanged(int nodeId,ConnectionProperties cp, boolean retry); NodeDao getNodeDao(); void setNodeDao(NodeDao dao); void setEventForwarder(EventForwarder eventForwarder); EventForwarder getEventForwarder(); RWSConfig getRwsConfig(); void setRwsConfig(RWSConfig rwsConfig); RancidAdapterConfig getRancidAdapterConfig(); void setRancidAdapterConfig(RancidAdapterConfig rancidAdapterConfig); String getName(); @Override boolean isNodeReady(final AdapterOperation op); @Override void processPendingOperationForNode(final AdapterOperation op); @EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI) void handleReloadConfigEvent(Event event); @EventHandler(uei = EventConstants.RANCID_DOWNLOAD_FAILURE_UEI) void handleRancidDownLoadFailure(Event e); @EventHandler(uei = EventConstants.RANCID_DOWNLOAD_SUCCESS_UEI) void handleRancidDownLoadSuccess(Event e); @EventHandler(uei = EventConstants.RANCID_GROUP_PROCESSING_COMPLETED_UEI) void handleRancidGroupProcessingCompleted(Event e); }
RancidProvisioningAdapter extends SimpleQueuedProvisioningAdapter implements InitializingBean { @Override public void processPendingOperationForNode(final AdapterOperation op) throws ProvisioningAdapterException { log().debug("processPendingOperationForNode: " + op.getType() + " for node: " + op.getNodeId() ); if (op.getType() == AdapterOperationType.ADD) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.UPDATE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.DELETE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); return null; } }); } else if (op.getType() == AdapterOperationType.CONFIG_CHANGE) { m_template.execute(new TransactionCallback<Object>() { public Object doInTransaction(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); return null; } }); } }  TransactionTemplate getTemplate(); void setTemplate(TransactionTemplate template); @Override void afterPropertiesSet(); void doAdd(int nodeId, ConnectionProperties cp, boolean retry); void doUpdate(int nodeId, ConnectionProperties cp, boolean retry); void doDelete(int nodeId,ConnectionProperties cp, boolean retry); void doNodeConfigChanged(int nodeId,ConnectionProperties cp, boolean retry); NodeDao getNodeDao(); void setNodeDao(NodeDao dao); void setEventForwarder(EventForwarder eventForwarder); EventForwarder getEventForwarder(); RWSConfig getRwsConfig(); void setRwsConfig(RWSConfig rwsConfig); RancidAdapterConfig getRancidAdapterConfig(); void setRancidAdapterConfig(RancidAdapterConfig rancidAdapterConfig); String getName(); @Override boolean isNodeReady(final AdapterOperation op); @Override void processPendingOperationForNode(final AdapterOperation op); @EventHandler(uei = EventConstants.RELOAD_DAEMON_CONFIG_UEI) void handleReloadConfigEvent(Event event); @EventHandler(uei = EventConstants.RANCID_DOWNLOAD_FAILURE_UEI) void handleRancidDownLoadFailure(Event e); @EventHandler(uei = EventConstants.RANCID_DOWNLOAD_SUCCESS_UEI) void handleRancidDownLoadSuccess(Event e); @EventHandler(uei = EventConstants.RANCID_GROUP_PROCESSING_COMPLETED_UEI) void handleRancidGroupProcessingCompleted(Event e); static final String NAME; }