Bug-5878: PCErr not generated by configuring 32-pcep.xml file to not advertise statef... 02/43602/1
authorAjay <ajayl.bro@gmail.com>
Tue, 2 Aug 2016 01:06:13 +0000 (01:06 +0000)
committerMilos Fabian <milfabia@cisco.com>
Wed, 10 Aug 2016 10:29:05 +0000 (10:29 +0000)
- throw exception and abort PCEP Topology Provider instantiation if stateful capability is not configured but stateful plugin is

Change-Id: Ie066cc4661f07877e133ce666819b242aa783c85
Signed-off-by: Ajay <ajayl.bro@gmail.com>
(cherry picked from commit 8d3f35e52ff92ff2848290a5dc271a8cb106c06f)

12 files changed:
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPCapability.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPDispatcher.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionNegotiatorFactory.java
pcep/api/src/main/java/org/opendaylight/protocol/pcep/PCEPSessionProposalFactory.java
pcep/ietf-stateful07/src/main/java/org/opendaylight/protocol/pcep/ietf/stateful07/PCEPStatefulCapability.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/BasePCEPSessionProposalFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/DefaultPCEPSessionNegotiatorFactory.java
pcep/impl/src/main/java/org/opendaylight/protocol/pcep/impl/PCEPDispatcherImpl.java
pcep/segment-routing/src/main/java/org/opendaylight/protocol/pcep/segment/routing/PCEPSegmentRoutingCapability.java
pcep/topology-provider/src/main/java/org/opendaylight/bgpcep/pcep/topology/provider/PCEPTopologyProvider.java
pcep/topology-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/topology/provider/PCEPTopologyProviderModuleTest.java
pcep/tunnel-provider/src/test/java/org/opendaylight/controller/config/yang/pcep/tunnel/provider/PCEPTunnelTopologyProviderModuleTest.java

index a78d07698f2a521a7d140be889b39e4fadc9f577..ed5fc07547737f18849374fb4324884aaddff428 100644 (file)
@@ -23,4 +23,5 @@ public interface PCEPCapability {
      */
     void setCapabilityProposal(InetSocketAddress address, TlvsBuilder builder);
 
+    boolean isStateful();
 }
index 19b393f9c6874a24f32b83e16f27ecd3e0d931e1..1191afa881f74ab4e065b1c7e4f175f88abd4664 100644 (file)
@@ -36,4 +36,6 @@ public interface PCEPDispatcher {
      * @return instance of PCEPServer
      */
     ChannelFuture createServer(InetSocketAddress address, Optional<KeyMapping> keys, PCEPSessionListenerFactory listenerFactory, PCEPPeerProposal peerProposal);
-}
\ No newline at end of file
+
+    PCEPSessionNegotiatorFactory getPCEPSessionNegotiatorFactory();
+}
index 01e55ddb82b6ed0d613e6c581b27723030a2806e..7f8449b4349f318fc75f52c8d0c65d351acbddc7 100644 (file)
@@ -27,4 +27,6 @@ public interface PCEPSessionNegotiatorFactory<S extends PCEPSession> {
      * @return PCEPSessionNegotiator instance
      */
     SessionNegotiator getSessionNegotiator(PCEPSessionListenerFactory sessionListenerFactory, Channel channel, Promise<S> promise, final PCEPPeerProposal peerProposal);
+
+    PCEPSessionProposalFactory getPCEPSessionProposalFactory();
 }
index 894f5a6c2b4021850faf34deee49cd2551ed6591..d84db397585ef497f632cbee05350f97a1b4d7ae 100644 (file)
@@ -8,6 +8,7 @@
 package org.opendaylight.protocol.pcep;
 
 import java.net.InetSocketAddress;
+import java.util.List;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.open.object.Open;
 
 /**
@@ -34,4 +35,6 @@ public interface PCEPSessionProposalFactory {
      * @return specific session proposal
      */
     Open getSessionProposal(InetSocketAddress address, int sessionId, PCEPPeerProposal peerProposal);
+
+    List<PCEPCapability> getCapabilities();
 }
index da21c2eb68cea9b2eec2d068ba24d5f29eca265b..ba76aad31b2aba6721fc3307daa0ee7184df71ec 100644 (file)
@@ -55,6 +55,7 @@ public class PCEPStatefulCapability implements PCEPCapability {
         }
     }
 
+    @Override
     public boolean isStateful() {
         return this.stateful;
     }
index 415944b1386357d07b8fc4476e4f130c366e8d1c..22d76524fda0a337d9e98fb343d5fc7781528386 100644 (file)
@@ -79,4 +79,8 @@ public final class BasePCEPSessionProposalFactory implements PCEPSessionProposal
         return this.deadTimer;
     }
 
+    @Override
+    public List<PCEPCapability> getCapabilities() {
+        return this.capabilities;
+    }
 }
index eb7b38cd8b518d28c85f2aef7d78b829c5ff502f..b7a63514f83e4e85cea6c4759f562b6a6ed2946d 100644 (file)
@@ -42,4 +42,9 @@ public final class DefaultPCEPSessionNegotiatorFactory extends AbstractPCEPSessi
         return new DefaultPCEPSessionNegotiator(promise, channel, listener, sessionId, this.maxUnknownMessages,
                 this.spf.getSessionProposal((InetSocketAddress)channel.remoteAddress(), sessionId, peerProposal), this.tlsConfiguration);
     }
+
+    @Override
+    public PCEPSessionProposalFactory getPCEPSessionProposalFactory() {
+        return this.spf;
+    }
 }
