* Implement endpoint group to condition mapping in endpoint registry 05/7005/1
authorRob Adams <readams@readams.net>
Wed, 14 May 2014 23:52:03 +0000 (16:52 -0700)
committerRob Adams <readams@readams.net>
Wed, 14 May 2014 23:52:03 +0000 (16:52 -0700)
* Some spelling tweaks to policy descriptions
* Sample configuration file to load endpoint registry provider

Change-Id: I02819a223de817fd8ea3375068ad4147837b9b19
Signed-off-by: Rob Adams <readams@readams.net>
groupbasedpolicy/src/main/java/org/opendaylight/groupbasedpolicy/endpoint/EndpointRegistry.java
groupbasedpolicy/src/main/resources/configuration/initial/10-groupbasedpolicy.xml [new file with mode: 0644]
groupbasedpolicy/src/main/yang/endpoint.yang
groupbasedpolicy/src/main/yang/policy.yang

index e64b2f40f8fa05a40fcfbc7026ac144b023ca2ca..92a80e70164f46bccf0148c2697775434ce98c5b 100644 (file)
@@ -14,16 +14,21 @@ import org.opendaylight.controller.sal.common.util.RpcErrors;
 import org.opendaylight.controller.sal.common.util.Rpcs;
 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.EndpointsL3;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.SetEndpointGroupConditionsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnsetEndpointGroupConditionsInput;
 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoint.fields.L3Address;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.ConditionMapping;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.ConditionMappingKey;
 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.l3.EndpointL3;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.l3.EndpointL3Builder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.l3.EndpointL3Key;
+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.EndpointL3Builder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.endpoints.EndpointL3Key;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.has.endpoint.group.conditions.EndpointGroupCondition;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.has.endpoint.group.conditions.EndpointGroupConditionKey;
 import org.opendaylight.yangtools.yang.binding.DataObject;
 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
 import org.opendaylight.yangtools.yang.common.RpcError;
@@ -56,8 +61,11 @@ public class EndpointRegistry implements AutoCloseable, EndpointService {
 
         rpcRegistration =
                 rpcRegistry.addRpcImplementation(EndpointService.class, this);
-
-        LOG.info("Created endpoint registry");
+        
+        // XXX TODO - age out endpoint data and remove 
+        // endpoint group/condition mappings with no conditions
+        
+        LOG.debug("Created endpoint registry");
     }
 
     @Override
@@ -94,7 +102,8 @@ public class EndpointRegistry implements AutoCloseable, EndpointService {
                 new EndpointKey(ep.getL2Namespace(), ep.getMacAddress());
         InstanceIdentifier<Endpoint> iid = 
                 InstanceIdentifier.builder(Endpoints.class)
-                    .child(Endpoint.class, key).build();
+                    .child(Endpoint.class, key)
+                    .build();
         DataModificationTransaction t = dataProvider.beginTransaction();
         t.putOperationalData(iid, ep);
         Collection<RpcError> errors = new ArrayList<>();
@@ -111,8 +120,9 @@ public class EndpointRegistry implements AutoCloseable, EndpointService {
                     .setL3Namespace(l3addr.getL3Namespace())
                     .build();
                 InstanceIdentifier<EndpointL3> iid_l3 = 
-                        InstanceIdentifier.builder(EndpointsL3.class)
-                            .child(EndpointL3.class, key3).build();
+                        InstanceIdentifier.builder(Endpoints.class)
+                            .child(EndpointL3.class, key3)
+                            .build();
                 t.putOperationalData(iid_l3, ep3);
                 
                 docommit(t, iid_l3.toString(), "register", errors);
@@ -145,8 +155,9 @@ public class EndpointRegistry implements AutoCloseable, EndpointService {
                             new EndpointL3Key(l3addr.getIpAddress(), 
                                               l3addr.getL3Namespace());
                     InstanceIdentifier<EndpointL3> iid_l3 = 
-                            InstanceIdentifier.builder(EndpointsL3.class)
-                                .child(EndpointL3.class, key3).build();
+                            InstanceIdentifier.builder(Endpoints.class)
+                                .child(EndpointL3.class, key3)
+                                .build();
                     DataModificationTransaction t =
                             dataProvider.beginTransaction();
                     t.removeOperationalData(iid_l3);
@@ -165,4 +176,58 @@ public class EndpointRegistry implements AutoCloseable, EndpointService {
                                                          errors);
         return Futures.immediateFuture(result);
     }
+
+    @Override
+    public Future<RpcResult<Void>> 
+        setEndpointGroupConditions(SetEndpointGroupConditionsInput input) {
+
+        ConditionMappingKey key = 
+                new ConditionMappingKey(input.getEndpointGroup());
+        
+        Collection<RpcError> errors = new ArrayList<>();
+        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();
+            DataModificationTransaction t =
+                    dataProvider.beginTransaction();
+            t.putOperationalData(iid, condition);
+            docommit(t, iid.toString(), "set", errors);
+        }
+        
+        RpcResult<Void> result = Rpcs.<Void>getRpcResult(errors.isEmpty(), 
+                                                         errors);
+        return Futures.immediateFuture(result);
+    }
+
+    @Override
+    public Future<RpcResult<Void>> 
+        unsetEndpointGroupConditions(UnsetEndpointGroupConditionsInput input) {
+
+        ConditionMappingKey key = 
+                new ConditionMappingKey(input.getEndpointGroup());
+        
+        Collection<RpcError> errors = new ArrayList<>();
+        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();
+            DataModificationTransaction t =
+                    dataProvider.beginTransaction();
+            t.removeOperationalData(iid);
+            docommit(t, iid.toString(), "set", errors);
+        }
+        
+        RpcResult<Void> result = Rpcs.<Void>getRpcResult(errors.isEmpty(), 
+                                                         errors);
+        return Futures.immediateFuture(result);
+    }
 }
