public static boolean isErrorMessage(NetconfMessage message) throws NetconfDocumentedException { return isErrorMessage(message.getDocument()); }
public static boolean isOKMessage(Document document) throws NetconfDocumentedException { return isOKMessage(XmlElement.fromDomDocument(document)); }
@Override public void channelRead(final ChannelHandlerContext ctx, final Object msg) throws Exception { ctx.pipeline().remove(ExiConfirmationInboundHandler.EXI_CONFIRMED_HANDLER); NetconfMessage netconfMessage = (NetconfMessage) msg; // Ok response to start-exi, try to add exi handlers if (NetconfMessageUtil.isOKMessage(netconfMessage)) { LOG.trace("Positive response on start-exi call received on session {}", session); try { session.startExiCommunication(startExiMessage); } catch (RuntimeException e) { // Unable to add exi, continue without exi LOG.warn("Unable to start exi communication, Communication will continue without exi on session {}", session, e); } // Error response } else if(NetconfMessageUtil.isErrorMessage(netconfMessage)) { LOG.warn( "Error response to start-exi message {}, Communication will continue without exi on session {}", netconfMessage, session); // Unexpected response to start-exi, throwing message away, continue without exi } else { LOG.warn("Unexpected response to start-exi message, should be ok, was {}, " + "Communication will continue without exi and response message will be thrown away on session {}", netconfMessage, session); } negotiationSuccessful(session); } }
@Override protected NetconfClientSession getSession(final NetconfClientSessionListener sessionListener, final Channel channel, final NetconfHelloMessage message) throws NetconfDocumentedException { long sessionId = extractSessionId(message.getDocument()); // Copy here is important: it disconnects the strings from the document Collection<String> capabilities = ImmutableList.copyOf(NetconfMessageUtil.extractCapabilitiesFromHello(message.getDocument())); // FIXME: scalability: we could instantiate a cache to share the same collections return new NetconfClientSession(sessionListener, channel, sessionId, capabilities); }
public static boolean isErrorMessage(Document document) throws NetconfDocumentedException { return isErrorMessage(XmlElement.fromDomDocument(document)); }
public static boolean isOKMessage(NetconfMessage message) throws NetconfDocumentedException { return isOKMessage(message.getDocument()); }
public static void checkSuccessReply(final NetconfMessage output) throws NetconfDocumentedException { if(NetconfMessageUtil.isErrorMessage(output)) { throw NetconfDocumentedException.fromXMLDocument(output.getDocument()); } }