From: Tony Tkacik Date: Wed, 23 Jul 2014 05:41:39 +0000 (+0000) Subject: Merge "NormalizedNode Mount APIs." X-Git-Tag: release/helium~454 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=commitdiff_plain;h=2f1946537e63cc66950d4359b77fd49dbe1bdea3;hp=a2f734db3ee72f6074e50e950408264779dabcc5 Merge "NormalizedNode Mount APIs." --- diff --git a/features/config-netty/pom.xml b/features/config-netty/pom.xml new file mode 100644 index 0000000000..98b97d1d95 --- /dev/null +++ b/features/config-netty/pom.xml @@ -0,0 +1,80 @@ + + + 4.0.0 + + org.opendaylight.controller + config-subsystem + 0.2.5-SNAPSHOT + ../../opendaylight/config/ + + config-netty-features + + pom + + + features.xml + + + + + org.opendaylight.controller + config-persister-features + ${config.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + diff --git a/features/config-netty/src/main/resources/features.xml b/features/config-netty/src/main/resources/features.xml new file mode 100644 index 0000000000..3121ca01a2 --- /dev/null +++ b/features/config-netty/src/main/resources/features.xml @@ -0,0 +1,16 @@ + + + + mvn:org.opendaylight.controller/config-persister-features/${config.version}/xml/features + + odl-config-netty-config-api + mvn:org.opendaylight.controller/netty-event-executor-config/${project.version} + mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version} + mvn:org.opendaylight.controller/netty-timer-config/${project.version} + mvn:org.opendaylight.controller/threadpool-config-api/${project.version} + mvn:org.opendaylight.controller/threadpool-config-impl/${project.version} + odl-config-startup + + \ No newline at end of file diff --git a/features/config-persister/pom.xml b/features/config-persister/pom.xml new file mode 100644 index 0000000000..969d0c8841 --- /dev/null +++ b/features/config-persister/pom.xml @@ -0,0 +1,96 @@ + + + 4.0.0 + + org.opendaylight.controller + config-subsystem + 0.2.5-SNAPSHOT + ../../opendaylight/config/ + + config-persister-features + + pom + + + features.xml + + + + + org.opendaylight.yangtools + features-yangtools + ${yangtools.version} + features + xml + runtime + + + org.opendaylight.controller + netconf-features + ${netconf.version} + features + xml + runtime + + + org.opendaylight.controller + config-features + ${config.version} + features + xml + runtime + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + + scm:git:ssh://git.opendaylight.org:29418/controller.git + scm:git:ssh://git.opendaylight.org:29418/controller.git + HEAD + https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL + + diff --git a/features/config-persister/src/main/resources/features.xml b/features/config-persister/src/main/resources/features.xml new file mode 100644 index 0000000000..2273a4a309 --- /dev/null +++ b/features/config-persister/src/main/resources/features.xml @@ -0,0 +1,32 @@ + + + + mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features + mvn:org.opendaylight.controller/netconf-features/${netconf.version}/xml/features + mvn:org.opendaylight.controller/config-features/${config.version}/xml/features + + odl-config-netconf-connector + odl-config-persister + odl-netconf-impl + + + odl-netconf-api + odl-config-api + yangtools-binding-generator + mvn:org.opendaylight.controller/config-persister-api/${project.version} + mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version} + mvn:org.opendaylight.controller/config-persister-directory-xml-adapter/${project.version} + mvn:org.opendaylight.controller/config-persister-impl/${project.version} + + mvn:org.opendaylight.controller/netconf-util/${netconf.version} + mvn:org.opendaylight.controller/netconf-mapping-api/${netconf.version} + + mvn:com.google.guava/guava/${guava.version} + mvn:commons-io/commons-io/${commons.io.version} + mvn:org.apache.commons/commons-lang3/${commons.lang3.version} + mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version} + mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version} + + \ No newline at end of file diff --git a/features/config/pom.xml b/features/config/pom.xml index 01a4ea74a2..7e5dd6472b 100644 --- a/features/config/pom.xml +++ b/features/config/pom.xml @@ -15,7 +15,16 @@ features.xml - + + + org.opendaylight.yangtools + features-yangtools + ${yangtools.version} + features + xml + runtime + + diff --git a/features/config/src/main/resources/features.xml b/features/config/src/main/resources/features.xml index 7c11b5b18b..e18f844622 100644 --- a/features/config/src/main/resources/features.xml +++ b/features/config/src/main/resources/features.xml @@ -4,13 +4,6 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://karaf.apache.org/xmlns/features/v1.2.0 http://karaf.apache.org/xmlns/features/v1.2.0"> mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features - mvn:org.opendaylight.controller/netconf-features/${netconf.version}/xml/features - - - odl-config-netconf-connector - odl-config-persister - odl-netconf-impl - yangtools-concepts @@ -30,24 +23,7 @@ odl-config-core mvn:org.opendaylight.controller/config-manager/${project.version} - - odl-netconf-api - odl-config-api - yangtools-binding-generator - mvn:org.opendaylight.controller/config-persister-api/${project.version} - mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version} - mvn:org.opendaylight.controller/config-persister-directory-xml-adapter/${project.version} - mvn:org.opendaylight.controller/config-persister-impl/${project.version} - mvn:org.opendaylight.controller/netconf-util/${netconf.version} - mvn:org.opendaylight.controller/netconf-mapping-api/${netconf.version} - - mvn:com.google.guava/guava/${guava.version} - mvn:commons-io/commons-io/${commons.io.version} - mvn:org.apache.commons/commons-lang3/${commons.lang3.version} - mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version} - mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version} - mvn:org.opendaylight.controller/config-api/${project.version} @@ -66,15 +42,6 @@ odl-config-api - - odl-config-netty-config-api - mvn:org.opendaylight.controller/netty-event-executor-config/${project.version} - mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version} - mvn:org.opendaylight.controller/netty-timer-config/${project.version} - mvn:org.opendaylight.controller/threadpool-config-api/${project.version} - mvn:org.opendaylight.controller/threadpool-config-impl/${project.version} - odl-config-startup - mvn:org.opendaylight.controller/netconf-config-dispatcher/${project.version} diff --git a/features/netconf/pom.xml b/features/netconf/pom.xml index 457fc64edd..90c088eaba 100644 --- a/features/netconf/pom.xml +++ b/features/netconf/pom.xml @@ -15,7 +15,24 @@ features.xml - + + + org.opendaylight.controller + config-features + ${config.version} + features + xml + runtime + + + org.opendaylight.controller + features-odl-protocol-framework + ${protocol-framework.version} + features + xml + runtime + + diff --git a/features/pom.xml b/features/pom.xml index dce47faea6..fb40fa93b1 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -14,6 +14,8 @@ config + config-persister + config-netty mdsal netconf protocol-framework diff --git a/features/protocol-framework/pom.xml b/features/protocol-framework/pom.xml index f0208d6452..045ac2dffe 100644 --- a/features/protocol-framework/pom.xml +++ b/features/protocol-framework/pom.xml @@ -15,7 +15,16 @@ features.xml - + + + org.opendaylight.controller + config-features + ${config.version} + features + xml + runtime + + diff --git a/opendaylight/distribution/opendaylight-karaf/pom.xml b/opendaylight/distribution/opendaylight-karaf/pom.xml index 4ef0b8e86b..efb7a374f3 100644 --- a/opendaylight/distribution/opendaylight-karaf/pom.xml +++ b/opendaylight/distribution/opendaylight-karaf/pom.xml @@ -63,23 +63,7 @@ org.opendaylight.controller - features-odl-protocol-framework - ${protocol-framework.version} - features - xml - runtime - - - org.opendaylight.controller - netconf-features - ${netconf.version} - features - xml - runtime - - - org.opendaylight.controller - config-features + config-netty-features ${config.version} features xml diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfSessionCapabilities.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfSessionCapabilities.java index 82903ea4ec..8964a80228 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfSessionCapabilities.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/listener/NetconfSessionCapabilities.java @@ -1,7 +1,15 @@ package org.opendaylight.controller.sal.connect.netconf.listener; -import java.util.Arrays; +import com.google.common.base.Objects; +import com.google.common.base.Optional; +import com.google.common.base.Preconditions; +import com.google.common.base.Predicate; +import com.google.common.base.Splitter; +import com.google.common.collect.ImmutableSet; +import com.google.common.collect.Iterables; + import java.util.Collection; +import java.util.HashSet; import java.util.Set; import org.opendaylight.controller.netconf.client.NetconfClientSession; @@ -10,24 +18,50 @@ import org.opendaylight.yangtools.yang.common.QName; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.google.common.base.Objects; -import com.google.common.base.Optional; -import com.google.common.base.Predicate; -import com.google.common.collect.FluentIterable; -import com.google.common.collect.Iterables; -import com.google.common.collect.Sets; - public final class NetconfSessionCapabilities { + private static final class ParameterMatcher { + private final Predicate predicate; + private final int skipLength; + + ParameterMatcher(final String name) { + predicate = new Predicate() { + @Override + public boolean apply(final String input) { + return input.startsWith(name); + } + }; - private static final Logger logger = LoggerFactory.getLogger(NetconfSessionCapabilities.class); + this.skipLength = name.length(); + } - private final Set capabilities; + private String from(final Iterable params) { + final Optional o = Iterables.tryFind(params, predicate); + if (!o.isPresent()) { + return null; + } + + return o.get().substring(skipLength); + } + } + + private static final Logger LOG = LoggerFactory.getLogger(NetconfSessionCapabilities.class); + private static final ParameterMatcher MODULE_PARAM = new ParameterMatcher("module="); + private static final ParameterMatcher REVISION_PARAM = new ParameterMatcher("revision="); + private static final ParameterMatcher BROKEN_REVISON_PARAM = new ParameterMatcher("amp;revision="); + private static final Splitter AMP_SPLITTER = Splitter.on('&'); + private static final Predicate CONTAINS_REVISION = new Predicate() { + @Override + public boolean apply(final String input) { + return input.contains("revision="); + } + }; private final Set moduleBasedCaps; + private final Set capabilities; private NetconfSessionCapabilities(final Set capabilities, final Set moduleBasedCaps) { - this.capabilities = capabilities; - this.moduleBasedCaps = moduleBasedCaps; + this.capabilities = Preconditions.checkNotNull(capabilities); + this.moduleBasedCaps = Preconditions.checkNotNull(moduleBasedCaps); } public Set getModuleBasedCaps() { @@ -65,47 +99,45 @@ public final class NetconfSessionCapabilities { } public static NetconfSessionCapabilities fromStrings(final Collection capabilities) { - final Set moduleBasedCaps = Sets.newHashSet(); + final Set moduleBasedCaps = new HashSet<>(); for (final String capability : capabilities) { - if(isModuleBasedCapability(capability)) { - final String[] parts = capability.split("\\?"); - final String namespace = parts[0]; - final FluentIterable queryParams = FluentIterable.from(Arrays.asList(parts[1].split("&"))); - - String revision = getStringAndTransform(queryParams, "revision=", "revision="); - - final String moduleName = getStringAndTransform(queryParams, "module=", "module="); + final int qmark = capability.indexOf('?'); + if (qmark == -1) { + continue; + } - if (revision == null) { - logger.debug("Netconf device was not reporting revision correctly, trying to get amp;revision="); - revision = getStringAndTransform(queryParams, "amp;revision=", "amp;revision="); + final String namespace = capability.substring(0, qmark); + final Iterable queryParams = AMP_SPLITTER.split(capability.substring(qmark + 1)); + final String moduleName = MODULE_PARAM.from(queryParams); + if (moduleName == null) { + continue; + } - if (revision == null) { - logger.warn("Netconf device returned revision incorrectly escaped for {}", capability); - } - } + String revision = REVISION_PARAM.from(queryParams); + if (revision != null) { moduleBasedCaps.add(QName.create(namespace, revision, moduleName)); + continue; } - } - - return new NetconfSessionCapabilities(Sets.newHashSet(capabilities), moduleBasedCaps); - } - private static boolean isModuleBasedCapability(final String capability) { - return capability.contains("?") && capability.contains("module=") && capability.contains("revision="); - } + /* + * We have seen devices which mis-escape revision, but the revision may not + * even be there. First check if there is a substring that matches revision. + */ + if (!Iterables.any(queryParams, CONTAINS_REVISION)) { + continue; + } - private static String getStringAndTransform(final Iterable queryParams, final String match, - final String substringToRemove) { - final Optional found = Iterables.tryFind(queryParams, new Predicate() { - @Override - public boolean apply(final String input) { - return input.startsWith(match); + LOG.debug("Netconf device was not reporting revision correctly, trying to get amp;revision="); + revision = BROKEN_REVISON_PARAM.from(queryParams); + if (revision == null) { + LOG.warn("Netconf device returned revision incorrectly escaped for {}, ignoring it", capability); } - }); - return found.isPresent() ? found.get().replaceAll(substringToRemove, "") : null; - } + // FIXME: do we really want to continue here? + moduleBasedCaps.add(QName.create(namespace, revision, moduleName)); + } + return new NetconfSessionCapabilities(ImmutableSet.copyOf(capabilities), ImmutableSet.copyOf(moduleBasedCaps)); + } } diff --git a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java index 0aeec64690..3ec3eb1633 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/main/java/org/opendaylight/controller/sal/connect/netconf/util/NetconfMessageTransformUtil.java @@ -12,7 +12,6 @@ import com.google.common.collect.Collections2; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import com.google.common.collect.Iterables; -import com.google.common.collect.Lists; import com.google.common.collect.Sets; import java.net.URI; @@ -29,8 +28,8 @@ import org.opendaylight.controller.netconf.api.NetconfMessage; import org.opendaylight.controller.netconf.util.messages.NetconfMessageUtil; import org.opendaylight.yangtools.yang.common.QName; import org.opendaylight.yangtools.yang.common.RpcError; -import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.common.RpcError.ErrorSeverity; +import org.opendaylight.yangtools.yang.common.RpcResultBuilder; import org.opendaylight.yangtools.yang.data.api.CompositeNode; import org.opendaylight.yangtools.yang.data.api.InstanceIdentifier; import org.opendaylight.yangtools.yang.data.api.Node; @@ -81,8 +80,7 @@ public class NetconfMessageTransformUtil { return null; } - for (final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument component : Lists - .reverse(identifier.getPath())) { + for (final org.opendaylight.yangtools.yang.data.api.InstanceIdentifier.PathArgument component : identifier.getReversePathArguments()) { if (component instanceof InstanceIdentifier.NodeIdentifierWithPredicates) { previous = toNode((InstanceIdentifier.NodeIdentifierWithPredicates)component, previous); } else { @@ -142,12 +140,12 @@ public class NetconfMessageTransformUtil { ErrorSeverity severity = toRpcErrorSeverity( ex.getErrorSeverity() ); return severity == ErrorSeverity.ERROR ? - RpcResultBuilder.newError( + RpcResultBuilder.newError( toRpcErrorType( ex.getErrorType() ), ex.getErrorTag().getTagValue(), ex.getLocalizedMessage(), null, infoBuilder.toString(), ex.getCause() ) : - RpcResultBuilder.newWarning( - toRpcErrorType( ex.getErrorType() ), ex.getErrorTag().getTagValue(), - ex.getLocalizedMessage(), null, infoBuilder.toString(), ex.getCause() ); + RpcResultBuilder.newWarning( + toRpcErrorType( ex.getErrorType() ), ex.getErrorTag().getTagValue(), + ex.getLocalizedMessage(), null, infoBuilder.toString(), ex.getCause() ); } private static ErrorSeverity toRpcErrorSeverity( final NetconfDocumentedException.ErrorSeverity severity ) { diff --git a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java index defaab629f..46ea4ff73c 100644 --- a/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java +++ b/opendaylight/md-sal/sal-netconf-connector/src/test/java/org/opendaylight/controller/sal/connect/netconf/NetconfDeviceTest.java @@ -102,11 +102,11 @@ public class NetconfDeviceTest { device.onRemoteSessionUp(sessionCaps, listener); verify(messageTransformer, timeout(10000).times(2)).toNotification(netconfMessage); - verify(facade, times(2)).onNotification(compositeNode); + verify(facade, timeout(10000).times(2)).onNotification(compositeNode); device.onNotification(netconfMessage); - verify(messageTransformer, times(3)).toNotification(netconfMessage); - verify(facade, times(3)).onNotification(compositeNode); + verify(messageTransformer, timeout(10000).times(3)).toNotification(netconfMessage); + verify(facade, timeout(10000).times(3)).onNotification(compositeNode); } @Test