- Add notification callback interface for new hosts added. 13/2013/1
authorSuchi Raman <suchi.raman@plexxi.com>
Fri, 18 Oct 2013 14:44:26 +0000 (10:44 -0400)
committerSuchi Raman <suchi.raman@plexxi.com>
Fri, 18 Oct 2013 14:44:26 +0000 (10:44 -0400)
- In progres affinity config with changes to groups/links/domains.

Signed-off-by: Suchi Raman <suchi.raman@plexxi.com>
affinity/implementation/src/main/java/org/opendaylight/affinity/affinity/internal/Activator.java
affinity/implementation/src/main/java/org/opendaylight/affinity/affinity/internal/AffinityManagerImpl.java
affinity/yang/pom.xml
affinity/yang/src/main/yang/affinity-config-all.yang [new file with mode: 0644]
affinity/yang/src/main/yang/affinity-topology-all.yang [deleted file]
pom.xml

index cdff5a7cc019a02bc5a2bc02cae26f5098f9aef6..88e55b9a8b5e0ea6fd9ee523f798d6293bfb0153 100644 (file)
@@ -17,7 +17,6 @@ import org.apache.felix.dm.Component;
 import org.opendaylight.controller.clustering.services.ICacheUpdateAware;
 import org.opendaylight.controller.clustering.services.IClusterContainerServices;
 import org.opendaylight.controller.configuration.IConfigurationContainerAware;
-import org.opendaylight.controller.hosttracker.IfIptoHost;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.affinity.affinity.IAffinityManager;
 import org.opendaylight.affinity.affinity.IAffinityManagerAware;
@@ -27,6 +26,9 @@ import org.slf4j.LoggerFactory;
 import org.opendaylight.affinity.l2agent.IfL2Agent;
 import org.opendaylight.controller.sal.flowprogrammer.IFlowProgrammerService;
 //import org.opendaylight.controller.forwardingrulesmanager.IForwardingRulesManager;
+import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.hosttracker.IfNewHostNotify;
+
 
 /**
  * AffinityManager Bundle Activator
@@ -93,6 +95,7 @@ public class Activator extends ComponentActivatorAbstractBase {
             c.setInterface(new String[] {
                     IAffinityManager.class.getName(),
                     ICacheUpdateAware.class.getName(),
+                    IfNewHostNotify.class.getName(),
                     IConfigurationContainerAware.class.getName() }, props);
 
             // Now lets add a service dependency to make sure the
index 445b9d5f89688b5347d569dafcb94474a220e2b1..32be680bb00d3eba46ef65a664984cb279490d59 100644 (file)
@@ -93,6 +93,7 @@ import org.opendaylight.affinity.affinity.IAffinityManager;
 import org.opendaylight.affinity.affinity.IAffinityManagerAware;
 
 import org.opendaylight.controller.hosttracker.IfIptoHost;
+import org.opendaylight.controller.hosttracker.IfNewHostNotify;
 import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
 import org.opendaylight.affinity.l2agent.IfL2Agent;
@@ -101,10 +102,10 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * The class caches latest network nodes statistics as notified by reader
- * services and provides API to retrieve them.
+ * Affinity configuration.
  */
