Skip to content

Commit

Permalink
Migrate more capabilities to XmlNetconfConstants
Browse files Browse the repository at this point in the history
We have multiple constants still lurking in NetconfMessageTransformUtil,
migrate them to XmlNetconfConstants so they are widely available.

JIRA: NETCONF-1006
Change-Id: Ic6c5f8d161e7533e2f9537901cc841615b7aaabd
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
  • Loading branch information
rovarga committed May 3, 2023
1 parent 31a1462 commit 44e2ed5
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,15 +151,16 @@ public String toString() {
}

public boolean isRollbackSupported() {
return containsNonModuleCapability(NetconfMessageTransformUtil.NETCONF_ROLLBACK_ON_ERROR_URI.toString());
return containsNonModuleCapability(
XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_ROLLBACK_ON_ERROR_1_0);
}

public boolean isCandidateSupported() {
return containsNonModuleCapability(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_CANDIDATE_1_0);
}

public boolean isRunningWritable() {
return containsNonModuleCapability(NetconfMessageTransformUtil.NETCONF_RUNNING_WRITABLE_URI.toString());
return containsNonModuleCapability(XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_WRITABLE_RUNNING_1_0);
}

public boolean isNotificationsSupported() {
Expand All @@ -170,8 +171,8 @@ public boolean isNotificationsSupported() {

public boolean isMonitoringSupported() {
return containsModuleCapability(NetconfMessageTransformUtil.IETF_NETCONF_MONITORING)
|| containsPartialNonModuleCapability(
NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString());
|| containsPartialNonModuleCapability(
NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
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_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 com.google.common.collect.Iterables;
Expand Down Expand Up @@ -77,7 +76,7 @@ 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 static final LeafNode<String> NETCONF_ERROR_OPTION_ROLLBACK =
ImmutableNodes.leafNode(NETCONF_ERROR_OPTION_NODEID, ROLLBACK_ON_ERROR_OPTION);
ImmutableNodes.leafNode(NETCONF_ERROR_OPTION_NODEID, "rollback-on-error");

private final NetconfRpcService rpc;
private final MountPointContext mountContext;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,12 +185,6 @@ private NetconfMessageTransformUtil() {
public static final URI NETCONF_ACTION_NAMESPACE = URI.create("urn:ietf:params:xml:ns:yang:1");
public static final String NETCONF_ACTION = "action";

public static final URI NETCONF_ROLLBACK_ON_ERROR_URI = URI
.create("urn:ietf:params:netconf:capability:rollback-on-error:1.0");
public static final String ROLLBACK_ON_ERROR_OPTION = "rollback-on-error";

public static final URI NETCONF_RUNNING_WRITABLE_URI = URI
.create("urn:ietf:params:netconf:capability:writable-running:1.0");

public static final @NonNull QName NETCONF_LOCK_QNAME = QName.create(NETCONF_QNAME, "lock").intern();
public static final @NonNull NodeIdentifier NETCONF_LOCK_NODEID = NodeIdentifier.create(NETCONF_LOCK_QNAME);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ private ListenableFuture<RpcResult<NetconfMessage>> sendRequest(final String mes
public void testOnSessionUp() {
final var testCapability = "urn:opendaylight:params:xml:ns:test?module=test-module&revision=2014-06-02";
final var serverCapabilities = Set.of(
NetconfMessageTransformUtil.NETCONF_ROLLBACK_ON_ERROR_URI.toString(),
XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_ROLLBACK_ON_ERROR_1_0,
NetconfMessageTransformUtil.IETF_NETCONF_MONITORING.getNamespace().toString(),
testCapability);
doReturn(serverCapabilities).when(spySession).getServerCapabilities();
Expand All @@ -157,7 +157,7 @@ public void testOnSessionUp() {

NetconfSessionPreferences actualCapabilites = netconfSessionPreferences.getValue();
assertTrue(actualCapabilites.containsNonModuleCapability(
NetconfMessageTransformUtil.NETCONF_ROLLBACK_ON_ERROR_URI.toString()));
"urn:ietf:params:netconf:capability:rollback-on-error:1.0"));
assertFalse(actualCapabilites.containsNonModuleCapability(testCapability));
assertEquals(Set.of(QName.create("urn:opendaylight:params:xml:ns:test", "2014-06-02", "test-module")),
actualCapabilites.moduleBasedCaps().keySet());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteCandidateRunningTx;
import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteCandidateTx;
import org.opendaylight.netconf.sal.connect.netconf.sal.tx.WriteRunningTx;
import org.opendaylight.netconf.sal.connect.netconf.util.NetconfMessageTransformUtil;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.base._1._0.rev110601.IetfNetconfService;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.monitoring.rev220718.NetconfTcp;
import org.opendaylight.yangtools.rfc8528.data.util.EmptyMountPointContext;
Expand Down Expand Up @@ -91,7 +90,7 @@ public void testNewReadWriteTransaction() {
@Test
public void testWritableRunningCandidateWriteTransaction() {
testWriteTransaction(WriteCandidateRunningTx.class,
NetconfMessageTransformUtil.NETCONF_RUNNING_WRITABLE_URI.toString(),
XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_WRITABLE_RUNNING_1_0,
XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_CANDIDATE_1_0);
}

Expand All @@ -103,7 +102,8 @@ public void testCandidateWriteTransaction() {

@Test
public void testRunningWriteTransaction() {
testWriteTransaction(WriteRunningTx.class, NetconfMessageTransformUtil.NETCONF_RUNNING_WRITABLE_URI.toString());
testWriteTransaction(WriteRunningTx.class,
XmlNetconfConstants.URN_IETF_PARAMS_NETCONF_CAPABILITY_WRITABLE_RUNNING_1_0);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ private XmlNetconfConstants() {
public static final String URN_IETF_PARAMS_XML_NS_NETCONF_EXI_1_0 = "urn:ietf:params:xml:ns:netconf:exi:1.0";
public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_NOTIFICATION_1_0 =
"urn:ietf:params:netconf:capability:notification:1.0";
public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_ROLLBACK_ON_ERROR_1_0 =
"urn:ietf:params:netconf:capability:rollback-on-error:1.0";
public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_WRITABLE_RUNNING_1_0 =
"urn:ietf:params:netconf:capability:writable-running:1.0";

public static final String URN_IETF_PARAMS_NETCONF_CAPABILITY_EXI_1_0 =
"urn:ietf:params:netconf:capability:exi:1.0";
Expand Down

0 comments on commit 44e2ed5

Please sign in to comment.