--- /dev/null
+package org.opendaylight.controller.affinity;
+
+import java.io.Serializable;
+import java.net.Inet4Address;
+import java.net.InetAddress;
+import java.nio.ByteBuffer;
+import java.util.Map;
+import java.net.UnknownHostException;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class defines an Inet address mask object.
+ */
+public class InetAddressMask {
+ private String name;
+
+ InetAddress networkAddress;
+ Short mask;
+
+ public InetAddressMask() {
+
+ }
+ /* String addrmask is in the a.b.c.d/m format. */
+ public InetAddressMask(String addrmask) {
+ this.networkAddress = getIPAddress(addrmask);
+ this.mask = getIPMaskLen(addrmask);
+ }
+
+ public InetAddress getIPAddress(String ipmask) {
+ InetAddress ip = null;
+ try {
+ ip = InetAddress.getByName(ipmask.split("/")[0]);
+ } catch (UnknownHostException e1) {
+ return null;
+ }
+ return ip;
+ }
+
+ public Short getIPMaskLen(String ipmask) {
+ Short maskLen = 0;
+ String[] s = ipmask.split("/");
+ maskLen = (s.length == 2) ? Short.valueOf(s[1]) : 32;
+ return maskLen;
+ }
+
+ /**
+ * Get the IP address portion of the sub-network of the static route.
+ * @return InetAddress: the IP address portion of the sub-network of the static route
+ */
+ public InetAddress getNetworkAddress() {
+ return networkAddress;
+ }
+
+ /**
+ * Set the IP address portion of the sub-network of the static route.
+ * @param networkAddress The IP address (InetAddress) to be set
+ */
+ public void setNetworkAddress(InetAddress networkAddress) {
+ this.networkAddress = networkAddress;
+ }
+
+ /**
+ * Get the mask of the sub-network of the static route.
+ * @return mask: the mask (InetAddress) of the sub-network of the static route
+ */
+ public Short getMask() {
+ return mask;
+ }
+
+ /**
+ * Set the sub-network's mask of the static route.
+ * @param mask The mask (InetAddress) to be set
+ */
+ public void setMask(Short mask) {
+ this.mask = mask;
+ }
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + ((mask == null) ? 0 : mask.hashCode());
+ result = prime * result
+ + ((networkAddress == null) ? 0 : networkAddress.hashCode());
+ return result;
+ }
+
+ @Override
+ public String toString() {
+ return "InetAddressMask [networkAddress=" + networkAddress + ", mask=" + mask + "]";
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ InetAddressMask other = (InetAddressMask) obj;
+ if (!networkAddress.equals(other.networkAddress))
+ return false;
+ if (!mask.equals(other.mask))
+ return false;
+ return true;
+ }
+}
--- /dev/null
+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 inventory {prefix inv;}
+
+ revision "2013-09-16" {
+ description "Initial revision of affinity model";
+ }
+
+ 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;
+ }
+ }
+
+ // Redirect flows through list of waypoints represented by node-connectors.
+ grouping redirect-path {
+ list node-connectors {
+ key id;
+ uses inv:node-connector-id; // or ref?
+ }
+ }
+
+ // 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 redirect-path {
+ container redirect-path {
+ uses redirect-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 {
+
+ }
+}
+
+
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">\r
- <modelVersion>4.0.0</modelVersion>\r
-\r
- <groupId>org.opendaylight.affinity</groupId>\r
- <artifactId>affinityParent</artifactId>\r
- <version>0.4.1-SNAPSHOT</version>\r
- <packaging>pom</packaging>\r
-\r
- <scm>\r
- <connection>scm:git:http://git.opendaylight.org/gerrit/p/affinity.git</connection>\r
- <developerConnection>scm:git:ssh://git.opendaylight.org:29418/affinity.git</developerConnection>\r
- </scm>\r
-\r
- <properties>\r
- <checkstyle.version>2.10</checkstyle.version>\r
- <commons.lang.version>3.1</commons.lang.version>\r
- <compiler.version>2.3.2</compiler.version>\r
- <enunciate.version>1.26.2</enunciate.version>\r
- <exam.version>3.0.0</exam.version>\r
- <failsafe.version>2.15</failsafe.version>\r
- <geminiweb.version>2.2.0.RELEASE</geminiweb.version>\r
- <jackson.version>1.9.8</jackson.version>\r
- <jersey.version>1.17</jersey.version>\r
- <junit.version>4.10</junit.version>\r
- <logback.version>1.0.9</logback.version>\r
- <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>\r
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>\r
- <projectinfo>2.6</projectinfo>\r
- <propertymavenplugin.version>1.0-alpha-2</propertymavenplugin.version>\r
- <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>\r
- <siteplugin>3.2</siteplugin>\r
- <slf4j.version>1.7.2</slf4j.version>\r
- <!-- Sonar properties using jacoco to retrieve integration test results -->\r
- <sonar.branch>${user.name}-private-view</sonar.branch>\r
- <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>\r
- <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>\r
- <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>\r
- <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>\r
- <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>\r
- <sonar.language>java</sonar.language>\r
- <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>\r
- <spring.version>3.1.3.RELEASE</spring.version>\r
- <spring-security.version>3.1.3.RELEASE</spring-security.version>\r
- <surefire.version>2.15</surefire.version>\r
- <testvm.argLine>-Xmx1024m -XX:MaxPermSize=256m</testvm.argLine>\r
- <url.version>1.5.0</url.version>\r
- <virgo.version>3.6.0.RELEASE</virgo.version>\r
- </properties>\r
-\r
- <modules>\r
- <module>affinity/api</module>\r
- <module>affinity/yang</module>\r
- <module>affinity/implementation</module>\r
- <module>affinity/integrationtest</module>\r
- <module>affinity/northbound</module>\r
- <module>analytics/api</module>\r
- <module>analytics/implementation</module>\r
- <module>analytics/integrationtest</module>\r
- <module>analytics/northbound</module>\r
- </modules>\r
-\r
- <repositories>\r
- <!-- To get SVNKit -->\r
- <repository>\r
- <id>svnkit-snapshots</id>\r
- <name>svnkit-snapshots</name>\r
- <url>${nexusproxy}/repositories/svnkit-snapshots/</url>\r
- </repository>\r
- <!-- OpenDayLight Released artifact -->\r
- <repository>\r
- <id>opendaylight-release</id>\r
- <name>opendaylight-release</name>\r
- <url>${nexusproxy}/repositories/opendaylight.release/</url>\r
- </repository>\r
- <!-- OpenDayLight Snapshot artifact -->\r
- <repository>\r
- <id>opendaylight-snapshot</id>\r
- <name>opendaylight-snapshot</name>\r
- <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>\r
- </repository>\r
- <!-- PAX Management -->\r
- <repository>\r
- <id>ops4j-releases</id>\r
- <name>ops4j-releases</name>\r
- <url>${nexusproxy}/repositories/ops4j-releases/</url>\r
- </repository>\r
- </repositories>\r
-\r
- <pluginRepositories>\r
- <pluginRepository>\r
- <id>opendaylight-release</id>\r
- <name>opendaylight-release</name>\r
- <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release/</url>\r
- </pluginRepository>\r
- <pluginRepository>\r
- <id>opendaylight-snapshot</id>\r
- <name>opendaylight-snapshot</name>\r
- <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>\r
- </pluginRepository>\r
- </pluginRepositories>\r
-\r
-\r
-\r
- <distributionManagement>\r
- <!-- OpenDayLight Released artifact -->\r
- <repository>\r
- <id>opendaylight-release</id>\r
- <url>${nexusproxy}/repositories/opendaylight.release/</url>\r
- </repository>\r
- <!-- OpenDayLight Snapshot artifact -->\r
- <snapshotRepository>\r
- <id>opendaylight-snapshot</id>\r
- <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>\r
- </snapshotRepository>\r
- <!-- Site deployment -->\r
- <site>\r
- <id>website</id>\r
- <url>${sitedeploy}</url>\r
- </site>\r
- </distributionManagement>\r
-\r
- <dependencies>\r
- <dependency>\r
- <groupId>junit</groupId>\r
- <artifactId>junit</artifactId>\r
- <version>4.10</version>\r
- <scope>test</scope>\r
- <optional>true</optional>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-simple</artifactId>\r
- <version>1.7.2</version>\r
- </dependency>\r
- </dependencies>\r
-\r
- <build>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.codehaus.mojo</groupId>\r
- <artifactId>buildnumber-maven-plugin</artifactId>\r
- <version>1.2</version>\r
- <executions>\r
- <execution>\r
- <phase>validate</phase>\r
- <goals>\r
- <goal>create</goal>\r
- </goals>\r
- </execution>\r
- </executions>\r
- <configuration>\r
- <doCheck>false</doCheck>\r
- <doUpdate>false</doUpdate>\r
- <providerImplementations>\r
- <svn>javasvn</svn>\r
- </providerImplementations>\r
- <revisionOnScmFailure>VersionUnknown</revisionOnScmFailure>\r
- </configuration>\r
- <dependencies>\r
- <dependency>\r
- <groupId>com.google.code.maven-scm-provider-svnjava</groupId>\r
- <artifactId>maven-scm-provider-svnjava</artifactId>\r
- <version>2.0.5</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.tmatesoft.svnkit</groupId>\r
- <artifactId>svnkit</artifactId>\r
- <version>1.7.4-v1</version>\r
- </dependency>\r
- <dependency>\r
- <groupId>org.apache.maven.scm</groupId>\r
- <artifactId>maven-scm-provider-svn-commons</artifactId>\r
- <version>1.7</version>\r
- </dependency>\r
- </dependencies>\r
- </plugin>\r
- </plugins>\r
- </build>\r
- <reporting>\r
- <plugins>\r
- <plugin>\r
- <groupId>org.codehaus.mojo</groupId>\r
- <artifactId>findbugs-maven-plugin</artifactId>\r
- <version>2.4.0</version>\r
- <configuration>\r
- <effort>Max</effort>\r
- <threshold>Low</threshold>\r
- <goal>site</goal>\r
- </configuration>\r
- </plugin>\r
- <plugin>\r
- <groupId>org.codehaus.mojo</groupId>\r
- <artifactId>jdepend-maven-plugin</artifactId>\r
- <version>2.0-beta-2</version>\r
- </plugin>\r
- </plugins>\r
- </reporting>\r
-</project>\r
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.opendaylight.affinity</groupId>
+ <artifactId>affinityParent</artifactId>
+ <version>0.4.1-SNAPSHOT</version>
+ <packaging>pom</packaging>
+
+ <scm>
+ <connection>scm:git:http://git.opendaylight.org/gerrit/p/affinity.git</connection>
+ <developerConnection>scm:git:ssh://git.opendaylight.org:29418/affinity.git</developerConnection>
+ </scm>
+
+ <properties>
+ <checkstyle.version>2.10</checkstyle.version>
+ <commons.lang.version>3.1</commons.lang.version>
+ <compiler.version>2.3.2</compiler.version>
+ <enunciate.version>1.26.2</enunciate.version>
+ <exam.version>3.0.0</exam.version>
+ <failsafe.version>2.15</failsafe.version>
+ <geminiweb.version>2.2.0.RELEASE</geminiweb.version>
+ <jackson.version>1.9.8</jackson.version>
+ <jersey.version>1.17</jersey.version>
+ <junit.version>4.10</junit.version>
+ <logback.version>1.0.9</logback.version>
+ <nexusproxy>http://nexus.opendaylight.org/content</nexusproxy>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <projectinfo>2.6</projectinfo>
+ <propertymavenplugin.version>1.0-alpha-2</propertymavenplugin.version>
+ <sitedeploy>dav:http://nexus.opendaylight.org/content/sites/site</sitedeploy>
+ <siteplugin>3.2</siteplugin>
+ <slf4j.version>1.7.2</slf4j.version>
+ <!-- Sonar properties using jacoco to retrieve integration test results -->
+ <sonar.branch>${user.name}-private-view</sonar.branch>
+ <sonar.dynamicAnalysis>reuseReports</sonar.dynamicAnalysis>
+ <sonar.host.url>https://sonar.opendaylight.org/</sonar.host.url>
+ <sonar.jacoco.Reportpath>target/jacoco.exec</sonar.jacoco.Reportpath>
+ <sonar.jacoco.itReportPath>target/jacoco-it.exec</sonar.jacoco.itReportPath>
+ <sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
+ <sonar.language>java</sonar.language>
+ <sonar.skippedModules>org.openflow.openflowj,net.sf.jung2</sonar.skippedModules>
+ <spring.version>3.1.3.RELEASE</spring.version>
+ <spring-security.version>3.1.3.RELEASE</spring-security.version>
+ <surefire.version>2.15</surefire.version>
+ <testvm.argLine>-Xmx1024m -XX:MaxPermSize=256m</testvm.argLine>
+ <url.version>1.5.0</url.version>
+ <virgo.version>3.6.0.RELEASE</virgo.version>
+ </properties>
+
+ <modules>
+ <module>affinity/api</module>
+<!-- <module>affinity/yang</module> -->
+ <module>affinity/implementation</module>
+ <module>affinity/integrationtest</module>
+ <module>affinity/northbound</module>
+ <module>analytics/api</module>
+ <module>analytics/implementation</module>
+ <module>analytics/integrationtest</module>
+ <module>analytics/northbound</module>
+ </modules>
+
+ <repositories>
+ <!-- To get SVNKit -->
+ <repository>
+ <id>svnkit-snapshots</id>
+ <name>svnkit-snapshots</name>
+ <url>${nexusproxy}/repositories/svnkit-snapshots/</url>
+ </repository>
+ <!-- OpenDayLight Released artifact -->
+ <repository>
+ <id>opendaylight-release</id>
+ <name>opendaylight-release</name>
+ <url>${nexusproxy}/repositories/opendaylight.release/</url>
+ </repository>
+ <!-- OpenDayLight Snapshot artifact -->
+ <repository>
+ <id>opendaylight-snapshot</id>
+ <name>opendaylight-snapshot</name>
+ <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+ </repository>
+ <!-- PAX Management -->
+ <repository>
+ <id>ops4j-releases</id>
+ <name>ops4j-releases</name>
+ <url>${nexusproxy}/repositories/ops4j-releases/</url>
+ </repository>
+ </repositories>
+
+ <pluginRepositories>
+ <pluginRepository>
+ <id>opendaylight-release</id>
+ <name>opendaylight-release</name>
+ <url>http://nexus.opendaylight.org/content/repositories/opendaylight.release/</url>
+ </pluginRepository>
+ <pluginRepository>
+ <id>opendaylight-snapshot</id>
+ <name>opendaylight-snapshot</name>
+ <url>http://nexus.opendaylight.org/content/repositories/opendaylight.snapshot/</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+
+
+ <distributionManagement>
+ <!-- OpenDayLight Released artifact -->
+ <repository>
+ <id>opendaylight-release</id>
+ <url>${nexusproxy}/repositories/opendaylight.release/</url>
+ </repository>
+ <!-- OpenDayLight Snapshot artifact -->
+ <snapshotRepository>
+ <id>opendaylight-snapshot</id>
+ <url>${nexusproxy}/repositories/opendaylight.snapshot/</url>
+ </snapshotRepository>
+ <!-- Site deployment -->
+ <site>
+ <id>website</id>
+ <url>${sitedeploy}</url>
+ </site>
+ </distributionManagement>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.10</version>
+ <scope>test</scope>
+ <optional>true</optional>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.7.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>buildnumber-maven-plugin</artifactId>
+ <version>1.2</version>
+ <executions>
+ <execution>
+ <phase>validate</phase>
+ <goals>
+ <goal>create</goal>
+ </goals>
+ </execution>
+ </executions>
+ <configuration>
+ <doCheck>false</doCheck>
+ <doUpdate>false</doUpdate>
+ <providerImplementations>
+ <svn>javasvn</svn>
+ </providerImplementations>
+ <revisionOnScmFailure>VersionUnknown</revisionOnScmFailure>
+ </configuration>
+ <dependencies>
+ <dependency>
+ <groupId>com.google.code.maven-scm-provider-svnjava</groupId>
+ <artifactId>maven-scm-provider-svnjava</artifactId>
+ <version>2.0.5</version>
+ </dependency>
+ <dependency>
+ <groupId>org.tmatesoft.svnkit</groupId>
+ <artifactId>svnkit</artifactId>
+ <version>1.7.4-v1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.scm</groupId>
+ <artifactId>maven-scm-provider-svn-commons</artifactId>
+ <version>1.7</version>
+ </dependency>
+ </dependencies>
+ </plugin>
+ </plugins>
+ </build>
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <version>2.4.0</version>
+ <configuration>
+ <effort>Max</effort>
+ <threshold>Low</threshold>
+ <goal>site</goal>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>jdepend-maven-plugin</artifactId>
+ <version>2.0-beta-2</version>
+ </plugin>
+ </plugins>
+ </reporting>
+</project>