-public class AffinityManagerImpl implements IAffinityManager, IConfigurationContainerAware, IObjectReader, ICacheUpdateAware<Long, String> {
+public class AffinityManagerImpl implements IAffinityManager, IfNewHostNotify,
+                                            IConfigurationContainerAware, IObjectReader, ICacheUpdateAware<Long, String> {
     private static final Logger log = LoggerFactory.getLogger(AffinityManagerImpl.class);
 
     private static String ROOT = GlobalConstants.STARTUPHOME.toString();
@@ -599,6 +600,24 @@ public class AffinityManagerImpl implements IAffinityManager, IConfigurationCont
        return hostPairList;
     }
 
+    private void notifyHostUpdate(HostNodeConnector host, boolean added) {
+        if (host == null) {
+            return;
+        }
+        log.info("Host update received (new = {}).", added);
+    }
+
+    @Override
+    public void notifyHTClient(HostNodeConnector host) {
+        notifyHostUpdate(host, true);
+    }
+
+    @Override
+    public void notifyHTClientHostRemoved(HostNodeConnector host) {
+        notifyHostUpdate(host, false);
+    }
+
+
     @Override
     public Status saveConfiguration() {
         return saveAffinityConfig();
index a03171b78ff2c7bce3584cfc53c3cca63ace4d2e..47496030950cc13369ec57584c5b63e149d1827d 100644 (file)
@@ -19,7 +19,7 @@
     <packaging>jar</packaging>
 
     <properties>
-        <yang.version>0.5.8-SNAPSHOT</yang.version>
+        <yang.version>0.5.9-SNAPSHOT</yang.version>
         <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
         <maven.compiler.source>1.7</maven.compiler.source>
         <maven.compiler.target>1.7</maven.compiler.target>
diff --git a/affinity/yang/src/main/yang/affinity-config-all.yang b/affinity/yang/src/main/yang/affinity-config-all.yang
new file mode 100644 (file)
index 0000000..614e8fa
--- /dev/null
@@ -0,0 +1,246 @@
+module affinity-config-all { 
+    namespace "urn:opendaylight:affinity";
+    prefix affinity;
+
+    import ietf-inet-types { prefix inet; }
+    import ietf-yang-types { prefix yang; }
+    import yang-ext { prefix ext; }
+    import opendaylight-inventory {prefix inv;}
+
+    revision "2013-09-25" {
+        description "Initial revision of affinity model to be reviewed";
+    }
+
+
+  //**************************************************
+  // Stationary location -- switch + port, includes physical or virtual 
+  // ports for example within a hypervisor representing a virtual switch. 
+  //**************************************************
+  grouping affinity-endpoint {
+      leaf switch-port {
+          type inv:node-connector-id;
+      }
+  }
+
+
+  //**************************************************
+  // Affinity address domain: This represents a domain (i.e, set) of one or
+  // more addresses. An affinity address may not have a corresponding
+  // endpoint on the network, for example, for traffic from a set of
+  // external addresses (north-south traffic in a data center), the source
+  // IP address domain is not required to map exactly to endpoints or node
+  // connectors on the network. We assume that there will be a resolution 
+  // service that resolves one of these into an endpoint, when the address 
+  // is present on the network. 
+  //**************************************************
+   grouping affinity-address-domain {
+        leaf id {
+            type string;
+        }
+        // Address is either an IP address, IP prefix, IP range, or
+        // MAC address, or MAC range. Address may also be a transport
+        // protocol layer address.
+
+        leaf address {
+            description "Mac or Inet address";
+            type union {
+                type inet:ip-address;
+                type inet:ip-prefix; // tbd
+                type inet:ip-range; // tbd
+                type yang:vlanid; // tbd
+                type yang:mac-address;
+                type yang:mac-address-range;
+                type yang:tp-address; // tbd
+            }
+        }
+    }
+
+    typedef affinity-group-ref {
+        type instance-identifier;
+    }
+    
+    typedef affinity-link-ref {
+        type instance-identifier;
+    }
+    
+    typedef network-service-chain-ref {
+        type instance-identifier;
+    }
+
+  //**************************************************
+  // Affinity group
+  //**************************************************
+    grouping affinity-group {
+        leaf id {
+            type string;
+        }   
+        list affinity-identifiers {
+            key id;
+            uses affinity-identifier;
+        }
+    }
+
+    //**************************************************
+    // Affinity link connects one group (from group) to another (to
+    // group). It represents a set of flows that start from the source group
+    // and end in the destination group.  An affinity link has attributes
+    // (policies) attached to it that represent how these flows must be
+    // handled. An affinity link also has directionality associated with
+    // it. A bidirectional affinity link is equivalent to two unidirectional
+    // affinity links, one in each direction.
+    //**************************************************
+    grouping affinity-link {
+        leaf id {
+            type string;
+        }
+        leaf from-affinity-group {
+            type affinity-group-ref;
+        }
+        leaf to-affinity-group {
+            type affinity-group-ref;
+        }
+        container attribute {
+            uses affinity-attribute; 
+        }
+    }
+
+    //**************************************************
+    // Affinity attribute. Each is expanded in their own grouping construct below. 
+    //**************************************************
+    grouping affinity-attribute {
+        leaf id {
+            type string;
+        }
+        choice attribute-type {
+            description "affinity attribute";
+            // Apply access control to selected flows. 
+            case access-control {
+                    leaf access-control {
+                        type values {
+                            enum permit;
+                            enum deny;
+                        }
+                    }
+                }
+                
+                // Apply waypoint routing to the selected flows and send it through service chain. 
+            case network-service-chain {
+                    leaf network-service-chain  {
+                        type network-service-chain-ref;
+                    }
+            }
+        }
+    }
+
+    //**************************************************
+    // Network service chain configuration. 
+    //**************************************************
+    grouping network-service-chain {
+        leaf id {
+            type string;
+        }   
+        list service-chain {
+            key id;
+            uses network-service-function;
+        }
+    }
+
+    //**************************************************
+    // Network-service-function represented by one of the following
+    // types of addresses.
+    //**************************************************
+    grouping network-service-function {
+        leaf id {
+            type string;
+        }
+        // Address is either an IP address, MAC address, or switch/port. 
+        leaf location {
+            description "Mac or Inet address";
+            type union {
+                type inv:node-connector-id;
+                type yang:mac-address;
+                type inet:ip-address;
+            }
+        }
+    }
+
+    // Main container that represents the complete set of affinity
+    // groups and links. Each set is represented as a YANG list with 'id'
+    // as the key. List contains affinity group and affinity link objects
+    // defined above.
+    container affinity-config {
+        list affinity-group {
+            key id;
+            ext:context-instance "affinity-group-context";
+            uses affinity-group;
+        }
+        list affinity-link {
+            key id;
+            ext:context-instance "affinity-link-context";
+            uses affinity-link;
+        }
+    }
+
+    //******************************
+    // RPCs to create affinity groups, add endpoints and address domains. 
+    //******************************
+    rpc create-affinity-group {
+        input {
+            uses affinity-group;
+        }
+        output {
+            leaf status {
+                type string;
+            }
+        }
+    }
+
+    rpc add-affinity-endpoint {
+        input {
+            leaf affinity-endpoint {
+                type inv:node-connector-id;
+            }
+        }
+        output {
+            leaf status {
+                type string;
+            }
+        }
+    }
+
+    rpc add-affinity-domain {
+        input {
+            leaf affinity-domain {
+                type affinity-domain;
+            }
+        }    
+        output {
+            leaf status {
+                type string;
+            }
+        }
+    }
+
+    rpc get-affinity-groups {
+        output {
+            list affinity-group {
+            key id;
+            uses affinity-group;
+            }
+        }
+    }
+    rpc get-affinity-links;
+    rpc get-affinity-group;
+    rpc get-affinity-link;
+
+    rpc get-stats-per-affinity-link;
+
+    //**************************************************
+    // Notifications 
+    //**************************************************
+    notification new-affinity-endpoint;
+    notification new-affinity-domain;
+    notification modify-affinity-attribute;
+}
+
+
diff --git a/affinity/yang/src/main/yang/affinity-topology-all.yang b/affinity/yang/src/main/yang/affinity-topology-all.yang
deleted file mode 100644 (file)
index 0105e81..0000000
+++ /dev/null
@@ -1,165 +0,0 @@
-module affinity-topology-all { 
-    namespace "urn:opendaylight:affinity";
-    prefix affinity;
-
-    import ietf-inet-types { prefix inet; }
-    import ietf-yang-types { prefix yang; }
-    import yang-ext { prefix ext; }
-    import opendaylight-inventory {prefix inv;}
-
-    revision "2013-09-25" {
-        description "Initial revision of affinity model to be reviewed";
-    }
-
-    typedef affinity-group-ref {
-        type instance-identifier;
-    }
-    
-    typedef affinity-link-ref {
-        type instance-identifier;
-    }
-
-    grouping affinity-group {
-        leaf id {
-            type string;
-        }   
-        list affinity-identifiers {
-            key id;
-            uses affinity-identifier;
-        }
-    }
-
-    grouping affinity-link {
-        leaf id {
-            type string;
-        }
-        leaf from-affinity-group {
-            type affinity-group-ref;
-        }
-        leaf to-affinity-group {
-            type affinity-group-ref;
-        }
-        leaf attribute {
-            type string;
-        }
-    }
-
-    grouping affinity-identifier {
-        leaf id {
-            type string;
-        }
-        // Address is either an IP address, IP prefix, or MAC address.
-        leaf address {
-            description "Mac or Inet address";
-            type union {
-                type inet:ip-address;
-                type inet:ip-prefix;
-                type yang:mac-address;
-            }
-        }
-    }
-
-    // Various types of affinity topologies. Used in union 'affinity-attribute'. 
-
-    // Isolate flows according to certain constraints. 
-    grouping isolate-path {
-        leaf max-flows-per-link {
-            type uint16;
-        }
-    }
-
-    // Route through shortest path per l2/l3 semantics. 
-    grouping shortest-path {
-        leaf max-flows-per-link {
-            type uint16;
-        }
-    }
-   
-    // oversubscription path
-    grouping oversubscription-path {
-        leaf max-link-oversubscription-percent {
-            type uint16;
-        }
-    }
-
-    // Affinity attribute. 
-    grouping affinity-attribute {
-        leaf id {
-            type string;
-        }
-        choice attribute-type {
-            description "affinity attribute";
-            case isolate-path {
-                 container isolate-path {
-                     uses isolate-path;
-                 }
-            }
-            case shortest-path {
-                    container shortest-path {
-                        uses shortest-path;
-                    }
-            }
-            case oversubscription-path {
-                    container oversubscription-path {
-                        uses oversubscription-path;
-                    }
-            }
-        }
-    }
-
-    identity affinity-group-context {
-        description "Identity used to mark affinity-group context";
-    }
-    identity affinity-link-context {
-        description "Identity used to mark affinity-link context";
-    }
-    
-    container affinity-topology {
-        list affinity-group {
-            key id;
-            ext:context-instance "affinity-group-context";
-            uses affinity-group;
-        }
-        list affinity-link {
-            key id;
-            ext:context-instance "affinity-link-context";
-            uses affinity-link;
-        }
-    }
-
-    rpc create-affinity-group {
-        input {
-            uses affinity-group;
-        }
-    }
-    rpc add-affinity-element {
-        input {
-            container element {
-                uses affinity-identifier;
-            }
-            leaf group {
-                type affinity-group-ref;
-            }
-        }
-    }
-
-    rpc get-affinity-groups {
-        output {
-            list affinity-group {
-            key id;
-            uses affinity-group;
-            }
-        }
-    }
-    rpc get-affinity-links {
-    
-    }
-    rpc get-affinity-group {
-    
-    }
-    rpc get-affinity-link {
-    
-    }
-}
-
-
diff --git a/pom.xml b/pom.xml
index 57807fff406e554639cc73db34a16d679ebfd0b8..78297e296eaaca77ffac70cda02ebdf02f78e569 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -49,7 +49,7 @@
 
     <modules>
       <module>affinity/api</module> 
-<!--      <module>affinity/yang</module>  -->
+      <module>affinity/yang</module>  
       <module>affinity/implementation</module>
       <module>affinity/integrationtest</module>
       <module>affinity/northbound</module>