Added SFs, EP handling, Resolved Policy for IOVisorRenderer 45/31745/14
authorKeith Burns (alagalah) <alagalah@gmail.com>
Mon, 21 Dec 2015 23:26:03 +0000 (15:26 -0800)
committerMartin Sunal <msunal@cisco.com>
Mon, 28 Dec 2015 09:36:04 +0000 (09:36 +0000)
- Cleaned up some core utils and IidFactory
- adding addition of IOVisor Module entry when Endpoint Aug is present

Change-Id: If8c952cc9b6f891eca7b88ccd63d6378bb2be6c9
Signed-off-by: Keith Burns (alagalah) <alagalah@gmail.com>
32 files changed:
features/src/main/features/features.xml
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/endpoint/EndpointRpcRegistry.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/resolver/PolicyResolver.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/sf/SupportedActionDefinitionListener.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/sf/SupportedClassifierDefinitionListener.java
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/util/DataTreeChangeHandler.java [moved from groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/sf/DataTreeChangeHandler.java with 99% similarity]
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/util/IidFactory.java
renderers/iovisor/src/main/config/default-config.xml
renderers/iovisor/src/main/java/org/opendaylight/controller/config/yang/config/iovisor_provider/impl/IovisorProviderModule.java
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/IovisorRenderer.java
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/ResolvedPolicyListener.java [new file with mode: 0644]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/EndpointListener.java
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/EndpointManager.java
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/IovisorEndpointAug.java [new file with mode: 0644]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/module/IovisorModuleManager.java
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Action.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ActionDefinitionListener.java [new file with mode: 0644]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/AllowAction.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassificationResult.java [new file with mode: 0644]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Classifier.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassifierDefinitionListener.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/EtherTypeClassifier.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/IpProtoClassifier.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/L4Classifier.java [new file with mode: 0755]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ParamDerivator.java [new file with mode: 0644]
renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/SubjectFeatures.java [new file with mode: 0755]
renderers/iovisor/src/main/yang/iovisor-provider-impl.yang
renderers/iovisor/src/main/yang/iovisor.yang
renderers/iovisor/src/test/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/IovisorRendererTest.java [new file with mode: 0644]
renderers/iovisor/src/test/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/EndpointListenerTest.java
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/endpoint/EndpointManager.java
renderers/ofoverlay/src/main/java/org/opendaylight/groupbasedpolicy/renderer/ofoverlay/sf/ClassifierDefinitionListener.java

index 1e7cef5bd54d40290f8a6764ac6b3cf001d1a353..3d1ae992ad62aed999e8fe0fdf1760d1eafcb3fc 100755 (executable)
@@ -99,6 +99,7 @@
         <feature>war</feature>
         <feature version='${aaa.version}'>odl-aaa-authn</feature>
         <feature version="${project.version}">odl-groupbasedpolicy-base</feature>
+        <feature version="${restconf.version}">odl-restconf</feature>
         <bundle>mvn:org.opendaylight.groupbasedpolicy/iovisor-renderer/{{VERSION}}</bundle>
         <bundle>mvn:com.sun.jersey/jersey-core/${jersey.version}</bundle>
         <bundle>mvn:com.sun.jersey/jersey-server/${jersey.version}</bundle>
index b27e9b80df53638983e5a43f346415a2459ea0b3..d3bcaa9ae4fb924dbe721d73b77336da4741596e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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,
@@ -22,6 +22,7 @@ import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
 import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointService;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.EndpointsBuilder;
@@ -65,15 +66,16 @@ import com.google.common.util.concurrent.ListenableFuture;
  * information about endpoints.
  */
 public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentationRegistry, AutoCloseable {
-    private static final Logger LOG =
-            LoggerFactory.getLogger(EndpointRpcRegistry.class);
+
+    private static final Logger LOG = LoggerFactory.getLogger(EndpointRpcRegistry.class);
 
     private final DataBroker dataProvider;
     private final RpcProviderRegistry rpcRegistry;
 
     private final BindingAwareBroker.RpcRegistration<EndpointService> rpcRegistration;
 
-    final static ConcurrentMap<String, EpRendererAugmentation> registeredRenderers = new ConcurrentHashMap<String, EpRendererAugmentation>();
+    final static ConcurrentMap<String, EpRendererAugmentation> registeredRenderers =
+            new ConcurrentHashMap<String, EpRendererAugmentation>();
 
     /**
      * This method registers a renderer for endpoint RPC API. This method
@@ -81,8 +83,8 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
      * registration is only allowed.
      *
      * @param epRendererAugmentation
-     *            - specific implementation RPC augmentation, if any. Otherwise
-     *            NULL
+     *        - specific implementation RPC augmentation, if any. Otherwise
+     *        NULL
      */
     @Override
     public void register(EpRendererAugmentation epRendererAugmentation) {
@@ -93,7 +95,6 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
     }
 
     /**
-     *
      * @param regImp the endpoint augmentation
      */
     @Override
@@ -109,27 +110,25 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
      * Constructor
      *
      * @param dataProvider the {@link DataBroker}
-     * @param rpcRegistry  the {@link RpcProviderRegistry}
+     * @param rpcRegistry the {@link RpcProviderRegistry}
      */
     public EndpointRpcRegistry(DataBroker dataProvider, RpcProviderRegistry rpcRegistry) {
         this.dataProvider = dataProvider;
         this.rpcRegistry = rpcRegistry;
         if (this.rpcRegistry != null) {
-            rpcRegistration =
-                    this.rpcRegistry.addRpcImplementation(EndpointService.class, this);
+            rpcRegistration = this.rpcRegistry.addRpcImplementation(EndpointService.class, this);
             LOG.debug("Added RPC Implementation Correctly");
         } else {
             rpcRegistration = null;
         }
 
         if (dataProvider != null) {
-            InstanceIdentifier<Endpoints> iid =
-                    InstanceIdentifier.builder(Endpoints.class).build();
+            InstanceIdentifier<Endpoints> iid = InstanceIdentifier.builder(Endpoints.class).build();
             WriteTransaction t = this.dataProvider.newWriteOnlyTransaction();
-            t.put(LogicalDatastoreType.OPERATIONAL,
-                    iid, new EndpointsBuilder().build());
+            t.put(LogicalDatastoreType.OPERATIONAL, iid, new EndpointsBuilder().build());
             CheckedFuture<Void, TransactionCommitFailedException> f = t.submit();
             Futures.addCallback(f, new FutureCallback<Void>() {
+
                 @Override
                 public void onFailure(Throwable t) {
                     LOG.error("Could not write endpoint base container", t);
@@ -159,12 +158,11 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
      * earlier.
      *
      * @param input
-     *            the input object
+     *        the input object
      */
     private EndpointBuilder buildEndpoint(RegisterEndpointInput input) {
         EndpointBuilder eb = new EndpointBuilder(input);
-        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
-                .entrySet()) {
+        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
             try {
                 Map.Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> augmentationEntry =
                         entry.getValue().buildEndpointAugmentation(input);
@@ -172,8 +170,7 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
                     eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
                 }
             } catch (Exception e) {
-                LOG.warn("Endpoint Augmentation error while processing "
-                        + entry.getKey() + ". Reason: ", e);
+                LOG.warn("Endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
             }
         }
         return eb;
@@ -185,12 +182,11 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
      * earlier.
      *
      * @param input
-     *            the input object
+     *        the input object
      */
     private EndpointL3Builder buildEndpointL3(RegisterEndpointInput input) {
         EndpointL3Builder eb = new EndpointL3Builder(input);
-        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
-                .entrySet()) {
+        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
             try {
                 Map.Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> augmentationEntry =
                         entry.getValue().buildEndpointL3Augmentation(input);
@@ -198,8 +194,7 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
                     eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
                 }
             } catch (Exception e) {
-                LOG.warn("L3 endpoint Augmentation error while processing "
-                        + entry.getKey() + ". Reason: ", e);
+                LOG.warn("L3 endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
             }
         }
         return eb;
@@ -211,12 +206,11 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
      * earlier.
      *
      * @param input
-     *            the input object
+     *        the input object
      */
     private EndpointL3PrefixBuilder buildL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) {
         EndpointL3PrefixBuilder eb = new EndpointL3PrefixBuilder(input);
-        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers
-                .entrySet()) {
+        for (Entry<String, EpRendererAugmentation> entry : registeredRenderers.entrySet()) {
             try {
                 Map.Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> augmentationEntry =
                         entry.getValue().buildL3PrefixEndpointAugmentation(input);
@@ -224,50 +218,34 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
                     eb.addAugmentation(augmentationEntry.getKey(), augmentationEntry.getValue());
                 }
             } catch (Exception e) {
-                LOG.warn("L3 endpoint Augmentation error while processing "
-                        + entry.getKey() + ". Reason: ", e);
+                LOG.warn("L3 endpoint Augmentation error while processing " + entry.getKey() + ". Reason: ", e);
             }
         }
         return eb;
     }
 
     @Override
-    public Future<RpcResult<Void>>
-            registerEndpoint(RegisterEndpointInput input) {
+    public Future<RpcResult<Void>> registerEndpoint(RegisterEndpointInput input) {
         long timestamp = System.currentTimeMillis();
 
         // TODO: Replicate RPC feedback implemented in L3Prefix register for
         // unmet requirements.
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
-        if (input.getL2Context() != null &&
-                input.getMacAddress() != null) {
-            Endpoint ep = buildEndpoint(input)
-                    .setTimestamp(timestamp)
-                    .build();
+        if (input.getL2Context() != null && input.getMacAddress() != null) {
+            Endpoint ep = buildEndpoint(input).setTimestamp(timestamp).build();
 
-            EndpointKey key =
-                    new EndpointKey(ep.getL2Context(), ep.getMacAddress());
-            InstanceIdentifier<Endpoint> iid =
-                    InstanceIdentifier.builder(Endpoints.class)
-                            .child(Endpoint.class, key)
-                            .build();
-            t.put(LogicalDatastoreType.OPERATIONAL, iid, ep, true);
+            EndpointKey key = new EndpointKey(ep.getL2Context(), ep.getMacAddress());
+            t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointIid(key), ep, true);
         }
         if (input.getL3Address() != null) {
             for (L3Address l3addr : input.getL3Address()) {
-                EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(),
-                        l3addr.getL3Context());
-                EndpointL3 ep3 = buildEndpointL3(input)
-                        .setIpAddress(key3.getIpAddress())
-                        .setL3Context(key3.getL3Context())
-                        .setTimestamp(timestamp)
-                        .build();
-                InstanceIdentifier<EndpointL3> iid_l3 =
-                        InstanceIdentifier.builder(Endpoints.class)
-                                .child(EndpointL3.class, key3)
-                                .build();
-                t.put(LogicalDatastoreType.OPERATIONAL, iid_l3, ep3, true);
+                EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), l3addr.getL3Context());
+                EndpointL3 ep3 = buildEndpointL3(input).setIpAddress(key3.getIpAddress())
+                    .setL3Context(key3.getL3Context())
+                    .setTimestamp(timestamp)
+                    .build();
+                t.put(LogicalDatastoreType.OPERATIONAL, IidFactory.l3EndpointIid(key3), ep3, true);
             }
         }
         ListenableFuture<Void> r = t.submit();
@@ -278,17 +256,20 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
     public Future<RpcResult<Void>> registerL3PrefixEndpoint(RegisterL3PrefixEndpointInput input) {
 
         if (input.getL3Context() == null) {
-            return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
-                    .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.").build());
+            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+                .withError(ErrorType.RPC, "L3 Prefix Endpoint must have L3Context.")
+                .build());
         }
         if (input.getIpPrefix() == null) {
-            return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
-                    .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.").build());
+            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+                .withError(ErrorType.RPC, "L3 Prefix Endpoint must have ip-prefix.")
+                .build());
         }
 
         if (input.getTenant() == null) {
-            return Futures.immediateFuture(RpcResultBuilder.<Void> failed()
-                    .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.").build());
+            return Futures.immediateFuture(RpcResultBuilder.<Void>failed()
+                .withError(ErrorType.RPC, "L3 Prefix Endpoint must have tenant.")
+                .build());
         }
 
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
@@ -302,9 +283,7 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
 
         EndpointL3Prefix epL3Prefix = buildL3PrefixEndpoint(input).setTimestamp(timestamp).build();
         InstanceIdentifier<EndpointL3Prefix> iid_l3prefix =
-                InstanceIdentifier.builder(Endpoints.class)
-                        .child(EndpointL3Prefix.class, epL3PrefixKey)
-                        .build();
+                InstanceIdentifier.builder(Endpoints.class).child(EndpointL3Prefix.class, epL3PrefixKey).build();
         t.put(LogicalDatastoreType.OPERATIONAL, iid_l3prefix, epL3Prefix);
 
         ListenableFuture<Void> r = t.submit();
@@ -312,29 +291,21 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
     }
 
     @Override
-    public Future<RpcResult<Void>>
-            unregisterEndpoint(UnregisterEndpointInput input) {
+    public Future<RpcResult<Void>> unregisterEndpoint(UnregisterEndpointInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
         if (input.getL2() != null) {
             for (L2 l2a : input.getL2()) {
-                EndpointKey key =
-                        new EndpointKey(l2a.getL2Context(),
-                                l2a.getMacAddress());
+                EndpointKey key = new EndpointKey(l2a.getL2Context(), l2a.getMacAddress());
                 InstanceIdentifier<Endpoint> iid =
-                        InstanceIdentifier.builder(Endpoints.class)
-                                .child(Endpoint.class, key).build();
+                        InstanceIdentifier.builder(Endpoints.class).child(Endpoint.class, key).build();
                 t.delete(LogicalDatastoreType.OPERATIONAL, iid);
             }
         }
         if (input.getL3() != null) {
             for (L3 l3addr : input.getL3()) {
-                EndpointL3Key key3 =
-                        new EndpointL3Key(l3addr.getIpAddress(),
-                                l3addr.getL3Context());
+                EndpointL3Key key3 = new EndpointL3Key(l3addr.getIpAddress(), l3addr.getL3Context());
                 InstanceIdentifier<EndpointL3> iid_l3 =
-                        InstanceIdentifier.builder(Endpoints.class)
-                                .child(EndpointL3.class, key3)
-                                .build();
+                        InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, key3).build();
                 t.delete(LogicalDatastoreType.OPERATIONAL, iid_l3);
             }
         }
@@ -345,21 +316,17 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
     }
 
     @Override
-    public Future<RpcResult<Void>>
-            setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
+    public Future<RpcResult<Void>> setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
-        ConditionMappingKey key =
-                new ConditionMappingKey(input.getEndpointGroup());
+        ConditionMappingKey key = new ConditionMappingKey(input.getEndpointGroup());
 
         for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
-            EndpointGroupConditionKey ckey =
-                    new EndpointGroupConditionKey(condition.getCondition());
-            InstanceIdentifier<EndpointGroupCondition> iid =
-                    InstanceIdentifier.builder(Endpoints.class)
-                            .child(ConditionMapping.class, key)
-                            .child(EndpointGroupCondition.class, ckey)
-                            .build();
+            EndpointGroupConditionKey ckey = new EndpointGroupConditionKey(condition.getCondition());
+            InstanceIdentifier<EndpointGroupCondition> iid = InstanceIdentifier.builder(Endpoints.class)
+                .child(ConditionMapping.class, key)
+                .child(EndpointGroupCondition.class, ckey)
+                .build();
             t.put(LogicalDatastoreType.OPERATIONAL, iid, condition);
         }
 
@@ -368,21 +335,17 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
     }
 
     @Override
