X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=netconf%2Fsal-netconf-connector%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fnetconf%2Fsal%2Fconnect%2Fnetconf%2Futil%2FNetconfBaseOps.java;h=88b45260707f66676d296d8c0a9e095ec8af1c6e;hb=982e75ece2483e413befe3edd8fd90022a644f72;hp=debd460936ecfb524da81fd2385688a47138fd28;hpb=6d7e12bf3ef64e5004703a1d540e7e26f30a9595;p=netconf.git diff --git a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java index debd460936..88b4526070 100644 --- a/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java +++ b/netconf/sal-netconf-connector/src/main/java/org/opendaylight/netconf/sal/connect/netconf/util/NetconfBaseOps.java @@ -5,50 +5,56 @@ * 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.sal.connect.netconf.util; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.EDIT_CONTENT_NODEID; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DEFAULT_OPERATION_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_ERROR_OPTION_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_LOCK_QNAME; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DEFAULT_OPERATION_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_DISCARD_CHANGES_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_EDIT_CONFIG_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_ERROR_OPTION_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_CONFIG_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_GET_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_LOCK_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_LOCK_PATH; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_SOURCE_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TARGET_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_QNAME; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_VALIDATE_QNAME; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_SOURCE_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_TARGET_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_NODEID; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_UNLOCK_PATH; +import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_VALIDATE_NODEID; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.ROLLBACK_ON_ERROR_OPTION; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toFilterStructure; import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toId; -import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.toPath; -import com.google.common.base.Function; -import com.google.common.base.Optional; import com.google.common.base.Preconditions; +import com.google.common.util.concurrent.FluentFuture; import com.google.common.util.concurrent.FutureCallback; -import com.google.common.util.concurrent.Futures; -import com.google.common.util.concurrent.ListenableFuture; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcResult; -import org.opendaylight.controller.md.sal.dom.api.DOMRpcService; +import com.google.common.util.concurrent.MoreExecutors; +import java.util.Locale; +import java.util.Optional; +import org.opendaylight.mdsal.dom.api.DOMRpcResult; +import org.opendaylight.mdsal.dom.api.DOMRpcService; import org.opendaylight.netconf.sal.connect.netconf.sal.KeepaliveSalFacade.KeepaliveDOMRpcService; import org.opendaylight.netconf.sal.connect.netconf.sal.SchemalessNetconfDeviceRpc; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.copy.config.input.target.ConfigTarget; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.edit.config.input.EditContent; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.get.config.input.source.ConfigSource; +import org.opendaylight.yangtools.yang.common.Empty; 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.YangInstanceIdentifier.NodeIdentifier; import org.opendaylight.yangtools.yang.data.api.schema.AnyXmlNode; import org.opendaylight.yangtools.yang.data.api.schema.ContainerNode; import org.opendaylight.yangtools.yang.data.api.schema.DataContainerChild; 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.builder.api.DataContainerNodeAttrBuilder; +import org.opendaylight.yangtools.yang.data.impl.schema.builder.api.DataContainerNodeBuilder; import org.opendaylight.yangtools.yang.model.api.SchemaContext; /** @@ -56,6 +62,8 @@ import org.opendaylight.yangtools.yang.model.api.SchemaContext; * According to RFC-6241 */ public final class NetconfBaseOps { + private static final NodeIdentifier CONFIG_SOURCE_NODEID = NodeIdentifier.create(ConfigSource.QNAME); + private static final NodeIdentifier CONFIG_TARGET_NODEID = NodeIdentifier.create(ConfigTarget.QNAME); private final DOMRpcService rpc; private final SchemaContext schemaContext; @@ -65,180 +73,173 @@ public final class NetconfBaseOps { this.rpc = rpc; this.schemaContext = schemaContext; - if ((rpc instanceof KeepaliveDOMRpcService) - && (((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc)) { + if (rpc instanceof KeepaliveDOMRpcService + && ((KeepaliveDOMRpcService) rpc).getDeviceRpc() instanceof SchemalessNetconfDeviceRpc) { this.transformer = new SchemalessRpcStructureTransformer(); } else { this.transformer = new NetconfRpcStructureTransformer(schemaContext); } } - public ListenableFuture lock(final FutureCallback callback, final QName datastore) { + public FluentFuture lock(final FutureCallback callback, final QName datastore) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(datastore); - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_LOCK_QNAME), getLockContent(datastore)); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NETCONF_LOCK_PATH, getLockContent(datastore)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture lockCandidate(final FutureCallback callback) { - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_LOCK_QNAME), getLockContent(NETCONF_CANDIDATE_QNAME)); - Futures.addCallback(future, callback); + public FluentFuture lockCandidate(final FutureCallback callback) { + final FluentFuture future = rpc.invokeRpc(NETCONF_LOCK_PATH, + getLockContent(NETCONF_CANDIDATE_QNAME)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture lockRunning(final FutureCallback callback) { - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_LOCK_QNAME), getLockContent(NETCONF_RUNNING_QNAME)); - Futures.addCallback(future, callback); + public FluentFuture lockRunning(final FutureCallback callback) { + final FluentFuture future = rpc.invokeRpc(NETCONF_LOCK_PATH, + getLockContent(NETCONF_RUNNING_QNAME)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture unlock(final FutureCallback callback, final QName datastore) { + public FluentFuture unlock(final FutureCallback callback, final QName datastore) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(datastore); - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_UNLOCK_QNAME), getUnLockContent(datastore)); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, getUnLockContent(datastore)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture unlockRunning(final FutureCallback callback) { - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_UNLOCK_QNAME), getUnLockContent(NETCONF_RUNNING_QNAME)); - Futures.addCallback(future, callback); + public FluentFuture unlockRunning(final FutureCallback callback) { + final FluentFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, + getUnLockContent(NETCONF_RUNNING_QNAME)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture unlockCandidate(final FutureCallback callback) { - final ListenableFuture future = - rpc.invokeRpc(toPath(NETCONF_UNLOCK_QNAME), getUnLockContent(NETCONF_CANDIDATE_QNAME)); - Futures.addCallback(future, callback); + public FluentFuture unlockCandidate(final FutureCallback callback) { + final FluentFuture future = rpc.invokeRpc(NETCONF_UNLOCK_PATH, + getUnLockContent(NETCONF_CANDIDATE_QNAME)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture discardChanges(final FutureCallback callback) { + public FluentFuture discardChanges(final FutureCallback callback) { Preconditions.checkNotNull(callback); - final ListenableFuture future = rpc.invokeRpc(toPath(NETCONF_DISCARD_CHANGES_QNAME), null); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NETCONF_DISCARD_CHANGES_PATH, null); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture commit(final FutureCallback callback) { + public FluentFuture commit(final FutureCallback callback) { Preconditions.checkNotNull(callback); - final ListenableFuture future = rpc.invokeRpc( - toPath(NetconfMessageTransformUtil.NETCONF_COMMIT_QNAME), NetconfMessageTransformUtil.COMMIT_RPC_CONTENT); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_COMMIT_PATH, + NetconfMessageTransformUtil.COMMIT_RPC_CONTENT); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture validate(final FutureCallback callback, final QName datastore) { + public FluentFuture validate(final FutureCallback callback, final QName datastore) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(datastore); - final ListenableFuture future = rpc.invokeRpc( - toPath(NetconfMessageTransformUtil.NETCONF_VALIDATE_QNAME), getValidateContent(datastore)); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NetconfMessageTransformUtil.NETCONF_VALIDATE_PATH, + getValidateContent(datastore)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture validateCandidate(final FutureCallback callback) { + public FluentFuture validateCandidate(final FutureCallback callback) { return validate(callback, NETCONF_CANDIDATE_QNAME); } - - public ListenableFuture validateRunning(final FutureCallback callback) { + public FluentFuture validateRunning(final FutureCallback callback) { return validate(callback, NETCONF_RUNNING_QNAME); } - public ListenableFuture copyConfig(final FutureCallback callback, + public FluentFuture copyConfig(final FutureCallback callback, final QName source, final QName target) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(source); Preconditions.checkNotNull(target); - final ListenableFuture future = rpc.invokeRpc( - toPath(NetconfMessageTransformUtil.NETCONF_COPY_CONFIG_QNAME), getCopyConfigContent(source, target)); - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NETCONF_COPY_CONFIG_PATH, + getCopyConfigContent(source, target)); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture copyRunningToCandidate(final FutureCallback callback) { + public FluentFuture copyRunningToCandidate(final FutureCallback callback) { return copyConfig(callback, NETCONF_RUNNING_QNAME, NETCONF_CANDIDATE_QNAME); } - public ListenableFuture getConfig(final FutureCallback callback, final QName datastore, + public FluentFuture getConfig(final FutureCallback callback, final QName datastore, final Optional filterPath) { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(datastore); - final ListenableFuture future; + final FluentFuture future; if (isFilterPresent(filterPath)) { final DataContainerChild node = transformer.toFilterStructure(filterPath.get()); - future = rpc.invokeRpc(toPath(NETCONF_GET_CONFIG_QNAME), - NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, getSourceNode(datastore), node)); + future = rpc.invokeRpc(NETCONF_GET_CONFIG_PATH, + NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_NODEID, getSourceNode(datastore), node)); } else { - future = rpc.invokeRpc(toPath(NETCONF_GET_CONFIG_QNAME), - NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_QNAME, getSourceNode(datastore))); + future = rpc.invokeRpc(NETCONF_GET_CONFIG_PATH, + NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_NODEID, getSourceNode(datastore))); } - Futures.addCallback(future, callback); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } - public ListenableFuture>> getConfigRunningData( + public FluentFuture>> getConfigRunningData( final FutureCallback callback, final Optional filterPath) { - final ListenableFuture configRunning = getConfigRunning(callback, filterPath); + final FluentFuture configRunning = getConfigRunning(callback, filterPath); return extractData(filterPath, configRunning); } - public ListenableFuture>> getData(final FutureCallback callback, + public FluentFuture>> getData(final FutureCallback callback, final Optional filterPath) { - final ListenableFuture configRunning = get(callback, filterPath); + final FluentFuture configRunning = get(callback, filterPath); return extractData(filterPath, configRunning); } - private ListenableFuture>> extractData( - final Optional path, final ListenableFuture configRunning) { - return Futures.transform(configRunning, (Function>>) result -> { - Preconditions.checkArgument( - result.getErrors().isEmpty(), "Unable to read data: %s, errors: %s", path, result.getErrors()); + private FluentFuture>> extractData( + final Optional path, final FluentFuture configRunning) { + return configRunning.transform(result -> { + Preconditions.checkArgument(result.getErrors().isEmpty(), "Unable to read data: %s, errors: %s", path, + result.getErrors()); final DataContainerChild dataNode = - ((ContainerNode) result.getResult()).getChild( - NetconfMessageTransformUtil.toId(NetconfMessageTransformUtil.NETCONF_DATA_QNAME)).get(); + ((ContainerNode) result.getResult()).getChild(NetconfMessageTransformUtil.NETCONF_DATA_NODEID) + .get(); return transformer.selectFromDataStructure(dataNode, path.get()); - }); + }, MoreExecutors.directExecutor()); } - public ListenableFuture getConfigRunning(final FutureCallback callback, + public FluentFuture getConfigRunning(final FutureCallback callback, final Optional filterPath) { return getConfig(callback, NETCONF_RUNNING_QNAME, filterPath); } - public ListenableFuture getConfigCandidate(final FutureCallback callback, + public FluentFuture getConfigCandidate(final FutureCallback callback, final Optional filterPath) { return getConfig(callback, NETCONF_CANDIDATE_QNAME, filterPath); } - public ListenableFuture get(final FutureCallback callback, + public FluentFuture get(final FutureCallback callback, final Optional filterPath) { Preconditions.checkNotNull(callback); - final ListenableFuture future; - - future = isFilterPresent(filterPath) - ? rpc.invokeRpc(toPath(NETCONF_GET_QNAME), - NetconfMessageTransformUtil.wrap(NETCONF_GET_QNAME, toFilterStructure(filterPath.get(), schemaContext))) - : rpc.invokeRpc(toPath(NETCONF_GET_QNAME), NetconfMessageTransformUtil.GET_RPC_CONTENT); - - Futures.addCallback(future, callback); + final FluentFuture future = rpc.invokeRpc(NETCONF_GET_PATH, isFilterPresent(filterPath) + ? NetconfMessageTransformUtil.wrap(NETCONF_GET_NODEID, toFilterStructure(filterPath.get(), schemaContext)) + : NetconfMessageTransformUtil.GET_RPC_CONTENT); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } @@ -246,31 +247,31 @@ public final class NetconfBaseOps { return filterPath.isPresent() && !filterPath.get().isEmpty(); } - public ListenableFuture editConfigCandidate(final FutureCallback callback, + public FluentFuture editConfigCandidate(final FutureCallback callback, final DataContainerChild editStructure, final ModifyAction modifyAction, final boolean rollback) { return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.of(modifyAction), rollback); } - public ListenableFuture editConfigCandidate(final FutureCallback callback, + public FluentFuture editConfigCandidate(final FutureCallback callback, final DataContainerChild editStructure, final boolean rollback) { - return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.absent(), rollback); + return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.empty(), rollback); } - public ListenableFuture editConfigRunning(final FutureCallback callback, + public FluentFuture editConfigRunning(final FutureCallback callback, final DataContainerChild editStructure, final ModifyAction modifyAction, final boolean rollback) { return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.of(modifyAction), rollback); } - public ListenableFuture editConfigRunning(final FutureCallback callback, + public FluentFuture editConfigRunning(final FutureCallback callback, final DataContainerChild editStructure, final boolean rollback) { - return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.absent(), rollback); + return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.empty(), rollback); } - public ListenableFuture editConfig( + public FluentFuture editConfig( final FutureCallback callback, final QName datastore, final DataContainerChild editStructure, final Optional modifyAction, final boolean rollback) { @@ -278,10 +279,10 @@ public final class NetconfBaseOps { Preconditions.checkNotNull(callback); Preconditions.checkNotNull(datastore); - final ListenableFuture future = rpc.invokeRpc(toPath(NETCONF_EDIT_CONFIG_QNAME), + final FluentFuture future = rpc.invokeRpc(NETCONF_EDIT_CONFIG_PATH, getEditConfigContent(datastore, editStructure, modifyAction, rollback)); - Futures.addCallback(future, callback); + future.addCallback(callback, MoreExecutors.directExecutor()); return future; } @@ -289,28 +290,28 @@ public final class NetconfBaseOps { final Optional operation, final YangInstanceIdentifier dataPath) { final AnyXmlNode configContent = transformer.createEditConfigStructure(lastChild, dataPath, operation); - return Builders.choiceBuilder().withNodeIdentifier(toId(EditContent.QNAME)).withChild(configContent).build(); + return Builders.choiceBuilder().withNodeIdentifier(EDIT_CONTENT_NODEID).withChild(configContent).build(); } private static ContainerNode getEditConfigContent( final QName datastore, final DataContainerChild editStructure, final Optional defaultOperation, final boolean rollback) { - final DataContainerNodeAttrBuilder editBuilder = - Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_EDIT_CONFIG_QNAME)); + final DataContainerNodeBuilder editBuilder = + Builders.containerBuilder().withNodeIdentifier(NETCONF_EDIT_CONFIG_NODEID); // Target editBuilder.withChild(getTargetNode(datastore)); // Default operation if (defaultOperation.isPresent()) { - final String opString = defaultOperation.get().name().toLowerCase(); - editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_DEFAULT_OPERATION_QNAME)) + final String opString = defaultOperation.get().name().toLowerCase(Locale.ROOT); + editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(NETCONF_DEFAULT_OPERATION_NODEID) .withValue(opString).build()); } // Error option if (rollback) { - editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(toId(NETCONF_ERROR_OPTION_QNAME)) + editBuilder.withChild(Builders.leafBuilder().withNodeIdentifier(NETCONF_ERROR_OPTION_NODEID) .withValue(ROLLBACK_ON_ERROR_OPTION).build()); } @@ -320,38 +321,36 @@ public final class NetconfBaseOps { } public static DataContainerChild getSourceNode(final QName datastore) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_SOURCE_QNAME)) - .withChild( - Builders.choiceBuilder().withNodeIdentifier(toId(ConfigSource.QNAME)).withChild( - Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() - ).build(); + return Builders.containerBuilder().withNodeIdentifier(NETCONF_SOURCE_NODEID) + .withChild(Builders.choiceBuilder().withNodeIdentifier(CONFIG_SOURCE_NODEID).withChild( + Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build()) + .build()).build(); } public static ContainerNode getLockContent(final QName datastore) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_LOCK_QNAME)) + return Builders.containerBuilder().withNodeIdentifier(NETCONF_LOCK_NODEID) .withChild(getTargetNode(datastore)).build(); } public static DataContainerChild getTargetNode(final QName datastore) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_TARGET_QNAME)) - .withChild( - Builders.choiceBuilder().withNodeIdentifier(toId(ConfigTarget.QNAME)).withChild( - Builders.leafBuilder().withNodeIdentifier(toId(datastore)).build()).build() - ).build(); + return Builders.containerBuilder().withNodeIdentifier(NETCONF_TARGET_NODEID) + .withChild(Builders.choiceBuilder().withNodeIdentifier(CONFIG_TARGET_NODEID).withChild( + Builders.leafBuilder().withNodeIdentifier(toId(datastore)).withValue(Empty.getInstance()).build()) + .build()).build(); } public static NormalizedNode getCopyConfigContent(final QName source, final QName target) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_COPY_CONFIG_QNAME)) + return Builders.containerBuilder().withNodeIdentifier(NETCONF_COPY_CONFIG_NODEID) .withChild(getTargetNode(target)).withChild(getSourceNode(source)).build(); } public static NormalizedNode getValidateContent(final QName source) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_VALIDATE_QNAME)) + return Builders.containerBuilder().withNodeIdentifier(NETCONF_VALIDATE_NODEID) .withChild(getSourceNode(source)).build(); } public static NormalizedNode getUnLockContent(final QName datastore) { - return Builders.containerBuilder().withNodeIdentifier(toId(NETCONF_UNLOCK_QNAME)) + return Builders.containerBuilder().withNodeIdentifier(NETCONF_UNLOCK_NODEID) .withChild(getTargetNode(datastore)).build(); }