diff --git a/groupbasedpolicy/src/main/resources/configuration/initial/10-groupbasedpolicy.xml b/groupbasedpolicy/src/main/resources/configuration/initial/10-groupbasedpolicy.xml
new file mode 100644 (file)
index 0000000..03f3613
--- /dev/null
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+ Copyright (c) 2013 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
+-->
+<snapshot>
+    <configuration>
+        <data xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
+            <modules xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+                <module>
+                    <type xmlns:endpoint="urn:opendaylight:params:xml:ns:yang:controller:config:endpoint-provider:impl">
+                        endpoint:endpoint-provider-impl
+                    </type>
+                    <name>endpoint-provider-impl</name>
+
+                    <rpc-registry>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+                        <name>binding-rpc-broker</name>
+                    </rpc-registry>
+
+                    <data-broker>
+                        <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-data-broker</type>
+                        <name>binding-data-broker</name>
+                    </data-broker>
+                </module>
+           </modules>
+        </data>
+
+    </configuration>
+
+    <required-capabilities>
+        <capability>urn:opendaylight:params:xml:ns:yang:controller:config:endpoint-provider:impl?module=endpoint-provider-impl&amp;revision=2014-04-21</capability>
+    </required-capabilities>
+
+</snapshot>
+
index e5546b7a865faca568ee58f7ae01e1288277c891..e7bff67acdeef710687494fc02d3dc9db6647cd8 100644 (file)
@@ -22,7 +22,8 @@ module endpoint {
         leaf tenant {
             type gbp-common:tenant-id;
             mandatory true;
-            description "The tenant with which this endpoint is associated";
+            description 
+                "The tenant with which this endpoint is associated";
         }
         leaf l2-namespace {
             type gbp-common:l2-namespace-id;
@@ -76,21 +77,47 @@ module endpoint {
         }
     }
 
+    grouping has-endpoint-group-conditions {
+        description 
+            "Base type for object with endpoint group to condition 
+             mappings.";
+
+        leaf endpoint-group {
+            description "The endpoint group conditions to assign";
+            type gbp-common:endpoint-group-id;
+        }
+        list endpoint-group-condition {
+            description 
+                "The conditions associated with this endpoint 
+                 group";
+            key "condition";
+            leaf condition {
+                description "A condition name to associate.";
+                type gbp-common:condition-name;
+            }
+        }
+    }
+
     container endpoints {
         description 
-            "Endpoints indexed by layer 2 addreses.  When modifying data here,
-             you must also modify data in the endpoints-l3 container as well.";
+            "Repository for operational state data about endpoints needed for
+             policy resolution.";
+
         list endpoint {
+            description 
+                "Endpoints indexed by layer 2 addreses.  When modifying
+                 data here, you must also modify data in the
+                 endpoints-l3 list as well.";
             key "l2-namespace mac-address";
             uses endpoint-fields;
         }
-    }
 
-    container endpoints-l3 {
-        description 
-            "Endpoints indexed by layer 3 addreses.  When modifying data here,
-             you must also modify data in the endpoints container as well.";
         list endpoint-l3 {
+            description 
+                "Endpoints indexed by layer 3 addreses.  When modifying 
+                 data here, you must also modify data in the endpoints
+                 list as well.";
+
             key "l3-namespace ip-address";
 
             leaf l3-namespace {
@@ -108,10 +135,17 @@ module endpoint {
 
             uses endpoint-fields;
         }
-    }
 
-    // XXX - TODO - allow registering conditions on endpoint groups
-    // and not just on endpoints themselves.
+        list condition-mapping {
+            description 
+                "A list mapping conditions to entire endpoint groups.
+                 This offers a quickly way to set a condition on many
+                 endpoints at once.";
+
+            key "endpoint-group";
+            uses has-endpoint-group-conditions;
+        }
+    }
 
     rpc register-endpoint {
         description
@@ -142,4 +176,25 @@ module endpoint {
             }
         }
     }
+
+    rpc set-endpoint-group-conditions {
+        description
+            "Set a list of conditions for a particular endpoint group.  
+             These conditions will apply to all endpoints in the
+             endpoint group.  These conditions will be added to the 
+             existing list of conditions.";
+
+        input {
+            uses has-endpoint-group-conditions;
+        }
+    }
+
+    rpc unset-endpoint-group-conditions {
+        description
+            "Remove a list of conditions from an endpoint group.";
+
+        input {
+            uses has-endpoint-group-conditions;
+        }
+    }
 }
index 2ea9b0373f8f06d36d364f710dcacf0e0ae1b969..e391f05f3311915a8d552ed8afbb1396c8c7f6e3 100644 (file)
@@ -531,7 +531,7 @@ module policy {
                     }
                 }
             }
-            leaf required {
+            leaf is-required {
                 description "Specify whether the parameter is
                              required for correct operation.";
                 default optional;
@@ -596,7 +596,7 @@ module policy {
             description
                 "A classifier is used to match traffic traveling between 
                  the endpoint groups that form the contract.
-                 Classifiers defintions can define parameters that
+                 Classifier defintions can define parameters that
                  will need to be filled in when a particular rule
                  references it.";
 
@@ -627,7 +627,7 @@ module policy {
         list action-definition {
             description
                 "A action to be applied to traffic across endpoint 
-                 groups.  Actions definitions can define parameters
+                 groups.  Action definitions can define parameters
                  that will need to be filled in when a particular rule
                  references it.";