-    public Future<RpcResult<Void>>
-            unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
+    public Future<RpcResult<Void>> unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
         WriteTransaction t = dataProvider.newWriteOnlyTransaction();
 
-        ConditionMappingKey key =
-                new ConditionMappingKey(input.getEndpointGroup());
+        ConditionMappingKey key = new ConditionMappingKey(input.getEndpointGroup());
 
         for (EndpointGroupCondition condition : input.getEndpointGroupCondition()) {
-            EndpointGroupConditionKey ckey =
-                    new EndpointGroupConditionKey(condition.getCondition());
-            InstanceIdentifier<EndpointGroupCondition> iid =
-                    InstanceIdentifier.builder(Endpoints.class)
-                            .child(ConditionMapping.class, key)
-                            .child(EndpointGroupCondition.class, ckey)
-                            .build();
+            EndpointGroupConditionKey ckey = new EndpointGroupConditionKey(condition.getCondition());
+            InstanceIdentifier<EndpointGroupCondition> iid = InstanceIdentifier.builder(Endpoints.class)
+                .child(ConditionMapping.class, key)
+                .child(EndpointGroupCondition.class, ckey)
+                .build();
 
             t.delete(LogicalDatastoreType.OPERATIONAL, iid);
         }
@@ -391,11 +354,11 @@ public class EndpointRpcRegistry implements EndpointService, EpRendererAugmentat
         return Futures.transform(r, futureTrans);
     }
 
-    Function<Void, RpcResult<Void>> futureTrans =
-            new Function<Void, RpcResult<Void>>() {
-                @Override
-                public RpcResult<Void> apply(Void input) {
-                    return RpcResultBuilder.<Void> success().build();
-                }
-            };
+    Function<Void, RpcResult<Void>> futureTrans = new Function<Void, RpcResult<Void>>() {
+
+        @Override
+        public RpcResult<Void> apply(Void input) {
+            return RpcResultBuilder.<Void>success().build();
+        }
+    };
 }
index 9bd1b108f11a764741b196e6a4d8796568c1114a..26a8cb5654219aa280dae7c228e1b8255b77c96b 100755 (executable)
@@ -28,8 +28,8 @@ import org.opendaylight.groupbasedpolicy.api.ValidationResult;
 import org.opendaylight.groupbasedpolicy.api.Validator;
 import org.opendaylight.groupbasedpolicy.dto.EgKey;
 import org.opendaylight.groupbasedpolicy.dto.IndexedTenant;
-import org.opendaylight.groupbasedpolicy.sf.DataTreeChangeHandler;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.groupbasedpolicy.util.InheritanceUtils;
 import org.opendaylight.groupbasedpolicy.util.PolicyInfoUtils;
index f7806a3ff1dac5adc5f6ce92de92e5376b437c6a..01d98e6e59849d72ea7d975432164237176da7bc 100644 (file)
@@ -26,9 +26,6 @@ import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
@@ -58,14 +55,8 @@ public class SupportedActionDefinitionListener
     public SupportedActionDefinitionListener(DataBroker dataProvider) {
         this.dataProvider = checkNotNull(dataProvider);
         registration =
-                dataProvider.registerDataTreeChangeListener(
-                        new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
-                                InstanceIdentifier.builder(Renderers.class)
-                                    .child(Renderer.class)
-                                    .child(Capabilities.class)
-                                    .child(SupportedActionDefinition.class)
-                                    .build()),
-                        this);
+                dataProvider.registerDataTreeChangeListener(new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+                        IidFactory.supportedActionDefinitionIidWildcard()), this);
     }
 
     @Override
@@ -77,13 +68,14 @@ public class SupportedActionDefinitionListener
                 case SUBTREE_MODIFIED:
                     ActionDefinitionId actionDefinitionId = rootNode.getDataAfter().getActionDefinitionId();
                     ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
-                    Optional<ActionDefinition> potentialAdFromConfDs = DataStoreHelper.readFromDs(
-                            LogicalDatastoreType.CONFIGURATION, IidFactory.actionDefinitionIid(actionDefinitionId), rwTx);
+                    Optional<ActionDefinition> potentialAdFromConfDs =
+                            DataStoreHelper.readFromDs(LogicalDatastoreType.CONFIGURATION,
+                                    IidFactory.actionDefinitionIid(actionDefinitionId), rwTx);
                     if (!potentialAdFromConfDs.isPresent()) {
                         LOG.error("Action-definition with ID {} does not exist in CONF datastore.", actionDefinitionId);
                         return;
                     }
-                    // TODO union and validation need to be finished
+                    // TODO validation needs to be finished - this is effectively a union.
                     ActionDefinition ad = potentialAdFromConfDs.get();
                     rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.actionDefinitionIid(actionDefinitionId), ad);
                     DataStoreHelper.submitToDs(rwTx);
index f396e4121a53851c64d065f5d4d4db08aee0c81d..355dd5a1024dab6710636b49e08a26d7a1fd73e2 100644 (file)
@@ -20,6 +20,7 @@ import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.api.PolicyValidatorRegistry;
 import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
