--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-subsystem</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ <relativePath>../../opendaylight/config/</relativePath>
+ </parent>
+ <artifactId>config-netty-features</artifactId>
+
+ <packaging>pom</packaging>
+
+ <properties>
+ <features.file>features.xml</features.file>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-persister-features</artifactId>
+ <version>${config.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<features name="odl-config-persister-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ 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">
+ <repository>mvn:org.opendaylight.controller/config-persister-features/${config.version}/xml/features</repository>
+ <feature name='odl-config-netty' version='${project.version}'>
+ <feature version='${project.version}'>odl-config-netty-config-api</feature>
+ <bundle>mvn:org.opendaylight.controller/netty-event-executor-config/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/netty-timer-config/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/threadpool-config-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/threadpool-config-impl/${project.version}</bundle>
+ <feature version='${project.version}'>odl-config-startup</feature>
+ </feature>
+</features>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-subsystem</artifactId>
+ <version>0.2.5-SNAPSHOT</version>
+ <relativePath>../../opendaylight/config/</relativePath>
+ </parent>
+ <artifactId>config-persister-features</artifactId>
+
+ <packaging>pom</packaging>
+
+ <properties>
+ <features.file>features.xml</features.file>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <version>${yangtools.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>netconf-features</artifactId>
+ <version>${netconf.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-features</artifactId>
+ <version>${config.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <filtering>true</filtering>
+ <directory>src/main/resources</directory>
+ </resource>
+ </resources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-resources-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>filter</id>
+ <goals>
+ <goal>resources</goal>
+ </goals>
+ <phase>generate-resources</phase>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>build-helper-maven-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>attach-artifacts</id>
+ <goals>
+ <goal>attach-artifact</goal>
+ </goals>
+ <phase>package</phase>
+ <configuration>
+ <artifacts>
+ <artifact>
+ <file>${project.build.directory}/classes/${features.file}</file>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </artifact>
+ </artifacts>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ <scm>
+ <connection>scm:git:ssh://git.opendaylight.org:29418/controller.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/controller.git</developerConnection>
+ <tag>HEAD</tag>
+ <url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
+ </scm>
+</project>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+
+<features name="odl-config-persister-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.2.0"
+ 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">
+ <repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/netconf-features/${netconf.version}/xml/features</repository>
+ <repository>mvn:org.opendaylight.controller/config-features/${config.version}/xml/features</repository>
+ <feature name='odl-config-startup' version='${project.version}'>
+ <feature version='${project.version}'>odl-config-netconf-connector</feature>
+ <feature version='${project.version}'>odl-config-persister</feature>
+ <feature version='${project.version}'>odl-netconf-impl</feature>
+ </feature>
+ <feature name='odl-config-persister' version='${project.version}'>
+ <feature version='${netconf.version}'>odl-netconf-api</feature>
+ <feature version='${project.version}'>odl-config-api</feature>
+ <feature version='${yangtools.version}'>yangtools-binding-generator</feature>
+ <bundle>mvn:org.opendaylight.controller/config-persister-api/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/config-persister-directory-xml-adapter/${project.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/config-persister-impl/${project.version}</bundle>
+
+ <bundle>mvn:org.opendaylight.controller/netconf-util/${netconf.version}</bundle>
+ <bundle>mvn:org.opendaylight.controller/netconf-mapping-api/${netconf.version}</bundle>
+
+ <bundle>mvn:com.google.guava/guava/${guava.version}</bundle>
+ <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
+ <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
+ <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version}</bundle>
+ <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
+ </feature>
+</features>
\ No newline at end of file
<features.file>features.xml</features.file>
</properties>
- <dependencies></dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.yangtools</groupId>
+ <artifactId>features-yangtools</artifactId>
+ <version>${yangtools.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
<build>
<resources>
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">
<repository>mvn:org.opendaylight.yangtools/features-yangtools/${yangtools.version}/xml/features</repository>
- <repository>mvn:org.opendaylight.controller/netconf-features/${netconf.version}/xml/features</repository>
-
- <feature name='odl-config-startup' version='${project.version}'>
- <feature version='${project.version}'>odl-config-netconf-connector</feature>
- <feature version='${project.version}'>odl-config-persister</feature>
- <feature version='${project.version}'>odl-netconf-impl</feature>
- </feature>
<feature name='odl-config-core' version='${project.version}'>
<feature version='${yangtools.version}'>yangtools-concepts</feature>
<feature version='${project.version}'>odl-config-core</feature>
<bundle>mvn:org.opendaylight.controller/config-manager/${project.version}</bundle>
</feature>
- <feature name='odl-config-persister' version='${project.version}'>
- <feature version='${netconf.version}'>odl-netconf-api</feature>
- <feature version='${project.version}'>odl-config-api</feature>
- <feature version='${yangtools.version}'>yangtools-binding-generator</feature>
- <bundle>mvn:org.opendaylight.controller/config-persister-api/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/config-persister-file-xml-adapter/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/config-persister-directory-xml-adapter/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/config-persister-impl/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-util/${netconf.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netconf-mapping-api/${netconf.version}</bundle>
-
- <bundle>mvn:com.google.guava/guava/${guava.version}</bundle>
- <bundle>mvn:commons-io/commons-io/${commons.io.version}</bundle>
- <bundle>mvn:org.apache.commons/commons-lang3/${commons.lang3.version}</bundle>
- <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.core/${eclipse.persistence.version}</bundle>
- <bundle>mvn:org.eclipse.persistence/org.eclipse.persistence.moxy/${eclipse.persistence.version}</bundle>
- </feature>
<feature name='odl-config-api' version='${project.version}'>
<bundle>mvn:org.opendaylight.controller/config-api/${project.version}</bundle>
<feature version='${project.version}'>odl-config-api</feature>
</feature>
- <feature name='odl-config-netty' version='${project.version}'>
- <feature version='${project.version}'>odl-config-netty-config-api</feature>
- <bundle>mvn:org.opendaylight.controller/netty-event-executor-config/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netty-threadgroup-config/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/netty-timer-config/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/threadpool-config-api/${project.version}</bundle>
- <bundle>mvn:org.opendaylight.controller/threadpool-config-impl/${project.version}</bundle>
- <feature version='${project.version}'>odl-config-startup</feature>
- </feature>
<feature name='odl-config-dispatcher' version='${project.version}'>
<bundle>mvn:org.opendaylight.controller/netconf-config-dispatcher/${project.version}</bundle>
</feature>
<features.file>features.xml</features.file>
</properties>
- <dependencies></dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-features</artifactId>
+ <version>${config.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>features-odl-protocol-framework</artifactId>
+ <version>${protocol-framework.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
<build>
<resources>
</prerequisites>
<modules>
<module>config</module>
+ <module>config-persister</module>
+ <module>config-netty</module>
<module>mdsal</module>
<module>netconf</module>
<module>protocol-framework</module>
<features.file>features.xml</features.file>
</properties>
- <dependencies></dependencies>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>config-features</artifactId>
+ <version>${config.version}</version>
+ <classifier>features</classifier>
+ <type>xml</type>
+ <scope>runtime</scope>
+ </dependency>
+ </dependencies>
<build>
<resources>
</dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
- <artifactId>features-odl-protocol-framework</artifactId>
- <version>${protocol-framework.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>netconf-features</artifactId>
- <version>${netconf.version}</version>
- <classifier>features</classifier>
- <type>xml</type>
- <scope>runtime</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>config-features</artifactId>
+ <artifactId>config-netty-features</artifactId>
<version>${config.version}</version>
<classifier>features</classifier>
<type>xml</type>
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;
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<String> predicate;
+ private final int skipLength;
+
+ ParameterMatcher(final String name) {
+ predicate = new Predicate<String>() {
+ @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<String> capabilities;
+ private String from(final Iterable<String> params) {
+ final Optional<String> 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<String> CONTAINS_REVISION = new Predicate<String>() {
+ @Override
+ public boolean apply(final String input) {
+ return input.contains("revision=");
+ }
+ };
private final Set<QName> moduleBasedCaps;
+ private final Set<String> capabilities;
private NetconfSessionCapabilities(final Set<String> capabilities, final Set<QName> moduleBasedCaps) {
- this.capabilities = capabilities;
- this.moduleBasedCaps = moduleBasedCaps;
+ this.capabilities = Preconditions.checkNotNull(capabilities);
+ this.moduleBasedCaps = Preconditions.checkNotNull(moduleBasedCaps);
}
public Set<QName> getModuleBasedCaps() {
}
public static NetconfSessionCapabilities fromStrings(final Collection<String> capabilities) {
- final Set<QName> moduleBasedCaps = Sets.newHashSet();
+ final Set<QName> moduleBasedCaps = new HashSet<>();
for (final String capability : capabilities) {
- if(isModuleBasedCapability(capability)) {
- final String[] parts = capability.split("\\?");
- final String namespace = parts[0];
- final FluentIterable<String> 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<String> 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<String> queryParams, final String match,
- final String substringToRemove) {
- final Optional<String> found = Iterables.tryFind(queryParams, new Predicate<String>() {
- @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));
+ }
}
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;
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;
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 {
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 ) {
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