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.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.util.mapping.AbstractSingletonNetconfOperation;
+import org.opendaylight.yangtools.yang.common.QName;
+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.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.ImmutableNormalizedNodeStreamWriter;
+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.SchemaContext;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+public class CopyConfig extends AbstractSingletonNetconfOperation {
+ private static final Logger LOG = LoggerFactory.getLogger(CopyConfig.class);
+
+ private static final String OPERATION_NAME = "copy-config";
+ private static final String CONFIG_KEY = "config";
+ private static final String TARGET_KEY = "target";
+ 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 CurrentSchemaContext schemaContext;
+ private final TransactionProvider transactionProvider;
+
+ public CopyConfig(final String netconfSessionIdForReporting, final CurrentSchemaContext schemaContext,
+ final TransactionProvider transactionProvider) {
+ super(netconfSessionIdForReporting);
+ this.schemaContext = schemaContext;
+ this.transactionProvider = transactionProvider;
+ }
+
+ @Override
+ protected Element handleWithNoSubsequentOperations(final Document document, final XmlElement operationElement)
+ throws DocumentedException {
+ final Datastore targetDatastore = extractTargetParameter(operationElement);
+ 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 NormalizedNode<?, ?> data = parseIntoNormalizedNode(schemaNode, element);
+ 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());
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ private NormalizedNode<?, ?> parseIntoNormalizedNode(final DataSchemaNode schemaNode, final XmlElement element)
+ throws DocumentedException {
+ if (!(schemaNode instanceof ContainerSchemaNode) && !(schemaNode instanceof ListSchemaNode)) {
+ // this should never happen since copy-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 = ImmutableNormalizedNodeStreamWriter.from(resultHolder);
+ 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 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();
+ }
+
+ 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.PROTOCOL, ErrorTag.UNKNOWN_ELEMENT,
+ ErrorSeverity.ERROR);
+ } else {
+ final XmlElement targetChildNode =
+ XmlElement.fromDomElement((Element) elementsByTagName.item(0)).getOnlyChildElement();
+ return Datastore.valueOf(targetChildNode.getName());
+ }
+ }
+
+ private static XmlElement extractConfigParameter(final XmlElement operationElement) throws DocumentedException {
+ final Optional<XmlElement> sourceNode = operationElement.getOnlyChildElementOptionally(SOURCE_KEY);
+ if (!sourceNode.isPresent()) {
+ throw new DocumentedException(SOURCE_KEY + " element is missing",
+ ErrorType.PROTOCOL,
+ ErrorTag.MISSING_ELEMENT,
+ ErrorSeverity.ERROR);
+ }
+ final Optional<XmlElement> configNode =
+ sourceNode.get().getOnlyChildElementOptionally(CONFIG_KEY);
+ if (!configNode.isPresent()) {
+ throw new DocumentedException(CONFIG_KEY + " element is missing",
+ ErrorType.PROTOCOL,
+ ErrorTag.MISSING_ELEMENT,
+ ErrorSeverity.ERROR);
+ }
+ return configNode.get();
+ }
+
+ private 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;
+ }
+
+}
--- /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 static org.opendaylight.yangtools.yang.test.util.YangParserTestUtils.parseYangResources;
+
+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.custommonkey.xmlunit.examples.RecursiveElementNameAndTextQualifier;
+import org.junit.Before;
+import org.junit.Test;
+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.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.GetConfig;
+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;
+
+public class CopyConfigTest {
+ private static final Logger LOG = LoggerFactory.getLogger(CopyConfigTest.class);
+ private 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";
+ private 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 = parseYangResources(CopyConfigTest.class,
+ "/yang/mdsal-netconf-mapping-test.yang");
+ 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);
+ }
+
+ @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"));
+ }
+
+ @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;
+ }
+
+ 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 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 copyConfig(final String resource) throws Exception {
+ final CopyConfig copyConfig = new CopyConfig(SESSION_ID_FOR_REPORTING, currentSchemaContext,
+ transactionProvider);
+ return executeOperation(copyConfig, resource);
+ }
+
+ 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 static void verifyResponse(final Document response, final Document template) throws Exception {
+ final DetailedDiff dd = new DetailedDiff(new Diff(response, template));
+ dd.overrideElementQualifier(new RecursiveElementNameAndTextQualifier());
+ 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());
+ }
+
+ 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());
+ }
+
+}
\ 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 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