@@ -27,9 +28,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinitionBuilder;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
@@ -54,13 +53,8 @@ public class SupportedClassifierDefinitionListener extends DataTreeChangeHandler
     private final PolicyValidatorRegistry validatorRegistry;
 
     public SupportedClassifierDefinitionListener(DataBroker dataProvider, PolicyValidatorRegistry validatorRegistry) {
-        super(dataProvider,
-                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
-                        InstanceIdentifier.builder(Renderers.class)
-                            .child(Renderer.class)
-                            .child(Capabilities.class)
-                            .child(SupportedClassifierDefinition.class)
-                            .build()));
+        super(dataProvider, new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+                IidFactory.supportedClassifierDefinitionIidWildcard()));
         this.validatorRegistry = validatorRegistry;
         if (validatorRegistry == null) {
             LOG.info(
similarity index 99%
rename from groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/sf/DataTreeChangeHandler.java
rename to groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/util/DataTreeChangeHandler.java
index 6dd6a5291f71799d6d73da44b598b5abbcfadff4..30a6c2e0d8a7fb5cc69e3e9e8b9e817661f88392 100644 (file)
@@ -6,7 +6,7 @@
  * and is available at http://www.eclipse.org/legal/epl-v10.html
  */
 
-package org.opendaylight.groupbasedpolicy.sf;
+package org.opendaylight.groupbasedpolicy.util;
 
 import static com.google.common.base.Preconditions.checkNotNull;
 
index 95d49509ae1dedcfc625caa3552ec7303dd31941..e588d7432dbf415878807c01b673d2b123e8e68e 100644 (file)
@@ -76,7 +76,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.r
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Interests;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.FollowedTenants;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenant;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.FollowedTenantKey;
@@ -90,7 +93,8 @@ public class IidFactory {
         throw new UnsupportedOperationException();
     }
 
-    private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID = InstanceIdentifier.builder(Endpoints.class).build();
+    private static final InstanceIdentifier<Endpoints> ENDPOINTS_IID =
+            InstanceIdentifier.builder(Endpoints.class).build();
 
     public static InstanceIdentifier<Tenant> tenantIid(TenantId id) {
         return InstanceIdentifier.builder(Tenants.class).child(Tenant.class, new TenantKey(id)).build();
@@ -142,7 +146,8 @@ public class IidFactory {
             .build();
     }
 
-    public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId, ClauseName clauseName) {
+    public static InstanceIdentifier<Clause> clauseIid(TenantId tenantId, ContractId contractId,
+            ClauseName clauseName) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
             .child(Policy.class)
@@ -206,7 +211,8 @@ public class IidFactory {
             .build();
     }
 
-    public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId, L2FloodDomainId l2FloodDomainId) {
+    public static InstanceIdentifier<L2FloodDomain> l2FloodDomainIid(TenantId tenantId,
+            L2FloodDomainId l2FloodDomainId) {
         return InstanceIdentifier.builder(Tenants.class)
             .child(Tenant.class, new TenantKey(tenantId))
             .child(ForwardingContext.class)
@@ -233,6 +239,7 @@ public class IidFactory {
 
     /**
      * Get the {@link Endpoint} {@link InstanceIdentifier} based on the {@link EndpointKey}
+     *
      * @param endpointKey The {@link EndpointKey} of a particular {@link Endpoint}
      * @return The {@link InstanceIdentifier} of the {@link Endpoint}
      */
@@ -244,16 +251,16 @@ public class IidFactory {
         return IidFactory.endpointIid(new EndpointKey(l2Context, macAddress));
     }
 
+    public static InstanceIdentifier<EndpointL3> l3EndpointIid(EndpointL3Key endpointL3Key) {
+        return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class, endpointL3Key).build();
+    }
+
     public static InstanceIdentifier<EndpointL3> l3EndpointIid(L3ContextId l3Context, IpAddress ipAddress) {
-        return InstanceIdentifier.builder(Endpoints.class)
-            .child(EndpointL3.class, new EndpointL3Key(ipAddress, l3Context))
-            .build();
+        return IidFactory.l3EndpointIid(new EndpointL3Key(ipAddress, l3Context));
     }
 
     public static InstanceIdentifier<EndpointL3> l3EndpointsIidWildcard() {
-        return InstanceIdentifier.builder(Endpoints.class)
-            .child(EndpointL3.class)
-            .build();
+        return InstanceIdentifier.builder(Endpoints.class).child(EndpointL3.class).build();
     }
 
     public static InstanceIdentifier<EndpointL3Prefix> endpointL3PrefixIid(L3ContextId l3Context, IpPrefix ipPrefix) {
@@ -285,4 +292,19 @@ public class IidFactory {
             .build();
     }
 
+    public static InstanceIdentifier<SupportedActionDefinition> supportedActionDefinitionIidWildcard() {
+        return InstanceIdentifier.builder(Renderers.class)
+            .child(Renderer.class)
+            .child(Capabilities.class)
+            .child(SupportedActionDefinition.class)
+            .build();
+    }
+
+    public static InstanceIdentifier<SupportedClassifierDefinition> supportedClassifierDefinitionIidWildcard() {
+        return InstanceIdentifier.builder(Renderers.class)
+            .child(Renderer.class)
+            .child(Capabilities.class)
+            .child(SupportedClassifierDefinition.class)
+            .build();
+    }
 }
index 6d42b28d6e37bc302b41c10add76a16ee1a99afe..1f2fc922e0f342cca5d881099ca1c4b960e2f9b0 100644 (file)
                     </data-broker>
 
                     <ep-renderer-augmentation-registry>
-                        <type xmlns:epr="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">epr:ep-renderer-augmentation-registry</type>
+                        <type xmlns:gbp="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">gbp:ep-renderer-augmentation-registry</type>
                         <name>ep-renderer-augmentation-registry</name>
                     </ep-renderer-augmentation-registry>
 
+                    <policy-validator-registry>
+                        <type xmlns:gbp="urn:opendaylight:params:xml:ns:yang:controller:config:groupbasedpolicy">gbp:policy-validator-registry</type>
+                        <name>policy-validator-registry</name>
+                    </policy-validator-registry>
+
                 </module>
             </modules>
         </data>
index c519846fa4d79a6a8e514b913e66b8ddf0a7c27b..3dc8533e72a56f41e5fe938b3957df32b9873f36 100644 (file)
@@ -10,12 +10,18 @@ package org.opendaylight.controller.config.yang.config.iovisor_provider.impl;
 
 import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
 
-public class IovisorProviderModule extends org.opendaylight.controller.config.yang.config.iovisor_provider.impl.AbstractIovisorProviderModule {
-    public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+public class IovisorProviderModule
+        extends org.opendaylight.controller.config.yang.config.iovisor_provider.impl.AbstractIovisorProviderModule {
+
+    public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
         super(identifier, dependencyResolver);
     }
 
-    public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.controller.config.yang.config.iovisor_provider.impl.IovisorProviderModule oldModule, java.lang.AutoCloseable oldInstance) {
+    public IovisorProviderModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier,
+            org.opendaylight.controller.config.api.DependencyResolver dependencyResolver,
+            org.opendaylight.controller.config.yang.config.iovisor_provider.impl.IovisorProviderModule oldModule,
+            java.lang.AutoCloseable oldInstance) {
         super(identifier, dependencyResolver, oldModule, oldInstance);
     }
 
@@ -26,7 +32,7 @@ public class IovisorProviderModule extends org.opendaylight.controller.config.ya
 
     @Override
     public java.lang.AutoCloseable createInstance() {
-        return  new IovisorRenderer(getDataBrokerDependency(),
-                                    getEpRendererAugmentationRegistryDependency());
+        return new IovisorRenderer(getDataBrokerDependency(), getEpRendererAugmentationRegistryDependency(),
+                getPolicyValidatorRegistryDependency());
     }
 }
index d67b13d842cc6cf5b6cfd23b4816e68ef7d79512..665cc09a6c15e166f272130897c7c7efc53e73f4 100644 (file)
@@ -8,10 +8,35 @@
 
 package org.opendaylight.groupbasedpolicy.renderer.iovisor;
 
+import java.util.Map.Entry;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.groupbasedpolicy.api.PolicyValidatorRegistry;
+import org.opendaylight.groupbasedpolicy.dto.EpKey;
 import org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint.EndpointManager;
 import org.opendaylight.groupbasedpolicy.renderer.iovisor.module.IovisorModuleManager;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.Action;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.ActionDefinitionListener;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.ClassifierDefinitionListener;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.sf.SubjectFeatures;
+import org.opendaylight.groupbasedpolicy.util.DataStoreHelper;
+import org.opendaylight.groupbasedpolicy.util.IidFactory;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.EndpointGroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.RendererName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroup;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.interests.followed.tenants.followed.tenant.FollowedEndpointGroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.ResolvedPolicies;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.resolved.policies.ResolvedPolicy;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -24,12 +49,47 @@ public class IovisorRenderer implements AutoCloseable {
 
     private EndpointManager endPointManager;
     private IovisorModuleManager iovisorModuleManager;
+    public static final RendererName RENDERER_NAME = new RendererName("IOVisor");
+    private final ClassifierDefinitionListener classifierDefinitionListener;
+    private ActionDefinitionListener actionDefinitionListener;
+    private ResolvedPolicyListener resolvedPolicyListener;
+    private DataBroker dataBroker;
 
-    public IovisorRenderer(DataBroker dataBroker,
-                           EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
-        LOG.info("IOVisor Renderer has Started");
+    public IovisorRenderer(DataBroker dataBroker, EpRendererAugmentationRegistry epRendererAugmentationRegistry,
+            PolicyValidatorRegistry policyValidatorRegistry) {
+        if (dataBroker != null)
+            this.dataBroker = dataBroker;
         this.endPointManager = new EndpointManager(dataBroker, epRendererAugmentationRegistry);
         this.iovisorModuleManager = new IovisorModuleManager(dataBroker);
+        this.resolvedPolicyListener =
+                new ResolvedPolicyListener(dataBroker, new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL,
+                        InstanceIdentifier.builder(ResolvedPolicies.class).child(ResolvedPolicy.class).build()));
+        classifierDefinitionListener = new ClassifierDefinitionListener(dataBroker, new DataTreeIdentifier<>(
+                LogicalDatastoreType.CONFIGURATION,
+                InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ClassifierDefinition.class).build()));
+        actionDefinitionListener = new ActionDefinitionListener(dataBroker, new DataTreeIdentifier<>(
+                LogicalDatastoreType.CONFIGURATION,
+                InstanceIdentifier.builder(SubjectFeatureDefinitions.class).child(ActionDefinition.class).build()));
+
+        for (Entry<ActionDefinitionId, Action> entry : SubjectFeatures.getActions().entrySet()) {
+            policyValidatorRegistry.register(entry.getKey(), entry.getValue());
+        }
+        LOG.info("IOVisor Renderer has Started");
+
+    }
+
+    // TODO PUNT THIS....
+    public void endpointPolicyUpdated(TenantId tenantId, EndpointGroupId epgId, EpKey epKey) {
+        // TODO a renderer should remove followed-EPG and followed-tenant at some point
+        if (dataBroker == null) {
+            LOG.error("DataBroker is null. Cannot write followed-epg {}", epKey);
+            return;
+        }
+        WriteTransaction wTx = dataBroker.newWriteOnlyTransaction();
+        FollowedEndpointGroup followedEpg = new FollowedEndpointGroupBuilder().setId(epgId).build();
+        wTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.followedEndpointgroupIid(RENDERER_NAME, tenantId, epgId),
+                followedEpg, true);
+        DataStoreHelper.submitToDs(wTx);
     }
 
     @Override
@@ -37,8 +97,14 @@ public class IovisorRenderer implements AutoCloseable {
         if (endPointManager != null) {
             endPointManager.close();
         }
+        if (classifierDefinitionListener != null)
+            classifierDefinitionListener.close();
+        if (actionDefinitionListener != null)
+            actionDefinitionListener.close();
         if (iovisorModuleManager != null) {
             iovisorModuleManager.close();
+            if (resolvedPolicyListener != null)
+                resolvedPolicyListener.close();
         }
     }
 }
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/ResolvedPolicyListener.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/ResolvedPolicyListener.java
new file mode 100644 (file)
index 0000000..eada65f
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.resolved.policy.rev150828.resolved.policies.ResolvedPolicy;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ResolvedPolicyListener extends DataTreeChangeHandler<ResolvedPolicy> {
+
+    protected ResolvedPolicyListener(DataBroker dataProvider, DataTreeIdentifier<ResolvedPolicy> pointOfInterest) {
+        super(dataProvider, pointOfInterest);
+        LOG.info("Initialised ResolvedPolicyListener");
+    }
+
+    private static final Logger LOG = LoggerFactory.getLogger(ResolvedPolicyListener.class);
+
+    @Override
+    protected void onWrite(DataObjectModification<ResolvedPolicy> rootNode,
+            InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+        LOG.info("Not implemented yet");
+
+    }
+
+    @Override
+    protected void onDelete(DataObjectModification<ResolvedPolicy> rootNode,
+            InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+        LOG.info("Not implemented yet");
+
+    }
+
+    @Override
+    protected void onSubreeModified(DataObjectModification<ResolvedPolicy> rootNode,
+            InstanceIdentifier<ResolvedPolicy> rootIdentifier) {
+        LOG.info("Not implemented yet");
+
+    }
+
+}
index 2e2781e4983c5f9d55b28a5731bddb7b3d588817..049713c030f98bfe0f719f48b74156079ee30ae2 100644 (file)
 
 package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
 
-import java.util.Map;
-import java.util.Map.Entry;
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.util.Collection;
 
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeChangeListener;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.groupbasedpolicy.renderer.iovisor.utils.IovisorModuleUtils;
 import org.opendaylight.groupbasedpolicy.util.IidFactory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentation;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.base.Preconditions;
-
-public class EndpointListener implements DataChangeListener, AutoCloseable {
+public class EndpointListener implements DataTreeChangeListener<EndpointL3>, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(EndpointListener.class);
 
-    private final ListenerRegistration<DataChangeListener> registerListener;
-
-    private DataBroker dataBroker;
+    private final DataBroker dataProvider;
+    private final ListenerRegistration<EndpointListener> registration;
+    private final EndpointManager endpointManager;
 
-    public EndpointListener(DataBroker dataBroker) {
-        this.dataBroker = dataBroker;
-        this.registerListener = dataBroker.registerDataChangeListener(
-                                                LogicalDatastoreType.OPERATIONAL,
-                                                IidFactory.endpointsIidWildcard().child(Endpoint.class),
-                                                this,
-                                                AsyncDataBroker.DataChangeScope.SUBTREE);
+    public EndpointListener(DataBroker dataProvider, EndpointManager endpointManager) {
+        this.dataProvider = checkNotNull(dataProvider);
+        registration = dataProvider.registerDataTreeChangeListener(
+                new DataTreeIdentifier<>(LogicalDatastoreType.OPERATIONAL, IidFactory.l3EndpointsIidWildcard()), this);
+        this.endpointManager = endpointManager;
     }
 
     @Override
-    public void onDataChanged(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
-        created(changes.getCreatedData());
-        updated(changes.getUpdatedData());
-        removed(changes);
-    }
-
-    /**
-     * Process created events.
-     *
-     * @param created
-     *            Created data
-     */
-    private void created(Map<InstanceIdentifier<?>, DataObject> created) {
-        for (Entry<InstanceIdentifier<?>, DataObject> newEndpoint : created.entrySet()) {
-            Endpoint endpoint = fromMd(newEndpoint.getKey(), (Endpoint) newEndpoint.getValue());
-            LOG.debug("Endpoint CREATED {}", endpoint);
-
-            // Validate the IOVisorModuleInstance
-            IovisorModuleAugmentation iovisorModuleAugmentation = endpoint.getAugmentation(IovisorModuleAugmentation.class);
-            Preconditions.checkNotNull(iovisorModuleAugmentation.getUri(), "At this point, the Endpoint should be provided with a IovisorModuleInstance");
-            if (IovisorModuleUtils.validateIovisorModuleInstance(dataBroker, iovisorModuleAugmentation.getUri())) {
-                LOG.debug("This Endpoint {} provides a valid IovisorModuleInstance {}", endpoint, iovisorModuleAugmentation.getUri());
-                // TODO process validated endpoint
+    public void onDataTreeChanged(Collection<DataTreeModification<EndpointL3>> changes) {
+        for (DataTreeModification<EndpointL3> change : changes) {
+            DataObjectModification<EndpointL3> rootNode = change.getRootNode();
+            switch (rootNode.getModificationType()) {
+                case WRITE:
+                case SUBTREE_MODIFIED:
+                    LOG.info("Received Endpoint {}", rootNode.getDataAfter().getIpAddress());
+                    if (rootNode.getDataAfter().getAugmentation(IovisorModuleAugmentation.class) != null) {
+                        endpointManager.processEndpoint(rootNode.getDataAfter());
+                    } else {
+                        LOG.info("Endpoint did not have IOVisor Module Augmentation (Location URI). Ignoring");
+                    }
+                    break;
+                case DELETE:
+                    LOG.warn("Received Endpoint {} but DELETE not implemented yet",
+                            rootNode.getDataAfter().getIpAddress());
             }
         }
     }
 
-    /**
-     * Process updated events.
-     *
-     * @param updated
-     *            updated data
-     */
-    private void updated(Map<InstanceIdentifier<?>, DataObject> updated) {
-        for (Entry<InstanceIdentifier<?>, DataObject> updatedEndpoint : updated.entrySet()) {
-            Endpoint endpoint = fromMd(updatedEndpoint.getKey(), (Endpoint) updatedEndpoint.getValue());
-            LOG.debug("Endpoint UPDATED {}", endpoint);
-            //TODO process updated event
-
-        }
-    }
-
-    /**
-     * Process REMOVED data.
-     *
-     * @param changes
-     *            Changes data
-     */
-    private void removed(AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes) {
-        for (InstanceIdentifier<?> deletedEndpointPath : changes.getRemovedPaths()) {
-            Endpoint endpoint = fromMd(deletedEndpointPath, (Endpoint) changes.getOriginalData().get(deletedEndpointPath));
-            LOG.debug("Endpoint REMOVED {}", endpoint);
-            // TODO process removed event
-        }
-    }
-
-    /**
-     * Get the object from MD-SAL based on the instance identifier.
-     *
-     * @param iid
-     *            {@link InstanceIdentifier} of the related event
-     * @param endpoint
-     *            Endpoint from the related event
-     * @return Endpoint constructed from the one gathered in the related event
-     */
-    private Endpoint fromMd(InstanceIdentifier<?> iid, Endpoint endpoint) {
-        EndpointBuilder result = new EndpointBuilder();
-
-        final EndpointKey endpointKey = iid.firstKeyOf(Endpoint.class);
-        if (endpointKey != null) {
-            result.setKey(endpointKey);
-        }
-
-        result.setCondition(endpoint.getCondition());
-        result.setEndpointGroup(endpoint.getEndpointGroup());
-        result.setEndpointGroups(endpoint.getEndpointGroups());
-        result.setL2Context(endpoint.getL2Context());
-        result.setL3Address(endpoint.getL3Address());
-        result.setMacAddress(endpoint.getMacAddress());
-        result.setNetworkContainment(endpoint.getNetworkContainment());
-        result.setTenant(endpoint.getTenant());
-        result.setTimestamp(endpoint.getTimestamp());
-
-        return result.build();
-    }
-
     @Override
     public void close() throws Exception {
-        if (registerListener != null)
-            registerListener.close();
+        registration.close();
     }
+
 }
index d0f19636db08cca73fe8c8df18a14daca5fa7580..c45a46955729ded23137cdee02904fa6a64e7e90 100644 (file)
@@ -8,66 +8,60 @@
 
 package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
 
-import java.util.Map.Entry;
-
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
 import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
-import org.opendaylight.yangtools.yang.binding.Augmentation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 import com.google.common.base.Preconditions;
 
-public class EndpointManager implements EpRendererAugmentation, AutoCloseable {
+public class EndpointManager implements AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(EndpointManager.class);
 
     private EndpointListener endpointListener;
-    private EpRendererAugmentationRegistry epRendererAugmentationRegistry;
+    private final IovisorEndpointAug iovisorEndpointAug;
 
-    public EndpointManager(DataBroker dataBroker,
-                           EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
-        LOG.info("Initialized IOVisor EndpointManager");
+    public EndpointManager(DataBroker dataBroker, EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
         Preconditions.checkNotNull(dataBroker, "DataBroker instance must not be null");
+        iovisorEndpointAug = new IovisorEndpointAug(epRendererAugmentationRegistry);
+        endpointListener = new EndpointListener(dataBroker, this);
+        LOG.info("Initialized IOVisor EndpointManager");
+    }
 
-        this.epRendererAugmentationRegistry = epRendererAugmentationRegistry;
-        this.endpointListener = new EndpointListener(dataBroker);
+    public void processEndpoint(EndpointL3 endpoint) {
+        /*
+         * Is Augmentation valid?
+         * - IPAddress or a name that can be resolved to an IPAddress
+         */
 
-        epRendererAugmentationRegistry.register(this);
-    }
+        /*
+         * IOVisorModule registered?
+         * - In this rev, we will register the IOVisorModule (agent)
+         */
 
-    @Override
-    public void close() throws Exception {
-        if (endpointListener != null) {
-            endpointListener.close();
-        }
-        epRendererAugmentationRegistry.unregister(this);
-    }
+        /*
+         * Validate there is a resolved policy for tenant/EPGs.
+         * - If so, add to resolved policy endpoint map thing
+         * - If not, wait until there is (listener)
+         * .... not real sure on this one... chicken and egg.
+         */
 
-    @Override
-    public Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> buildEndpointAugmentation(
-            RegisterEndpointInput input) {
-        // TODO Auto-generated method stub
-        return null;
-    }
+        /*
+         * Validate there is a valid forwarding model
+         *
+         */
 
-    @Override
-    public Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> buildEndpointL3Augmentation(
-            RegisterEndpointInput input) {
-        // TODO Auto-generated method stub
-        return null;
+        LOG.info("Processed Endpoint {}", endpoint);
     }
 
     @Override
-    public Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> buildL3PrefixEndpointAugmentation(
-            RegisterL3PrefixEndpointInput input) {
-        // TODO Auto-generated method stub
-        return null;
+    public void close() throws Exception {
+        if (iovisorEndpointAug != null)
+            iovisorEndpointAug.close();
+        if (endpointListener != null)
+            endpointListener.close();
+
     }
-}
\ No newline at end of file
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/IovisorEndpointAug.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/endpoint/IovisorEndpointAug.java
new file mode 100644 (file)
index 0000000..f80b787
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
+
+import java.util.AbstractMap.SimpleImmutableEntry;
+import java.util.Map.Entry;
+
+import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentation;
+import org.opendaylight.groupbasedpolicy.api.EpRendererAugmentationRegistry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterL3PrefixEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentationInput;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class IovisorEndpointAug implements EpRendererAugmentation, AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(IovisorEndpointAug.class);
+
+    private EpRendererAugmentationRegistry epRendererAugmentationRegistry;
+
+    public IovisorEndpointAug(EpRendererAugmentationRegistry epRendererAugmentationRegistry) {
+        this.epRendererAugmentationRegistry = epRendererAugmentationRegistry;
+        this.epRendererAugmentationRegistry.register(this);
+        LOG.info("IovisorRenderer: Registered endpoint augmentation");
+    }
+
+    @Override
+    public void close() throws Exception {
+        epRendererAugmentationRegistry.unregister(this);
+    }
+
+    @Override
+    public Entry<Class<? extends Augmentation<Endpoint>>, Augmentation<Endpoint>> buildEndpointAugmentation(
+            RegisterEndpointInput input) {
+        LOG.info("IovisorRenderer does not Augment Endpoint class");
+        return null;
+    }
+
+    @Override
+    public Entry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>> buildEndpointL3Augmentation(
+            RegisterEndpointInput input) {
+        IovisorModuleAugmentationInput iomAugInput = input.getAugmentation(IovisorModuleAugmentationInput.class);
+        if (iomAugInput == null) {
+            return null;
+        }
+        return new SimpleImmutableEntry<Class<? extends Augmentation<EndpointL3>>, Augmentation<EndpointL3>>(
+                IovisorModuleAugmentation.class, new IovisorModuleAugmentationBuilder(iomAugInput).build());
+
+    }
+
+    @Override
+    public Entry<Class<? extends Augmentation<EndpointL3Prefix>>, Augmentation<EndpointL3Prefix>> buildL3PrefixEndpointAugmentation(
+            RegisterL3PrefixEndpointInput input) {
+        LOG.info("IovisorRenderer does not Augment EndpointL3Prefix class");
+        return null;
+    }
+}
index 0215d3bb7844ba15a295a85b3985ebd2f2765e0f..1e5b04959918d195c93b207fadf6f095cf6b7d52 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2015 Inocybe Technologies and others.  All rights reserved.
+ * Copyright (c) 2015 Inocybe Technologies and others. 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,
@@ -21,10 +21,10 @@ public class IovisorModuleManager implements AutoCloseable {
     private IovisorModuleListener iovisorModuleListener;
 
     public IovisorModuleManager(DataBroker dataBroker) {
-        LOG.info("Initialized IOVisor IovisorModuleManager");
         Preconditions.checkNotNull(dataBroker, "DataBroker instance must not be null");
 
         this.iovisorModuleListener = new IovisorModuleListener(dataBroker);
+        LOG.info("Initialized IOVisor IovisorModuleManager");
     }
 
     @Override
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Action.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Action.java
new file mode 100755 (executable)
index 0000000..931cf1a
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+
+import org.opendaylight.groupbasedpolicy.api.Validator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.action.definition.SupportedParameterValues;
+
+/**
+ * Represent an action definition, and provide tools for generating
+ * flow instructions based on the action
+ */
+public abstract class Action implements Validator<ActionInstance> {
+
+    /**
+     * Get the action definition for this action
+     *
+     * @return the {@link ActionDefinition} for this action
+     */
+    public abstract ActionDefinitionId getId();
+
+    /**
+     * Get the action definition for this action
+     *
+     * @return the {@link ActionDefinition} for this action
+     */
+    public abstract ActionDefinition getActionDef();
+
+    /**
+     * The result represents supported parameters for the action by renderer
+     *
+     * @return list of supported parameters by the action
+     */
+    public abstract List<SupportedParameterValues> getSupportedParameterValues();
+
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ActionDefinitionListener.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ActionDefinitionListener.java
new file mode 100644 (file)
index 0000000..66b5f65
--- /dev/null
@@ -0,0 +1,108 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinitionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedActionDefinitionKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class ActionDefinitionListener extends DataTreeChangeHandler<ActionDefinition> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ActionDefinitionListener.class);
+    private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+        .child(Renderer.class, new RendererKey(IovisorRenderer.RENDERER_NAME))
+        .child(Capabilities.class)
+        .build();
+    private static String PUT = "stored";
+    private static String DELETED = "removed";
+
+    public ActionDefinitionListener(DataBroker dataProvider, DataTreeIdentifier<ActionDefinition> pointOfInterest) {
+        super(dataProvider, pointOfInterest);
+    }
+
+    private SupportedActionDefinition createSupportedActionDefinition(Action action) {
+        return new SupportedActionDefinitionBuilder().setActionDefinitionId(action.getId())
+            .setSupportedParameterValues(action.getSupportedParameterValues())
+            .build();
+    }
+
+    private FutureCallback<Void> logDebugResult(final SupportedActionDefinitionKey supportedActionDefinitionKey,
+            final String putOrDeleted) {
+        return new FutureCallback<Void>() {
+
+            @Override
+            public void onSuccess(Void result) {
+                LOG.debug("Capability of renerer {} was {}: {}", IovisorRenderer.RENDERER_NAME.getValue(), putOrDeleted,
+                        supportedActionDefinitionKey);
+            }
+
+            @Override
+            public void onFailure(Throwable t) {
+                LOG.error("Capability of renderer {} was NOT {}: {}", IovisorRenderer.RENDERER_NAME.getValue(),
+                        putOrDeleted, supportedActionDefinitionKey, t);
+            }
+        };
+    }
+
+    @Override
+    protected void onWrite(DataObjectModification<ActionDefinition> rootNode,
+            InstanceIdentifier<ActionDefinition> rootIdentifier) {
+        onSubreeModified(rootNode, rootIdentifier);
+    }
+
+    @Override
+    protected void onDelete(DataObjectModification<ActionDefinition> rootNode,
+            InstanceIdentifier<ActionDefinition> rootIdentifier) {
+        ActionDefinition actionDefinitionBefore = checkNotNull(rootNode.getDataBefore());
+        Action ourAction = SubjectFeatures.getAction(actionDefinitionBefore.getId());
+        if (ourAction != null) {
+            SupportedActionDefinitionKey supportedActionDefinitionKey =
+                    new SupportedActionDefinitionKey(ourAction.getId());
+            WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+            wTx.delete(LogicalDatastoreType.OPERATIONAL,
+                    CAPABILITIES_IID.child(SupportedActionDefinition.class, supportedActionDefinitionKey));
+            Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinitionKey, DELETED));
+        }
+    }
+
+    @Override
+    protected void onSubreeModified(DataObjectModification<ActionDefinition> rootNode,
+            InstanceIdentifier<ActionDefinition> rootIdentifier) {
+        ActionDefinition actionDefinitionAfter = checkNotNull(rootNode.getDataAfter());
+        Action ourAction = SubjectFeatures.getAction(actionDefinitionAfter.getId());
+        if (ourAction != null) {
+            SupportedActionDefinition supportedActionDefinition = createSupportedActionDefinition(ourAction);
+            WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+            wTx.put(LogicalDatastoreType.OPERATIONAL,
+                    CAPABILITIES_IID.child(SupportedActionDefinition.class, supportedActionDefinition.getKey()),
+                    supportedActionDefinition, true);
+            Futures.addCallback(wTx.submit(), logDebugResult(supportedActionDefinition.getKey(), PUT));
+        }
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/AllowAction.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/AllowAction.java
new file mode 100755 (executable)
index 0000000..5ffacdc
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.opendaylight.groupbasedpolicy.api.ValidationResult;
+import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;
+import org.opendaylight.groupbasedpolicy.dto.ValidationResultBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.tenants.tenant.policy.subject.feature.instances.ActionInstance;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.action.definition.SupportedParameterValues;
+
+/**
+ * Allow action
+ */
+public class AllowAction extends Action {
+
+    @Override
+    public ActionDefinitionId getId() {
+        return AllowActionDefinition.ID;
+    }
+
+    @Override
+    public ActionDefinition getActionDef() {
+        return AllowActionDefinition.DEFINITION;
+    }
+
+    @Override
+    public ValidationResult validate(ActionInstance actionInstance) {
+        return new ValidationResultBuilder().success().build();
+    }
+
+    @Override
+    public List<SupportedParameterValues> getSupportedParameterValues() {
+        // allow action definition has no parameter
+        return Collections.emptyList();
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassificationResult.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassificationResult.java
new file mode 100644 (file)
index 0000000..cb4a379
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+
+import com.google.common.base.Preconditions;
+
+public class ClassificationResult {
+
+    private final String errorMessage;
+    private final boolean isSuccessful;
+
+    /**
+     * @param errorMessage cannot be {@code null}
+     */
+    public ClassificationResult(String errorMessage) {
+        this.errorMessage = Preconditions.checkNotNull(errorMessage);
+        this.isSuccessful = false;
+    }
+
+    /**
+     * @param matches cannot be {@code null}
+     */
+    public ClassificationResult(List<String> matches) {
+        errorMessage = "";
+        this.isSuccessful = true;
+    }
+
+    /**
+     * @return contains error message if {@link #isSuccessfull()} == {@code false}
+     */
+    public String getErrorMessage() {
+        return errorMessage;
+    }
+
+    /**
+     * @return {@code true} if {@link ClassificationResult} contains result. {@code false} if
+     *         {@link ClassificationResult} contains error message.
+     */
+    public boolean isSuccessfull() {
+        return isSuccessful;
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Classifier.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/Classifier.java
new file mode 100755 (executable)
index 0000000..17f84b8
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+
+/**
+ * Represent a classifier definition, and provide tools for generating flow
+ * rules based on the classifier
+ */
+public abstract class Classifier {
+
+    protected final Classifier parent;
+
+    public static final EtherTypeClassifier ETHER_TYPE_CL = new EtherTypeClassifier(null);
+    public static final IpProtoClassifier IP_PROTO_CL = new IpProtoClassifier(ETHER_TYPE_CL);
+    public static final L4Classifier L4_CL = new L4Classifier(IP_PROTO_CL);
+
+    protected Classifier(Classifier parent) {
+        this.parent = parent;
+    }
+
+    /**
+     * Get the classifier definition id for this classifier
+     *
+     * @return the {@link ClassifierDefinitionId} for this classifier
+     */
+    public abstract ClassifierDefinitionId getId();
+
+    /**
+     * Get the classifier definition for this classifier
+     *
+     * @return the {@link ClassifierDefinition} for this classifier
+     */
+    public abstract ClassifierDefinition getClassifierDefinition();
+
+    /**
+     * @return parent classifier, see {@link Classifier}
+     */
+    public final Classifier getParent() {
+        return parent;
+    }
+
+    /**
+     * The result represents supported parameters for the classifier by renderer
+     *
+     * @return list of supported parameters by the classifier
+     */
+    public abstract List<SupportedParameterValues> getSupportedParameterValues();
+
+    /**
+     * Checks presence of required {@code params} in order to decide if classifier can update
+     * {@code matches} properly
+     *
+     * @param params inserted parameters, not null
+     * @throws IllegalArgumentException when any of required {@code params} is not present
+     */
+    protected abstract void checkPresenceOfRequiredParams(Map<String, ParameterValue> params);
+
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassifierDefinitionListener.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ClassifierDefinitionListener.java
new file mode 100755 (executable)
index 0000000..3bd0ba3
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataObjectModification;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeIdentifier;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.groupbasedpolicy.renderer.iovisor.IovisorRenderer;
+import org.opendaylight.groupbasedpolicy.util.DataTreeChangeHandler;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.Renderers;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.Renderer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.RendererKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.Capabilities;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinitionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.SupportedClassifierDefinitionKey;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+
+public class ClassifierDefinitionListener extends DataTreeChangeHandler<ClassifierDefinition> {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ClassifierDefinitionListener.class);
+
+    private static final String PUT = "stored";
+    private static final String DELETED = "removed";
+    private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+        .child(Renderer.class, new RendererKey(IovisorRenderer.RENDERER_NAME))
+        .child(Capabilities.class)
+        .build();
+
+    public ClassifierDefinitionListener(DataBroker dataBroker,
+            DataTreeIdentifier<ClassifierDefinition> pointOfInterest) {
+        super(dataBroker, pointOfInterest);
+    }
+
+    private SupportedClassifierDefinition createSupportedClassifierDefinition(Classifier classifier) {
+        SupportedClassifierDefinitionBuilder scdBuilder =
+                new SupportedClassifierDefinitionBuilder().setClassifierDefinitionId(classifier.getId())
+                    .setSupportedParameterValues(classifier.getSupportedParameterValues());
+        if (classifier.getParent() != null) {
+            scdBuilder.setParentClassifierDefinitionId(classifier.getParent().getId());
+        }
+        return scdBuilder.build();
+    }
+
+    private FutureCallback<Void> logDebugResult(final SupportedClassifierDefinitionKey supportedClassifierDefinitionKey,
+            final String putOrDeleted) {
+        return new FutureCallback<Void>() {
+
+            @Override
+            public void onSuccess(Void result) {
+                LOG.debug("Capability of renerer {} was {}: {}", IovisorRenderer.RENDERER_NAME.getValue(), putOrDeleted,
+                        supportedClassifierDefinitionKey);
+            }
+
+            @Override
+            public void onFailure(Throwable t) {
+                LOG.error("Capability of renderer {} was NOT {}: {}", IovisorRenderer.RENDERER_NAME.getValue(),
+                        putOrDeleted, supportedClassifierDefinitionKey, t);
+            }
+        };
+    }
+
+    @Override
+    protected void onWrite(DataObjectModification<ClassifierDefinition> rootNode,
+            InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+        onSubreeModified(rootNode, rootIdentifier);
+    }
+
+    @Override
+    protected void onDelete(DataObjectModification<ClassifierDefinition> rootNode,
+            InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+        ClassifierDefinition classifierDefinitionBefore = checkNotNull(rootNode.getDataBefore());
+        Classifier ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionBefore.getId());
+        if (ourClassifier != null) {
+            SupportedClassifierDefinitionKey supportedClassifierDefinitionKey =
+                    new SupportedClassifierDefinitionKey(ourClassifier.getId());
+            WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+            wTx.delete(LogicalDatastoreType.OPERATIONAL,
+                    CAPABILITIES_IID.child(SupportedClassifierDefinition.class, supportedClassifierDefinitionKey));
+            Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinitionKey, DELETED));
+        }
+    }
+
+    @Override
+    protected void onSubreeModified(DataObjectModification<ClassifierDefinition> rootNode,
+            InstanceIdentifier<ClassifierDefinition> rootIdentifier) {
+        ClassifierDefinition classifierDefinitionAfter = checkNotNull(rootNode.getDataAfter());
+        Classifier ourClassifier = SubjectFeatures.getClassifier(classifierDefinitionAfter.getId());
+        if (ourClassifier != null) {
+            SupportedClassifierDefinition supportedClassifierDefinition =
+                    createSupportedClassifierDefinition(ourClassifier);
+            WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
+            wTx.put(LogicalDatastoreType.OPERATIONAL,
+                    CAPABILITIES_IID.child(SupportedClassifierDefinition.class, supportedClassifierDefinition.getKey()),
+                    supportedClassifierDefinition, true);
+            Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinition.getKey(), PUT));
+        }
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/EtherTypeClassifier.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/EtherTypeClassifier.java
new file mode 100755 (executable)
index 0000000..65db552
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match on the ether type of the traffic
+ */
+public class EtherTypeClassifier extends Classifier {
+
+    protected EtherTypeClassifier(Classifier parent) {
+        super(parent);
+    }
+
+    @Override
+    public ClassifierDefinitionId getId() {
+        return EtherTypeClassifierDefinition.ID;
+    }
+
+    @Override
+    public ClassifierDefinition getClassifierDefinition() {
+        return EtherTypeClassifierDefinition.DEFINITION;
+    }
+
+    @Override
+    public List<SupportedParameterValues> getSupportedParameterValues() {
+
+        List<SupportedIntValue> values = ImmutableList.of(
+                new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.ARP_VALUE).build(),
+                new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv4_VALUE).build(),
+                new SupportedIntValueBuilder().setValue(EtherTypeClassifierDefinition.IPv6_VALUE).build());
+        SupportedParameterValuesBuilder b = new SupportedParameterValuesBuilder();
+        b.setParameterName(new ParameterName(EtherTypeClassifierDefinition.ETHERTYPE_PARAM));
+        b.setParameterType(new IntBuilder().setSupportedIntValue(values).build());
+
+        return ImmutableList.of(b.build());
+    }
+
+    @Override
+    protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+        if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM) == null) {
+            throw new IllegalArgumentException(
+                    "Parameter " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " not specified.");
+        }
+        if (params.get(EtherTypeClassifierDefinition.ETHERTYPE_PARAM).getIntValue() == null) {
+            throw new IllegalArgumentException(
+                    "Value of " + EtherTypeClassifierDefinition.ETHERTYPE_PARAM + " parameter is not present.");
+        }
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/IpProtoClassifier.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/IpProtoClassifier.java
new file mode 100755 (executable)
index 0000000..7eba44d
--- /dev/null
@@ -0,0 +1,92 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match on the IP protocol of IP traffic
+ */
+public class IpProtoClassifier extends Classifier {
+
+    protected IpProtoClassifier(Classifier parent) {
+        super(parent);
+    }
+
+    @Override
+    public ClassifierDefinitionId getId() {
+        return IpProtoClassifierDefinition.ID;
+    }
+
+    @Override
+    public ClassifierDefinition getClassifierDefinition() {
+        return IpProtoClassifierDefinition.DEFINITION;
+    }
+
+    @Override
+    public List<SupportedParameterValues> getSupportedParameterValues() {
+
+        List<SupportedIntValue> values = ImmutableList.of(
+                new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.ICMP_VALUE).build(),
+                new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.SCTP_VALUE).build(),
+                new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.TCP_VALUE).build(),
+                new SupportedIntValueBuilder().setValue(IpProtoClassifierDefinition.UDP_VALUE).build());
+        SupportedParameterValuesBuilder b = new SupportedParameterValuesBuilder();
+        b.setParameterName(new ParameterName(IpProtoClassifierDefinition.PROTO_PARAM));
+        b.setParameterType(new IntBuilder().setSupportedIntValue(values).build());
+
+        return ImmutableList.of(b.build());
+    }
+
+    @Override
+    protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+        if (params.get(IpProtoClassifierDefinition.PROTO_PARAM) == null) {
+            throw new IllegalArgumentException(
+                    "Parameter " + IpProtoClassifierDefinition.PROTO_PARAM + " not specified.");
+        }
+        if (params.get(IpProtoClassifierDefinition.PROTO_PARAM).getIntValue() == null) {
+            throw new IllegalArgumentException(
+                    "Value of " + IpProtoClassifierDefinition.PROTO_PARAM + " parameter is not present.");
+        }
+    }
+
+    /**
+     * Return the IpProtocol value. May return null.
+     * 
+     * @param params the parameters of classifier-instance inserted by user
+     * @return the IpProtocol value
+     */
+    public static Long getIpProtoValue(Map<String, ParameterValue> params) {
+        if (params == null) {
+            return null;
+        }
+        if (params.get(IpProtoClassifierDefinition.PROTO_PARAM) == null) {
+            return null;
+        }
+        Long proto = params.get(IpProtoClassifierDefinition.PROTO_PARAM).getIntValue();
+        if (proto != null) {
+            return proto;
+        }
+        return null;
+    }
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/L4Classifier.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/L4Classifier.java
new file mode 100755 (executable)
index 0000000..7bb668e
--- /dev/null
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ParameterName;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.parameter.value.RangeValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.IntBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.parameters.type.parameter.type.RangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValues;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.capabilities.supported.classifier.definition.SupportedParameterValuesBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueInRange;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported._int.value.fields.SupportedIntValueInRangeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported.range.value.fields.SupportedRangeValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.supported.range.value.fields.SupportedRangeValueBuilder;
+
+import com.google.common.collect.ImmutableList;
+
+/**
+ * Match against TCP or UDP, and source and/or destination ports
+ */
+public class L4Classifier extends Classifier {
+
+    protected L4Classifier(Classifier parent) {
+        super(parent);
+    }
+
+    @Override
+    public ClassifierDefinitionId getId() {
+        return L4ClassifierDefinition.ID;
+    }
+
+    @Override
+    public ClassifierDefinition getClassifierDefinition() {
+        return L4ClassifierDefinition.DEFINITION;
+    }
+
+    @Override
+    public List<SupportedParameterValues> getSupportedParameterValues() {
+        List<SupportedIntValueInRange> allPossiblePortsIntInRange =
+                ImmutableList.of(new SupportedIntValueInRangeBuilder().setMin(1L).setMax(65535L).build());
+        List<SupportedRangeValue> allPossiblePortsRange =
+                ImmutableList.of(new SupportedRangeValueBuilder().setMin(1L).setMax(65535L).build());
+
+        SupportedParameterValues srcPorts = new SupportedParameterValuesBuilder()
+            .setParameterName(new ParameterName(L4ClassifierDefinition.SRC_PORT_PARAM))
+            .setParameterType(new IntBuilder().setSupportedIntValueInRange(allPossiblePortsIntInRange).build())
+            .build();
+        SupportedParameterValues dstPorts = new SupportedParameterValuesBuilder()
+            .setParameterName(new ParameterName(L4ClassifierDefinition.DST_PORT_PARAM))
+            .setParameterType(new IntBuilder().setSupportedIntValueInRange(allPossiblePortsIntInRange).build())
+            .build();
+
+        SupportedParameterValues srcPortsRange = new SupportedParameterValuesBuilder()
+            .setParameterName(new ParameterName(L4ClassifierDefinition.SRC_PORT_RANGE_PARAM))
+            .setParameterType(new RangeBuilder().setSupportedRangeValue(allPossiblePortsRange).build())
+            .build();
+        SupportedParameterValues dstPortsRange = new SupportedParameterValuesBuilder()
+            .setParameterName(new ParameterName(L4ClassifierDefinition.DST_PORT_RANGE_PARAM))
+            .setParameterType(new RangeBuilder().setSupportedRangeValue(allPossiblePortsRange).build())
+            .build();
+
+        return ImmutableList.of(srcPorts, dstPorts, srcPortsRange, dstPortsRange);
+    }
+
+    @Override
+    protected void checkPresenceOfRequiredParams(Map<String, ParameterValue> params) {
+        validatePortParam(params, L4ClassifierDefinition.SRC_PORT_PARAM, L4ClassifierDefinition.SRC_PORT_RANGE_PARAM);
+        validatePortParam(params, L4ClassifierDefinition.DST_PORT_PARAM, L4ClassifierDefinition.DST_PORT_RANGE_PARAM);
+        validateRange(params, L4ClassifierDefinition.SRC_PORT_RANGE_PARAM);
+        validateRange(params, L4ClassifierDefinition.DST_PORT_RANGE_PARAM);
+    }
+
+    private void validatePortParam(Map<String, ParameterValue> params, String portParam, String portRangeParam) {
+        if (params.get(portParam) != null) {
+            StringBuilder paramLog = new StringBuilder();
+            if (params.get(portParam).getIntValue() == null) {
+                paramLog.append("Value of ").append(portParam).append(" parameter is not specified.");
+                throw new IllegalArgumentException(paramLog.toString());
+            }
+            if (params.get(portRangeParam) != null) {
+                paramLog.append("Source port parameters ")
+                    .append(portParam)
+                    .append(" and ")
+                    .append(portRangeParam)
+                    .append(" are mutually exclusive.");
+                throw new IllegalArgumentException(paramLog.toString());
+            }
+        }
+    }
+
+    private void validateRange(Map<String, ParameterValue> params, String portRangeParam) {
+        if (params.get(portRangeParam) != null) {
+            validateRangeValue(params.get(portRangeParam).getRangeValue());
+        }
+    }
+
+    private void validateRangeValue(RangeValue rangeValueParam) {
+        if (rangeValueParam == null) {
+            throw new IllegalArgumentException("Range parameter is specifiet but value is not present.");
+        }
+        final Long min = rangeValueParam.getMin();
+        final Long max = rangeValueParam.getMax();
+        if (min > max) {
+            throw new IllegalArgumentException("Range value mismatch. " + min + " is greater than MAX " + max + ".");
+        }
+    }
+
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ParamDerivator.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/ParamDerivator.java
new file mode 100644 (file)
index 0000000..f0b2ffd
--- /dev/null
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2015 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValue;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.instance.ParameterValueBuilder;
+
+public abstract class ParamDerivator {
+
+    /**
+     * TODO: These are buried somewhere in MDSAL MODEL but NFI how to tease them out. Seems
+     * ridiculous we have to pull these sort of things
+     * in from OFP of LLDP or some such. Quicker to just define them here and rant about it in a
+     * comment.
+     */
+
+    /**
+     * IPv4 ethertype
+     */
+    public static final Long IPv4 = Long.valueOf(0x0800);
+    /**
+     * IPv6 ethertype
+     */
+    public static final Long IPv6 = Long.valueOf(0x86DD);
+
+    /**
+     * It is possible to derive missing parameters.
+     * <p>
+     * Examle:
+     * <p>
+     * Ether-type parameter is missing. Derivation policy might instruct: ipv4 and ipv6 flows need
+     * to be created if ether-type parameter is not present. In this case two derivations of
+     * {@code params} should be returned. One with ipv4 ether-type, the other with ipv6.
+     *
+     * @param params parameters inserted by user
+     * @return list of {@code params} updated with derived values
+     */
+    public abstract List<Map<String, ParameterValue>> deriveParameter(Map<String, ParameterValue> params);
+
+    public static final ParamDerivator ETHER_TYPE_DERIVATOR = new ParamDerivator() {
+
+        @Override
+        public List<Map<String, ParameterValue>> deriveParameter(Map<String, ParameterValue> params) {
+
+            if (!params.containsKey(EtherTypeClassifierDefinition.ETHERTYPE_PARAM)) {
+                Map<String, ParameterValue> ipv4Params = new HashMap<>(params);
+                Map<String, ParameterValue> ipv6Params = new HashMap<>(params);
+                ipv4Params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM,
+                        new ParameterValueBuilder().setIntValue(IPv4).build());
+                ipv6Params.put(EtherTypeClassifierDefinition.ETHERTYPE_PARAM,
+                        new ParameterValueBuilder().setIntValue(IPv6).build());
+                List<Map<String, ParameterValue>> derivedParams = new ArrayList<>();
+                derivedParams.add(ipv4Params);
+                derivedParams.add(ipv6Params);
+                return derivedParams;
+            }
+            return Collections.singletonList(params);
+        }
+    };
+}
diff --git a/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/SubjectFeatures.java b/renderers/iovisor/src/main/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/sf/SubjectFeatures.java
new file mode 100755 (executable)
index 0000000..94f3813
--- /dev/null
@@ -0,0 +1,90 @@
+/*
+ * Copyright (c) 2014 Cisco Systems, Inc. and others. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor.sf;
+
+import java.util.List;
+import java.util.Map;
+
+import org.opendaylight.groupbasedpolicy.api.sf.AllowActionDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.EtherTypeClassifierDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.IpProtoClassifierDefinition;
+import org.opendaylight.groupbasedpolicy.api.sf.L4ClassifierDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ActionDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ClassifierDefinitionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.SubjectFeatureDefinitionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ActionDefinition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.policy.rev140421.subject.feature.definitions.ClassifierDefinition;
+
+import com.google.common.base.Function;
+import com.google.common.collect.Collections2;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
+/**
+ * Defines the subject features that are supported by the OF overlay renderer
+ */
+public class SubjectFeatures {
+
+    private static final Map<ClassifierDefinitionId, Classifier> classifiers =
+            ImmutableMap.of(EtherTypeClassifierDefinition.ID, Classifier.ETHER_TYPE_CL, IpProtoClassifierDefinition.ID,
+                    Classifier.IP_PROTO_CL, L4ClassifierDefinition.ID, Classifier.L4_CL);
+
+    private static final List<ClassifierDefinition> classifierDefs = ImmutableList
+        .copyOf(Collections2.transform(classifiers.values(), new Function<Classifier, ClassifierDefinition>() {
+
+            @Override
+            public ClassifierDefinition apply(Classifier input) {
+                return input.getClassifierDefinition();
+            }
+        }));
+
+    private static final Map<ActionDefinitionId, Action> actions =
+            ImmutableMap.<ActionDefinitionId, Action>of(AllowActionDefinition.ID, new AllowAction());
+
+    private static final List<ActionDefinition> actionDefs =
+            ImmutableList.copyOf(Collections2.transform(actions.values(), new Function<Action, ActionDefinition>() {
+
+                @Override
+                public ActionDefinition apply(Action input) {
+                    return input.getActionDef();
+                }
+            }));
+
+    public static final SubjectFeatureDefinitions IOVISOR_FEATURES = new SubjectFeatureDefinitionsBuilder()
+        .setActionDefinition(actionDefs).setClassifierDefinition(classifierDefs).build();
+
+    /**
+     * Get the {@link Classifier} associated with the given
+     * {@link ClassifierDefinitionId}
+     *
+     * @param id the {@link ClassifierDefinitionId} to look up
+     * @return the {@link Classifier} if one exists, or <code>null</code>
+     *         otherwise
+     */
+    public static Classifier getClassifier(ClassifierDefinitionId id) {
+        return classifiers.get(id);
+    }
+
+    public static Map<ActionDefinitionId, Action> getActions() {
+        return actions;
+    }
+
+    /**
+     * Get the {@link Action} associated with the given
+     * {@link ActionDefinitionId}
+     *
+     * @param id the {@link ActionDefinitionId} to look up
+     * @return the {@link Action} if one exists, or <code>null</code>
+     *         otherwise
+     */
+    public static Action getAction(ActionDefinitionId id) {
+        return actions.get(id);
+    }
+}
index 4c217fa8b9436219d417578e58a6d865e5e1a3ce..d64758f4195c6f687cd678e96ac4abb5003e3c11 100644 (file)
@@ -45,7 +45,7 @@ module iovisor-provider-impl {
                     }
                 }
             }