index f85cde1509606820bcee163b77610ec055b4af47..fc6c6e2765147c507667b76db44b5b7c885ede31 100644 (file)
@@ -145,4 +145,9 @@ public class PCEPDispatcherImpl implements PCEPDispatcher, Closeable {
     protected interface ChannelPipelineInitializer {
         void initializeChannel(SocketChannel socketChannel, Promise<PCEPSessionImpl> promise);
     }
-}
\ No newline at end of file
+
+    @Override
+    public PCEPSessionNegotiatorFactory getPCEPSessionNegotiatorFactory() {
+        return this.snf;
+    }
+}
index 04f35d9e6da3dfb6c574073d87af3dfe368d74c5..cecfa807ab5ae8a49a1b56468cd71e63e424a562 100644 (file)
@@ -35,4 +35,9 @@ public class PCEPSegmentRoutingCapability implements PCEPCapability {
     public boolean isSegmentRoutingCapable() {
         return this.isSegmentRoutingCapable;
     }
+
+    @Override
+    public boolean isStateful() {
+        return false;
+    }
 }
index 169a6c3bdc87b4d11e5c309b28a0964e3cb659d7..1b307ebff1202ef5ecd47bb23db6720f79548c15 100755 (executable)
@@ -12,6 +12,7 @@ import com.google.common.base.Preconditions;
 import io.netty.channel.Channel;
 import io.netty.channel.ChannelFuture;
 import java.net.InetSocketAddress;
+import java.util.List;
 import java.util.concurrent.ExecutionException;
 import org.opendaylight.bgpcep.programming.spi.InstructionScheduler;
 import org.opendaylight.bgpcep.topology.DefaultTopologyReference;
@@ -22,6 +23,7 @@ import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFaile
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.protocol.concepts.KeyMapping;
+import org.opendaylight.protocol.pcep.PCEPCapability;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.network.topology.rev140113.NetworkTopologyContext;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.programming.rev131106.NetworkTopologyPcepProgrammingService;
@@ -54,6 +56,17 @@ public final class PCEPTopologyProvider extends DefaultTopologyReference impleme
             final InstanceIdentifier<Topology> topology, final TopologySessionListenerFactory listenerFactory,
             final Optional<PCEPTopologyProviderRuntimeRegistrator> runtimeRootRegistrator, final int rpcTimeout) throws InterruptedException,
             ExecutionException, ReadFailedException, TransactionCommitFailedException {
+        List<PCEPCapability> capabilities = dispatcher.getPCEPSessionNegotiatorFactory().getPCEPSessionProposalFactory().getCapabilities();
+        boolean statefulCapability = false;
+        for (final PCEPCapability capability : capabilities) {
+            if (capability.isStateful()) {
+                statefulCapability = true;
+                break;
+            }
+        }
+        if (!statefulCapability && listenerFactory != null) {
+            throw new IllegalStateException("Stateful capability not defined, aborting PCEP Topology Provider instantiation");
+        }
 
         final ServerSessionManager manager = new ServerSessionManager(dataBroker, topology, listenerFactory, rpcTimeout);
         if (runtimeRootRegistrator.isPresent()) {
@@ -98,4 +111,4 @@ public final class PCEPTopologyProvider extends DefaultTopologyReference impleme
             LOG.error("Failed to shutdown session manager", e);
         }
     }
-}
\ No newline at end of file
+}
index 4f090e66e378a7eb7b5fef172d97a2a4ff97383a..86f165cd996b48a2a14ae286cc03b7cb45be9dc6 100644 (file)
@@ -27,6 +27,7 @@ import org.opendaylight.controller.config.yang.pcep.impl.PCEPDispatcherImplModul
 import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
@@ -55,7 +56,7 @@ public class PCEPTopologyProviderModuleTest extends AbstractInstructionScheduler
         SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
         setupMockService(PCEPExtensionProviderContext.class, extContext);
         BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
-                Collections.emptyList());
+                Arrays.asList(new PCEPStatefulCapability(true, true, true, true, true, true, true)));
         setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
         NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
         setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),
index f2e3acb961ca2e5c75090d71be41be3c53002c96..3d21ff947ceaec417cc2cb6dc870025498675260 100644 (file)
@@ -10,6 +10,7 @@ package org.opendaylight.controller.config.yang.pcep.tunnel.provider;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 import io.netty.channel.nio.NioEventLoopGroup;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import javax.management.ObjectName;
@@ -28,6 +29,7 @@ import org.opendaylight.controller.config.yang.pcep.topology.provider.Stateful07
 import org.opendaylight.controller.config.yang.programming.impl.AbstractInstructionSchedulerTest;
 import org.opendaylight.protocol.pcep.PCEPDispatcher;
 import org.opendaylight.protocol.pcep.PCEPSessionProposalFactory;
+import org.opendaylight.protocol.pcep.ietf.stateful07.PCEPStatefulCapability;
 import org.opendaylight.protocol.pcep.impl.BasePCEPSessionProposalFactory;
 import org.opendaylight.protocol.pcep.impl.DefaultPCEPSessionNegotiatorFactory;
 import org.opendaylight.protocol.pcep.impl.PCEPDispatcherImpl;
@@ -50,7 +52,7 @@ public class PCEPTunnelTopologyProviderModuleTest extends AbstractInstructionSch
         SimplePCEPExtensionProviderContext extContext = new SimplePCEPExtensionProviderContext();
         setupMockService(PCEPExtensionProviderContext.class, extContext);
         BasePCEPSessionProposalFactory proposalFactory = new BasePCEPSessionProposalFactory(120, 30,
-                Collections.emptyList());
+                Arrays.asList(new PCEPStatefulCapability(true, true, true, true, true, true, true)));
         setupMockService(PCEPSessionProposalFactory.class, proposalFactory);
         NioEventLoopGroup eventLoopGroup = new NioEventLoopGroup();
         setupMockService(PCEPDispatcher.class, new PCEPDispatcherImpl(extContext.getMessageHandlerRegistry(),