Remove sr-capable leaf 33/104033/10
authorRobert Varga <robert.varga@pantheon.tech>
Sun, 15 Jan 2023 21:22:36 +0000 (22:22 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Mon, 16 Jan 2023 22:36:05 +0000 (23:36 +0100)
The bit with advertizement is not used anywhere, as we always end up
loading the default configuration. Remove the unused leaf.

JIRA: BGPCEP-967
Change-Id: I03b9da1af231d495dc359f309984079f88b6a0e6
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapability.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/SegmentRoutingActivator.java
pcep/segment-routing/src/main/resources/OSGI-INF/blueprint/pcep-segment-routing.xml
pcep/segment-routing/src/main/yang/pcep-segment-routing-app-config.yang
pcep/segment-routing/src/test/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapabilityTest.java

index 5fc7351f2e03450bdc1203c6f6ca2e263faaa99d..c0490b6a2f3942b5a8b8a257f846a2a8c0edbdcc 100644 (file)
@@ -9,10 +9,8 @@ package org.opendaylight.protocol.pcep.segment.routing;
 
 import com.google.common.base.MoreObjects;
 import java.net.InetSocketAddress;
-import org.eclipse.jdt.annotation.NonNull;
 import org.kohsuke.MetaInfServices;
 import org.opendaylight.protocol.pcep.PCEPCapability;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
@@ -20,33 +18,15 @@ import org.opendaylight.yangtools.yang.common.Uint8;
 
 @MetaInfServices
 public class PCEPSegmentRoutingCapability implements PCEPCapability {
-    private static final @NonNull Tlvs1 AUGMENTATION = new Tlvs1Builder()
-        .setSrPceCapability(new SrPceCapabilityBuilder()
-            .setNFlag(Boolean.FALSE)
-            .setXFlag(Boolean.FALSE)
-            .setMsd(Uint8.ZERO)
-            .build())
-        .build();
-
-    private final boolean isSegmentRoutingCapable;
-
-    public PCEPSegmentRoutingCapability() {
-        this(true);
-    }
-
-    public PCEPSegmentRoutingCapability(final boolean isSegmentRoutingCapable) {
-        this.isSegmentRoutingCapable = isSegmentRoutingCapable;
-    }
-
     @Override
     public void setCapabilityProposal(final InetSocketAddress address, final TlvsBuilder builder) {
-        if (isSegmentRoutingCapable) {
-            builder.addAugmentation(AUGMENTATION);
-        }
-    }
-
-    public boolean isSegmentRoutingCapable() {
-        return isSegmentRoutingCapable;
+        builder.addAugmentation(new Tlvs1Builder()
+            .setSrPceCapability(new SrPceCapabilityBuilder()
+                .setNFlag(Boolean.FALSE)
+                .setXFlag(Boolean.FALSE)
+                .setMsd(Uint8.ZERO)
+                .build())
+            .build());
     }
 
     @Override
@@ -56,6 +36,6 @@ public class PCEPSegmentRoutingCapability implements PCEPCapability {
 
     @Override
     public String toString() {
-        return MoreObjects.toStringHelper(this).add("srCapable", isSegmentRoutingCapable).toString();
+        return MoreObjects.toStringHelper(this).toString();
     }
 }
index b34fcb2cf93d083feec83966ae8d9835251a87e9..6d056a46fe87c1c01756ed2fc0c1e6525f592c56 100644 (file)
@@ -15,6 +15,7 @@ import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator;
 import org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderContext;
 import org.opendaylight.protocol.pcep.spi.TlvRegistry;
 import org.opendaylight.protocol.pcep.spi.VendorInformationTlvRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.segment.routing.app.config.rev230115.PcepSegmentRoutingConfig;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.add.lsp.input.arguments.ero.subobject.subobject.type.SrEroType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.add.lsp.input.arguments.rro.subobject.subobject.type.SrRroType;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapability;
@@ -31,6 +32,11 @@ public class SegmentRoutingActivator implements PCEPExtensionProviderActivator {
         ianaSrSubobjectsType = true;
     }
 
+    @Deprecated
+    public SegmentRoutingActivator(final PcepSegmentRoutingConfig config) {
+        this(config.requireIanaSrSubobjectsType());
+    }
+
     @Deprecated
     public SegmentRoutingActivator(final boolean ianaSrSubobjectsType) {
         this.ianaSrSubobjectsType = ianaSrSubobjectsType;
index bb1cd26219fa92df8b20cb91bb3912c224e4709c..01e39e81606f5aca6187a33cf1f8d768a2029bf2 100644 (file)
            xmlns:odl="http://opendaylight.org/xmlns/blueprint/v1.0.0">
 
   <odl:clustered-app-config id="segmentRoutingConfig"
-      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.segment.routing.app.config.rev160707.PcepSegmentRoutingConfig"/>
+      binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.controller.pcep.segment.routing.app.config.rev230115.PcepSegmentRoutingConfig"/>
 
   <!-- Protocal extension provider -->
 
   <bean id="segmentRoutingActivator" class="org.opendaylight.protocol.pcep.segment.routing.SegmentRoutingActivator">
-    <argument>
-      <bean factory-ref="segmentRoutingConfig" factory-method="getIanaSrSubobjectsType"/>
-    </argument>
+    <argument ref="segmentRoutingConfig"/>
   </bean>
 
   <service ref="segmentRoutingActivator" interface="org.opendaylight.protocol.pcep.spi.PCEPExtensionProviderActivator"
           odl:type="org.opendaylight.protocol.pcep.segment.routing.SegmentRoutingActivator"/>
-
-  <!-- Capabilities -->
-
-  <bean id="segmentRoutingCapability" class="org.opendaylight.protocol.pcep.segment.routing.PCEPSegmentRoutingCapability">
-    <argument>
-      <bean factory-ref="segmentRoutingConfig" factory-method="getSrCapable"/>
-    </argument>
-  </bean>
-
-  <service ref="segmentRoutingCapability" interface="org.opendaylight.protocol.pcep.PCEPCapability"
-          odl:type="org.opendaylight.protocol.pcep.segment.routing.PCEPSegmentRoutingCapability"/>
 </blueprint>
index dab21b8137e897e18122b83ba90885733ab7fe37..d9f52987a855e4b56f682c4e3112b4020823aacd 100644 (file)
@@ -1,21 +1,23 @@
 module pcep-segment-routing-app-config {
-    yang-version 1;
     namespace "urn:opendaylight:params:xml:ns:yang:controller:pcep:segment-routing-app-config";
     prefix "pcep-segment-routing-app-config";
 
     description
-      "Configuration for the PCEP segment routing extension.";
+      "Configuration for the PCEP segment routing extension.
 
-    revision "2016-07-07" {
-        description
-            "Initial revision.
+       Copyright (c) 2016 Brocade Communications Systems, Inc. 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";
 
-            Copyright (c) 2016 Brocade Communications Systems, Inc. All rights reserved.
+    revision "2023-01-15" {
+        description "Removed sr-capable leaf.";
+    }
 
-            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";
+    revision "2016-07-07" {
+        description "Initial revision.";
     }
 
     container pcep-segment-routing-config {
@@ -25,11 +27,5 @@ module pcep-segment-routing-app-config {
             type boolean;
             default true;
         }
-
-        leaf sr-capable {
-            description "Advertize segment-routing capability";
-            type boolean;
-            default true;
-        }
     }
 }
index d863a187666e18b00240d80b6936590ecf79b82b..20db9b2d6baa8366be1762a8666d03dee6a68e38 100644 (file)
@@ -7,25 +7,25 @@
  */
 package org.opendaylight.protocol.pcep.segment.routing;
 
-import org.junit.Assert;
+import static org.junit.Assert.assertEquals;
+
 import org.junit.Test;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.Tlvs1Builder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.segment.routing.rev200720.sr.pce.capability.tlv.SrPceCapabilityBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.Tlvs;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.open.object.open.TlvsBuilder;
 import org.opendaylight.yangtools.yang.common.Uint8;
 
 public class PCEPSegmentRoutingCapabilityTest {
-    private static final Tlvs EXPECTED_TLVS =
-        new TlvsBuilder().addAugmentation(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep
-                .segment.routing.rev200720.Tlvs1Builder().setSrPceCapability(new SrPceCapabilityBuilder()
-                    .setNFlag(Boolean.FALSE).setXFlag(Boolean.FALSE).setMsd(Uint8.ZERO).build()).build()).build();
-
     @Test
     public void testSegmentRoutingCapability() {
-        final PCEPSegmentRoutingCapability sspf = new PCEPSegmentRoutingCapability(true);
-        Assert.assertTrue(sspf.isSegmentRoutingCapable());
-        final TlvsBuilder builder = new TlvsBuilder();
-        sspf.setCapabilityProposal(null, builder);
-        Assert.assertEquals(EXPECTED_TLVS, builder.build());
+        final var builder = new TlvsBuilder();
+        new PCEPSegmentRoutingCapability().setCapabilityProposal(null, builder);
+        assertEquals(new TlvsBuilder()
+            .addAugmentation(new Tlvs1Builder()
+                .setSrPceCapability(new SrPceCapabilityBuilder()
+                    .setNFlag(Boolean.FALSE).setXFlag(Boolean.FALSE).setMsd(Uint8.ZERO)
+                    .build())
+                .build())
+            .build(), builder.build());
     }
 }