-            // EpRendererAugmentationRegistrar service
+            // EpRendererAugmentationRegistry service
             container ep-renderer-augmentation-registry {
                 uses config:service-ref {
                     refine type {
@@ -54,6 +54,15 @@ module iovisor-provider-impl {
                     }
                 }
             }
+            // PolicyProviderRegistry service
+            container policy-validator-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity gbpcfg:policy-validator-registry;
+                    }
+                }
+            }
         }
     }
 }
index 28d612f79971e77b5897e201ac833b5b61757259..b37237b54784accf2648b63714e377ab35fff7bd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2014 Cisco Systems, Inc. and others.  All rights reserved.
+ * Copyright (c) 2015 Cisco Systems, Inc. and others.  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,
@@ -51,9 +51,15 @@ module iovisor {
         }
     }
 
-    augment "/endpoint:endpoints/endpoint:endpoint" {
+    augment "/endpoint:endpoints/endpoint:endpoint-l3" {
         description "Augmentation adding the IOVisor module location";
         ext:augment-identifier "iovisor-module-augmentation";
         uses iovisor-module;
     }
+
+    augment "/endpoint:register-endpoint/endpoint:input" {
+        description "Augmentation adding the IOVisor module location";
+        ext:augment-identifier "iovisor-module-augmentation-input";
+        uses iovisor-module;
+    }
 }
