@Override public void doInTransactionWithoutResult(TransactionStatus arg0) { doAdd(op.getNodeId(),m_cp,true); } });
@Override public void doInTransactionWithoutResult(TransactionStatus arg0) { doDelete(op.getNodeId(),m_cp,true); } });
@Override public void doInTransactionWithoutResult(TransactionStatus arg0) { doNodeConfigChanged(op.getNodeId(),m_cp,true); } });
/** * <p>afterPropertiesSet</p> * * @throws java.lang.Exception if any. */ @Override public void afterPropertiesSet() throws Exception { RWSClientApi.init(); Assert.notNull(m_rwsConfig, "Rancid Provisioning Adapter requires RWSConfig property to be set."); m_cp = getRWSConnection(); Assert.notNull(m_nodeDao, "Rancid Provisioning Adapter requires nodeDao property to be set."); getRancidCategories(); m_template.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus arg0) { buildRancidNodeMap(); } }); }
private void buildRancidNodeMap() { if (!isAdapterConfigured()) { LOG.info("RANCID is not configured. Skipping node map generation."); return; } List<OnmsNode> nodes = m_nodeDao.findAllProvisionedNodes(); m_onmsNodeRancidNodeMap = new ConcurrentHashMap<Integer, RancidNode>(nodes.size()); m_onmsNodeIpMap = new ConcurrentHashMap<Integer, String>(nodes.size()); for (OnmsNode onmsNode : nodes) { String ipaddr = getSuitableIpForRancid(onmsNode); if (ipaddr != null) m_onmsNodeIpMap.putIfAbsent(onmsNode.getId(), ipaddr); RancidNode rNode = getSuitableRancidNode(onmsNode); if (rNode != null) { m_onmsNodeRancidNodeMap.putIfAbsent(onmsNode.getId(), rNode); } } }
private void updateConfiguration(int nodeid, RancidNode rNode,ConnectionProperties cp, boolean retry) throws ProvisioningAdapterException { LOG.debug("updateConfiguration: Updating Rancid Router.db configuration for node: {} type: {} group: {}", rNode.getDeviceName(), rNode.getDeviceType(),rNode.getGroup()); try { RWSClientApi.updateRWSRancidNode(cp, rNode); } catch (Throwable e) { cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("updateConfiguration: retry update on standByConn: {}", cp.getUrl()); updateConfiguration(nodeid, rNode, cp, false); } else { sendAndThrow(nodeid, e); } } }
if (! isAdapterConfigured()) { return; RancidNode rUpdatedNode = getSuitableRancidNode(node); LOG.debug("doUpdate: found updated Node : {}", rUpdatedNode); if ( updateAuth(rUpdatedNode.getAuth(), rRemoteNodeAuth) ) { LOG.debug("doUpdate: updating authentication data"); try { } catch (RancidApiException e) { LOG.error("doUpdate: Failed to create node: {} Exception: {}", e.getMessage(), nodeId); sendAndThrow(nodeId, e); cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doUpdate: retry Update on standByConn: {}", cp.getUrl()); doUpdate(nodeId, cp, false); } else { sendAndThrow(nodeId, re); doDelete(nodeId, cp, retry); } catch (RancidApiException e) { LOG.error("doUpdate: Failed to create node: {} Exception: {}", e.getMessage(), nodeId); sendAndThrow(nodeId, e);
if (! isAdapterConfigured()) { return; RancidNode rNode = getSuitableRancidNode(node); rNode.setStateUp(true); LOG.error("doAdd: Error Duplicate node: {}", node); ProvisioningAdapterException e = new ProvisioningAdapterException("Duplicate node has been added: "+node); sendAndThrow(nodeId, e); return; sendAndThrow(nodeId, ae); } catch (Throwable e) { cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doAdd: retry Add on standByConn: {}", cp.getUrl()); doAdd(nodeId, cp, false); } else { sendAndThrow(nodeId, e);
if (! isAdapterConfigured()) { return; cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doDelete: retry Delete on standByConn: {}", cp.getUrl()); doDelete(nodeId, cp, false); } else { sendAndThrow(nodeId, e);
private void getRancidCategories() { if (!isAdapterConfigured()) { LOG.info("RANCID is not configured. Skipping category initialization."); return; } try { m_rancid_categories = RWSClientApi.getRWSResourceDeviceTypesPatternList(m_cp).getResource(); } catch (RancidApiException e) { ConnectionProperties cp = getStandByRWSConnection(); if (cp != null) { try { m_rancid_categories = RWSClientApi.getRWSResourceDeviceTypesPatternList(m_cp).getResource(); } catch (RancidApiException e1) { LOG.warn("getRancidCategories: not able to retrieve rancid categories from RWS server"); m_rancid_categories = new ArrayList<>(); m_rancid_categories.add("cisco"); LOG.warn("getRancidCategories: setting categories list to 'cisco'"); } } } }
if (isReloadConfigEventTarget(event)) { EventBuilder ebldr = null; LOG.debug("reloading the rancid adapter configuration"); getEventForwarder().sendNow(ebldr.getEvent());
@Override public void doInTransactionWithoutResult(TransactionStatus arg0) { doUpdate(op.getNodeId(),m_cp,true); } });
private void sendAndThrow(int nodeId, Throwable e) { LOG.debug("sendAndThrow: error working on nodeid: {}", nodeId); LOG.debug("sendAndThrow: Exception: {}", e.getMessage()); Event event = buildEvent(EventConstants.PROVISIONING_ADAPTER_FAILED, nodeId).addParam("reason", MESSAGE_PREFIX+e.getLocalizedMessage()).getEvent(); m_eventForwarder.sendNow(event); throw new ProvisioningAdapterException(MESSAGE_PREFIX, e); }
if (! isAdapterConfigured()) { return; RancidNode rUpdatedNode = getSuitableRancidNode(node); LOG.debug("doUpdate: found updated Node : {}", rUpdatedNode); if ( updateAuth(rUpdatedNode.getAuth(), rRemoteNodeAuth) ) { LOG.debug("doUpdate: updating authentication data"); try { } catch (RancidApiException e) { LOG.error("doUpdate: Failed to create node: {} Exception: {}", e.getMessage(), nodeId); sendAndThrow(nodeId, e); cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doUpdate: retry Update on standByConn: {}", cp.getUrl()); doUpdate(nodeId, cp, false); } else { sendAndThrow(nodeId, re); doDelete(nodeId, cp, retry); } catch (RancidApiException e) { LOG.error("doUpdate: Failed to create node: {} Exception: {}", e.getMessage(), nodeId); sendAndThrow(nodeId, e);
if (! isAdapterConfigured()) { return; RancidNode rNode = getSuitableRancidNode(node); rNode.setStateUp(true); LOG.error("doAdd: Error Duplicate node: {}", node); ProvisioningAdapterException e = new ProvisioningAdapterException("Duplicate node has been added: "+node); sendAndThrow(nodeId, e); return; sendAndThrow(nodeId, ae); } catch (Throwable e) { cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doAdd: retry Add on standByConn: {}", cp.getUrl()); doAdd(nodeId, cp, false); } else { sendAndThrow(nodeId, e);
if (! isAdapterConfigured()) { return; cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("doDelete: retry Delete on standByConn: {}", cp.getUrl()); doDelete(nodeId, cp, false); } else { sendAndThrow(nodeId, e);
private void updateConfiguration(int nodeid, RancidNode rNode,ConnectionProperties cp, boolean retry) throws ProvisioningAdapterException { LOG.debug("updateConfiguration: Updating Rancid Router.db configuration for node: {} type: {} group: {}", rNode.getDeviceName(), rNode.getDeviceType(),rNode.getGroup()); try { RWSClientApi.updateRWSRancidNode(cp, rNode); } catch (Throwable e) { cp = getStandByRWSConnection(); if (retry && cp != null) { LOG.info("updateConfiguration: retry update on standByConn: {}", cp.getUrl()); updateConfiguration(nodeid, rNode, cp, false); } else { sendAndThrow(nodeid, e); } } }
private void buildRancidNodeMap() { if (!isAdapterConfigured()) { LOG.info("RANCID is not configured. Skipping node map generation."); return; } List<OnmsNode> nodes = m_nodeDao.findAllProvisionedNodes(); m_onmsNodeRancidNodeMap = new ConcurrentHashMap<Integer, RancidNode>(nodes.size()); m_onmsNodeIpMap = new ConcurrentHashMap<Integer, String>(nodes.size()); for (OnmsNode onmsNode : nodes) { String ipaddr = getSuitableIpForRancid(onmsNode); if (ipaddr != null) m_onmsNodeIpMap.putIfAbsent(onmsNode.getId(), ipaddr); RancidNode rNode = getSuitableRancidNode(onmsNode); if (rNode != null) { m_onmsNodeRancidNodeMap.putIfAbsent(onmsNode.getId(), rNode); } } }
/** * <p>afterPropertiesSet</p> * * @throws java.lang.Exception if any. */ @Override public void afterPropertiesSet() throws Exception { RWSClientApi.init(); Assert.notNull(m_rwsConfig, "Rancid Provisioning Adapter requires RWSConfig property to be set."); m_cp = getRWSConnection(); Assert.notNull(m_nodeDao, "Rancid Provisioning Adapter requires nodeDao property to be set."); getRancidCategories(); m_template.execute(new TransactionCallbackWithoutResult() { @Override public void doInTransactionWithoutResult(TransactionStatus arg0) { buildRancidNodeMap(); } }); }
private void getRancidCategories() { if (!isAdapterConfigured()) { LOG.info("RANCID is not configured. Skipping category initialization."); return; } try { m_rancid_categories = RWSClientApi.getRWSResourceDeviceTypesPatternList(m_cp).getResource(); } catch (RancidApiException e) { ConnectionProperties cp = getStandByRWSConnection(); if (cp != null) { try { m_rancid_categories = RWSClientApi.getRWSResourceDeviceTypesPatternList(m_cp).getResource(); } catch (RancidApiException e1) { LOG.warn("getRancidCategories: not able to retrieve rancid categories from RWS server"); m_rancid_categories = new ArrayList<>(); m_rancid_categories.add("cisco"); LOG.warn("getRancidCategories: setting categories list to 'cisco'"); } } } }