import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.COMMIT_RPC_CONTENT;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.EDIT_CONTENT_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.GET_RPC_CONTENT;
-import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_QNAME;
+import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_CANDIDATE_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_COMMIT_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_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_NODEID;
import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_LOCK_QNAME;
-import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_QNAME;
+import static org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil.NETCONF_RUNNING_NODEID;
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_VALIDATE_QNAME;
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 com.google.common.collect.Iterables;
import com.google.common.util.concurrent.FutureCallback;
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.rfc8528.data.api.MountPointContext;
import org.opendaylight.yangtools.yang.common.Empty;
-import org.opendaylight.yangtools.yang.common.QName;
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.ChoiceNode;
* Provides base operations for NETCONF e.g. {@code get}, {@code get-config}, {@code edit-config}, {@code commit} etc.
* as per <a href="https://www.rfc-editor.org/rfc/rfc6241#section-7">RFC6241 Protocol Operations</a>.
*/
-// FIXME: datastore etc. should require NodeIdentifier instead of QName to reduce GC pressure
// FIXME: turn Optional arguments to @Nullable
public final class NetconfBaseOps {
private static final NodeIdentifier CONFIG_SOURCE_NODEID = NodeIdentifier.create(ConfigSource.QNAME);
}
public ListenableFuture<? extends DOMRpcResult> lock(final FutureCallback<DOMRpcResult> callback,
- final QName datastore) {
+ final NodeIdentifier datastore) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_LOCK_QNAME, getLockContent(datastore)));
}
public ListenableFuture<? extends DOMRpcResult> lockCandidate(final FutureCallback<DOMRpcResult> callback) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_LOCK_QNAME,
- getLockContent(NETCONF_CANDIDATE_QNAME)));
+ getLockContent(NETCONF_CANDIDATE_NODEID)));
}
public ListenableFuture<? extends DOMRpcResult> lockRunning(final FutureCallback<DOMRpcResult> callback) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_LOCK_QNAME,
- getLockContent(NETCONF_RUNNING_QNAME)));
+ getLockContent(NETCONF_RUNNING_NODEID)));
}
public ListenableFuture<? extends DOMRpcResult> unlock(final FutureCallback<DOMRpcResult> callback,
- final QName datastore) {
+ final NodeIdentifier datastore) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_UNLOCK_QNAME,
getUnLockContent(datastore)));
}
public ListenableFuture<? extends DOMRpcResult> unlockRunning(final FutureCallback<DOMRpcResult> callback) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_UNLOCK_QNAME,
- getUnLockContent(NETCONF_RUNNING_QNAME)));
+ getUnLockContent(NETCONF_RUNNING_NODEID)));
}
public ListenableFuture<? extends DOMRpcResult> unlockCandidate(final FutureCallback<DOMRpcResult> callback) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_UNLOCK_QNAME,
- getUnLockContent(NETCONF_CANDIDATE_QNAME)));
+ getUnLockContent(NETCONF_CANDIDATE_NODEID)));
}
public ListenableFuture<? extends DOMRpcResult> discardChanges(final FutureCallback<DOMRpcResult> callback) {
}
public ListenableFuture<? extends DOMRpcResult> validate(final FutureCallback<DOMRpcResult> callback,
- final QName datastore) {
+ final NodeIdentifier datastore) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_VALIDATE_QNAME,
getValidateContent(requireNonNull(datastore))));
}
public ListenableFuture<? extends DOMRpcResult> validateCandidate(final FutureCallback<DOMRpcResult> callback) {
- return validate(callback, NETCONF_CANDIDATE_QNAME);
+ return validate(callback, NETCONF_CANDIDATE_NODEID);
}
public ListenableFuture<? extends DOMRpcResult> validateRunning(final FutureCallback<DOMRpcResult> callback) {
- return validate(callback, NETCONF_RUNNING_QNAME);
+ return validate(callback, NETCONF_RUNNING_NODEID);
}
public ListenableFuture<? extends DOMRpcResult> copyConfig(final FutureCallback<DOMRpcResult> callback,
- final QName source, final QName target) {
+ final NodeIdentifier sourceDatastore, final NodeIdentifier targetDatastore) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_COPY_CONFIG_QNAME,
- getCopyConfigContent(source, target)));
+ getCopyConfigContent(sourceDatastore, targetDatastore)));
}
public ListenableFuture<? extends DOMRpcResult> copyRunningToCandidate(
final FutureCallback<DOMRpcResult> callback) {
- return copyConfig(callback, NETCONF_RUNNING_QNAME, NETCONF_CANDIDATE_QNAME);
+ return copyConfig(callback, NETCONF_RUNNING_NODEID, NETCONF_CANDIDATE_NODEID);
}
public ListenableFuture<? extends DOMRpcResult> getConfig(final FutureCallback<DOMRpcResult> callback,
- final QName datastore, final Optional<YangInstanceIdentifier> filterPath) {
+ final NodeIdentifier datastore, final Optional<YangInstanceIdentifier> filterPath) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_GET_CONFIG_QNAME, nonEmptyFilter(filterPath)
.map(path -> NetconfMessageTransformUtil.wrap(NETCONF_GET_CONFIG_NODEID,
getSourceNode(datastore), transformer.toFilterStructure(path)))
}
private ListenableFuture<? extends DOMRpcResult> getConfig(final FutureCallback<DOMRpcResult> callback,
- final QName datastore, final Optional<YangInstanceIdentifier> filterPath,
+ final NodeIdentifier datastore, final Optional<YangInstanceIdentifier> filterPath,
final List<YangInstanceIdentifier> fields) {
final ContainerNode rpcInput;
if (nonEmptyFilter(filterPath).isPresent()) {
public ListenableFuture<? extends DOMRpcResult> getConfigRunning(final FutureCallback<DOMRpcResult> callback,
final Optional<YangInstanceIdentifier> filterPath) {
- return getConfig(callback, NETCONF_RUNNING_QNAME, filterPath);
+ return getConfig(callback, NETCONF_RUNNING_NODEID, filterPath);
}
private ListenableFuture<? extends DOMRpcResult> getConfigRunning(final FutureCallback<DOMRpcResult> callback,
final Optional<YangInstanceIdentifier> filterPath, final List<YangInstanceIdentifier> fields) {
- return getConfig(callback, NETCONF_RUNNING_QNAME, filterPath, fields);
+ return getConfig(callback, NETCONF_RUNNING_NODEID, filterPath, fields);
}
public ListenableFuture<? extends DOMRpcResult> getConfigCandidate(final FutureCallback<DOMRpcResult> callback,
final Optional<YangInstanceIdentifier> filterPath) {
- return getConfig(callback, NETCONF_CANDIDATE_QNAME, filterPath);
+ return getConfig(callback, NETCONF_CANDIDATE_NODEID, filterPath);
}
public ListenableFuture<? extends DOMRpcResult> get(final FutureCallback<DOMRpcResult> callback,
public ListenableFuture<? extends DOMRpcResult> editConfigCandidate(
final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild editStructure,
final ModifyAction modifyAction, final boolean rollback) {
- return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.of(modifyAction), rollback);
+ return editConfig(callback, NETCONF_CANDIDATE_NODEID, editStructure, Optional.of(modifyAction), rollback);
}
public ListenableFuture<? extends DOMRpcResult> editConfigCandidate(
final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild editStructure,
final boolean rollback) {
- return editConfig(callback, NETCONF_CANDIDATE_QNAME, editStructure, Optional.empty(), rollback);
+ return editConfig(callback, NETCONF_CANDIDATE_NODEID, editStructure, Optional.empty(), rollback);
}
public ListenableFuture<? extends DOMRpcResult> editConfigRunning(
final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild editStructure,
final ModifyAction modifyAction, final boolean rollback) {
- return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.of(modifyAction), rollback);
+ return editConfig(callback, NETCONF_RUNNING_NODEID, editStructure, Optional.of(modifyAction), rollback);
}
public ListenableFuture<? extends DOMRpcResult> editConfigRunning(
final FutureCallback<? super DOMRpcResult> callback, final DataContainerChild editStructure,
final boolean rollback) {
- return editConfig(callback, NETCONF_RUNNING_QNAME, editStructure, Optional.empty(), rollback);
+ return editConfig(callback, NETCONF_RUNNING_NODEID, editStructure, Optional.empty(), rollback);
}
public ListenableFuture<? extends DOMRpcResult> editConfig(
- final FutureCallback<? super DOMRpcResult> callback, final QName datastore,
+ final FutureCallback<? super DOMRpcResult> callback, final NodeIdentifier datastore,
final DataContainerChild editStructure, final Optional<ModifyAction> modifyAction,
final boolean rollback) {
return addCallback(requireNonNull(callback), rpc.invokeRpc(NETCONF_EDIT_CONFIG_QNAME,
.build();
}
- private static ContainerNode getEditConfigContent(final QName datastore, final DataContainerChild editStructure,
- final Optional<ModifyAction> defaultOperation, final boolean rollback) {
+ private static ContainerNode getEditConfigContent(final NodeIdentifier datastore,
+ final DataContainerChild editStructure, final Optional<ModifyAction> defaultOperation,
+ final boolean rollback) {
final var editBuilder = Builders.containerBuilder()
.withNodeIdentifier(NETCONF_EDIT_CONFIG_NODEID)
// Target
return editBuilder.withChild(editStructure).build();
}
- public static @NonNull ContainerNode getSourceNode(final QName datastore) {
+ public static @NonNull ContainerNode getSourceNode(final NodeIdentifier datastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_SOURCE_NODEID)
.withChild(Builders.choiceBuilder()
.build();
}
- public static @NonNull ContainerNode getLockContent(final QName datastore) {
+ public static @NonNull ContainerNode getLockContent(final NodeIdentifier datastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_LOCK_NODEID)
.withChild(getTargetNode(datastore))
.build();
}
- public static @NonNull ContainerNode getTargetNode(final QName datastore) {
+ public static @NonNull ContainerNode getTargetNode(final NodeIdentifier datastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_TARGET_NODEID)
.withChild(Builders.choiceBuilder()
.withNodeIdentifier(CONFIG_TARGET_NODEID)
- .withChild(ImmutableNodes.leafNode(toId(datastore), Empty.value()))
+ .withChild(ImmutableNodes.leafNode(datastore, Empty.value()))
.build())
.build();
}
- public static @NonNull ContainerNode getCopyConfigContent(final QName source, final QName target) {
+ public static @NonNull ContainerNode getCopyConfigContent(final NodeIdentifier sourceDatastore,
+ final NodeIdentifier targetDatastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_COPY_CONFIG_NODEID)
- .withChild(getTargetNode(target))
- .withChild(getSourceNode(source))
+ .withChild(getTargetNode(targetDatastore))
+ .withChild(getSourceNode(sourceDatastore))
.build();
}
- public static @NonNull ContainerNode getValidateContent(final QName source) {
+ public static @NonNull ContainerNode getValidateContent(final NodeIdentifier sourceDatastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_VALIDATE_NODEID)
- .withChild(getSourceNode(source))
+ .withChild(getSourceNode(sourceDatastore))
.build();
}
- public static @NonNull ContainerNode getUnLockContent(final QName datastore) {
+ public static @NonNull ContainerNode getUnLockContent(final NodeIdentifier datastore) {
return Builders.containerBuilder()
.withNodeIdentifier(NETCONF_UNLOCK_NODEID)
.withChild(getTargetNode(datastore))