diff --git a/renderers/iovisor/src/test/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/IovisorRendererTest.java b/renderers/iovisor/src/test/java/org/opendaylight/groupbasedpolicy/renderer/iovisor/IovisorRendererTest.java
new file mode 100644 (file)
index 0000000..9825e15
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * Copyright (c) 2015 Cisco Systems. 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
+ */
+
+package org.opendaylight.groupbasedpolicy.renderer.iovisor;
+
+import org.junit.Test;
+
+public class IovisorRendererTest {
+
+    @Test
+    public void IovisorRendererClassTest() {
+        // TODO Implement me
+    }
+
+    @Test
+    public void endpointPolicyUpdatedTest() {
+        // TODO implement me
+    }
+}
index 2213931963707dec511097f9cfbbf305cb6c28ce..77285714c93e03f5887becf84582d664157cc65d 100644 (file)
@@ -7,13 +7,8 @@
  */
 
 package org.opendaylight.groupbasedpolicy.renderer.iovisor.endpoint;
-import static org.mockito.Matchers.any;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.when;
 
-import java.util.HashMap;
-import java.util.Map;
+import java.util.Collection;
 
 import org.junit.Before;
 import org.junit.Test;
@@ -22,18 +17,11 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
-import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.controller.md.sal.binding.api.DataTreeModification;
 import org.opendaylight.groupbasedpolicy.renderer.iovisor.utils.IovisorModuleUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.iovisor.rev151030.IovisorModuleAugmentation;
 import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.powermock.api.mockito.PowerMockito;
