X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fnetconf%2Fnetconf-client%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fnetconf%2Fclient%2FNetconfClientSessionNegotiatorFactory.java;h=4c5fd1d1ec040ef6218e36d619c47409cddbb8d8;hb=b2e81149739c87f0ecc2ce7f06448d7a5d3162b8;hp=ac13729d885fbf5b83ff21d4e9a90e91ab2dfa64;hpb=c6e3620a5b02b3993cd0ae7539f5cd0fecf4ba8d;p=controller.git diff --git a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java index ac13729d88..4c5fd1d1ec 100644 --- a/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java +++ b/opendaylight/netconf/netconf-client/src/main/java/org/opendaylight/controller/netconf/client/NetconfClientSessionNegotiatorFactory.java @@ -33,11 +33,22 @@ import org.slf4j.LoggerFactory; public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorFactory { - public static final Set CLIENT_CAPABILITIES = ImmutableSet.of( + public static final Set EXI_CLIENT_CAPABILITIES = ImmutableSet.of( XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0, XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1, XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_EXI_1_0); + public static final Set LEGACY_EXI_CLIENT_CAPABILITIES = ImmutableSet.of( + XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0, + XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_EXI_1_0); + + public static final Set DEFAULT_CLIENT_CAPABILITIES = ImmutableSet.of( + XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0, + XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_1); + + public static final Set LEGACY_FRAMING_CLIENT_CAPABILITIES = ImmutableSet.of( + XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_BASE_1_0); + private static final Logger LOG = LoggerFactory.getLogger(NetconfClientSessionNegotiatorFactory.class); private static final String START_EXI_MESSAGE_ID = "default-start-exi"; private static final EXIOptions DEFAULT_OPTIONS; @@ -61,19 +72,35 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF DEFAULT_OPTIONS = opts; } + private final Set clientCapabilities; + public NetconfClientSessionNegotiatorFactory(final Timer timer, final Optional additionalHeader, final long connectionTimeoutMillis) { this(timer, additionalHeader, connectionTimeoutMillis, DEFAULT_OPTIONS); } + public NetconfClientSessionNegotiatorFactory(final Timer timer, + final Optional additionalHeader, + final long connectionTimeoutMillis, final Set capabilities) { + this(timer, additionalHeader, connectionTimeoutMillis, DEFAULT_OPTIONS, capabilities); + + } + public NetconfClientSessionNegotiatorFactory(final Timer timer, final Optional additionalHeader, final long connectionTimeoutMillis, final EXIOptions exiOptions) { + this(timer, additionalHeader, connectionTimeoutMillis, exiOptions, EXI_CLIENT_CAPABILITIES); + } + + public NetconfClientSessionNegotiatorFactory(final Timer timer, + final Optional additionalHeader, + final long connectionTimeoutMillis, final EXIOptions exiOptions, final Set capabilities) { this.timer = Preconditions.checkNotNull(timer); this.additionalHeader = additionalHeader; this.connectionTimeoutMillis = connectionTimeoutMillis; this.options = exiOptions; + this.clientCapabilities = capabilities; } @Override @@ -84,9 +111,9 @@ public class NetconfClientSessionNegotiatorFactory implements SessionNegotiatorF NetconfMessage startExiMessage = NetconfStartExiMessage.create(options, START_EXI_MESSAGE_ID); NetconfHelloMessage helloMessage = null; try { - helloMessage = NetconfHelloMessage.createClientHello(CLIENT_CAPABILITIES, additionalHeader); + helloMessage = NetconfHelloMessage.createClientHello(clientCapabilities, additionalHeader); } catch (NetconfDocumentedException e) { - LOG.error("Unable to create client hello message with capabilities {} and additional handler {}",CLIENT_CAPABILITIES,additionalHeader); + LOG.error("Unable to create client hello message with capabilities {} and additional handler {}", clientCapabilities,additionalHeader); throw new IllegalStateException(e); }