<name>OpenDaylight :: MDSAL :: APIDOCS</name>
<dependencies>
+ <dependency>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odl-jackson-2.8</artifactId>
+ <version>3.1.0</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<artifactId>odl-restconf</artifactId>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018 Red Hat, Inc. and others.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+<features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+ <feature name="odl-mdsal-apidocs" version="${project.version}">
+ <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
+ </feature>
+</features>
<!-- TODO: Remove this when RESTCONF is converted to GSON -->
<dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-core</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-annotations</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.core</groupId>
- <artifactId>jackson-databind</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.datatype</groupId>
- <artifactId>jackson-datatype-json-org</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-base</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.jaxrs</groupId>
- <artifactId>jackson-jaxrs-json-provider</artifactId>
- </dependency>
- <dependency>
- <groupId>com.fasterxml.jackson.module</groupId>
- <artifactId>jackson-module-jaxb-annotations</artifactId>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odl-jackson-2.8</artifactId>
+ <version>3.1.0</version>
+ <type>xml</type>
+ <classifier>features</classifier>
</dependency>
</dependencies>
</project>
<features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
<feature name="odl-restconf-common" version="${project.version}">
<feature version="[3.0.0,4)">odl-karaf-feat-jetty</feature>
+ <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
<feature version="[2.0.1,3)">odl-yangtools-export</feature>
</feature>
</features>
<type>xml</type>
<classifier>features</classifier>
</dependency>
+
+ <dependency>
+ <groupId>org.opendaylight.odlparent</groupId>
+ <artifactId>odl-jackson-2.8</artifactId>
+ <version>3.1.0</version>
+ <type>xml</type>
+ <classifier>features</classifier>
+ </dependency>
</dependencies>
</project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Copyright © 2018 Red Hat, Inc. and others.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+<features name="odl-netconf-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0">
+ <feature name="odl-restconf" version="${project.version}">
+ <feature version="[3.1.0,4)">odl-jackson-2.8</feature>
+ </feature>
+</features>
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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.5.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.aaa</groupId>
- <artifactId>aaa-artifacts</artifactId>
- <version>0.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.aaa</groupId>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<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.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.netconf</groupId>
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import java.io.DataOutputStream;
import java.io.IOException;
import java.math.BigInteger;
+import java.nio.charset.StandardCharsets;
import java.security.GeneralSecurityException;
import java.security.KeyFactory;
import java.security.PublicKey;
// look for the Base64 encoded part of the line to decode
// both ssh-rsa and ssh-dss begin with "AAAA" due to the length bytes
- bytes = Base64.getDecoder().decode(keyLine.getBytes());
+ bytes = Base64.getDecoder().decode(keyLine.getBytes(StandardCharsets.UTF_8));
if (bytes.length == 0) {
throw new IllegalArgumentException("No Base64 part to decode in " + keyLine);
}
private String decodeType() {
int len = decodeInt();
- String type = new String(bytes, pos, len);
+ String type = new String(bytes, pos, len, StandardCharsets.UTF_8);
pos += len;
return type;
}
}
public static String encodePublicKey(final PublicKey publicKey) throws IOException {
- String publicKeyEncoded;
ByteArrayOutputStream byteOs = new ByteArrayOutputStream();
- if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_RSA)) {
+ if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_RSA) && publicKey instanceof RSAPublicKey) {
RSAPublicKey rsaPublicKey = (RSAPublicKey) publicKey;
DataOutputStream dout = new DataOutputStream(byteOs);
- dout.writeInt(KEY_TYPE_RSA.getBytes().length);
- dout.write(KEY_TYPE_RSA.getBytes());
+ dout.writeInt(KEY_TYPE_RSA.getBytes(StandardCharsets.UTF_8).length);
+ dout.write(KEY_TYPE_RSA.getBytes(StandardCharsets.UTF_8));
dout.writeInt(rsaPublicKey.getPublicExponent().toByteArray().length);
dout.write(rsaPublicKey.getPublicExponent().toByteArray());
dout.writeInt(rsaPublicKey.getModulus().toByteArray().length);
dout.write(rsaPublicKey.getModulus().toByteArray());
- } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_DSA)) {
+ } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_DSA) && publicKey instanceof DSAPublicKey) {
DSAPublicKey dsaPublicKey = (DSAPublicKey) publicKey;
DSAParams dsaParams = dsaPublicKey.getParams();
DataOutputStream dout = new DataOutputStream(byteOs);
- dout.writeInt(KEY_TYPE_DSA.getBytes().length);
- dout.write(KEY_TYPE_DSA.getBytes());
+ dout.writeInt(KEY_TYPE_DSA.getBytes(StandardCharsets.UTF_8).length);
+ dout.write(KEY_TYPE_DSA.getBytes(StandardCharsets.UTF_8));
dout.writeInt(dsaParams.getP().toByteArray().length);
dout.write(dsaParams.getP().toByteArray());
dout.writeInt(dsaParams.getQ().toByteArray().length);
dout.write(dsaParams.getG().toByteArray());
dout.writeInt(dsaPublicKey.getY().toByteArray().length);
dout.write(dsaPublicKey.getY().toByteArray());
- } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_ECDSA)) {
+ } else if (publicKey.getAlgorithm().equals(KEY_FACTORY_TYPE_ECDSA) && publicKey instanceof BCECPublicKey) {
BCECPublicKey ecPublicKey = (BCECPublicKey) publicKey;
DataOutputStream dout = new DataOutputStream(byteOs);
- dout.writeInt(KEY_TYPE_ECDSA.getBytes().length);
- dout.write(KEY_TYPE_ECDSA.getBytes());
- dout.writeInt(ECDSA_SUPPORTED_CURVE_NAME.getBytes().length);
- dout.write(ECDSA_SUPPORTED_CURVE_NAME.getBytes());
+ dout.writeInt(KEY_TYPE_ECDSA.getBytes(StandardCharsets.UTF_8).length);
+ dout.write(KEY_TYPE_ECDSA.getBytes(StandardCharsets.UTF_8));
+ dout.writeInt(ECDSA_SUPPORTED_CURVE_NAME.getBytes(StandardCharsets.UTF_8).length);
+ dout.write(ECDSA_SUPPORTED_CURVE_NAME.getBytes(StandardCharsets.UTF_8));
byte[] coordX = ecPublicKey.getQ().getAffineXCoord().getEncoded();
byte[] coordY = ecPublicKey.getQ().getAffineYCoord().getEncoded();
} else {
throw new IllegalArgumentException("Unknown public key encoding: " + publicKey.getAlgorithm());
}
- publicKeyEncoded = new String(Base64.getEncoder().encodeToString(byteOs.toByteArray()));
- return publicKeyEncoded;
+ return Base64.getEncoder().encodeToString(byteOs.toByteArray());
}
}
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.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.5.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>mockito-core</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import org.opendaylight.netconf.topology.api.SchemaRepositoryProvider;
abstract class BaseCallHomeTopology extends AbstractNetconfTopology {
-
- protected DOMMountPointService mountPointService = null;
-
BaseCallHomeTopology(final String topologyId, final NetconfClientDispatcher clientDispatcher,
final EventExecutor eventExecutor,
final ScheduledThreadPool keepaliveExecutor,
super(topologyId, clientDispatcher, eventExecutor, keepaliveExecutor,
processingExecutor, schemaRepositoryProvider, dataBroker, mountPointService,
encryptionService);
- this.mountPointService = mountPointService;
}
}
return remoteAddress.toString();
}
- private class DeviceConfig implements DataTreeChangeListener<Device> {
+ private static class DeviceConfig implements DataTreeChangeListener<Device> {
private final AuthorizedKeysDecoder keyDecoder = new AuthorizedKeysDecoder();
}
}
- private class DeviceOp implements DataTreeChangeListener<Device> {
+ private static class DeviceOp implements DataTreeChangeListener<Device> {
private final ConcurrentMap<String, Device> byPublicKey = new ConcurrentHashMap<>();
}
}
- private class GlobalConfig implements DataTreeChangeListener<Global> {
+ private static class GlobalConfig implements DataTreeChangeListener<Global> {
private volatile Global current = null;
}
}
- private final String path;
private Properties properties;
public Configuration() {
- path = "<no-path>";
properties = new Properties();
}
public Configuration(final String path) throws ConfigurationException {
- this.path = path;
try {
this.properties = readFromPath(path);
} catch (IOException ioe) {
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>2.5.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>yang-data-codec-xml</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.netconf.mapping.api.NetconfOperation;
import org.opendaylight.netconf.mdsal.connector.ops.Commit;
+import org.opendaylight.netconf.mdsal.connector.ops.CopyConfig;
import org.opendaylight.netconf.mdsal.connector.ops.DiscardChanges;
import org.opendaylight.netconf.mdsal.connector.ops.EditConfig;
import org.opendaylight.netconf.mdsal.connector.ops.Lock;
new Commit(netconfSessionIdForReporting, transactionProvider),
new DiscardChanges(netconfSessionIdForReporting, transactionProvider),
new EditConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
+ new CopyConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
new Get(netconfSessionIdForReporting, schemaContext, transactionProvider),
new GetConfig(netconfSessionIdForReporting, schemaContext, transactionProvider),
new Lock(netconfSessionIdForReporting),
--- /dev/null
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.mdsal.connector.ops;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Strings;
+import com.google.common.collect.ImmutableMap;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.util.Iterator;
+import java.util.Map;
+import javax.xml.transform.dom.DOMSource;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.netconf.api.NetconfDocumentedException;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.yangtools.yang.common.QName;
+import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
+import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+abstract class AbstractEdit extends AbstractSingletonNetconfOperation {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractEdit.class);
+ private static final String TARGET_KEY = "target";
+
+ protected final CurrentSchemaContext schemaContext;
+
+ protected AbstractEdit(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext) {
+ super(netconfSessionIdForReporting);
+ this.schemaContext = schemaContext;
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ protected void parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element,
+ final NormalizedNodeStreamWriter writer) throws DocumentedException {
+ if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
+ // This should never happen since any edit operation on any other node type
+ // should not be possible nor makes sense
+ LOG.debug("DataNode from module is not ContainerSchemaNode nor ListSchemaNode, aborting..");
+ throw new UnsupportedOperationException("implement exception if parse fails");
+ }
+
+ final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), schemaNode);
+ try {
+ xmlParser.traverse(new DOMSource(element.getDomElement()));
+ } catch (final Exception ex) {
+ throw new NetconfDocumentedException("Error parsing input: " + ex.getMessage(), ex, ErrorType.PROTOCOL,
+ ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
+ }
+ }
+
+ protected DataSchemaNode getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
+ throws DocumentedException {
+ final Iterator<Module> it;
+ try {
+ // Returns module with newest revision since findModuleByNamespace returns a set of modules and we only
+ // need the newest one
+ it = schemaContext.getCurrentContext().findModules(new URI(namespace)).iterator();
+ } catch (final URISyntaxException e) {
+ throw new NetconfDocumentedException("Unable to create URI for namespace : " + namespace, e,
+ ErrorType.APPLICATION, ErrorTag.INVALID_VALUE, ErrorSeverity.ERROR);
+ }
+
+ if (!it.hasNext()) {
+ // No module is present with this namespace
+ throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
+ ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
+ }
+
+ final Module module = it.next();
+ final java.util.Optional<DataSchemaNode> schemaNode =
+ module.findDataChildByName(QName.create(module.getQNameModule(), element.getName()));
+ if (!schemaNode.isPresent()) {
+ throw new DocumentedException(
+ "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
+ ErrorType.APPLICATION,
+ ErrorTag.UNKNOWN_NAMESPACE,
+ ErrorSeverity.ERROR);
+ }
+
+ return schemaNode.get();
+ }
+
+ protected static Datastore extractTargetParameter(final XmlElement operationElement, final String operationName)
+ throws DocumentedException {
+ final NodeList elementsByTagName = getElementsByTagName(operationElement, TARGET_KEY);
+ // Direct lookup instead of using XmlElement class due to performance
+ if (elementsByTagName.getLength() == 0) {
+ final Map<String, String> errorInfo = ImmutableMap.of("bad-attribute", TARGET_KEY, "bad-element",
+ operationName);
+ throw new DocumentedException("Missing target element", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
+ ErrorSeverity.ERROR, errorInfo);
+ } else if (elementsByTagName.getLength() > 1) {
+ throw new DocumentedException("Multiple target elements", ErrorType.RPC, ErrorTag.UNKNOWN_ATTRIBUTE,
+ ErrorSeverity.ERROR);
+ } else {
+ final XmlElement targetChildNode =
+ XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
+ return Datastore.valueOf(targetChildNode.getName());
+ }
+ }
+
+ protected static XmlElement getElement(final XmlElement parent, final String elementName)
+ throws DocumentedException {
+ final Optional<XmlElement> childNode = parent.getOnlyChildElementOptionally(elementName);
+ if (!childNode.isPresent()) {
+ throw new DocumentedException(elementName + " element is missing",
+ ErrorType.PROTOCOL,
+ ErrorTag.MISSING_ELEMENT,
+ ErrorSeverity.ERROR);
+ }
+
+ return childNode.get();
+ }
+
+ protected static NodeList getElementsByTagName(final XmlElement parent, final String key) throws
+ DocumentedException {
+ final Element domParent = parent.getDomElement();
+ final NodeList elementsByTagName;
+
+ if (Strings.isNullOrEmpty(domParent.getPrefix())) {
+ elementsByTagName = domParent.getElementsByTagName(key);
+ } else {
+ elementsByTagName = domParent.getElementsByTagNameNS(parent.getNamespace(), key);
+ }
+
+ return elementsByTagName;
+ }
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.mdsal.connector.ops;
+
+import com.google.common.base.Optional;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.controller.config.util.xml.XmlElement;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
+import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
+import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
+import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
+import org.opendaylight.yangtools.yang.data.impl.schema.ImmutableNormalizedNodeStreamWriter;
+import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
+import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+public final class CopyConfig extends AbstractEdit {
+ private static final String OPERATION_NAME = "copy-config";
+ private static final String CONFIG_KEY = "config";
+ private static final String SOURCE_KEY = "source";
+
+ // Top-level "data" node without child nodes
+ private static final ContainerNode EMPTY_ROOT_NODE = Builders.containerBuilder()
+ .withNodeIdentifier(new YangInstanceIdentifier.NodeIdentifier(SchemaContext.NAME)).build();
+
+ private final TransactionProvider transactionProvider;
+
+ public CopyConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
+ final TransactionProvider transactionProvider) {
+ super(netconfSessionIdForReporting, schemaContext);
+ this.transactionProvider = transactionProvider;
+ }
+
+ @Override
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
+ throws DocumentedException {
+ final Datastore targetDatastore = extractTargetParameter(operationElement, OPERATION_NAME);
+ if (targetDatastore == Datastore.running) {
+ throw new DocumentedException("edit-config on running datastore is not supported",
+ ErrorType.PROTOCOL,
+ ErrorTag.OPERATION_NOT_SUPPORTED,
+ ErrorSeverity.ERROR);
+ }
+ final XmlElement configElement = extractConfigParameter(operationElement);
+
+ // <copy-config>, unlike <edit-config>, always replaces entire configuration,
+ // so remove old configuration first:
+ final DOMDataReadWriteTransaction rwTx = transactionProvider.getOrCreateTransaction();
+ rwTx.put(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.EMPTY, EMPTY_ROOT_NODE);
+
+ // Then create nodes present in the <config> element:
+ for (final XmlElement element : configElement.getChildElements()) {
+ final String ns = element.getNamespace();
+ final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element);
+ final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
+ parseIntoNormalizedNode(schemaNode, element, ImmutableNormalizedNodeStreamWriter.from(resultHolder));
+ final NormalizedNode<?, ?> data = resultHolder.getResult();
+ final YangInstanceIdentifier path = YangInstanceIdentifier.create(data.getIdentifier());
+ // Doing merge instead of put to support top-level list:
+ rwTx.merge(LogicalDatastoreType.CONFIGURATION, path, data);
+ }
+ return XmlUtil.createElement(document, XmlNetconfConstants.OK, Optional.absent());
+ }
+
+ private static XmlElement extractConfigParameter(final XmlElement operationElement) throws DocumentedException {
+ final XmlElement source = getElement(operationElement, SOURCE_KEY);
+ return getElement(source, CONFIG_KEY);
+ }
+
+ @Override
+ protected String getOperationName() {
+ return OPERATION_NAME;
+ }
+}
package org.opendaylight.netconf.mdsal.connector.ops;
-import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.base.Strings;
-import com.google.common.collect.ImmutableMap;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
-import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
-import javax.xml.transform.dom.DOMSource;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
import org.opendaylight.controller.config.util.xml.XmlUtil;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
-import org.opendaylight.netconf.api.NetconfDocumentedException;
import org.opendaylight.netconf.api.xml.XmlNetconfConstants;
import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
import org.opendaylight.netconf.mdsal.connector.ops.DataTreeChangeTracker.DataTreeChange;
-import org.opendaylight.netconf.util.mapping.AbstractSingletonNetconfOperation;
-import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.ModifyAction;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.AugmentationNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
import org.opendaylight.yangtools.yang.data.api.schema.MapNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
-import org.opendaylight.yangtools.yang.data.api.schema.stream.NormalizedNodeStreamWriter;
-import org.opendaylight.yangtools.yang.data.codec.xml.XmlParserStream;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
import org.opendaylight.yangtools.yang.data.impl.schema.NormalizedNodeResult;
-import org.opendaylight.yangtools.yang.model.api.ContainerSchemaNode;
import org.opendaylight.yangtools.yang.model.api.DataSchemaNode;
import org.opendaylight.yangtools.yang.model.api.ListSchemaNode;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaNode;
import org.opendaylight.yangtools.yang.model.util.SchemaContextUtil;
import org.slf4j.Logger;
import org.w3c.dom.Element;
import org.w3c.dom.NodeList;
-public class EditConfig extends AbstractSingletonNetconfOperation {
+public final class EditConfig extends AbstractEdit {
private static final Logger LOG = LoggerFactory.getLogger(EditConfig.class);
private static final String OPERATION_NAME = "edit-config";
private static final String CONFIG_KEY = "config";
- private static final String TARGET_KEY = "target";
private static final String DEFAULT_OPERATION_KEY = "default-operation";
- private final CurrentSchemaContext schemaContext;
private final TransactionProvider transactionProvider;
public EditConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
final TransactionProvider transactionProvider) {
- super(netconfSessionIdForReporting);
- this.schemaContext = schemaContext;
+ super(netconfSessionIdForReporting, schemaContext);
this.transactionProvider = transactionProvider;
}
@Override
protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
throws DocumentedException {
- final Datastore targetDatastore = extractTargetParameter(operationElement);
+ final Datastore targetDatastore = extractTargetParameter(operationElement, OPERATION_NAME);
if (targetDatastore == Datastore.running) {
throw new DocumentedException("edit-config on running datastore is not supported",
ErrorType.PROTOCOL,
for (final XmlElement element : configElement.getChildElements()) {
final String ns = element.getNamespace();
- final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element).get();
-
+ final DataSchemaNode schemaNode = getSchemaNodeFromNamespace(ns, element);
final DataTreeChangeTracker changeTracker = new DataTreeChangeTracker(defaultAction);
-
- parseIntoNormalizedNode(schemaNode, element, changeTracker);
+ parseIntoNormalizedNode(schemaNode, element,
+ new EditOperationNormalizedNodeStreamWriter(new NormalizedNodeResult(), changeTracker));
executeOperations(changeTracker);
}
}
}
- @SuppressWarnings("checkstyle:IllegalCatch")
- private NormalizedNode<?, ?> parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element,
- final DataTreeChangeTracker changeTracker) throws DocumentedException {
- if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
- //this should never happen since edit-config on any other node type should not be possible nor makes sense
- LOG.debug("DataNode from module is not ContainerSchemaNode nor ListSchemaNode, aborting..");
- throw new UnsupportedOperationException("implement exception if parse fails");
- }
-
- final NormalizedNodeResult resultHolder = new NormalizedNodeResult();
- final NormalizedNodeStreamWriter writer = new EditOperationNormalizedNodeStreamWriter(resultHolder,
- changeTracker);
- final XmlParserStream xmlParser = XmlParserStream.create(writer, schemaContext.getCurrentContext(), schemaNode);
- try {
- xmlParser.traverse(new DOMSource(element.getDomElement()));
- } catch (final Exception ex) {
- throw new NetconfDocumentedException("Error parsing input: " + ex.getMessage(), ex, ErrorType.PROTOCOL,
- ErrorTag.MALFORMED_MESSAGE, ErrorSeverity.ERROR);
- }
-
- return resultHolder.getResult();
- }
-
- private Optional<DataSchemaNode> getSchemaNodeFromNamespace(final String namespace, final XmlElement element)
- throws DocumentedException {
- final Iterator<Module> it;
- try {
- // returns module with newest revision since findModuleByNamespace returns a set of modules and we only
- // need the newest one
- it = schemaContext.getCurrentContext().findModules(new URI(namespace)).iterator();
- } catch (final URISyntaxException e) {
- LOG.debug("Unable to create URI for namespace : {}", namespace);
- return Optional.absent();
- }
-
- if (!it.hasNext()) {
- // no module is present with this namespace
- throw new NetconfDocumentedException("Unable to find module by namespace: " + namespace,
- ErrorType.APPLICATION, ErrorTag.UNKNOWN_NAMESPACE, ErrorSeverity.ERROR);
- }
-
- final Module module = it.next();
- final java.util.Optional<DataSchemaNode> schemaNode =
- module.findDataChildByName(QName.create(module.getQNameModule(), element.getName()));
- if (!schemaNode.isPresent()) {
- if (schemaNode != null) {
- throw new DocumentedException(
- "Unable to find node with namespace: " + namespace + "in module: " + module.toString(),
- ErrorType.APPLICATION,
- ErrorTag.UNKNOWN_NAMESPACE,
- ErrorSeverity.ERROR);
- }
- }
-
- return Optional.fromJavaUtil(schemaNode);
- }
-
- private static Datastore extractTargetParameter(final XmlElement operationElement) throws DocumentedException {
- final NodeList elementsByTagName = getElementsByTagName(operationElement, TARGET_KEY);
- // Direct lookup instead of using XmlElement class due to performance
- if (elementsByTagName.getLength() == 0) {
- final Map<String, String> errorInfo = ImmutableMap.of("bad-attribute", TARGET_KEY, "bad-element",
- OPERATION_NAME);
- throw new DocumentedException("Missing target element", ErrorType.PROTOCOL, ErrorTag.MISSING_ATTRIBUTE,
- ErrorSeverity.ERROR, errorInfo);
- } else if (elementsByTagName.getLength() > 1) {
- throw new DocumentedException("Multiple target elements", ErrorType.RPC, ErrorTag.UNKNOWN_ATTRIBUTE,
- ErrorSeverity.ERROR);
- } else {
- final XmlElement targetChildNode =
- XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
- return Datastore.valueOf(targetChildNode.getName());
- }
- }
-
private static ModifyAction getDefaultOperation(final XmlElement operationElement) throws DocumentedException {
final NodeList elementsByTagName = getElementsByTagName(operationElement, DEFAULT_OPERATION_KEY);
if (elementsByTagName.getLength() == 0) {
}
- private static XmlElement getElement(final XmlElement operationElement, final String elementName)
- throws DocumentedException {
- final Optional<XmlElement> childNode = operationElement.getOnlyChildElementOptionally(elementName);
- if (!childNode.isPresent()) {
- throw new DocumentedException(elementName + " element is missing",
- ErrorType.PROTOCOL,
- ErrorTag.MISSING_ELEMENT,
- ErrorSeverity.ERROR);
- }
-
- return childNode.get();
- }
-
- @VisibleForTesting
- static NodeList getElementsByTagName(final XmlElement operationElement, final String key) throws
- DocumentedException {
- final Element element = operationElement.getDomElement();
- final NodeList elementsByTagName;
-
- if (Strings.isNullOrEmpty(element.getPrefix())) {
- elementsByTagName = element.getElementsByTagName(key);
- } else {
- elementsByTagName = element.getElementsByTagNameNS(operationElement.getNamespace(), key);
- }
-
- return elementsByTagName;
- }
-
@Override
protected String getOperationName() {
return OPERATION_NAME;
@Nullable
private NormalizedNode<?, ?> rpcToNNode(final XmlElement element, @Nullable final ContainerSchemaNode input)
throws DocumentedException {
- if (input.getChildNodes().isEmpty()) {
+ if (input == null || input.getChildNodes().isEmpty()) {
return null;
}
--- /dev/null
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.mdsal.connector.ops;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+
+import com.google.common.io.ByteSource;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.MoreExecutors;
+import java.io.StringWriter;
+import java.util.EnumMap;
+import java.util.concurrent.ExecutorService;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+import org.custommonkey.xmlunit.DetailedDiff;
+import org.custommonkey.xmlunit.Diff;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.junit.Before;
+import org.mockito.MockitoAnnotations;
+import org.opendaylight.controller.config.util.xml.XmlUtil;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
+import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.controller.sal.core.spi.data.DOMStore;
+import org.opendaylight.netconf.mapping.api.NetconfOperation;
+import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
+import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
+import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
+import org.opendaylight.netconf.mdsal.connector.ops.get.Get;
+import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
+import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
+import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+abstract class AbstractNetconfOperationTest {
+ private static final Logger LOG = LoggerFactory.getLogger(AbstractNetconfOperationTest.class);
+ protected static final String SESSION_ID_FOR_REPORTING = "netconf-test-session1";
+ private static final String RPC_REPLY_ELEMENT = "rpc-reply";
+ private static final String DATA_ELEMENT = "data";
+ protected static final Document RPC_REPLY_OK = getReplyOk();
+
+ private CurrentSchemaContext currentSchemaContext;
+ private TransactionProvider transactionProvider;
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+
+ XMLUnit.setIgnoreWhitespace(true);
+ XMLUnit.setIgnoreAttributeOrder(true);
+
+ final SchemaContext schemaContext = getSchemaContext();
+ final SchemaService schemaService = new SchemaServiceStub(schemaContext);
+ final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
+ final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
+
+ currentSchemaContext = new CurrentSchemaContext(schemaService, sourceIdentifier -> {
+ final YangTextSchemaSource yangTextSchemaSource =
+ YangTextSchemaSource.delegateForByteSource(sourceIdentifier, ByteSource.wrap("module test".getBytes()));
+ return Futures.immediateCheckedFuture(yangTextSchemaSource);
+ });
+
+ final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
+ datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
+ datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
+
+ final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
+ 16, 16, "CommitFutures", CopyConfigTest.class);
+
+ final SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
+ MoreExecutors.listeningDecorator(listenableFutureExecutor));
+ this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
+ }
+
+ protected abstract SchemaContext getSchemaContext();
+
+ protected CurrentSchemaContext getCurrentSchemaContext() {
+ return currentSchemaContext;
+ }
+
+ protected TransactionProvider getTransactionProvider() {
+ return transactionProvider;
+ }
+
+ @SuppressWarnings("illegalCatch")
+ private static Document getReplyOk() {
+ Document doc;
+ try {
+ doc = XmlFileLoader.xmlFileToDocument("messages/mapping/rpc-reply_ok.xml");
+ } catch (final Exception e) {
+ LOG.debug("unable to load rpc reply ok.", e);
+ doc = XmlUtil.newDocument();
+ }
+ return doc;
+ }
+
+ protected Document commit() throws Exception {
+ final Commit commit = new Commit(SESSION_ID_FOR_REPORTING, transactionProvider);
+ return executeOperation(commit, "messages/mapping/commit.xml");
+ }
+
+ protected Document discardChanges() throws Exception {
+ final DiscardChanges discardOp = new DiscardChanges(SESSION_ID_FOR_REPORTING, transactionProvider);
+ return executeOperation(discardOp, "messages/mapping/discardChanges.xml");
+ }
+
+ protected Document edit(final String resource) throws Exception {
+ final EditConfig editConfig = new EditConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
+ transactionProvider);
+ return executeOperation(editConfig, resource);
+ }
+
+ protected Document get() throws Exception {
+ final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+ return executeOperation(get, "messages/mapping/get.xml");
+ }
+
+ protected Document getWithFilter(final String resource) throws Exception {
+ final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+ return executeOperation(get, resource);
+ }
+
+ protected Document getConfigRunning() throws Exception {
+ final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+ return executeOperation(getConfig, "messages/mapping/getConfig.xml");
+ }
+
+ protected Document getConfigCandidate() throws Exception {
+ final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+ return executeOperation(getConfig, "messages/mapping/getConfig_candidate.xml");
+ }
+
+ protected Document getConfigWithFilter(final String resource) throws Exception {
+ final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
+ return executeOperation(getConfig, resource);
+ }
+
+ protected static Document lock() throws Exception {
+ final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(lock, "messages/mapping/lock.xml");
+ }
+
+ protected static Document unlock() throws Exception {
+ final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(unlock, "messages/mapping/unlock.xml");
+ }
+
+ protected static Document lockWithoutTarget() throws Exception {
+ final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(lock, "messages/mapping/lock_notarget.xml");
+ }
+
+ protected static Document unlockWithoutTarget() throws Exception {
+ final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(unlock, "messages/mapping/unlock_notarget.xml");
+ }
+
+ protected static Document lockCandidate() throws Exception {
+ final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(lock, "messages/mapping/lock_candidate.xml");
+ }
+
+ protected static Document unlockCandidate() throws Exception {
+ final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
+ return executeOperation(unlock, "messages/mapping/unlock_candidate.xml");
+ }
+
+ protected static Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
+ final Document request = XmlFileLoader.xmlFileToDocument(filename);
+ final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
+
+ LOG.debug("Got response {}", response);
+ return response;
+ }
+
+ protected static void assertEmptyDatastore(final Document response) {
+ final NodeList nodes = response.getChildNodes();
+ assertTrue(nodes.getLength() == 1);
+
+ assertEquals(nodes.item(0).getLocalName(), RPC_REPLY_ELEMENT);
+
+ final NodeList replyNodes = nodes.item(0).getChildNodes();
+ assertTrue(replyNodes.getLength() == 1);
+
+ final Node dataNode = replyNodes.item(0);
+ assertEquals(dataNode.getLocalName(), DATA_ELEMENT);
+ assertFalse(dataNode.hasChildNodes());
+ }
+
+ protected static void verifyResponse(final Document response, final Document template) throws Exception {
+ final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
+ dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());
+ if (!dd.similar()) {
+ LOG.warn("Actual response:");
+ printDocument(response);
+ LOG.warn("Expected response:");
+ printDocument(template);
+ fail("Differences found: " + dd.toString());
+ }
+ }
+
+ private static void printDocument(final Document doc) throws Exception {
+ final TransformerFactory tf = TransformerFactory.newInstance();
+ final Transformer transformer = tf.newTransformer();
+ transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "no");
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml");
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes");
+ transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");
+ transformer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4");
+
+ final StringWriter writer = new StringWriter();
+ transformer.transform(new DOMSource(doc),
+ new StreamResult(writer));
+ LOG.warn(writer.getBuffer().toString());
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.mdsal.connector.ops;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.util.xml.DocumentedException;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
+import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
+import org.opendaylight.netconf.util.test.XmlFileLoader;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.w3c.dom.Document;
+
+public class CopyConfigTest extends AbstractNetconfOperationTest {
+
+ @Override
+ protected SchemaContext getSchemaContext() {
+ return parseYangResources(CopyConfigTest.class,
+ "/yang/mdsal-netconf-mapping-test.yang");
+ }
+
+
+ @Test
+ public void testTargetMissing() throws Exception {
+ try {
+ copyConfig("messages/mapping/copyConfigs/copyConfig_no_target.xml");
+ fail("Should have failed - <target> element is missing");
+ } catch (final DocumentedException e) {
+ assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+ assertTrue(e.getErrorTag() == ErrorTag.MISSING_ATTRIBUTE);
+ assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+ }
+ }
+
+ @Test
+ public void testSourceMissing() throws Exception {
+ try {
+ copyConfig("messages/mapping/copyConfigs/copyConfig_no_source.xml");
+ fail("Should have fanode1iled - <source> element is missing");
+ } catch (final DocumentedException e) {
+ assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+ assertTrue(e.getErrorTag() == ErrorTag.MISSING_ELEMENT);
+ assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+ }
+ }
+
+ @Test
+ public void testConfigMissing() throws Exception {
+ try {
+ copyConfig("messages/mapping/copyConfigs/copyConfig_no_config.xml");
+ fail("Should have failed - <config> element is missing");
+ } catch (final DocumentedException e) {
+ assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+ assertTrue(e.getErrorTag() == ErrorTag.MISSING_ELEMENT);
+ assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+ }
+ }
+
+ @Test
+ public void testRunning() throws Exception {
+ try {
+ copyConfig("messages/mapping/copyConfigs/copyConfig_running.xml");
+ fail("Should have failed - copy config on running datastore is not supported");
+ } catch (final DocumentedException e) {
+ assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
+ assertTrue(e.getErrorTag() == ErrorTag.OPERATION_NOT_SUPPORTED);
+ assertTrue(e.getErrorType() == ErrorType.PROTOCOL);
+ }
+ }
+
+ @Test
+ public void testCandidateTransaction() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_modules.xml"), RPC_REPLY_OK);
+ verifyResponse(getConfigCandidate(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_top_modules_control.xml"));
+ assertEmptyDatastore(getConfigRunning());
+
+ verifyResponse(discardChanges(), RPC_REPLY_OK);
+ assertEmptyDatastore(getConfigCandidate());
+ }
+
+ @Test
+ public void testWithCommit() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_modules.xml"), RPC_REPLY_OK);
+ final Document expectedConfig = XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_top_modules_control.xml");
+ verifyResponse(getConfigCandidate(), expectedConfig);
+
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), expectedConfig);
+ }
+
+ @Test
+ public void testDeleteSubtree() throws Exception {
+ // Initialize datastore
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_delete_setup.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_delete_setup_control.xml"));
+
+ // Issue second copy-config, this time without top container
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_delete.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_delete_control.xml"));
+ }
+
+ @Test
+ public void testList() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_list_setup.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_list_setup_control.xml"));
+
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_list_update.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_list_update_control.xml"));
+ }
+
+ @Test
+ public void testOrderedList() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_ordered_list_setup.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_ordered_list_setup_control.xml"));
+
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_ordered_list_update.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_ordered_list_update_control.xml"));
+ }
+
+ @Test
+ public void testToplevelList() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_toplevel_list_setup.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_toplevel_list_setup_control.xml"));
+
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_toplevel_list_update.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_toplevel_list_update_control.xml"));
+ }
+
+ @Test
+ public void testEmptyContainer() throws Exception {
+ // Check that empty non-presence container is removed.
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_empty_container.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_empty_container_control.xml"));
+ }
+
+ @Test
+ public void testEmptyPresenceContainer() throws Exception {
+ // Check that empty presence container is not removed.
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_empty_presence_container.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_empty_presence_container_control.xml"));
+ }
+
+ @Test
+ public void testAugmentations() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_top_augmentation.xml"),
+ RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_top_augmentation_control.xml"));
+ }
+
+ @Test
+ public void testChoices() throws Exception {
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices1.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices2.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices3.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(copyConfig("messages/mapping/copyConfigs/copyConfig_choices4.xml"), RPC_REPLY_OK);
+ verifyResponse(commit(), RPC_REPLY_OK);
+ verifyResponse(getConfigRunning(), XmlFileLoader.xmlFileToDocument(
+ "messages/mapping/copyConfigs/copyConfig_choices_control.xml"));
+ }
+
+ private Document copyConfig(final String resource) throws Exception {
+ final CopyConfig copyConfig = new CopyConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+ getTransactionProvider());
+ return executeOperation(copyConfig, resource);
+ }
+}
\ No newline at end of file
package org.opendaylight.netconf.mdsal.connector.ops;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.doAnswer;
-import com.google.common.io.ByteSource;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.MoreExecutors;
import java.io.StringWriter;
-import java.util.EnumMap;
-import java.util.concurrent.ExecutorService;
import javax.xml.transform.OutputKeys;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
-import org.custommonkey.xmlunit.DetailedDiff;
-import org.custommonkey.xmlunit.Diff;
-import org.custommonkey.xmlunit.XMLUnit;
import org.junit.Assert;
-import org.junit.Before;
import org.junit.Test;
-import org.mockito.Mock;
import org.mockito.Mockito;
-import org.mockito.MockitoAnnotations;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorSeverity;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorTag;
import org.opendaylight.controller.config.util.xml.DocumentedException.ErrorType;
import org.opendaylight.controller.config.util.xml.XmlElement;
import org.opendaylight.controller.config.util.xml.XmlUtil;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.controller.md.sal.dom.broker.impl.SerializedDOMDataBroker;
-import org.opendaylight.controller.md.sal.dom.store.impl.InMemoryDOMDataStoreFactory;
-import org.opendaylight.controller.sal.core.api.model.SchemaService;
-import org.opendaylight.controller.sal.core.spi.data.DOMStore;
-import org.opendaylight.netconf.mapping.api.NetconfOperation;
-import org.opendaylight.netconf.mapping.api.NetconfOperationChainedExecution;
import org.opendaylight.netconf.mdsal.connector.CurrentSchemaContext;
import org.opendaylight.netconf.mdsal.connector.TransactionProvider;
-import org.opendaylight.netconf.mdsal.connector.ops.get.Get;
import org.opendaylight.netconf.mdsal.connector.ops.get.GetConfig;
-import org.opendaylight.netconf.util.test.NetconfXmlUnitRecursiveQualifier;
import org.opendaylight.netconf.util.test.XmlFileLoader;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.util.concurrent.SpecialExecutors;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
-import org.opendaylight.yangtools.yang.model.api.Module;
import org.opendaylight.yangtools.yang.model.api.SchemaContext;
-import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
-import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
-import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
-import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceProvider;
import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
-import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
-public class NetconfMDSalMappingTest {
+public class NetconfMDSalMappingTest extends AbstractNetconfOperationTest {
private static final Logger LOG = LoggerFactory.getLogger(NetconfMDSalMappingTest.class);
private static final String TARGET_KEY = "target";
- private static final String RPC_REPLY_ELEMENT = "rpc-reply";
- private static final String DATA_ELEMENT = "data";
private static final String FILTER_NODE = "filter";
private static final String GET_CONFIG = "get-config";
private static final QName TOP = QName.create("urn:opendaylight:mdsal:mapping:test", "2015-02-26", "top");
private static final YangInstanceIdentifier AUGMENTED_CONTAINER_IN_MODULES =
YangInstanceIdentifier.builder().node(TOP).node(MODULES).build();
- private static final String SESSION_ID_FOR_REPORTING = "netconf-test-session1";
- private static final Document RPC_REPLY_OK = NetconfMDSalMappingTest.getReplyOk();
- private CurrentSchemaContext currentSchemaContext = null;
- private SchemaContext schemaContext = null;
- private TransactionProvider transactionProvider = null;
-
- @Mock
- private SchemaSourceProvider<YangTextSchemaSource> sourceProvider;
-
- @SuppressWarnings("illegalCatch")
- private static Document getReplyOk() {
- Document doc;
- try {
- doc = XmlFileLoader.xmlFileToDocument("messages/mapping/rpc-reply_ok.xml");
- } catch (final Exception e) {
- LOG.debug("unable to load rpc reply ok.", e);
- doc = XmlUtil.newDocument();
- }
- return doc;
- }
-
- @Before
- public void setUp() throws Exception {
- MockitoAnnotations.initMocks(this);
-
- XMLUnit.setIgnoreWhitespace(true);
- XMLUnit.setIgnoreAttributeOrder(true);
-
- this.schemaContext = YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
+ @Override
+ protected SchemaContext getSchemaContext() {
+ return YangParserTestUtils.parseYangResources(NetconfMDSalMappingTest.class,
"/META-INF/yang/config@2013-04-05.yang", "/yang/mdsal-netconf-mapping-test.yang");
- schemaContext.getModules();
- final SchemaService schemaService = createSchemaService();
-
- final DOMStore operStore = InMemoryDOMDataStoreFactory.create("DOM-OPER", schemaService);
- final DOMStore configStore = InMemoryDOMDataStoreFactory.create("DOM-CFG", schemaService);
-
- final EnumMap<LogicalDatastoreType, DOMStore> datastores = new EnumMap<>(LogicalDatastoreType.class);
- datastores.put(LogicalDatastoreType.CONFIGURATION, configStore);
- datastores.put(LogicalDatastoreType.OPERATIONAL, operStore);
-
- final ExecutorService listenableFutureExecutor = SpecialExecutors.newBlockingBoundedCachedThreadPool(
- 16, 16, "CommitFutures", NetconfMDSalMappingTest.class);
-
- final SerializedDOMDataBroker sdb = new SerializedDOMDataBroker(datastores,
- MoreExecutors.listeningDecorator(listenableFutureExecutor));
- this.transactionProvider = new TransactionProvider(sdb, SESSION_ID_FOR_REPORTING);
-
- doAnswer(invocationOnMock -> {
- final SourceIdentifier sId = (SourceIdentifier) invocationOnMock.getArguments()[0];
- final YangTextSchemaSource yangTextSchemaSource =
- YangTextSchemaSource.delegateForByteSource(sId, ByteSource.wrap("module test".getBytes()));
- return Futures.immediateFuture(yangTextSchemaSource);
-
- }).when(sourceProvider).getSource(any(SourceIdentifier.class));
-
- this.currentSchemaContext = new CurrentSchemaContext(schemaService, sourceProvider);
}
@Test
@Test
public void testIncorrectGet() throws Exception {
try {
- executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider),
- "messages/mapping/bad_getConfig.xml");
+ executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+ getTransactionProvider()), "messages/mapping/bad_getConfig.xml");
fail("Should have failed, this is an incorrect request");
} catch (final DocumentedException e) {
assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
}
try {
- executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider),
- "messages/mapping/bad_namespace_getConfig.xml");
+ executeOperation(new GetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+ getTransactionProvider()), "messages/mapping/bad_namespace_getConfig.xml");
fail("Should have failed, this is an incorrect request");
} catch (final DocumentedException e) {
assertTrue(e.getErrorSeverity() == ErrorSeverity.ERROR);
private void verifyFilterIdentifier(final String resource, final YangInstanceIdentifier identifier)
throws Exception {
- final TestingGetConfig getConfig = new TestingGetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
- transactionProvider);
+ final TestingGetConfig getConfig = new TestingGetConfig(SESSION_ID_FOR_REPORTING, getCurrentSchemaContext(),
+ getTransactionProvider());
final Document request = XmlFileLoader.xmlFileToDocument(resource);
final YangInstanceIdentifier iid = getConfig.getInstanceIdentifierFromDocument(request);
assertEquals(identifier, iid);
verifyResponse(commit(), RPC_REPLY_OK);
assertEmptyDatastore(getConfigRunning());
}
-
- private static void verifyResponse(final Document response, final Document template) throws Exception {
- final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
- dd.overrideElementQualifier(new NetconfXmlUnitRecursiveQualifier());
-
- printDocument(response);
- printDocument(template);
-
- assertTrue(dd.toString(), dd.similar());
- }
-
- private static void assertEmptyDatastore(final Document response) {
- final NodeList nodes = response.getChildNodes();
- assertTrue(nodes.getLength() == 1);
-
- assertEquals(nodes.item(0).getLocalName(), RPC_REPLY_ELEMENT);
-
- final NodeList replyNodes = nodes.item(0).getChildNodes();
- assertTrue(replyNodes.getLength() == 1);
-
- final Node dataNode = replyNodes.item(0);
- assertEquals(dataNode.getLocalName(), DATA_ELEMENT);
- assertFalse(dataNode.hasChildNodes());
- }
-
- private Document commit() throws Exception {
- final Commit commit = new Commit(SESSION_ID_FOR_REPORTING, transactionProvider);
- return executeOperation(commit, "messages/mapping/commit.xml");
- }
-
- private Document discardChanges() throws Exception {
- final DiscardChanges discardOp = new DiscardChanges(SESSION_ID_FOR_REPORTING, transactionProvider);
- return executeOperation(discardOp, "messages/mapping/discardChanges.xml");
- }
-
- private Document edit(final String resource) throws Exception {
- final EditConfig editConfig = new EditConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
- transactionProvider);
- return executeOperation(editConfig, resource);
- }
-
- private Document get() throws Exception {
- final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
- return executeOperation(get, "messages/mapping/get.xml");
- }
-
- private Document getWithFilter(final String resource) throws Exception {
- final Get get = new Get(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
- return executeOperation(get, resource);
- }
-
- private Document getConfigRunning() throws Exception {
- final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
- return executeOperation(getConfig, "messages/mapping/getConfig.xml");
- }
-
- private Document getConfigCandidate() throws Exception {
- final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
- return executeOperation(getConfig, "messages/mapping/getConfig_candidate.xml");
- }
-
- private Document getConfigWithFilter(final String resource) throws Exception {
- final GetConfig getConfig = new GetConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext, transactionProvider);
- return executeOperation(getConfig, resource);
- }
-
- private static Document lock() throws Exception {
- final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
- return executeOperation(lock, "messages/mapping/lock.xml");
- }
-
- private static Document unlock() throws Exception {
- final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
- return executeOperation(unlock, "messages/mapping/unlock.xml");
- }
-
- private static Document lockWithoutTarget() throws Exception {
- final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
- return executeOperation(lock, "messages/mapping/lock_notarget.xml");
- }
-
- private static Document unlockWithoutTarget() throws Exception {
- final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
- return executeOperation(unlock, "messages/mapping/unlock_notarget.xml");
- }
-
- private static Document lockCandidate() throws Exception {
- final Lock lock = new Lock(SESSION_ID_FOR_REPORTING);
- return executeOperation(lock, "messages/mapping/lock_candidate.xml");
- }
-
- private static Document unlockCandidate() throws Exception {
- final Unlock unlock = new Unlock(SESSION_ID_FOR_REPORTING);
- return executeOperation(unlock, "messages/mapping/unlock_candidate.xml");
- }
-
- private static Document executeOperation(final NetconfOperation op, final String filename) throws Exception {
- final Document request = XmlFileLoader.xmlFileToDocument(filename);
- final Document response = op.handle(request, NetconfOperationChainedExecution.EXECUTION_TERMINATION_POINT);
-
- LOG.debug("Got response {}", response);
- return response;
- }
-
- private SchemaService createSchemaService() {
- return new SchemaService() {
-
- @Override
- public void addModule(final Module module) {
- }
-
- @Override
- public void removeModule(final Module module) {
-
- }
-
- @Override
- public SchemaContext getSessionContext() {
- return schemaContext;
- }
-
- @Override
- public SchemaContext getGlobalContext() {
- return schemaContext;
- }
-
- @Override
- public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
- final SchemaContextListener listener) {
- listener.onGlobalContextUpdated(getGlobalContext());
- return new ListenerRegistration<SchemaContextListener>() {
- @Override
- public void close() {
-
- }
-
- @Override
- public SchemaContextListener getInstance() {
- return listener;
- }
- };
- }
- };
- }
}
--- /dev/null
+/*
+ * Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+
+package org.opendaylight.netconf.mdsal.connector.ops;
+
+import org.opendaylight.controller.sal.core.api.model.SchemaService;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.model.api.Module;
+import org.opendaylight.yangtools.yang.model.api.SchemaContext;
+import org.opendaylight.yangtools.yang.model.api.SchemaContextListener;
+
+final class SchemaServiceStub implements SchemaService {
+ private final SchemaContext schemaContext;
+
+ SchemaServiceStub(SchemaContext schemaContext) {
+ this.schemaContext = schemaContext;
+ }
+
+ @Override
+ public void addModule(final Module module) {
+ }
+
+ @Override
+ public void removeModule(final Module module) {
+
+ }
+
+ @Override
+ public SchemaContext getSessionContext() {
+ return schemaContext;
+ }
+
+ @Override
+ public SchemaContext getGlobalContext() {
+ return schemaContext;
+ }
+
+ @Override
+ public ListenerRegistration<SchemaContextListener> registerSchemaContextListener(
+ final SchemaContextListener listener) {
+ listener.onGlobalContextUpdated(getGlobalContext());
+ return new ListenerRegistration<SchemaContextListener>() {
+ @Override
+ public void close() {
+ }
+
+ @Override
+ public SchemaContextListener getInstance() {
+ return listener;
+ }
+ };
+ }
+}
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <text>some text</text>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <text-cont>
+ <text>some text</text>
+ </text-cont>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <augmented-case>augmented case text</augmented-case>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <choice-wrapper>
+ <text2>some text</text2>
+ </choice-wrapper>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <choice-wrapper>
+ <text2>some text</text2>
+ </choice-wrapper>
+ </top>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ </mapping-nodes>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ </mapping-nodes>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <augmented-container>
+ <identifier>augmented container</identifier>
+ </augmented-container>
+ <module>
+ <id>module1</id>
+ <type>type1</type>
+ <desc>module1-desc</desc>
+ </module>
+ <module>
+ <id>module2</id>
+ </module>
+ <module>
+ <id>module3</id>
+ </module>
+ </modules>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ </mapping-nodes>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <augmented-container>
+ <identifier>augmented container</identifier>
+ </augmented-container>
+ <module>
+ <id>module1</id>
+ <type>type1</type>
+ <desc>module1-desc</desc>
+ </module>
+ <module>
+ <id>module2</id>
+ </module>
+ <module>
+ <id>module3</id>
+ </module>
+ </modules>
+ </top>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data/>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top-with-presence xmlns="urn:opendaylight:mdsal:mapping:test" />
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <top-with-presence xmlns="urn:opendaylight:mdsal:mapping:test" />
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node2</id>
+ <content>content2</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node3</id>
+ <content>content3</content>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1</id>
+ <content>content1</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node2</id>
+ <content>content2</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node3</id>
+ <content>content3</content>
+ </mapping-node>
+ </mapping-nodes>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>new_node</id>
+ <content>new_node content</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node2</id>
+ <content>content2</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node3</id>
+ <content>updated content3</content>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>new_node</id>
+ <content>new_node content</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node2</id>
+ <content>content2</content>
+ </mapping-node>
+ <mapping-node>
+ <id>node3</id>
+ <content>updated content3</content>
+ </mapping-node>
+ </mapping-nodes>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1-put</id>
+ <content>put content</content>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>id</id>
+ <ordered-items>
+ <ordered-item>
+ <id>item1</id>
+ <content>content1</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item2</id>
+ <content>content2</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item3</id>
+ <content>content3</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item4</id>
+ <content>content4</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item5</id>
+ <content>content5</content>
+ </ordered-item>
+ </ordered-items>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>id</id>
+ <ordered-items>
+ <ordered-item>
+ <id>item1</id>
+ <content>content1</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item2</id>
+ <content>content2</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item3</id>
+ <content>content3</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item4</id>
+ <content>content4</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item5</id>
+ <content>content5</content>
+ </ordered-item>
+ </ordered-items>
+ </mapping-node>
+ </mapping-nodes>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>id</id>
+ <ordered-items>
+ <ordered-item>
+ <id>item1</id>
+ <content>udated content1</content>
+ </ordered-item>
+ <ordered-item>
+ <id>new_item</id>
+ <content>new_item content</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item2</id>
+ <content>content2</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item5</id>
+ <content>content5</content>
+ </ordered-item>
+ </ordered-items>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>id</id>
+ <ordered-items>
+ <ordered-item>
+ <id>item1</id>
+ <content>udated content1</content>
+ </ordered-item>
+ <ordered-item>
+ <id>new_item</id>
+ <content>new_item content</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item2</id>
+ <content>content2</content>
+ </ordered-item>
+ <ordered-item>
+ <id>item5</id>
+ <content>content5</content>
+ </ordered-item>
+ </ordered-items>
+ </mapping-node>
+ </mapping-nodes>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <running/>
+ </target>
+ <source>
+ <config>
+ <mapping-nodes xmlns="urn:opendaylight:mdsal:mapping:test">
+ <mapping-node>
+ <id>node1-put</id>
+ <content>put content</content>
+ </mapping-node>
+ </mapping-nodes>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <augmented-container>
+ <identifier>augmented container</identifier>
+ </augmented-container>
+ <module>
+ <id>module1</id>
+ <type>type1</type>
+ <desc>module1-desc</desc>
+ </module>
+ </modules>
+ <mid-level>
+ <low-level>
+ <lowest-level>
+ <note>note1</note>
+ <note>note2</note>
+ </lowest-level>
+ </low-level>
+ <low-level2>
+ <note>note1</note>
+ <note>note2</note>
+ </low-level2>
+ </mid-level>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <augmented-container>
+ <identifier>augmented container</identifier>
+ </augmented-container>
+ <module>
+ <id>module1</id>
+ <type>type1</type>
+ <desc>module1-desc</desc>
+ </module>
+ </modules>
+ <mid-level>
+ <low-level>
+ <lowest-level>
+ <note>note1</note>
+ <note>note2</note>
+ </lowest-level>
+ </low-level>
+ <low-level2>
+ <note>note1</note>
+ <note>note2</note>
+ </low-level2>
+ </mid-level>
+ </top>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <module>
+ <id>module1</id>
+ </module>
+ <module>
+ <id>module2</id>
+ </module>
+ </modules>
+ </top>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <top xmlns="urn:opendaylight:mdsal:mapping:test">
+ <modules>
+ <module>
+ <id>module1</id>
+ </module>
+ <module>
+ <id>module2</id>
+ </module>
+ </modules>
+ </top>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item1</id>
+ <content>content1</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item2</id>
+ <content>content2</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item3</id>
+ <content>content3</content>
+ </toplevel-list>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item1</id>
+ <content>content1</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item2</id>
+ <content>content2</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item3</id>
+ <content>content3</content>
+ </toplevel-list>
+ </data>
+</rpc-reply>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc message-id="a" a="64" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <copy-config>
+ <target>
+ <candidate/>
+ </target>
+ <source>
+ <config>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>new_item</id>
+ <content>new_item content</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item3</id>
+ <content>updated content3</content>
+ </toplevel-list>
+ </config>
+ </source>
+ </copy-config>
+</rpc>
\ No newline at end of file
--- /dev/null
+<!--
+ ~ Copyright (c) 2018 Cisco Systems, Inc. and others. All rights reserved.
+ ~
+ ~ This program and the accompanying materials are made available under the
+ ~ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ ~ and is available at http://www.eclipse.org/legal/epl-v10.html
+ -->
+
+<rpc-reply a="64" id="a" message-id="101" xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlnx="a:b:c:d">
+ <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>new_item</id>
+ <content>new_item content</content>
+ </toplevel-list>
+ <toplevel-list xmlns="urn:opendaylight:mdsal:mapping:test">
+ <id>item3</id>
+ <content>updated content3</content>
+ </toplevel-list>
+ </data>
+</rpc-reply>
\ No newline at end of file
}
}
}
+
+ list toplevel-list {
+ key "id";
+ leaf id {
+ type string;
+ }
+
+ leaf content {
+ type string;
+ }
+ }
+
+ container top-with-presence {
+ presence "For testing presence containers";
+
+ }
}
\ No newline at end of file
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<!-- compile dependencies -->
<dependency>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
<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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<!-- compile dependencies -->
<dependency>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>yang-test-util</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>2.5.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>hamcrest-core</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Future;
import java.util.regex.Pattern;
.put(cntr.getNotificationUrnPrefix(), cntr);
Map<String, Stream> availableStreams = getAvailableStreams();
LOG.debug("Stream configuration compare...");
- for (String urnPrefix : this.urnPrefixToStreamMap.keySet()) {
- final String streamName = this.urnPrefixToStreamMap.get(urnPrefix);
+ for (Entry<String, String> entry : this.urnPrefixToStreamMap.entrySet()) {
+ String urnPrefix = entry.getKey();
+ final String streamName = entry.getValue();
LOG.debug("urnPrefix: {} streamName: {}", urnPrefix, streamName);
if (availableStreams.containsKey(streamName)) {
LOG.debug("Stream containig on device");
}
}
- private void nodeUpdated(final InstanceIdentifier<?> key, final Node node) {
- Preconditions.checkNotNull(key);
- if (!validateNode(node)) {
- LOG.warn("NodeUpdated event : Node [{}] is null or not valid.", key.toString());
- return;
- }
-
- LOG.info("Netconf event source [{}] is updating...", key.toString());
- NetconfEventSourceRegistration nesr = registrationMap.get(key);
- if (nesr != null) {
- nesr.updateStatus();
- } else {
- nodeCreated(key, node);
- }
- }
-
private void nodeRemoved(final InstanceIdentifier<?> key) {
Preconditions.checkNotNull(key);
LOG.info("Netconf event source [{}] is removing...", key.toString());
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
<artifactId>mockito-configuration</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
package org.opendaylight.netconf.api;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.util.Map;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.w3c.dom.Document;
super(message, cause, errorType, errorTag, errorSeverity, errorInfo);
}
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
public NetconfDocumentedException(final DocumentedException exception) {
super(exception.getMessage(), (Exception) exception.getCause(), exception.getErrorType(),
exception.getErrorTag(), exception.getErrorSeverity(), exception.getErrorInfo());
package org.opendaylight.netconf.api.util;
-import com.google.common.collect.Sets;
+import com.google.common.collect.ImmutableSet;
import java.util.Set;
/**
public static final String NETCONF_MONITORING = "ietf-netconf-monitoring";
public static final String NETCONF_NOTIFICATION = "ietf-netconf-notifications";
- public static final Set<String> CONFIG_SERVICE_MARKERS = Sets.newHashSet(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR,
+ public static final Set<String> CONFIG_SERVICE_MARKERS = ImmutableSet.of(SERVICE_NAME, CONFIG_NETCONF_CONNECTOR,
NETCONF_MONITORING, NETCONF_NOTIFICATION);
private NetconfConstants() {
<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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.5.0-SNAPSHOT</version>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
import io.netty.channel.EventLoopGroup;
import io.netty.util.Timer;
import io.netty.util.concurrent.Future;
-import java.io.Closeable;
import org.opendaylight.netconf.client.conf.NetconfClientConfiguration;
import org.opendaylight.netconf.client.conf.NetconfReconnectingClientConfiguration;
import org.opendaylight.protocol.framework.AbstractDispatcher;
import org.slf4j.LoggerFactory;
public class NetconfClientDispatcherImpl extends AbstractDispatcher<NetconfClientSession, NetconfClientSessionListener>
- implements NetconfClientDispatcher, Closeable {
+ implements NetconfClientDispatcher {
private static final Logger LOG = LoggerFactory.getLogger(NetconfClientDispatcherImpl.class);
import com.google.common.collect.ImmutableSet;
import com.google.common.collect.Interner;
import com.google.common.collect.Interners;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.ChannelFutureListener;
}
@Override
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
protected void handleMessage(final NetconfHelloMessage netconfMessage) throws NetconfDocumentedException {
final NetconfClientSession session = getSessionForHelloMessage(netconfMessage);
replaceHelloMessageInboundHandler(session);
// If exi should be used, try to initiate exi communication
// Call negotiationSuccessFul after exi negotiation is finished successfully or not
- if (shouldUseExi(netconfMessage)) {
+ final NetconfMessage startExiMessage = sessionPreferences.getStartExiMessage();
+ if (shouldUseExi(netconfMessage) && startExiMessage instanceof NetconfStartExiMessage) {
LOG.debug("Netconf session {} should use exi.", session);
- NetconfStartExiMessage startExiMessage = (NetconfStartExiMessage) sessionPreferences.getStartExiMessage();
- tryToInitiateExi(session, startExiMessage);
+ tryToInitiateExi(session, (NetconfStartExiMessage) startExiMessage);
} else {
// Exi is not supported, release session immediately
LOG.debug("Netconf session {} isn't capable of using exi.", session);
});
}
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST")
private boolean shouldUseExi(final NetconfHelloMessage helloMsg) {
return containsExi10Capability(helloMsg.getDocument())
&& containsExi10Capability(sessionPreferences.getHelloMessage().getDocument());
}
}
- return Long.valueOf(textContent);
+ return Long.parseLong(textContent);
}
private static String getSessionIdWithXPath(final Document doc, final XPathExpression sessionIdXPath) {
package org.opendaylight.netconf.client;
import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GlobalEventExecutor;
import io.netty.util.concurrent.Promise;
private NetconfClientSession clientSession;
@GuardedBy("this")
+ @SuppressFBWarnings("RV_RETURN_VALUE_IGNORED")
private void dispatchRequest() {
while (!requests.isEmpty()) {
final RequestEntry e = requests.peek();
negotiationFutureListener = future -> {
if (future.isSuccess()) {
- connectPromise.setSuccess();
+ channelPromise.setSuccess();
}
};
//complete connection promise with netconf negotiation future
negotiationFuture.addListener(negotiationFutureListener);
} else {
- connectPromise.setFailure(future.cause());
+ channelPromise.setFailure(future.cause());
}
});
ctx.connect(remoteAddress, localAddress, tcpConnectFuture);
@Override
public void disconnect(final ChannelHandlerContext ctx, final ChannelPromise promise) throws Exception {
+ if (connectPromise == null) {
+ return;
+ }
+
// If we have already succeeded and the session was dropped after, we need to fire inactive to notify
// reconnect logic
if (connectPromise.isSuccess()) {
return sslHandlerFactory;
}
- @SuppressWarnings("checkstyle:FallThrough")
private void validateConfiguration() {
Preconditions.checkNotNull(clientProtocol, " ");
switch (clientProtocol) {
case TLS:
+ validateTlsConfiguration();
+ validateTcpConfiguration();
+ break;
case SSH:
- if (clientProtocol == NetconfClientProtocol.SSH) {
- validateSshConfiguration();
- } else {
- validateTlsConfiguration();
- }
- // Fall through intentional (ssh or tls validation is a superset of tcp validation)
+ validateSshConfiguration();
+ validateTcpConfiguration();
+ break;
case TCP:
validateTcpConfiguration();
break;
public enum NetconfClientProtocol {
TCP, SSH, TLS
}
-}
\ No newline at end of file
+}
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<!-- Apache Karaf console dependency -->
<dependency>
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
if (!Strings.isNullOrEmpty(deviceId)) {
status = service.disconnectDevice(deviceId);
} else {
- if (!NetconfCommandUtils.isIpValid(deviceIp) && !NetconfCommandUtils.isPortValid(devicePort)) {
+ if (!NetconfCommandUtils.isIpValid(deviceIp) || !NetconfCommandUtils.isPortValid(devicePort)) {
return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
status = service.disconnectDevice(deviceIp, devicePort);
table.column(NetconfConsoleConstants.NETCONF_PORT).alignLeft();
table.column(NetconfConsoleConstants.STATUS).alignLeft();
- for (final String nodeIds : allDevices.keySet()) {
- final Map<String, String> attributes = allDevices.get(nodeIds);
+ for (final Map<String, String> attributes : allDevices.values()) {
table.addRow().addContent(attributes.get(NetconfConsoleConstants.NETCONF_ID),
attributes.get(NetconfConsoleConstants.NETCONF_IP),
attributes.get(NetconfConsoleConstants.NETCONF_PORT),
import com.google.common.base.Strings;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import javax.annotation.Nonnull;
import org.apache.karaf.shell.commands.Command;
import org.apache.karaf.shell.commands.Option;
}
if (!NetconfCommandUtils.isIpValid(deviceIp)
- || (devicePort != null && !NetconfCommandUtils.isPortValid(devicePort))) {
+ || devicePort != null && !NetconfCommandUtils.isPortValid(devicePort)) {
return "Invalid IP:" + deviceIp + " or Port:" + devicePort + "Please enter a valid entry to proceed.";
}
table.column(NetconfConsoleConstants.STATUS).alignLeft();
table.column(NetconfConsoleConstants.AVAILABLE_CAPABILITIES).alignLeft();
- for (final String nodeId : devices.keySet()) {
- final Map<String, List<String>> device = devices.get(nodeId);
+ for (final Entry<String, Map<String, List<String>>> entry : devices.entrySet()) {
+ final String nodeId = entry.getKey();
+ final Map<String, List<String>> device = entry.getValue();
table.addRow().addContent(nodeId,
device.get(NetconfConsoleConstants.NETCONF_IP).get(NetconfConsoleConstants.DEFAULT_INDEX),
device.get(NetconfConsoleConstants.NETCONF_PORT).get(NetconfConsoleConstants.DEFAULT_INDEX),
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
attributes.put(NetconfConsoleConstants.NETCONF_IP,
netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
attributes.put(NetconfConsoleConstants.NETCONF_PORT, netconfNode.getPort().getValue().toString());
- attributes.put(NetconfConsoleConstants.STATUS, netconfNode.getConnectionStatus().name().toLowerCase());
+ attributes.put(NetconfConsoleConstants.STATUS, netconfNode.getConnectionStatus().name()
+ .toLowerCase(Locale.ROOT));
netconfNodes.put(node.getNodeId().getValue(), attributes);
}
return netconfNodes;
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
package org.opendaylight.netconf.impl;
import com.google.common.base.Optional;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.Channel;
import io.netty.channel.local.LocalAddress;
import io.netty.util.Timer;
}
@Override
+ @SuppressFBWarnings("BC_UNCONFIRMED_CAST_OF_RETURN_VALUE")
protected NetconfServerSession getSession(
NetconfServerSessionListener sessionListener, Channel channel,
NetconfHelloMessage message) {
int msgLength = out.readableBytes();
int chunkCount = msgLength / ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE;
- if ((msgLength % ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE) != 0) {
+ if (msgLength % ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE != 0) {
chunkCount++;
}
+
+ byte[] endOfChunkBytes = NetconfMessageConstants.END_OF_CHUNK.getBytes(StandardCharsets.UTF_8);
for (int i = 1; i <= chunkCount; i++) {
ByteBuf recievedOutbound = (ByteBuf) messages.poll();
int exptHeaderLength = ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE;
if (i == chunkCount) {
- exptHeaderLength = msgLength - (ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE * (i - 1));
- byte[] eom = new byte[NetconfMessageConstants.END_OF_CHUNK.length];
- recievedOutbound
- .getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_CHUNK.length, eom);
- assertArrayEquals(NetconfMessageConstants.END_OF_CHUNK, eom);
+ exptHeaderLength = msgLength - ChunkedFramingMechanismEncoder.DEFAULT_CHUNK_SIZE * (i - 1);
+ byte[] eom = new byte[endOfChunkBytes.length];
+ recievedOutbound.getBytes(recievedOutbound.readableBytes() - endOfChunkBytes.length, eom);
+ assertArrayEquals(endOfChunkBytes, eom);
}
byte[] header = new byte[String.valueOf(exptHeaderLength).length()
testChunkChannel.writeOutbound(this.msg);
ByteBuf recievedOutbound = (ByteBuf) testChunkChannel.readOutbound();
- byte[] eom = new byte[NetconfMessageConstants.END_OF_MESSAGE.length];
- recievedOutbound.getBytes(recievedOutbound.readableBytes() - NetconfMessageConstants.END_OF_MESSAGE.length,
- eom);
- assertArrayEquals(NetconfMessageConstants.END_OF_MESSAGE, eom);
+ byte[] endOfMsgBytes = NetconfMessageConstants.END_OF_MESSAGE.getBytes(StandardCharsets.UTF_8);
+ byte[] eom = new byte[endOfMsgBytes.length];
+ recievedOutbound.getBytes(recievedOutbound.readableBytes() - endOfMsgBytes.length, eom);
+ assertArrayEquals(endOfMsgBytes, eom);
testChunkChannel.writeInbound(recievedOutbound);
NetconfMessage receivedMessage = (NetconfMessage) testChunkChannel.readInbound();
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>guava</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<!-- compile dependencies -->
<dependency>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
@XmlElement(name = "namespace")
public String getNamespace() {
- return schema.getNamespace().getValue().toString();
+ return schema.getNamespace().getValue();
}
@XmlElement(name = "location")
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>com.siemens.ct.exi</groupId>
<artifactId>exificient</artifactId>
</dependency>
</dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
import java.nio.charset.StandardCharsets;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
public class ChunkedFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
public static final int DEFAULT_CHUNK_SIZE = 8192;
do {
final int xfer = Math.min(chunkSize, msg.readableBytes());
- out.writeBytes(NetconfMessageConstants.START_OF_CHUNK);
+ out.writeBytes(MessageParts.START_OF_CHUNK);
out.writeBytes(String.valueOf(xfer).getBytes(StandardCharsets.US_ASCII));
out.writeByte('\n');
out.writeBytes(msg, xfer);
} while (msg.isReadable());
- out.writeBytes(NetconfMessageConstants.END_OF_CHUNK);
+ out.writeBytes(MessageParts.END_OF_CHUNK);
}
}
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.MessageToByteEncoder;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
public class EOMFramingMechanismEncoder extends MessageToByteEncoder<ByteBuf> {
@Override
protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) {
out.writeBytes(msg);
- out.writeBytes(NetconfMessageConstants.END_OF_MESSAGE);
+ out.writeBytes(MessageParts.END_OF_MESSAGE);
}
}
--- /dev/null
+/*
+ * Copyright (c) 2018 Inocybe Technologies and others. All rights reserved.
+ *
+ * This program and the accompanying materials are made available under the
+ * terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at http://www.eclipse.org/legal/epl-v10.html
+ */
+package org.opendaylight.netconf.nettyutil.handler;
+
+import static java.nio.charset.StandardCharsets.UTF_8;
+
+import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
+
+/**
+ * netconf message part constants as bytes.
+ *
+ * @author Thomas Pantelis
+ */
+interface MessageParts {
+ byte[] END_OF_MESSAGE = NetconfMessageConstants.END_OF_MESSAGE.getBytes(UTF_8);
+ byte[] START_OF_CHUNK = NetconfMessageConstants.START_OF_CHUNK.getBytes(UTF_8);
+ byte[] END_OF_CHUNK = NetconfMessageConstants.END_OF_CHUNK.getBytes(UTF_8);
+}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
public class NetconfEOMAggregator extends DelimiterBasedFrameDecoder {
- public static final ByteBuf DELIMITER = Unpooled.wrappedBuffer(NetconfMessageConstants.END_OF_MESSAGE);
+ public static final ByteBuf DELIMITER = Unpooled.wrappedBuffer(MessageParts.END_OF_MESSAGE);
public NetconfEOMAggregator() {
super(Integer.MAX_VALUE, DELIMITER);
session = future.getSession();
final AuthFuture authenticateFuture = authenticationHandler.authenticate(session);
+ final ClientSession localSession = session;
authenticateFuture.addListener(future1 -> {
if (future1.isSuccess()) {
- handleSshAuthenticated(session, ctx);
+ handleSshAuthenticated(localSession, ctx);
} else {
// Exception does not have to be set in the future, add simple exception in such case
final Throwable exception = future1.getException() == null
// TODO we should also read from error stream and at least log from that
+ ClientChannel localChannel = channel;
sshReadAsyncListener = new AsyncSshHandlerReader(() -> AsyncSshHandler.this.disconnect(ctx, ctx.newPromise()),
- msg -> ctx.fireChannelRead(msg), channel.toString(), channel.getAsyncOut());
+ msg -> ctx.fireChannelRead(msg), localChannel.toString(), localChannel.getAsyncOut());
// if readAsyncListener receives immediate close,
// it will close this handler and closing this handler sets channel variable to null
this.connectPromise = promise;
if (negotiationFuture != null) {
-
negotiationFutureListener = future -> {
if (future.isSuccess()) {
- connectPromise.setSuccess();
+ promise.setSuccess();
}
};
//complete connection promise with netconf negotiation future
if (session != null && !session.isClosed() && !session.isClosing()) {
session.close(false).addListener(future -> {
- if (!future.isClosed()) {
- session.close(true);
+ synchronized (this) {
+ if (!future.isClosed()) {
+ session.close(true);
+ }
+ session = null;
}
- session = null;
});
}
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.junit.Test;
-import org.opendaylight.netconf.util.messages.NetconfMessageConstants;
public class EOMFramingMechanismEncoderTest {
final ByteBuf destination = Unpooled.buffer();
new EOMFramingMechanismEncoder().encode(null, source, destination);
- assertEquals(Unpooled.wrappedBuffer(source.array(), NetconfMessageConstants.END_OF_MESSAGE), destination);
+ assertEquals(Unpooled.wrappedBuffer(source.array(), MessageParts.END_OF_MESSAGE), destination);
}
-}
\ No newline at end of file
+}
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.5.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
package org.opendaylight.netconf.notifications;
import com.google.common.base.Preconditions;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.text.ParsePosition;
import java.time.Instant;
import java.time.LocalDateTime;
/**
* Create new notification with provided timestamp.
*/
+ @SuppressFBWarnings("EI_EXPOSE_REP2") // stores a reference to an externally mutable Date object
public NetconfNotification(final Document notificationContent, final Date eventTime) {
super(wrapNotification(notificationContent, eventTime));
this.eventTime = eventTime;
*
* @return notification event time
*/
+ @SuppressFBWarnings("EI_EXPOSE_REP")
public Date getEventTime() {
return eventTime;
}
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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.5.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>2.5.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
-import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import java.io.IOException;
private static RpcDefinition findCreateSubscriptionRpc() {
return Iterables.getFirst(Collections2.filter(NOTIFICATIONS_SCHEMA_CTX.getOperations(),
- new Predicate<RpcDefinition>() {
- @Override
- public boolean apply(final RpcDefinition input) {
- return input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION);
- }
- }), null);
+ input -> input.getQName().getLocalName().equals(CreateSubscription.CREATE_SUBSCRIPTION)), null);
}
/**
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2016 Cisco Systems, Inc. and others. All rights reserved.
+
+ This program and the accompanying materials are made available under the
+ terms of the Eclipse Public License v1.0 which accompanies this distribution,
+ and is available at http://www.eclipse.org/legal/epl-v10.html
+-->
+<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.mdsal</groupId>
+ <artifactId>binding-parent</artifactId>
+ <version>0.13.0-SNAPSHOT</version>
+ <relativePath/>
+ </parent>
+
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.opendaylight.aaa</groupId>
+ <artifactId>aaa-artifacts</artifactId>
+ <version>0.8.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>mdsal-artifacts</artifactId>
+ <version>1.8.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-artifacts</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <type>pom</type>
+ <scope>import</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-checkstyle-plugin</artifactId>
+ <configuration>
+ <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
<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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
package org.opendaylight.netconf.ssh;
-import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
+import java.nio.charset.StandardCharsets;
import org.apache.sshd.common.io.IoInputStream;
import org.apache.sshd.common.io.IoOutputStream;
import org.apache.sshd.server.ExitCallback;
writeAdditionalHeader(ctx);
asyncSshHandlerWriter = new AsyncSshHandlerWriter(out);
- asyncSshHandlerReader = new AsyncSshHandlerReader(new AutoCloseable() {
- @Override
- public void close() throws Exception {
- // Close both sessions (delegate server and remote client)
- ctx.fireChannelInactive();
- ctx.disconnect();
- ctx.close();
- asyncSshHandlerReader.close();
- asyncSshHandlerWriter.close();
- }
- }, new AsyncSshHandlerReader.ReadMsgHandler() {
- @Override
- public void onMessageRead(final ByteBuf msg) {
- if (LOG.isTraceEnabled()) {
- LOG.trace("Forwarding message for client: {} on channel: {}, message: {}",
- netconfHelloMessageAdditionalHeader.getAddress(), ctx.channel(),
- AsyncSshHandlerWriter.byteBufToString(msg));
- }
- // Just forward to delegate
- ctx.writeAndFlush(msg);
+ asyncSshHandlerReader = new AsyncSshHandlerReader(() -> {
+ // Close both sessions (delegate server and remote client)
+ ctx.fireChannelInactive();
+ ctx.disconnect();
+ ctx.close();
+ asyncSshHandlerReader.close();
+ asyncSshHandlerWriter.close();
+ }, msg -> {
+ if (LOG.isTraceEnabled()) {
+ LOG.trace("Forwarding message for client: {} on channel: {}, message: {}",
+ netconfHelloMessageAdditionalHeader.getAddress(), ctx.channel(),
+ AsyncSshHandlerWriter.byteBufToString(msg));
}
+ // Just forward to delegate
+ ctx.writeAndFlush(msg);
}, "ssh" + netconfHelloMessageAdditionalHeader.getAddress(), in);
}
private void writeAdditionalHeader(final ChannelHandlerContext ctx) {
- ctx.writeAndFlush(Unpooled.copiedBuffer(netconfHelloMessageAdditionalHeader.toFormattedString().getBytes()));
+ ctx.writeAndFlush(Unpooled.copiedBuffer(netconfHelloMessageAdditionalHeader.toFormattedString()
+ .getBytes(StandardCharsets.UTF_8)));
}
@Override
import io.netty.channel.EventLoopGroup;
import java.io.IOException;
import java.nio.channels.AsynchronousChannelGroup;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
sshServer.start();
}
- private static Map<String, String> getProperties(final SshProxyServerConfiguration sshProxyServerConfiguration) {
- final Map<String, String> ret = new HashMap<>();
- ret.put(ServerFactoryManager.IDLE_TIMEOUT, String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
- // TODO make auth timeout configurable on its own
- ret.put(ServerFactoryManager.AUTH_TIMEOUT, String.valueOf(sshProxyServerConfiguration.getIdleTimeout()));
-
- return ret;
- }
-
@Override
public void close() throws IOException {
try {
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<artifactId>org.osgi.compendium</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
</project>
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
<artifactId>akka-testkit_2.12</artifactId>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
+import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
private NetconfNodeManager netconfNodeManager;
private ActorRef masterActorRef;
private boolean finalClose = false;
- private boolean closed = false;
+ private final AtomicBoolean closed = new AtomicBoolean(false);
private boolean isMaster;
NetconfTopologyContext(final NetconfTopologySetup netconfTopologyDeviceSetup,
}
}
- private synchronized void stopDeviceConnectorAndActor() {
- if (closed) {
+ private void stopDeviceConnectorAndActor() {
+ if (!closed.compareAndSet(false, true)) {
return;
}
if (remoteDeviceConnector != null) {
netconfTopologyDeviceSetup.getActorSystem().stop(masterActorRef);
masterActorRef = null;
}
- closed = true;
}
}
NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId, final NetconfNode node,
final ActorRef deviceContextActorRef) {
//setup default values since default value is not supported in mdsal
- final Long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
+ final long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
? NetconfTopologyUtils.DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
- final Long keepaliveDelay = node.getKeepaliveDelay() == null
+ final long keepaliveDelay = node.getKeepaliveDelay() == null
? NetconfTopologyUtils.DEFAULT_KEEPALIVE_DELAY : node.getKeepaliveDelay();
- final Boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
+ final boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
? NetconfTopologyUtils.DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
RemoteDeviceHandler<NetconfSessionPreferences> salFacade = new MasterSalFacade(remoteDeviceId,
@Override
public ReconnectStrategy createReconnectStrategy() {
- final Long maxSleep = null;
- final Long deadline = null;
-
return new TimedReconnectStrategy(executor, minSleep,
- minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
+ minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);
}
}
}
Futures.addCallback(remoteSchemaContext, new FutureCallback<SchemaContext>() {
@Override
- public void onSuccess(final SchemaContext result) {
+ public void onSuccess(@Nonnull final SchemaContext result) {
LOG.info("{}: Schema context resolved: {}", id, result.getModules());
slaveSalManager.registerSlaveMountPoint(result, deviceRpcService, masterReference);
}
Futures.addCallback(read, new FutureCallback<Optional<NormalizedNode<?, ?>>>() {
@Override
- public void onSuccess(final Optional<NormalizedNode<?, ?>> result) {
+ public void onSuccess(@Nonnull final Optional<NormalizedNode<?, ?>> result) {
if (!result.isPresent()) {
sender.tell(new EmptyReadResponse(), self);
return;
import akka.util.Timeout;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
return delegateWrite.cancel();
}
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> commit() {
- return delegateWrite.commit(getIdentifier());
- }
-
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(final LogicalDatastoreType store,
final YangInstanceIdentifier path) {
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.messages.transactions.PutRequest;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitFailedReply;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest;
-import org.opendaylight.yangtools.yang.common.RpcResult;
-import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.slf4j.Logger;
});
}
- public ListenableFuture<RpcResult<TransactionStatus>> commit(final Object identifier) {
- LOG.trace("{}: Commit", id);
-
- final CheckedFuture<Void, TransactionCommitFailedException> submit = submit(identifier);
- return Futures.transform(submit, new Function<Void, RpcResult<TransactionStatus>>() {
- @Nullable
- @Override
- public RpcResult<TransactionStatus> apply(@Nullable final Void input) {
- return RpcResultBuilder.success(TransactionStatus.SUBMITED).build();
- }
- });
- }
-
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier identifier) {
Preconditions.checkState(opened.get(), "%s: Transaction was closed %s", id, identifier);
LOG.trace("{}: Delete {} via NETCONF: {}", id, store, identifier);
import akka.actor.ActorSystem;
import akka.util.Timeout;
import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
return proxyWriteAdapter.submit(getIdentifier());
}
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> commit() {
- return proxyWriteAdapter.commit(getIdentifier());
- }
-
@Override
public void delete(final LogicalDatastoreType store, final YangInstanceIdentifier identifier) {
proxyWriteAdapter.delete(store, identifier);
package org.opendaylight.netconf.topology.singleton.messages;
-import java.io.Serializable;
import java.util.List;
import org.opendaylight.controller.md.sal.dom.api.DOMDataBroker;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
/**
* Master sends this message to the own actor to set necessary parameters.
*/
-public class CreateInitialMasterActorData implements Serializable {
- private static final long serialVersionUID = 1L;
-
+public class CreateInitialMasterActorData {
private final DOMDataBroker deviceDataBroker;
private final List<SourceIdentifier> allSourceIdentifiers;
private final DOMRpcService deviceRpc;
package org.opendaylight.netconf.topology.singleton.messages;
-import java.io.Serializable;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
/**
* Master sends this message to the own actor to refresh setup data.
*/
-public class RefreshSetupMasterActorData implements Serializable {
- private static final long serialVersionUID = 1L;
-
+public class RefreshSetupMasterActorData {
private final NetconfTopologySetup netconfTopologyDeviceSetup;
private final RemoteDeviceId remoteDeviceId;
package org.opendaylight.netconf.topology.singleton.messages;
import akka.util.Timeout;
-import java.io.Serializable;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.impl.utils.NetconfTopologySetup;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaRepository;
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceRegistry;
-public class RefreshSlaveActor implements Serializable {
+public class RefreshSlaveActor {
private final SchemaRepository schemaRepository;
private final RemoteDeviceId id;
package org.opendaylight.netconf.topology.singleton.messages;
import com.google.common.collect.Iterables;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
public class SchemaPathMessage implements Serializable {
private static final long serialVersionUID = 1L;
- private SchemaPath schemaPath;
+ @SuppressFBWarnings("SE_BAD_FIELD")
+ private final SchemaPath schemaPath;
public SchemaPathMessage(final SchemaPath schemaPath) {
this.schemaPath = schemaPath;
private SchemaPathMessage schemaPathMessage;
- Proxy() {
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
//due to Externalizable
}
private InvokeRpcMessage invokeRpcMessage;
- Proxy() {
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
//due to Externalizable
}
package org.opendaylight.netconf.topology.singleton.messages.rpc;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.Externalizable;
import java.io.IOException;
import java.io.ObjectInput;
public class InvokeRpcMessageReply implements Serializable {
private static final long serialVersionUID = 1L;
+ @SuppressFBWarnings("SE_BAD_FIELD")
private final Collection<RpcError> rpcErrors;
private final NormalizedNodeMessage normalizedNodeMessage;
private InvokeRpcMessageReply invokeRpcMessageReply;
- Proxy() {
+ @SuppressWarnings("checkstyle:RedundantModifier")
+ public Proxy() {
//due to Externalizable
}
import java.io.Serializable;
public class NewReadTransactionReply implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef txActor;
import java.io.Serializable;
public class NewReadTransactionRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import java.io.Serializable;
public class NewReadWriteTransactionReply implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef txActor;
import java.io.Serializable;
public class NewWriteTransactionReply implements Serializable {
+ private static final long serialVersionUID = 1L;
private final ActorRef txActor;
import java.io.Serializable;
public class NewWriteTransactionRequest implements Serializable {
+ private static final long serialVersionUID = 1L;
}
import akka.util.Timeout;
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
import java.net.InetSocketAddress;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import org.junit.Before;
import org.junit.Test;
import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitReply;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
}
}
- @Test
- public void testCommit() throws Exception {
- final ListenableFuture<RpcResult<TransactionStatus>> submitFuture = tx.commit();
- masterActor.expectMsgClass(SubmitRequest.class);
- masterActor.reply(new SubmitReply());
- Assert.assertEquals(TransactionStatus.SUBMITED, submitFuture.get().getResult());
- }
-
@Test
public void testDelete() throws Exception {
tx.delete(STORE, PATH);
Assert.assertEquals(DocumentedException.ErrorType.APPLICATION, de.getErrorType());
}
}
-}
\ No newline at end of file
+}
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitReply;
import org.opendaylight.netconf.topology.singleton.messages.transactions.SubmitRequest;
import org.opendaylight.yangtools.yang.common.QName;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode;
import org.opendaylight.yangtools.yang.data.impl.schema.Builders;
}
}
- @Test
- public void testCommit() throws Exception {
- final ListenableFuture<RpcResult<TransactionStatus>> submitFuture = tx.commit();
- masterActor.expectMsgClass(SubmitRequest.class);
- masterActor.reply(new SubmitReply());
- Assert.assertEquals(TransactionStatus.SUBMITED, submitFuture.get().getResult());
- }
-
@Test
public void testDelete() throws Exception {
tx.delete(STORE, PATH);
submit.checkedGet();
}
-}
\ No newline at end of file
+}
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.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
<version>0.8.0-SNAPSHOT</version>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
protected NetconfConnectorDTO createDeviceCommunicator(final NodeId nodeId,
final NetconfNode node) {
//setup default values since default value is not supported in mdsal
- final Long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
+ final long defaultRequestTimeoutMillis = node.getDefaultRequestTimeoutMillis() == null
? DEFAULT_REQUEST_TIMEOUT_MILLIS : node.getDefaultRequestTimeoutMillis();
- final Long keepaliveDelay = node.getKeepaliveDelay() == null
+ final long keepaliveDelay = node.getKeepaliveDelay() == null
? DEFAULT_KEEPALIVE_DELAY : node.getKeepaliveDelay();
- final Boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
+ final boolean reconnectOnChangedSchema = node.isReconnectOnChangedSchema() == null
? DEFAULT_RECONNECT_ON_CHANGED_SCHEMA : node.isReconnectOnChangedSchema();
final IpAddress ipAddress = node.getHost().getIpAddress();
@Override
public ReconnectStrategy createReconnectStrategy() {
- final Long maxSleep = null;
- final Long deadline = null;
-
return new TimedReconnectStrategy(executor, minSleep,
- minSleep, sleepFactor, maxSleep, connectionAttempts, deadline);
+ minSleep, sleepFactor, null /*maxSleep*/, connectionAttempts, null /*deadline*/);
}
}
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>bundle-parent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<name>${project.artifactId}</name>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>2.5.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<!-- compile dependencies -->
<dependency>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
package org.opendaylight.netconf.util.messages;
-import static java.nio.charset.StandardCharsets.UTF_8;
-
-public final class NetconfMessageConstants {
-
- private NetconfMessageConstants(){}
+public interface NetconfMessageConstants {
/**
* The NETCONF 1.0 old-style message separator. This is framing mechanism
* is used by default.
*/
- public static final byte[] END_OF_MESSAGE = "]]>]]>".getBytes(UTF_8);
+ String END_OF_MESSAGE = "]]>]]>";
// bytes
- public static final int MIN_HEADER_LENGTH = 4;
+ int MIN_HEADER_LENGTH = 4;
// bytes
- public static final int MAX_HEADER_LENGTH = 13;
-
- public static final byte[] START_OF_CHUNK = "\n#".getBytes(UTF_8);
- public static final byte[] END_OF_CHUNK = "\n##\n".getBytes(UTF_8);
+ int MAX_HEADER_LENGTH = 13;
+ String START_OF_CHUNK = "\n#";
+ String END_OF_CHUNK = "\n##\n";
}
<module>mdsal-netconf-notification</module>
<module>mdsal-netconf-yang-library</module>
<module>mdsal-netconf-impl</module>
+ <module>netconf-parent</module>
<module>netconf-util</module>
<module>netconf-netty-util</module>
<module>netconf-mapping-api</module>
<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.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<version>1.8.0-SNAPSHOT</version>
<packaging>bundle</packaging>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>1.5.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<tag>HEAD</tag>
<url>https://wiki.opendaylight.org/view/OpenDaylight_Controller:MD-SAL</url>
</scm>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
- </plugins>
- </build>
</project>
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
import java.util.AbstractMap;
import java.util.Collections;
+import java.util.Locale;
import java.util.Map;
import java.util.Optional;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.regex.Pattern;
import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.mdsal.binding.generator.impl.ModuleInfoBackedContext;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
+import org.xml.sax.SAXException;
/**
* Holds URLs with YANG schema resources for all yang modules reported in
if (connection instanceof HttpURLConnection) {
connection.setRequestProperty("Accept", "application/xml");
final String userpass = username + ":" + password;
- final String basicAuth = "Basic " + printBase64Binary(userpass.getBytes());
+ final String basicAuth = "Basic " + printBase64Binary(userpass.getBytes(StandardCharsets.UTF_8));
connection.setRequestProperty("Authorization", basicAuth);
}
String extension = "";
final int i = fileName.lastIndexOf(46);
if (i != -1) {
- extension = fileName.substring(i).toLowerCase();
+ extension = fileName.substring(i).toLowerCase(Locale.ROOT);
}
return extension.equals(".json");
final NormalizedNodeStreamWriter writer = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
final JsonParserStream jsonParser = JsonParserStream.create(writer, LIBRARY_CONTEXT);
- final JsonReader reader = new JsonReader(new InputStreamReader(in));
+ final JsonReader reader = new JsonReader(new InputStreamReader(in, Charset.defaultCharset()));
jsonParser.parse(reader);
return resultHolder.isFinished() ? Optional.of(resultHolder.getResult()) : Optional.empty();
}
- @SuppressWarnings("checkstyle:IllegalCatch")
private static Optional<NormalizedNode<?, ?>> readXml(final InputStream in) {
try {
final DocumentBuilder docBuilder = UntrustedXML.newDocumentBuilder();
xmlParser.traverse(new DOMSource(doc.getDocumentElement()));
final NormalizedNode<?, ?> parsed = resultHolder.getResult();
return Optional.of(parsed);
- } catch (final Exception e) {
+ } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+ | SAXException e) {
LOG.warn("Unable to parse yang library xml content", e);
}
private static Optional<String> getValueOfSimpleNode(
final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {
- final Object value = node.getValue();
- return value == null || Strings.isNullOrEmpty(value.toString()) ? Optional.empty()
- : Optional.of(value.toString().trim());
+ final String valueStr = node.getValue().toString();
+ return Strings.isNullOrEmpty(valueStr) ? Optional.empty() : Optional.of(valueStr.trim());
}
@Override
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.stream.Collectors;
+import javax.annotation.Nonnull;
import javax.annotation.concurrent.GuardedBy;
import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcException;
final FutureCallback<DeviceSources> resolvedSourceCallback = new FutureCallback<DeviceSources>() {
@Override
- public void onSuccess(final DeviceSources result) {
+ public void onSuccess(@Nonnull final DeviceSources result) {
addProvidedSourcesToSchemaRegistry(result);
setUpSchema(result);
}
updateTransformer(null);
}
- private void updateTransformer(final MessageTransformer<NetconfMessage> transformer) {
+ private synchronized void updateTransformer(final MessageTransformer<NetconfMessage> transformer) {
messageTransformer = transformer;
}
if (cause instanceof MissingSchemaSourceException) {
requiredSources = handleMissingSchemaSourceException(
- requiredSources, (MissingSchemaSourceException) e.getCause());
+ requiredSources, (MissingSchemaSourceException) cause);
continue;
}
if (cause instanceof SchemaResolutionException) {
private static Optional<String> getValueOfSimpleNode(
final NormalizedNode<? extends YangInstanceIdentifier.PathArgument, ?> node) {
- final Object value = node.getValue();
- return value == null || Strings.isNullOrEmpty(value.toString())
- ? Optional.empty() : Optional.of(value.toString().trim());
+ final String valueStr = node.getValue().toString();
+ return Strings.isNullOrEmpty(valueStr) ? Optional.empty() : Optional.of(valueStr.trim());
}
@Override
try {
request = requests.peek();
if (request != null && request.future.isUncancellable()) {
- requests.poll();
+ request = requests.poll();
// we have just removed one request from the queue
// we can also release one permit
if (semaphore != null) {
@Override
public ListenableFuture<RpcResult<NetconfMessage>> sendRequest(final NetconfMessage message, final QName rpc) {
sessionLock.lock();
-
- if (semaphore != null && !semaphore.tryAcquire()) {
- LOG.warn("Limit of concurrent rpc messages was reached (limit :"
- + concurentRpcMsgs + "). Rpc reply message is needed. Discarding request of Netconf device with id"
- + id.getName());
- sessionLock.unlock();
- return Futures.immediateFailedFuture(new NetconfDocumentedException(
- "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
- + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
- }
-
try {
+ if (semaphore != null && !semaphore.tryAcquire()) {
+ LOG.warn("Limit of concurrent rpc messages was reached (limit :" + concurentRpcMsgs
+ + "). Rpc reply message is needed. Discarding request of Netconf device with id" + id.getName());
+ return Futures.immediateFailedFuture(new NetconfDocumentedException(
+ "Limit of rpc messages was reached (Limit :" + concurentRpcMsgs
+ + ") waiting for emptying the queue of Netconf device with id" + id.getName()));
+ }
+
return sendRequestWithLock(message, rpc);
} finally {
sessionLock.unlock();
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.AbstractFuture;
import javax.annotation.Nullable;
-import javax.annotation.concurrent.GuardedBy;
final class UncancellableFuture<V> extends AbstractFuture<V> {
- @GuardedBy("this")
- private boolean uncancellable = false;
+ private volatile boolean uncancellable = false;
UncancellableFuture(final boolean uncancellable) {
this.uncancellable = uncancellable;
}
- public synchronized boolean setUncancellable() {
+ public boolean setUncancellable() {
if (isCancelled()) {
return false;
}
return true;
}
- public synchronized boolean isUncancellable() {
+ public boolean isUncancellable() {
return uncancellable;
}
@Override
- public synchronized boolean cancel(final boolean mayInterruptIfRunning) {
+ public boolean cancel(final boolean mayInterruptIfRunning) {
return !uncancellable && super.cancel(mayInterruptIfRunning);
}
@Override
- public synchronized boolean set(@Nullable final V value) {
+ public boolean set(@Nullable final V value) {
Preconditions.checkState(uncancellable);
return super.set(value);
}
if (result != null && result.getResult() != null) {
LOG.debug("{}: Keepalive RPC successful with response: {}", id, result.getResult());
scheduleKeepalive();
- } else if (result != null && result.getErrors() != null) {
+ } else if (result != null && !result.getErrors().isEmpty()) {
LOG.warn("{}: Keepalive RPC failed with error: {}", id, result.getErrors());
scheduleKeepalive();
} else {
- LOG.warn("{} Keepalive RPC returned null with response: {}. Reconnecting netconf session", id, result);
+ LOG.warn("{} Keepalive RPC returned null with response. Reconnecting netconf session", id);
reconnect();
}
}
public static final class KeepaliveDOMRpcService implements DOMRpcService {
private final DOMRpcService deviceRpc;
- private ResetKeepalive resetKeepaliveTask;
+ private final ResetKeepalive resetKeepaliveTask;
private final long defaultRequestTimeoutMillis;
private final ScheduledExecutorService executor;
*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
}
}, MoreExecutors.directExecutor());
- return Futures.makeChecked(transformed, new Function<Exception, DOMRpcException>() {
- @Nullable
- @Override
- public DOMRpcException apply(@Nullable final Exception exception) {
- return new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type);
- }
- });
+ return Futures.makeChecked(transformed, exception ->
+ new DOMRpcImplementationNotAvailableException(exception, "Unable to invoke rpc %s", type));
}
@Nonnull
}, MoreExecutors.directExecutor());
}
- private static Node getNodeWithId(final RemoteDeviceId id) {
- final NodeBuilder builder = getNodeIdBuilder(id);
- return builder.build();
- }
-
private static NodeBuilder getNodeIdBuilder(final RemoteDeviceId id) {
final NodeBuilder nodeBuilder = new NodeBuilder();
nodeBuilder.setKey(new NodeKey(new NodeId(id.getName())));
*/
package org.opendaylight.netconf.sal.connect.netconf.sal;
-import com.google.common.base.Function;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
listener.sendRequest(netconfMessage, type.getLastComponent());
final ListenableFuture<DOMRpcResult> transformed =
- Futures.transform(rpcResultListenableFuture, (Function<RpcResult<NetconfMessage>, DOMRpcResult>) input1 -> {
+ Futures.transform(rpcResultListenableFuture, input1 -> {
if (input1.isSuccessful()) {
return transformer.toRpcResult(input1.getResult(), type);
- } else {
- return new DefaultDOMRpcResult(input1.getErrors());
}
+
+ return new DefaultDOMRpcResult(input1.getErrors());
}, MoreExecutors.directExecutor());
- return Futures.makeChecked(transformed,
- e -> new DOMRpcImplementationNotAvailableException(e,
+ return Futures.makeChecked(transformed, e -> new DOMRpcImplementationNotAvailableException(e,
"Unable to invoke rpc %s on device %s", type, deviceId));
}
public <T extends DOMRpcAvailabilityListener> ListenerRegistration<T> registerRpcListener(@Nonnull final T lsnr) {
throw new UnsupportedOperationException("Not available for netconf 1.0");
}
-
}
import com.google.common.util.concurrent.SettableFuture;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
-import javax.annotation.Nullable;
+import javax.annotation.Nonnull;
import org.opendaylight.controller.config.util.xml.DocumentedException;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
protected final List<ListenableFuture<DOMRpcResult>> resultsFutures;
private final List<TxListener> listeners = new CopyOnWriteArrayList<>();
// Allow commit to be called only once
- protected boolean finished = false;
+ protected volatile boolean finished = false;
public AbstractWriteTx(final NetconfBaseOps netOps, final RemoteDeviceId id, final boolean rollbackSupport) {
this.netOps = netOps;
editStructure, Optional.of(ModifyAction.NONE), "delete");
}
- @Override
- public final ListenableFuture<RpcResult<TransactionStatus>> commit() {
+ protected final ListenableFuture<RpcResult<Void>> commitConfiguration() {
listeners.forEach(listener -> listener.onTransactionSubmitted(this));
checkNotFinished();
finished = true;
- final ListenableFuture<RpcResult<TransactionStatus>> result = performCommit();
- Futures.addCallback(result, new FutureCallback<RpcResult<TransactionStatus>>() {
+ final ListenableFuture<RpcResult<Void>> result = performCommit();
+ Futures.addCallback(result, new FutureCallback<RpcResult<Void>>() {
@Override
- public void onSuccess(@Nullable final RpcResult<TransactionStatus> result) {
- if (result != null && result.isSuccessful()) {
+ public void onSuccess(@Nonnull final RpcResult<Void> rpcResult) {
+ if (rpcResult.isSuccessful()) {
listeners.forEach(txListener -> txListener.onTransactionSuccessful(AbstractWriteTx.this));
} else {
final TransactionCommitFailedException cause =
new TransactionCommitFailedException("Transaction failed",
- result.getErrors().toArray(new RpcError[result.getErrors().size()]));
+ rpcResult.getErrors().toArray(new RpcError[rpcResult.getErrors().size()]));
listeners.forEach(listener -> listener.onTransactionFailed(AbstractWriteTx.this, cause));
}
}
return result;
}
- protected abstract ListenableFuture<RpcResult<TransactionStatus>> performCommit();
+ protected abstract ListenableFuture<RpcResult<Void>> performCommit();
private void checkEditable(final LogicalDatastoreType store) {
checkNotFinished();
DataContainerChild<?, ?> editStructure,
Optional<ModifyAction> defaultOperation, String operation);
- protected ListenableFuture<RpcResult<TransactionStatus>> resultsToTxStatus() {
- final SettableFuture<RpcResult<TransactionStatus>> transformed = SettableFuture.create();
+ protected ListenableFuture<RpcResult<Void>> resultsToTxStatus() {
+ final SettableFuture<RpcResult<Void>> transformed = SettableFuture.create();
Futures.addCallback(Futures.allAsList(resultsFutures), new FutureCallback<List<DOMRpcResult>>() {
@Override
- public void onSuccess(final List<DOMRpcResult> domRpcResults) {
+ public void onSuccess(@Nonnull final List<DOMRpcResult> domRpcResults) {
domRpcResults.forEach(domRpcResult -> {
if (!domRpcResult.getErrors().isEmpty() && !transformed.isDone()) {
final NetconfDocumentedException exception =
});
if (!transformed.isDone()) {
- transformed.set(RpcResultBuilder.success(TransactionStatus.COMMITED).build());
+ transformed.set(RpcResultBuilder.<Void>success().build());
}
}
import com.google.common.base.Optional;
import com.google.common.util.concurrent.CheckedFuture;
-import com.google.common.util.concurrent.ListenableFuture;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataReadWriteTransaction;
import org.opendaylight.controller.md.sal.dom.api.DOMDataWriteTransaction;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
return delegateWriteTx.submit();
}
- @Override
- public ListenableFuture<RpcResult<TransactionStatus>> commit() {
- return delegateWriteTx.commit();
- }
-
@Override
public CheckedFuture<Optional<NormalizedNode<?, ?>>, ReadFailedException> read(
final LogicalDatastoreType store, final YangInstanceIdentifier path) {
package org.opendaylight.netconf.sal.connect.netconf.sal.tx;
-import com.google.common.base.Function;
import com.google.common.base.Optional;
import com.google.common.base.Preconditions;
import com.google.common.util.concurrent.CheckedFuture;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
private void lock() {
final FutureCallback<DOMRpcResult> lockCandidateCallback = new FutureCallback<DOMRpcResult>() {
@Override
- public void onSuccess(final DOMRpcResult result) {
+ public void onSuccess(@Nonnull final DOMRpcResult result) {
if (isSuccess(result)) {
if (LOG.isTraceEnabled()) {
LOG.trace("Lock candidate successful");
@Override
public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
- final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commit(),
- (Function<RpcResult<TransactionStatus>, Void>) input -> {
- Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
- "Submit failed with errors: %s", input.getErrors());
- return null;
- }, MoreExecutors.directExecutor());
+ final ListenableFuture<Void> commitFutureAsVoid = Futures.transform(commitConfiguration(), input -> {
+ Preconditions.checkArgument(input.isSuccessful() && input.getErrors().isEmpty(),
+ "Submit failed with errors: %s", input.getErrors());
+ return null;
+ }, MoreExecutors.directExecutor());
return Futures.makeChecked(commitFutureAsVoid, input -> new TransactionCommitFailedException(
"Submit of transaction " + getIdentifier() + " failed", input));
}
@Override
- public synchronized ListenableFuture<RpcResult<TransactionStatus>> performCommit() {
+ public synchronized ListenableFuture<RpcResult<Void>> performCommit() {
resultsFutures.add(netOps.commit(new NetconfRpcFutureCallback("Commit", id)));
- final ListenableFuture<RpcResult<TransactionStatus>> txResult = resultsToTxStatus();
+ final ListenableFuture<RpcResult<Void>> txResult = resultsToTxStatus();
- Futures.addCallback(txResult, new FutureCallback<RpcResult<TransactionStatus>>() {
+ Futures.addCallback(txResult, new FutureCallback<RpcResult<Void>>() {
@Override
- public void onSuccess(@Nullable final RpcResult<TransactionStatus> result) {
+ public void onSuccess(@Nullable final RpcResult<Void> result) {
cleanupOnSuccess();
}
import com.google.common.util.concurrent.MoreExecutors;
import java.util.ArrayList;
import java.util.List;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfBaseOps;
@Override
public synchronized CheckedFuture<Void, TransactionCommitFailedException> submit() {
- final ListenableFuture<Void> commmitFutureAsVoid = Futures.transform(commit(),
- (Function<RpcResult<TransactionStatus>, Void>) input -> null, MoreExecutors.directExecutor());
+ final ListenableFuture<Void> commmitFutureAsVoid = Futures.transform(commitConfiguration(),
+ (Function<RpcResult<Void>, Void>) input -> null, MoreExecutors.directExecutor());
return Futures.makeChecked(commmitFutureAsVoid,
input -> new TransactionCommitFailedException("Submit of transaction " + getIdentifier() + " failed",
}
@Override
- public synchronized ListenableFuture<RpcResult<TransactionStatus>> performCommit() {
+ public synchronized ListenableFuture<RpcResult<Void>> performCommit() {
for (final Change change : changes) {
resultsFutures.add(change.execute(id, netOps, rollbackSupport));
}
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
+import javax.annotation.Nonnull;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
}
@Override
- public YangTextSchemaSource apply(final DOMRpcResult input) {
+ public YangTextSchemaSource apply(@Nonnull final DOMRpcResult input) {
if (input.getErrors().isEmpty()) {
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
+import java.nio.charset.Charset;
import java.util.Map;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
private ListenableFuture<? extends YangTextSchemaSource> download(final SourceIdentifier sourceIdentifier) {
final URL url = availableSources.get(sourceIdentifier);
try (InputStream in = url.openStream()) {
- final String schemaContent = new String(ByteStreams.toByteArray(in));
+ final String schemaContent = new String(ByteStreams.toByteArray(in), Charset.defaultCharset());
final NetconfRemoteSchemaYangSourceProvider.NetconfYangTextSchemaSource yangSource =
new NetconfRemoteSchemaYangSourceProvider
.NetconfYangTextSchemaSource(id, sourceIdentifier, Optional.of(schemaContent));
import com.google.common.collect.Multimap;
import com.google.common.collect.Multimaps;
import java.io.IOException;
+import java.net.URISyntaxException;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
import java.util.Map;
import javax.annotation.Nonnull;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.stream.XMLStreamException;
import javax.xml.transform.dom.DOMResult;
import javax.xml.transform.dom.DOMSource;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import org.xml.sax.SAXException;
public class NetconfMessageTransformer implements MessageTransformer<NetconfMessage> {
this.strictParsing = strictParsing;
}
- @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public synchronized DOMNotification toNotification(final NetconfMessage message) {
final Map.Entry<Date, XmlElement> stripped = NetconfMessageTransformUtil.stripNotification(message);
notificationAsContainerSchemaNode, strictParsing);
xmlParser.traverse(new DOMSource(element));
content = (ContainerNode) resultHolder.getResult();
- } catch (final Exception e) {
+ } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+ | SAXException | UnsupportedOperationException e) {
throw new IllegalArgumentException(String.format("Failed to parse notification %s", element), e);
}
return new NetconfDeviceNotification(content, stripped.getKey());
|| rpc.getNamespace().equals(NetconfMessageTransformUtil.CREATE_SUBSCRIPTION_RPC_QNAME.getNamespace());
}
- @SuppressWarnings("checkstyle:IllegalCatch")
@Override
public synchronized DOMRpcResult toRpcResult(final NetconfMessage message, final SchemaPath rpc) {
final NormalizedNode<?, ?> normalizedNode;
strictParsing);
xmlParser.traverse(new DOMSource(xmlData));
dataNode = (ContainerNode) resultHolder.getResult();
- } catch (final Exception e) {
+ } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+ | SAXException e) {
throw new IllegalArgumentException(String.format("Failed to parse data response %s", xmlData), e);
}
rpcDefinition.getOutput(), strictParsing);
xmlParser.traverse(new DOMSource(element));
normalizedNode = resultHolder.getResult();
- } catch (final Exception e) {
+ } catch (XMLStreamException | URISyntaxException | IOException | ParserConfigurationException
+ | SAXException e) {
throw new IllegalArgumentException(String.format("Failed to parse RPC response %s", element), e);
}
}
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.MoreExecutors;
+import java.util.Locale;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade.KeepaliveDOMRpcService;
// Default operation
if (defaultOperation.isPresent()) {
- final String opString = defaultOperation.get().name().toLowerCase();
+ final String opString = defaultOperation.get().name().toLowerCase(Locale.ROOT);
editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_DEFAULT_OPERATION_QNAME))
.withValue(opString).build());
}
package org.opendaylight.netconf.sal.connect.netconf.util;
import com.google.common.util.concurrent.FutureCallback;
+import javax.annotation.Nonnull;
import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult;
import org.opendaylight.netconf.sal.connect.util.RemoteDeviceId;
import org.slf4j.Logger;
}
@Override
- public void onSuccess(final DOMRpcResult result) {
+ public void onSuccess(@Nonnull final DOMRpcResult result) {
if (result.getErrors().isEmpty()) {
LOG.trace("{}: {} invoked successfully", id, type);
} else {
import com.google.common.base.Preconditions;
import java.util.Collections;
import java.util.List;
+import java.util.Locale;
import java.util.Map;
+import java.util.Map.Entry;
import javax.xml.transform.dom.DOMSource;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.XmlElement;
final YangInstanceIdentifier.NodeIdentifierWithPredicates keyedId =
(YangInstanceIdentifier.NodeIdentifierWithPredicates) lastPathArgument;
final Map<QName, Object> keyValues = keyedId.getKeyValues();
- for (QName qualifiedName : keyValues.keySet()) {
+ for (Entry<QName, Object> entry : keyValues.entrySet()) {
+ QName qualifiedName = entry.getKey();
final List<XmlElement> key =
dataElement.getChildElementsWithinNamespace(qualifiedName.getLocalName(),
qualifiedName.getNamespace().toString());
} catch (DocumentedException e) {
throw new IllegalStateException("Key value not present in key element", e);
}
- if (!keyValues.get(qualifiedName).equals(textContent)) {
+ if (!entry.getValue().equals(textContent)) {
throw new IllegalStateException("Key value in path not equal to key value in xml");
}
}
}
private static String toOperationString(final ModifyAction operation) {
- return operation.name().toLowerCase();
+ return operation.name().toLowerCase(Locale.ROOT);
}
private static Element getSourceElement(final DOMSource source) {
verify(delegateWriteTx).submit();
}
- @Test
- public void commit() throws Exception {
- tx.commit();
- verify(delegateWriteTx).commit();
- }
-
@Test
public void cancel() throws Exception {
tx.cancel();
Assert.assertNotEquals(tx.getIdentifier(), tx2.getIdentifier());
}
-}
\ No newline at end of file
+}
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.opendaylight.odlparent</groupId>
- <artifactId>odlparent</artifactId>
- <version>3.0.2</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<dependencyManagement>
<dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.yangtools</groupId>
- <artifactId>yangtools-artifacts</artifactId>
- <version>2.0.2</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
<dependency>
<groupId>org.opendaylight.controller</groupId>
<artifactId>config-artifacts</artifactId>
<type>pom</type>
<scope>import</scope>
</dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.mdsal.model</groupId>
- <artifactId>mdsal-model-artifacts</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
</dependencies>
</dependencyManagement>
</execution>
</executions>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
import com.google.common.collect.Sets;
import java.util.Collections;
import java.util.Set;
+import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import org.opendaylight.controller.config.util.capability.Capability;
import org.opendaylight.netconf.api.monitoring.NetconfManagementSession;
public class DummyMonitoringService implements NetconfMonitoringService {
private static final Sessions EMPTY_SESSIONS = new SessionsBuilder().setSession(Collections.emptyList()).build();
- private static final Function<Capability, Uri> CAPABILITY_URI_FUNCTION = new Function<Capability, Uri>() {
- @Nullable
- @Override
- public Uri apply(Capability capability) {
- return new Uri(capability.getCapabilityUri());
- }
- };
+ private static final Function<Capability, Uri> CAPABILITY_URI_FUNCTION =
+ capability -> new Uri(capability.getCapabilityUri());
private static final Function<Capability, Schema> CAPABILITY_SCHEMA_FUNCTION = new Function<Capability, Schema>() {
@Nullable
@Override
- public Schema apply(@Nullable Capability capability) {
+ public Schema apply(@Nonnull Capability capability) {
return new SchemaBuilder()
.setIdentifier(capability.getModuleName().get())
.setNamespace(new Uri(capability.getModuleNamespace().get()))
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.AsyncHttpClientConfig;
import com.ning.http.client.HttpResponseStatus;
-import com.ning.http.client.ListenableFuture;
import com.ning.http.client.Realm;
import com.ning.http.client.Request;
import com.ning.http.client.Response;
}
private void invokeAsync() {
- final ArrayList<ListenableFuture<Response>> futures = new ArrayList<>();
LOG.info("Begin sending async requests");
for (final Request request : payloads) {
} catch (InterruptedException e) {
LOG.warn("Semaphore acquire interrupted");
}
- futures.add(asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
+ asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
@Override
public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
super.onStatusReceived(status);
semaphore.release();
return response;
}
- }));
+ });
}
LOG.info("Requests sent, waiting for responses");
import com.google.common.io.ByteStreams;
import com.google.common.io.CharStreams;
import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public final class Main {
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
}
@SuppressWarnings("checkstyle:IllegalCatch")
+ @SuppressFBWarnings({"UW_UNCOND_WAIT", "WA_NOT_IN_LOOP"})
public static void main(final String[] args) {
final TesttoolParameters params = TesttoolParameters.parseArgs(args, TesttoolParameters.getParser());
params.validate();
} else {
try {
future.get();
- } catch (final ExecutionException e) {
+ } catch (final ExecutionException | InterruptedException e) {
LOG.info("{}. thread failed.", threadNum, e);
}
}
configGenerator.updateFeatureFile(generated);
configGenerator.changeLoadOrder();
}
- } catch (final Exception e) {
+ } catch (RuntimeException | InterruptedException e) {
LOG.error("Unhandled exception", e);
netconfDeviceSimulator.close();
System.exit(1);
Preconditions.checkState(configDir.mkdirs(), "Unable to create directory " + configDir);
}
- for (final File file : configDir.listFiles(pathname ->
- !pathname.isDirectory() && pathname.getName().startsWith(SIM_DEVICE_CFG_PREFIX))) {
- Preconditions.checkState(file.delete(), "Unable to clean previous generated file %s", file);
+ final File[] files = configDir.listFiles(pathname ->
+ !pathname.isDirectory() && pathname.getName().startsWith(SIM_DEVICE_CFG_PREFIX));
+ if (files != null) {
+ for (final File file : files) {
+ Preconditions.checkState(file.delete(), "Unable to clean previous generated file %s", file);
+ }
}
try (InputStream stream = Main.class.getResourceAsStream(NETCONF_CONNECTOR_XML)) {
String configContent = String.format(
middleBlueprint, name, address, String.valueOf(openDevice), String.valueOf(!useSsh));
configContent = String.format(
- "%s%s%d%s\n%s\n", configContent, "<connection-timeout-millis>",
+ "%s%s%d%s%n%s%n", configContent, "<connection-timeout-millis>",
generateConfigsTimeout, "</connection-timeout-millis>", "</module>");
builder.append(configContent);
import com.google.common.collect.Sets;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.Channel;
import io.netty.channel.ChannelFuture;
import io.netty.channel.local.LocalAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressFBWarnings("DM_DEFAULT_ENCODING")
public class NetconfDeviceSimulator implements Closeable {
private static final Logger LOG = LoggerFactory.getLogger(NetconfDeviceSimulator.class);
import com.ning.http.client.AsyncHttpClientConfig.Builder;
import com.ning.http.client.Request;
import com.ning.http.client.Response;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import net.sourceforge.argparse4j.inf.ArgumentParser;
-import net.sourceforge.argparse4j.inf.ArgumentParserException;
import org.opendaylight.netconf.test.tool.config.Configuration;
import org.opendaylight.netconf.test.tool.config.ConfigurationBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
public final class ScaleUtil {
private static final ScheduledExecutorService EXECUTOR = new LoggingWrapperExecutor(4);
private static final Semaphore SEMAPHORE = new Semaphore(0);
root.error("Failed to start any simulated devices, exiting...");
System.exit(1);
}
- if (params.distroFolder != null) {
- final Main.ConfigGenerator configGenerator = new Main.ConfigGenerator(
- params.distroFolder, openDevices);
- final List<File> generated = configGenerator.generate(
- params.ssh, params.generateConfigBatchSize,
- params.generateConfigsTimeout, params.generateConfigsAddress,
- params.devicesPerPort);
- configGenerator.updateFeatureFile(generated);
- configGenerator.changeLoadOrder();
+
+ if (params.distroFolder == null) {
+ root.error("Distro folder is not set, exiting...");
+ System.exit(1);
}
+
+ final Main.ConfigGenerator configGenerator = new Main.ConfigGenerator(
+ params.distroFolder, openDevices);
+ final List<File> generated = configGenerator.generate(
+ params.ssh, params.generateConfigBatchSize,
+ params.generateConfigsTimeout, params.generateConfigsAddress,
+ params.devicesPerPort);
+ configGenerator.updateFeatureFile(generated);
+ configGenerator.changeLoadOrder();
} catch (final Exception e) {
root.error("Unhandled exception", e);
netconfDeviceSimulator.close();
if (f.isDirectory()) {
deleteFolder(f);
} else {
- f.delete();
+ if (!f.delete()) {
+ root.warn("Failed to delete {}", f);
+ }
}
}
}
- folder.delete();
- }
-
- private static TesttoolParameters parseArgs(final String[] args, final ArgumentParser parser) {
- final TesttoolParameters parameters = new TesttoolParameters();
- try {
- parser.parseArgs(args, parameters);
- return parameters;
- } catch (ArgumentParserException e) {
- parser.handleError(e);
+ if (!folder.delete()) {
+ root.warn("Failed to delete {}", folder);
}
-
- System.exit(1);
- return null;
}
private static class ScaleVerifyCallable implements Callable {
return new LogOnExceptionCallable(callable);
}
- private class LogOnExceptionCallable implements Callable {
- private Callable theCallable;
+ private static class LogOnExceptionCallable implements Callable {
+ private final Callable theCallable;
LogOnExceptionCallable(Callable theCallable) {
this.theCallable = theCallable;
import com.google.common.base.Preconditions;
import com.google.common.io.CharStreams;
import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.StringJoiner;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
+@SuppressFBWarnings({"DM_EXIT", "DM_DEFAULT_ENCODING"})
public class TesttoolParameters {
private static final String HOST_KEY = "{HOST}";
checkArgument(schemasDir.isDirectory(), "Schemas dir has to be a directory");
checkArgument(schemasDir.canRead(), "Schemas dir has to be readable");
- final List<File> files = Arrays.asList(schemasDir.listFiles());
+ final File[] filesArray = schemasDir.listFiles();
+ final List<File> files = filesArray != null ? Arrays.asList(filesArray) : Collections.emptyList();
for (final File file : files) {
final Matcher matcher = YANG_FILENAME_PATTERN.matcher(file.getName());
if (!matcher.matches()) {
- final BufferedReader reader;
- try {
- reader = new BufferedReader(new FileReader(file));
+ try (BufferedReader reader = new BufferedReader(new FileReader(file))) {
String line = reader.readLine();
while (!DATE_PATTERN.matcher(line).find()) {
line = reader.readLine();
final String revision = m.group(1);
final String correctName = moduleName + "@" + revision + ".yang";
final File correctNameFile = new File(correctName);
- file.renameTo(correctNameFile);
+ if (!file.renameTo(correctNameFile)) {
+ System.err.println("Failed to rename " + file);
+ }
}
} catch (final IOException e) {
// print error to console (test tool is running from console)
final int batchedRequests = openDevices.size() / generateConfigBatchSize;
final int batchedRequestsPerThread = batchedRequests / threadAmount;
- final int leftoverBatchedRequests = (batchedRequests) % threadAmount;
- final int leftoverRequests = openDevices.size() - (batchedRequests * generateConfigBatchSize);
+ final int leftoverBatchedRequests = batchedRequests % threadAmount;
+ final int leftoverRequests = openDevices.size() - batchedRequests * generateConfigBatchSize;
final StringBuilder destBuilder = new StringBuilder(DEST);
destBuilder.replace(destBuilder.indexOf(ADDRESS_PORT),
controllerDestination);
for (int l = 0; l < threadAmount; l++) {
- from = l * (batchedRequests * batchedRequestsPerThread);
- to = from + (batchedRequests * batchedRequestsPerThread);
+ from = l * batchedRequests * batchedRequestsPerThread;
+ to = from + batchedRequests * batchedRequestsPerThread;
iterator = openDevices.subList(from, to).iterator();
allThreadsPayloads.add(createBatchedPayloads(batchedRequestsPerThread, iterator, editContentString,
destBuilder.toString()));
}
ArrayList<Execution.DestToPayload> payloads = null;
if (leftoverBatchedRequests > 0) {
- from = threadAmount * (batchedRequests * batchedRequestsPerThread);
- to = from + (batchedRequests * batchedRequestsPerThread);
+ from = threadAmount * batchedRequests * batchedRequestsPerThread;
+ to = from + batchedRequests * batchedRequestsPerThread;
iterator = openDevices.subList(from, to).iterator();
payloads = createBatchedPayloads(leftoverBatchedRequests, iterator, editContentString,
destBuilder.toString());
}
if (leftoverRequests > 0) {
- from = (threadAmount) * requestPerThreads;
+ from = threadAmount * requestPerThreads;
to = from + leftoverRequests;
iterator = openDevices.subList(from, to).iterator();
allThreadsPayloads.add(createPayloads(iterator, editContentString));
final ArrayList<Execution.DestToPayload> payloads = new ArrayList<>();
for (int i = 0; i < batchedRequestsCount; i++) {
- String payload = "";
+ StringBuilder payload = new StringBuilder();
for (int j = 0; j < generateConfigBatchSize; j++) {
final StringBuilder payloadBuilder = new StringBuilder(
prepareMessage(openDevices.next(), editContentString));
- payload += modifyMessage(payloadBuilder, j, generateConfigBatchSize);
+ payload.append(modifyMessage(payloadBuilder, j, generateConfigBatchSize));
}
- payloads.add(new Execution.DestToPayload(destination, payload));
+ payloads.add(new Execution.DestToPayload(destination, payload.toString()));
}
return payloads;
}
import com.ning.http.client.AsyncCompletionHandler;
import com.ning.http.client.AsyncHttpClient;
import com.ning.http.client.HttpResponseStatus;
-import com.ning.http.client.ListenableFuture;
import com.ning.http.client.Request;
import com.ning.http.client.Response;
import java.util.ArrayList;
@Override
public void invoke() {
- final ArrayList<ListenableFuture<Response>> futures = new ArrayList<>();
LOG.info("Begin sending async requests");
for (final Request request : payloads) {
} catch (InterruptedException e) {
LOG.warn("Semaphore acquire interrupted");
}
- futures.add(asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
+ asyncHttpClient.executeRequest(request, new AsyncCompletionHandler<Response>() {
@Override
public STATE onStatusReceived(HttpResponseStatus status) throws Exception {
super.onStatusReceived(status);
semaphore.release();
return response;
}
- }));
+ });
}
LOG.info("Requests sent, waiting for responses");
import com.google.common.base.Stopwatch;
import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+@SuppressFBWarnings("DM_EXIT")
public final class RestPerfClient {
private static final Logger LOG = LoggerFactory.getLogger(RestPerfClient.class);
// and do not log it
if (allThreadsCompleted) {
LOG.info(
- "Requests per second: {}", (parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+ "Requests per second: {}", parameters.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
}
System.exit(0);
}
import ch.qos.logback.classic.Level;
import com.google.common.base.Stopwatch;
import com.google.common.io.Files;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.util.HashedWheelTimer;
import io.netty.util.Timer;
import org.w3c.dom.Node;
import org.xml.sax.SAXException;
+@SuppressFBWarnings("DM_EXIT")
public final class StressClient {
private static final Logger LOG = LoggerFactory.getLogger(StressClient.class);
started.stop();
LOG.info("FINISHED. Execution time: {}", started);
- LOG.info("Requests per second: {}", (params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS)));
+ LOG.info("Requests per second: {}", params.editCount * 1000.0 / started.elapsed(TimeUnit.MILLISECONDS));
// Cleanup
timer.stop();
}
}
- if (e1Children.isEmpty() && e1Children.isEmpty()) {
+ if (e1Children.isEmpty() && e2Children.isEmpty()) {
try {
return e1.getTextContent().equals(e2.getTextContent());
} catch (final DocumentedException e) {
import com.google.common.base.Optional;
import java.io.File;
import java.io.IOException;
-import java.util.Collections;
import java.util.List;
import org.opendaylight.controller.config.util.xml.DocumentedException;
import org.opendaylight.controller.config.util.xml.XmlElement;
private static DataList loadInitialConfigXMLFile(final File file) {
LOG.info("Loading initial config xml file: {}", file.getName());
DataList configData = new DataList();
- List<XmlElement> xmlElementList = Collections.emptyList();
try {
Element element = XmlUtil.readXmlToElement(file);
XmlElement xmlElement = XmlElement.fromDomElement(element);
- xmlElementList = xmlElement.getChildElements();
+ List<XmlElement> xmlElementList = xmlElement.getChildElements();
configData.setConfigList(xmlElementList);
} catch (IOException e) {
LOG.info("IO exception loading xml file: {} ", e.getMessage());
package org.opendaylight.netconf.test.tool.scale.util;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import net.sourceforge.argparse4j.ArgumentParsers;
import net.sourceforge.argparse4j.annotation.Arg;
import net.sourceforge.argparse4j.inf.ArgumentParser;
import net.sourceforge.argparse4j.inf.ArgumentParserException;
+@SuppressFBWarnings("DM_EXIT")
public class ScaleUtilParameters {
@Arg(dest = "distro-folder")
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.mdsal</groupId>
- <artifactId>binding-parent</artifactId>
- <version>0.13.0-SNAPSHOT</version>
- <relativePath/>
+ <groupId>org.opendaylight.netconf</groupId>
+ <artifactId>netconf-parent</artifactId>
+ <version>1.5.0-SNAPSHOT</version>
+ <relativePath>../netconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
</instructions>
</configuration>
</plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-checkstyle-plugin</artifactId>
- <configuration>
- <propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
- </configuration>
- </plugin>
</plugins>
</build>
- <dependencyManagement>
- <dependencies>
- <dependency>
- <groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-artifacts</artifactId>
- <version>${project.version}</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- <dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>mdsal-artifacts</artifactId>
- <version>1.8.0-SNAPSHOT</version>
- <type>pom</type>
- <scope>import</scope>
- </dependency>
- </dependencies>
- </dependencyManagement>
-
<dependencies>
<dependency>
<groupId>org.opendaylight.controller</groupId>
import org.opendaylight.yangtools.yang.model.repo.spi.SchemaSourceListener;
import org.opendaylight.yangtools.yang.model.repo.util.FilesystemSchemaSourceCache;
import org.opendaylight.yangtools.yang.parser.repo.SharedSchemaRepository;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-import org.osgi.framework.ServiceReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
return sourceIdentifier.getRevision().map(rev -> new OptionalRevision(new RevisionIdentifier(rev.toString())))
.orElse(NO_REVISION);
}
-
- private <T> T getObjectFromBundleContext(final Class<T> type, final String serviceRefName) {
- final BundleContext bundleContext = FrameworkUtil.getBundle(getClass()).getBundleContext();
- final ServiceReference<?> serviceReference = bundleContext.getServiceReference(serviceRefName);
- return (T) bundleContext.getService(serviceReference);
- }
}
import com.google.common.io.ByteStreams;
import com.google.common.util.concurrent.ListenableFuture;
import java.io.IOException;
+import java.nio.charset.Charset;
import java.util.concurrent.ExecutionException;
import org.opendaylight.yanglib.api.YangLibService;
import org.opendaylight.yangtools.yang.common.Revision;
try {
final YangTextSchemaSource source = sourceFuture.get();
- return new String(ByteStreams.toByteArray(source.openStream()));
+ return new String(ByteStreams.toByteArray(source.openStream()), Charset.defaultCharset());
} catch (InterruptedException | ExecutionException | IOException e) {
throw new IllegalStateException("Unable to get schema " + sourceId, e);
}
</parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>netconf-parent</artifactId>
+ <artifactId>netconf-aggregator</artifactId>
<version>1.5.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
*/
package org.opendaylight.protocol.framework;
+import com.google.common.base.Preconditions;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelFutureListener;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.concurrent.Promise;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-
/**
* Abstract base class for session negotiators. It implements the basic
* substrate to implement SessionNegotiator API specification, with subclasses
* @param <S> Protocol session type, has to extend {@code ProtocolSession<M>}
*/
@Deprecated
-public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>> extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
+public abstract class AbstractSessionNegotiator<M, S extends AbstractProtocolSession<?>>
+ extends ChannelInboundHandlerAdapter implements SessionNegotiator<S> {
private final Logger LOG = LoggerFactory.getLogger(AbstractSessionNegotiator.class);
private final Promise<S> promise;
protected final Channel channel;
* @param msg Message which should be sent.
*/
protected final void sendMessage(final M msg) {
- this.channel.writeAndFlush(msg).addListener(
- (ChannelFutureListener) f -> {
- if (!f.isSuccess()) {
- LOG.info("Failed to send message {}", msg, f.cause());
- negotiationFailed(f.cause());
- } else {
- LOG.trace("Message {} sent to socket", msg);
- }
- });
+ this.channel.writeAndFlush(msg).addListener(f -> {
+ if (!f.isSuccess()) {
+ LOG.info("Failed to send message {}", msg, f.cause());
+ negotiationFailed(f.cause());
+ } else {
+ LOG.trace("Message {} sent to socket", msg);
+ }
+ });
}
@Override
import io.netty.util.concurrent.DefaultPromise;
import io.netty.util.concurrent.EventExecutor;
import io.netty.util.concurrent.Future;
-import io.netty.util.concurrent.GenericFutureListener;
import java.net.InetSocketAddress;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
channel.pipeline().addLast(new ClosedChannelHandler(ReconnectPromise.this));
});
- pending.addListener((GenericFutureListener<Future<Object>>) future -> {
+ pending.addListener(future -> {
if (!future.isSuccess() && !ReconnectPromise.this.isDone()) {
ReconnectPromise.this.setFailure(future.cause());
}
</parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-parent</artifactId>
+ <artifactId>restconf-subsystem</artifactId>
<version>1.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>restconf-binding-parent</module>
+ <module>restconf-parent</module>
<module>restconf-artifacts</module>
<module>restconf-models</module>
<module>restconf-common-models</module>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../../restconf-binding-parent</relativePath>
+ <relativePath>../../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../../restconf-binding-parent</relativePath>
+ <relativePath>../../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../../restconf-binding-parent</relativePath>
+ <relativePath>../../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
import org.junit.Test;
import org.mockito.ArgumentCaptor;
import org.mockito.Mockito;
-import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPoint;
import org.opendaylight.controller.md.sal.dom.api.DOMMountPointService;
import org.opendaylight.netconf.sal.restconf.impl.BrokerFacade;
import org.opendaylight.netconf.sal.restconf.impl.ControllerContext;
import org.opendaylight.netconf.sal.restconf.impl.RestconfImpl;
-import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
import org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode;
import org.opendaylight.yangtools.yang.model.api.Module;
// - we expecting problems with singletons ControllerContext as schemaContext holder
public void createConfigurationDataTest() throws UnsupportedEncodingException, ParseException {
initMocking();
- final RpcResult<TransactionStatus> rpcResult = new DummyRpcResult.Builder<TransactionStatus>().result(
- TransactionStatus.COMMITED).build();
-
when(brokerFacade.commitConfigurationDataPost((SchemaContext) null, any(YangInstanceIdentifier.class),
any(NormalizedNode.class), null, null))
.thenReturn(mock(CheckedFuture.class));
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
</parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
<packaging>pom</packaging>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<groupId>org.opendaylight.netconf</groupId>
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.opendaylight.netconf</groupId>
- <artifactId>restconf-binding-parent</artifactId>
+ <artifactId>restconf-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath>../restconf-binding-parent</relativePath>
+ <relativePath>../restconf-parent</relativePath>
</parent>
<artifactId>sal-restconf-broker</artifactId>