-import org.powermock.api.support.membermodification.MemberMatcher;
-import org.powermock.api.support.membermodification.MemberModifier;
 import org.powermock.core.classloader.annotations.PrepareForTest;
 import org.powermock.modules.junit4.PowerMockRunner;
 
@@ -41,59 +29,21 @@ import org.powermock.modules.junit4.PowerMockRunner;
 @PrepareForTest({EndpointListener.class, IovisorModuleUtils.class})
 public class EndpointListenerTest {
 
-    @Mock EndpointListener endpointListner;
-    @Mock DataBroker dataBroker;
-    @Mock ListenerRegistration<DataChangeListener> registerListener;
+    @Mock
+    EndpointListener endpointListner;
+    @Mock
+    DataBroker dataBroker;
+    @Mock
+    ListenerRegistration<DataChangeListener> registerListener;
 
-    @Mock AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changes;
+    @Mock
+    Collection<DataTreeModification<Endpoint>> changes;
 
     @Before
     public void setUp() {
         endpointListner = PowerMockito.mock(EndpointListener.class, Mockito.CALLS_REAL_METHODS);
     }
 
-    @Test
-    public void onDataChangedTest() throws Exception {
-        MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "created", Map.class));
-        MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "updated", Map.class));
-        MemberModifier.suppress(MemberMatcher.method(EndpointListener.class, "removed", AsyncDataChangeEvent.class));
-
-        endpointListner.onDataChanged(changes);
-
-        PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("created", any(Map.class));
-        PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("updated", any(Map.class));
-        PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("removed", any(AsyncDataChangeEvent.class));
-    }
-
-    @SuppressWarnings("unchecked")
-    @Test
-    public void createdTest() throws Exception {
-        InstanceIdentifier<?> endpointIid = InstanceIdentifier.create(Endpoints.class)
-                                                                    .child(Endpoint.class)
-                                                                    .augmentation(IovisorModuleAugmentation.class);
-
-        IovisorModuleAugmentation aug = mock(IovisorModuleAugmentation.class);
-        when(aug.getUri()).thenReturn(mock(Uri.class));
-
-        Endpoint endpoint = mock(Endpoint.class);
-        when(endpoint.getAugmentation(any(Class.class))).thenReturn(aug);
-
-        PowerMockito.doReturn(endpoint).when(endpointListner, "fromMd", any(InstanceIdentifier.class), any(Endpoint.class));
-
-        Map<InstanceIdentifier<?>, DataObject> created = new HashMap<>();
-        created.put(endpointIid, endpoint);
-        when(changes.getCreatedData()).thenReturn(created);
-
-        PowerMockito.mockStatic(IovisorModuleUtils.class);
-        PowerMockito.when(IovisorModuleUtils.validateIovisorModuleInstance(any(DataBroker.class), any(Uri.class))).thenReturn(true);
-
-        endpointListner.onDataChanged(changes);
-        PowerMockito.verifyPrivate(endpointListner, times(1)).invoke("fromMd", any(InstanceIdentifier.class), any(Endpoint.class));
-
-        // TODO test what happens when the validateIovisorModuleInstance returns
-        // true or false. (Not yet implemented)
-    }
-
     @Test
     public void updatedTest() {
         // Nothing to test
@@ -103,4 +53,4 @@ public class EndpointListenerTest {
     public void removedTest() {
         // Nothing to test
     }
-}
\ No newline at end of file
+}
index 1bd972f5fe1f659dcb4e0b457f1eb7f5fc1f7d64..fa7dcc70ccb9c0c4a2da3cfae2d0645e1c412bb1 100644 (file)
@@ -90,7 +90,8 @@ public class EndpointManager implements AutoCloseable {
     private final EndpointManagerListener endpointListener;
     private final ConcurrentHashMap<EpKey, Endpoint> endpoints = new ConcurrentHashMap<>();
     private final ConcurrentHashMap<EpKey, Endpoint> externalEndpointsWithoutLocation = new ConcurrentHashMap<>();
-    private final ConcurrentHashMap<NodeId, ConcurrentMap<EgKey, Set<EpKey>>> endpointsByGroupByNode = new ConcurrentHashMap<>();
+    private final ConcurrentHashMap<NodeId, ConcurrentMap<EgKey, Set<EpKey>>> endpointsByGroupByNode =
+            new ConcurrentHashMap<>();
     private final ConcurrentHashMap<NodeId, Set<EpKey>> endpointsByNode = new ConcurrentHashMap<>();
     private final ConcurrentHashMap<EgKey, Set<EpKey>> endpointsByGroup = new ConcurrentHashMap<>();
     private final ScheduledExecutorService executor;
@@ -106,8 +107,8 @@ public class EndpointManager implements AutoCloseable {
         }
     };
 
