@Test public void executeRequest() { GetRequest req = new GetRequest(); listener.executeRequest(client, req, resp); assertTrue(resp.isOk()); }
public void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response) { try { String responseString = executeNC(clientInfo, request.requestToString()); Document document = DocumentUtils.stringToDocument(responseString); NetConfResponse netconfResponse = DocumentToPojoTransformer.getNetconfResponse(document); response.setMessageId(request.getMessageId()); response.addErrors(netconfResponse.getErrors()); response.setOk(netconfResponse.isOk()); if ((response instanceof NetconfRpcResponse) && (netconfResponse instanceof NetconfRpcResponse)) { for (Element element : ((NetconfRpcResponse)netconfResponse).getRpcOutputElements()) { ((NetconfRpcResponse)response).addRpcOutputElement(element); } } else { response.setData(netconfResponse.getData()); } } catch (NetconfMessageBuilderException | DispatchException e) { LOGGER.info("Exec netconf request failed : %s", e); response.addError(NetconfRpcErrorUtil.getApplicationError(NetconfRpcErrorTag.OPERATION_FAILED, "Error while executing netconf message - " + e.getMessage())); } }
NbiNetconfServerMessageListener implements NetconfServerMessageListener { public void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response) { try { String responseString = executeNC(clientInfo, request.requestToString()); Document document = DocumentUtils.stringToDocument(responseString); NetConfResponse netconfResponse = DocumentToPojoTransformer.getNetconfResponse(document); response.setMessageId(request.getMessageId()); response.addErrors(netconfResponse.getErrors()); response.setOk(netconfResponse.isOk()); if ((response instanceof NetconfRpcResponse) && (netconfResponse instanceof NetconfRpcResponse)) { for (Element element : ((NetconfRpcResponse)netconfResponse).getRpcOutputElements()) { ((NetconfRpcResponse)response).addRpcOutputElement(element); } } else { response.setData(netconfResponse.getData()); } } catch (NetconfMessageBuilderException | DispatchException e) { LOGGER.info("Exec netconf request failed : %s", e); response.addError(NetconfRpcErrorUtil.getApplicationError(NetconfRpcErrorTag.OPERATION_FAILED, "Error while executing netconf message - " + e.getMessage())); } } }
NbiNetconfServerMessageListener implements NetconfServerMessageListener { public void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response) { try { String responseString = executeNC(clientInfo, request.requestToString()); Document document = DocumentUtils.stringToDocument(responseString); NetConfResponse netconfResponse = DocumentToPojoTransformer.getNetconfResponse(document); response.setMessageId(request.getMessageId()); response.addErrors(netconfResponse.getErrors()); response.setOk(netconfResponse.isOk()); if ((response instanceof NetconfRpcResponse) && (netconfResponse instanceof NetconfRpcResponse)) { for (Element element : ((NetconfRpcResponse)netconfResponse).getRpcOutputElements()) { ((NetconfRpcResponse)response).addRpcOutputElement(element); } } else { response.setData(netconfResponse.getData()); } } catch (NetconfMessageBuilderException | DispatchException e) { LOGGER.info("Exec netconf request failed : %s", e); response.addError(NetconfRpcErrorUtil.getApplicationError(NetconfRpcErrorTag.OPERATION_FAILED, "Error while executing netconf message - " + e.getMessage())); } } NbiNetconfServerMessageListener(NetconfServer coreNetconfServer, Aggregator aggregator); }
NbiNetconfServerMessageListener implements NetconfServerMessageListener { public void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response) { try { String responseString = executeNC(clientInfo, request.requestToString()); Document document = DocumentUtils.stringToDocument(responseString); NetConfResponse netconfResponse = DocumentToPojoTransformer.getNetconfResponse(document); response.setMessageId(request.getMessageId()); response.addErrors(netconfResponse.getErrors()); response.setOk(netconfResponse.isOk()); if ((response instanceof NetconfRpcResponse) && (netconfResponse instanceof NetconfRpcResponse)) { for (Element element : ((NetconfRpcResponse)netconfResponse).getRpcOutputElements()) { ((NetconfRpcResponse)response).addRpcOutputElement(element); } } else { response.setData(netconfResponse.getData()); } } catch (NetconfMessageBuilderException | DispatchException e) { LOGGER.info("Exec netconf request failed : %s", e); response.addError(NetconfRpcErrorUtil.getApplicationError(NetconfRpcErrorTag.OPERATION_FAILED, "Error while executing netconf message - " + e.getMessage())); } } NbiNetconfServerMessageListener(NetconfServer coreNetconfServer, Aggregator aggregator); String executeNC(NetconfClientInfo clientInfo, String netconfRequest); void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response); @Override void onHello(NetconfClientInfo info, Set<String> clientCaps); @Override void onGet(NetconfClientInfo info, GetRequest req, NetConfResponse resp); @Override void onGetConfig(NetconfClientInfo info, GetConfigRequest req, NetConfResponse resp); @Override List<Notification> onEditConfig(NetconfClientInfo info, EditConfigRequest req, NetConfResponse resp); @Override void onCopyConfig(NetconfClientInfo info, CopyConfigRequest req, NetConfResponse resp); @Override void onDeleteConfig(NetconfClientInfo info, DeleteConfigRequest req, NetConfResponse resp); @Override void onLock(NetconfClientInfo info, LockRequest req, NetConfResponse resp); @Override void onUnlock(NetconfClientInfo info, UnLockRequest req, NetConfResponse resp); @Override void onCloseSession(NetconfClientInfo info, CloseSessionRequest req, NetConfResponse resp); @Override void onKillSession(NetconfClientInfo info, KillSessionRequest req, NetConfResponse resp); @Override void onInvalidRequest(NetconfClientInfo info, Document req, NetConfResponse resp); @Override void sessionClosed(String arg0, int sessionId); @Override List<Notification> onRpc(NetconfClientInfo info, NetconfRpcRequest rpcRequest, NetconfRpcResponse response); @Override void onCreateSubscription(NetconfClientInfo info, NetconfRpcRequest req, ResponseChannel responseChannel); @Override void onAction(NetconfClientInfo info, ActionRequest req, ActionResponse resp); }
NbiNetconfServerMessageListener implements NetconfServerMessageListener { public void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response) { try { String responseString = executeNC(clientInfo, request.requestToString()); Document document = DocumentUtils.stringToDocument(responseString); NetConfResponse netconfResponse = DocumentToPojoTransformer.getNetconfResponse(document); response.setMessageId(request.getMessageId()); response.addErrors(netconfResponse.getErrors()); response.setOk(netconfResponse.isOk()); if ((response instanceof NetconfRpcResponse) && (netconfResponse instanceof NetconfRpcResponse)) { for (Element element : ((NetconfRpcResponse)netconfResponse).getRpcOutputElements()) { ((NetconfRpcResponse)response).addRpcOutputElement(element); } } else { response.setData(netconfResponse.getData()); } } catch (NetconfMessageBuilderException | DispatchException e) { LOGGER.info("Exec netconf request failed : %s", e); response.addError(NetconfRpcErrorUtil.getApplicationError(NetconfRpcErrorTag.OPERATION_FAILED, "Error while executing netconf message - " + e.getMessage())); } } NbiNetconfServerMessageListener(NetconfServer coreNetconfServer, Aggregator aggregator); String executeNC(NetconfClientInfo clientInfo, String netconfRequest); void executeRequest(NetconfClientInfo clientInfo, AbstractNetconfRequest request, NetConfResponse response); @Override void onHello(NetconfClientInfo info, Set<String> clientCaps); @Override void onGet(NetconfClientInfo info, GetRequest req, NetConfResponse resp); @Override void onGetConfig(NetconfClientInfo info, GetConfigRequest req, NetConfResponse resp); @Override List<Notification> onEditConfig(NetconfClientInfo info, EditConfigRequest req, NetConfResponse resp); @Override void onCopyConfig(NetconfClientInfo info, CopyConfigRequest req, NetConfResponse resp); @Override void onDeleteConfig(NetconfClientInfo info, DeleteConfigRequest req, NetConfResponse resp); @Override void onLock(NetconfClientInfo info, LockRequest req, NetConfResponse resp); @Override void onUnlock(NetconfClientInfo info, UnLockRequest req, NetConfResponse resp); @Override void onCloseSession(NetconfClientInfo info, CloseSessionRequest req, NetConfResponse resp); @Override void onKillSession(NetconfClientInfo info, KillSessionRequest req, NetConfResponse resp); @Override void onInvalidRequest(NetconfClientInfo info, Document req, NetConfResponse resp); @Override void sessionClosed(String arg0, int sessionId); @Override List<Notification> onRpc(NetconfClientInfo info, NetconfRpcRequest rpcRequest, NetconfRpcResponse response); @Override void onCreateSubscription(NetconfClientInfo info, NetconfRpcRequest req, ResponseChannel responseChannel); @Override void onAction(NetconfClientInfo info, ActionRequest req, ActionResponse resp);  }