-    public EndpointManager(DataBroker dataProvider, RpcProviderRegistry rpcRegistry, NotificationService notificationService, ScheduledExecutorService executor,
-                           SwitchManager switchManager) {
+    public EndpointManager(DataBroker dataProvider, RpcProviderRegistry rpcRegistry,
+            NotificationService notificationService, ScheduledExecutorService executor, SwitchManager switchManager) {
         this.executor = executor;
         this.dataProvider = dataProvider;
         if (rpcRegistry != null) {
@@ -176,7 +177,7 @@ public class EndpointManager implements AutoCloseable {
      * Get the endpoints in a particular group on a particular node
      *
      * @param nodeId - the node ID to look up
-     * @param eg     - the group to look up
+     * @param eg - the group to look up
      * @return the endpoints
      */
     public synchronized Collection<Endpoint> getEndpointsForNode(NodeId nodeId, EgKey eg) {
@@ -239,26 +240,26 @@ public class EndpointManager implements AutoCloseable {
      */
     public synchronized Collection<Endpoint> getExtEpsNoLocForGroup(final EgKey eg) {
 
-        return ImmutableSet.copyOf(Collections2.filter(externalEndpointsWithoutLocation.values(),
-                new Predicate<Endpoint>() {
-
-                    @Override
-                    public boolean apply(Endpoint input) {
-                        Set<EndpointGroupId> epgIds = new HashSet<>();
-                        if (input.getEndpointGroup() != null) {
-                            epgIds.add(input.getEndpointGroup());
-                        }
-                        if (input.getEndpointGroups() != null) {
-                            epgIds.addAll(input.getEndpointGroups());
-                        }
-                        if (epgIds.isEmpty()) {
-                            LOG.error("No EPGs for {}. This is not a valid Endpoint.", input.getKey());
-                            return false;
-                        }
-                        return (epgIds.contains(eg.getEgId()));
+        return ImmutableSet
+            .copyOf(Collections2.filter(externalEndpointsWithoutLocation.values(), new Predicate<Endpoint>() {
+
+                @Override
+                public boolean apply(Endpoint input) {
+                    Set<EndpointGroupId> epgIds = new HashSet<>();
+                    if (input.getEndpointGroup() != null) {
+                        epgIds.add(input.getEndpointGroup());
+                    }
+                    if (input.getEndpointGroups() != null) {
+                        epgIds.addAll(input.getEndpointGroups());
                     }
+                    if (epgIds.isEmpty()) {
+                        LOG.error("No EPGs for {}. This is not a valid Endpoint.", input.getKey());
+                        return false;
+                    }
+                    return (epgIds.contains(eg.getEgId()));
+                }
 
-                }));
+            }));
     }
 
     /**
@@ -269,17 +270,17 @@ public class EndpointManager implements AutoCloseable {
      */
     protected synchronized void processL3Endpoint(EndpointL3 oldL3Ep, EndpointL3 newL3Ep) {
         // TODO Bug 3543
-        //create L3 endpoint
+        // create L3 endpoint
         if (oldL3Ep == null && newL3Ep != null) {
             createL3Endpoint(newL3Ep);
         }
 
-        //update L3 endpoint
+        // update L3 endpoint
         if (oldL3Ep != null && newL3Ep != null) {
             updateL3Endpoint(newL3Ep);
         }
 
-        //remove L3 endpoint
+        // remove L3 endpoint
         if (oldL3Ep != null && newL3Ep == null) {
             removeL3Endpoint(oldL3Ep);
         }
@@ -306,7 +307,7 @@ public class EndpointManager implements AutoCloseable {
         boolean notifyOldEg = false;
         boolean notifyNewEg = false;
 
-        //maintain external endpoints map
+        // maintain external endpoints map
         if (newLoc == null && oldLoc == null) {
             if (newEp != null && newEpKey != null) {
                 externalEndpointsWithoutLocation.put(newEpKey, newEp);
@@ -317,50 +318,54 @@ public class EndpointManager implements AutoCloseable {
             return;
         }
 
-        //maintain endpoint maps
-        //new endpoint
+        // maintain endpoint maps
+        // new endpoint
         if (newEp != null && newEpKey != null) {
             endpoints.put(newEpKey, newEp);
+            // TODO This and the create endpoint / update endpoint section will cause switchUpdate
+            // to be called twice. Consider removing
             notifyEndpointUpdated(newEpKey);
         }
-        //odl endpoint
+        // odl endpoint
         else if (oldEpKey != null) {
             endpoints.remove(oldEpKey);
+            // TODO This and the create endpoint / update endpoint section will cause switchUpdate
+            // to be called twice. Consider removing
             notifyEndpointUpdated(oldEpKey);
         }
 
-        //create endpoint
+        // create endpoint
         if (oldEp == null && newEp != null && newLoc != null) {
             createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
             notifyNewLoc = true;
             notifyNewEg = true;
         }
 
-        //update endpoint
-        if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null &&
-                newLoc != null && (oldEpKey.toString().equals(newEpKey.toString()))) {
+        // update endpoint
+        if (oldEp != null && newEp != null && oldEpKey != null && newEpKey != null && newLoc != null
+                && (oldEpKey.toString().equals(newEpKey.toString()))) {
 
-            //endpoint was moved, new location exists but is different from old one
+            // endpoint was moved, new location exists but is different from old one
             if (oldLoc != null && !(oldLoc.getValue().equals(newLoc.getValue()))) {
-                //remove old endpoint
+                // remove old endpoint
                 removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
                 notifyOldLoc = true;
                 notifyOldEg = true;
             }
-            //add moved endpoint
+            // add moved endpoint
             createEndpoint(newLoc, newEpKey, newEpgIds, tenantId);
             notifyNewLoc = true;
             notifyNewEg = true;
         }
 
-        //remove endpoint
+        // remove endpoint
         if (oldEp != null && newEp == null) {
             removeEndpoint(oldEp, oldLoc, oldEpKey, oldEpgIds);
             notifyOldLoc = true;
             notifyOldEg = true;
         }
 
-        //notifications
+        // notifications
         if (notifyOldLoc)
             notifyNodeEndpointUpdated(oldLoc, oldEpKey);
         if (notifyNewLoc)
@@ -418,7 +423,8 @@ public class EndpointManager implements AutoCloseable {
             }
         }
 
-        // Update endpointsByGroupByNode and endpointsByGroup, get map of EPGs and their Endpoints for Node
+        // Update endpointsByGroupByNode and endpointsByGroup, get map of EPGs and their Endpoints
+        // for Node
         ConcurrentMap<EgKey, Set<EpKey>> map = endpointsByGroupByNode.get(oldLoc);
         for (EndpointGroupId oldEpgId : oldEpgIds) {
             // endpointsByGroupByNode
@@ -483,7 +489,7 @@ public class EndpointManager implements AutoCloseable {
 
     }
 
-    //auto closeable
+    // auto closeable
     @Override
     public void close() throws Exception {
         if (endpointListener != null)
@@ -507,7 +513,8 @@ public class EndpointManager implements AutoCloseable {
     protected boolean isInternal(Endpoint ep) {
         Preconditions.checkNotNull(ep);
         OfOverlayContext ofc = ep.getAugmentation(OfOverlayContext.class);
-        return ofc == null || ofc.getLocationType() == null || ofc.getLocationType().equals(EndpointLocation.LocationType.Internal);
+        return ofc == null || ofc.getLocationType() == null
+                || ofc.getLocationType().equals(EndpointLocation.LocationType.Internal);
     }
 
     public boolean isExternal(Endpoint ep) {
@@ -518,7 +525,8 @@ public class EndpointManager implements AutoCloseable {
      * Get the endpoints container from data store.
      * Note: There are maps maintained by listener when higher performance is required.
      *
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints}
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.Endpoints}
      */
     protected Endpoints getEndpointsFromDataStore() {
         /*
@@ -534,8 +542,8 @@ public class EndpointManager implements AutoCloseable {
             return null;
         }
         ReadOnlyTransaction rTx = dataProvider.newReadOnlyTransaction();
-        Optional<Endpoints> endpoints = DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL,
-                IidFactory.endpointsIidWildcard(), rTx);
+        Optional<Endpoints> endpoints =
+                DataStoreHelper.readFromDs(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointsIidWildcard(), rTx);
         if (!endpoints.isPresent()) {
             LOG.warn("No Endpoints present in data store.");
             return null;
@@ -546,7 +554,8 @@ public class EndpointManager implements AutoCloseable {
     /**
      * Return all L3Endpoints from data store.
      *
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
      */
     protected Collection<EndpointL3> getL3Endpoints() {
         Endpoints endpoints = getEndpointsFromDataStore();
@@ -560,7 +569,8 @@ public class EndpointManager implements AutoCloseable {
     /**
      * Return all L3Prefix Endpoints from data store.
      *
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
      */
     private Collection<EndpointL3Prefix> getEndpointsL3Prefix() {
         Endpoints endpoints = getEndpointsFromDataStore();
@@ -574,8 +584,11 @@ public class EndpointManager implements AutoCloseable {
     /**
      * Return all L3Prefix Endpoints which come under particular tenant
      *
-     * @param tenantId - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId} to resolve
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
+     * @param tenantId - the
+     *        {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.TenantId}
+     *        to resolve
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Prefix}
      */
     public Collection<EndpointL3Prefix> getEndpointsL3PrefixForTenant(final TenantId tenantId) {
         Collection<EndpointL3Prefix> l3PrefixEndpoints = getEndpointsL3Prefix();
@@ -596,7 +609,8 @@ public class EndpointManager implements AutoCloseable {
     /**
      * Return all L3Endpoints containing network and port address translation in augmentation
      *
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
      */
     public Collection<EndpointL3> getL3EndpointsWithNat() {
         Collection<EndpointL3> l3Endpoints = getL3Endpoints();
@@ -608,8 +622,8 @@ public class EndpointManager implements AutoCloseable {
             @Override
             public boolean apply(EndpointL3 input) {
                 return !((input.getAugmentation(OfOverlayL3Nat.class) == null)
-                        || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null)
-                        || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null));
+                        || (input.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null) || (input
+                            .getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null));
             }
         });
         if (l3Endpoints == null) {
@@ -621,13 +635,16 @@ public class EndpointManager implements AutoCloseable {
     /**
      * Return NAPT of concrete endpoint
      *
-     * @param endpointL3 - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3} to resolve
-     * @return the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint}
+     * @param endpointL3 - the
+     *        {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3}
+     *        to resolve
+     * @return the
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint}
      */
     public List<NaptTranslation> getNaptAugL3Endpoint(EndpointL3 endpointL3) {
         if ((endpointL3.getAugmentation(OfOverlayL3Nat.class) == null)
-                || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null)
-                || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null)) {
+                || (endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations() == null) || (endpointL3
+                    .getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation() == null)) {
             return null;
         }
         return endpointL3.getAugmentation(OfOverlayL3Nat.class).getNaptTranslations().getNaptTranslation();
@@ -649,8 +666,11 @@ public class EndpointManager implements AutoCloseable {
      * directly represented in the endpoint object
      * set
      *
-     * @param endpoint - the {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint} to resolve
-     * @return the list of {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName}
+     * @param endpoint - the
+     *        {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.Endpoint}
+     *        to resolve
+     * @return the list of
+     *         {@link org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.common.rev140421.ConditionName}
      */
     public List<ConditionName> getConditionsForEndpoint(Endpoint endpoint) {
         // TODO Be alagalah From Helium: consider group conditions as well. Also
@@ -742,8 +762,8 @@ public class EndpointManager implements AutoCloseable {
         }
 
         IndexedTenant indexedTenant;
-        Optional<Tenant> tenant = readFromDs(LogicalDatastoreType.CONFIGURATION,
-                IidFactory.tenantIid(l3Ep.getTenant()), rwTx);
+        Optional<Tenant> tenant =
+                readFromDs(LogicalDatastoreType.CONFIGURATION, IidFactory.tenantIid(l3Ep.getTenant()), rwTx);
         if (tenant.isPresent()) {
             indexedTenant = new IndexedTenant(tenant.get());
         } else {
@@ -753,20 +773,20 @@ public class EndpointManager implements AutoCloseable {
         }
         List<L3Address> l3Address = new ArrayList<>();
         l3Address.add(new L3AddressBuilder().setIpAddress(l3Ep.getIpAddress())
-                .setL3Context(l3Ep.getL3Context())
-                .setKey(new L3AddressKey(l3Ep.getIpAddress(), l3Ep.getL3Context()))
-                .build());
+            .setL3Context(l3Ep.getL3Context())
+            .setKey(new L3AddressKey(l3Ep.getIpAddress(), l3Ep.getL3Context()))
+            .build());
         L2BridgeDomain l2Bd = indexedTenant.resolveL2BridgeDomain(l3Ep.getNetworkContainment());
         Endpoint ep = new EndpointBuilder().setKey(new EndpointKey(l2Bd.getId(), l3Ep.getMacAddress()))
-                .setMacAddress(l3Ep.getMacAddress())
-                .setL2Context(l2Bd.getId())
-                .setEndpointGroups(l3Ep.getEndpointGroups())
-                .setTenant(l3Ep.getTenant())
-                .setL3Address(l3Address)
-                .setCondition(l3Ep.getCondition())
-                .setNetworkContainment(l3Ep.getNetworkContainment())
-                .addAugmentation(OfOverlayContext.class, ofCtx)
-                .build();
+            .setMacAddress(l3Ep.getMacAddress())
+            .setL2Context(l2Bd.getId())
+            .setEndpointGroups(l3Ep.getEndpointGroups())
+            .setTenant(l3Ep.getTenant())
+            .setL3Address(l3Address)
+            .setCondition(l3Ep.getCondition())
+            .setNetworkContainment(l3Ep.getNetworkContainment())
+            .addAugmentation(OfOverlayContext.class, ofCtx)
+            .build();
         rwTx.put(LogicalDatastoreType.OPERATIONAL, IidFactory.endpointIid(ep.getL2Context(), ep.getMacAddress()), ep);
         return ep;
     }
index ba60bd86eb65474d1544ccf25f6b70f43554804f..6aba6038f22d9f7ddc9c45e1cb04b6697e00ddb1 100755 (executable)
@@ -40,7 +40,7 @@ import com.google.common.util.concurrent.Futures;
 public class ClassifierDefinitionListener implements DataTreeChangeListener<ClassifierDefinition>, AutoCloseable {
 
     private static final Logger LOG = LoggerFactory.getLogger(ClassifierDefinitionListener.class);
-    private static final InstanceIdentifier<Capabilities> CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
+    private static final InstanceIdentifier<Capabilities> RENDERER_CAPABILITIES_IID = InstanceIdentifier.builder(Renderers.class)
         .child(Renderer.class, new RendererKey(OFOverlayRenderer.RENDERER_NAME))
         .child(Capabilities.class)
         .build();
@@ -74,7 +74,7 @@ public class ClassifierDefinitionListener implements DataTreeChangeListener<Clas
                         SupportedClassifierDefinition supportedClassifierDefinition =
                                 createSupportedClassifierDefinition(ourClassifier);
                         WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
-                        wTx.put(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID
+                        wTx.put(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID
                             .child(SupportedClassifierDefinition.class, supportedClassifierDefinition.getKey()),
                                 supportedClassifierDefinition, true);
                         Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinition.getKey(), PUT));
@@ -88,7 +88,7 @@ public class ClassifierDefinitionListener implements DataTreeChangeListener<Clas
                         SupportedClassifierDefinitionKey supportedClassifierDefinitionKey =
                                 new SupportedClassifierDefinitionKey(ourClassifier.getId());
                         WriteTransaction wTx = dataProvider.newWriteOnlyTransaction();
-                        wTx.delete(LogicalDatastoreType.OPERATIONAL, CAPABILITIES_IID
+                        wTx.delete(LogicalDatastoreType.OPERATIONAL, RENDERER_CAPABILITIES_IID
                             .child(SupportedClassifierDefinition.class, supportedClassifierDefinitionKey));
                         Futures.addCallback(wTx.submit(), logDebugResult(supportedClassifierDefinitionKey, DELETED));
                     }