restructure and base modules for different features 86/17786/3
authoresravik <vivek.v.srivastava@ericsson.com>
Mon, 6 Apr 2015 09:44:12 +0000 (15:14 +0530)
committeresravik <vivek.v.srivastava@ericsson.com>
Mon, 6 Apr 2015 12:11:23 +0000 (17:41 +0530)
Change-Id: Ia34864c0af00f4ec3b4f5f92874c280ae8393452
Signed-off-by: esravik <vivek.v.srivastava@ericsson.com>
59 files changed:
.gitignore
fibmanager/fibmanager-api/pom.xml [new file with mode: 0644]
fibmanager/fibmanager-api/src/main/yang/odl-fib.yang [new file with mode: 0644]
fibmanager/fibmanager-impl/pom.xml [new file with mode: 0644]
fibmanager/fibmanager-impl/src/main/config/default-config.xml [new file with mode: 0644]
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModule.java [new file with mode: 0644]
fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModuleFactory.java [new file with mode: 0644]
fibmanager/fibmanager-impl/src/main/yang/fibmanager-impl.yang [new file with mode: 0644]
fibmanager/pom.xml [new file with mode: 0644]
idmanager/idmanager-api/pom.xml [new file with mode: 0644]
idmanager/idmanager-api/src/main/yang/id-manager.yang [new file with mode: 0644]
idmanager/idmanager-impl/pom.xml [new file with mode: 0644]
idmanager/idmanager-impl/src/main/config/default-config.xml [new file with mode: 0644]
idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModule.java [new file with mode: 0644]
idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModuleFactory.java [new file with mode: 0644]
idmanager/idmanager-impl/src/main/yang/idmanager-impl.yang [new file with mode: 0644]
idmanager/pom.xml [new file with mode: 0644]
interfacemgr/interfacemgr-api/pom.xml [new file with mode: 0644]
interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang [new file with mode: 0644]
interfacemgr/pom.xml
mdsalutil/mdsalutil-api/pom.xml [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/AbstractSwitchEntity.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionInfo.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/BucketInfo.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/FlowEntity.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/GroupEntity.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionInfo.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionType.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MDSALUtil.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchFieldType.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchInfo.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataConstants.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/NwConstants.java [new file with mode: 0644]
mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/interfaces/IMdsalApiManager.java [new file with mode: 0644]
mdsalutil/mdsalutil-impl/pom.xml [new file with mode: 0644]
mdsalutil/mdsalutil-impl/src/main/config/default-config.xml [new file with mode: 0644]
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/vpnservice/mdsalutil/internal/MDSALManager.java [new file with mode: 0644]
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModule.java [new file with mode: 0644]
mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModuleFactory.java [new file with mode: 0644]
mdsalutil/mdsalutil-impl/src/main/yang/mdsalutil-impl.yang [new file with mode: 0644]
mdsalutil/pom.xml [new file with mode: 0644]
nexthopmgr/nexthopmgr-api/pom.xml [new file with mode: 0644]
nexthopmgr/nexthopmgr-api/src/main/yang/l3nexthop.yang [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/pom.xml [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/config/default-config.xml [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/AbstractDataChangeListener.java [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModule.java [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModuleFactory.java [new file with mode: 0644]
nexthopmgr/nexthopmgr-impl/src/main/yang/nexthopmgr-impl.yang [new file with mode: 0644]
nexthopmgr/pom.xml [new file with mode: 0644]
pom.xml
vpnmanager-api/pom.xml
vpnmanager-api/src/main/yang/bgp-l3vpn.yang [deleted file]
vpnmanager-api/src/main/yang/odl-l3vpn.yang
vpnmanager-impl/pom.xml

index 1e74788..76a4e1e 100644 (file)
@@ -8,6 +8,7 @@
 .classpath
 .project
 .settings
+.metadata
 target
 *.iml
 .idea
diff --git a/fibmanager/fibmanager-api/pom.xml b/fibmanager/fibmanager-api/pom.xml
new file mode 100644 (file)
index 0000000..a66b1c3
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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">
+  <parent>
+    <groupId>org.opendaylight.yangtools</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>fibmanager-api</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <!-- ODL -->
+    <ietf.inet.types.version>2010.09.24.7-SNAPSHOT</ietf.inet.types.version>
+    <ietf.yang.types.version>2010.09.24.7-SNAPSHOT</ietf.yang.types.version>
+    <yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
+    <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+    <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-inet-types</artifactId>
+      <version>${ietf.inet.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-yang-types</artifactId>
+      <version>${ietf.yang.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-interfaces</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>iana-if-type-2014-05-08</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.model</groupId>
+      <artifactId>model-inventory</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/fibmanager/fibmanager-api/src/main/yang/odl-fib.yang b/fibmanager/fibmanager-api/src/main/yang/odl-fib.yang
new file mode 100644 (file)
index 0000000..bb5b720
--- /dev/null
@@ -0,0 +1,36 @@
+module odl-fib {
+       namespace "urn:opendaylight:vpnservice:fibmanager";
+       prefix odl-fib;
+       
+       revision "2015-03-30" {
+               description "FIB Manager module";
+       }
+       
+       grouping ipv4Entries{
+               list ipv4Entry{
+                       key  "destPrefix";
+                       leaf destPrefix {type string;}
+                       leaf nextHopAddress {type string;}
+               }
+       }
+
+       grouping vrfEntries{
+               list vrfEntry{
+                       key  "destPrefix";
+                       leaf destPrefix {type string;}
+                       leaf label {type uint32;}
+                       leaf nextHopAddress {type string;}
+               }
+       }
+
+       container fibEntries {
+               list vrfTables{
+                       key "routeDistinguisher";
+                       leaf routeDistinguisher {type string;}
+                       uses vrfEntries;
+               }
+               container ipv4Table{
+                       uses  ipv4Entries;                      
+               }
+       }
+}
\ No newline at end of file
diff --git a/fibmanager/fibmanager-impl/pom.xml b/fibmanager/fibmanager-impl/pom.xml
new file mode 100644 (file)
index 0000000..732bd2f
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+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
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>fibmanager-impl</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <configLocation>
+            ${project.basedir}/../../commons/src/main/resources/vpns_checks.xml
+          </configLocation>
+          <failsOnError>true</failsOnError>
+          <includes>**/*.java,**/*.xml,**/*.ini,**/*.sh,**/*.bat</includes>
+          <excludes>**/yang/</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/fibmanager/fibmanager-impl/src/main/config/default-config.xml b/fibmanager/fibmanager-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..a624ae7
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:fibmanager:impl?module=fibmanager-impl&amp;revision=2015-03-25</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <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:prefix="urn:opendaylight:params:xml:ns:yang:fibmanager:impl">prefix:fibmanager-impl</type>
+          <name>fibmanager-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModule.java b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModule.java
new file mode 100644 (file)
index 0000000..c845721
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.fibmanager.impl.rev150325;
+public class FibmanagerImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.fibmanager.impl.rev150325.AbstractFibmanagerImplModule {
+    public FibmanagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public FibmanagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.fibmanager.impl.rev150325.FibmanagerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        // TODO:implement
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+}
diff --git a/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModuleFactory.java b/fibmanager/fibmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/fibmanager/impl/rev150325/FibmanagerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..c64420d
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: fibmanager-impl yang module local name: fibmanager-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Thu Apr 02 18:16:00 IST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.fibmanager.impl.rev150325;
+public class FibmanagerImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.fibmanager.impl.rev150325.AbstractFibmanagerImplModuleFactory {
+
+}
diff --git a/fibmanager/fibmanager-impl/src/main/yang/fibmanager-impl.yang b/fibmanager/fibmanager-impl/src/main/yang/fibmanager-impl.yang
new file mode 100644 (file)
index 0000000..a9321ae
--- /dev/null
@@ -0,0 +1,35 @@
+module fibmanager-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:fibmanager:impl";
+    prefix "fibmanager-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for fibmanager project";
+
+    revision "2015-03-25" {
+        description
+            "Initial revision";
+    }
+
+    identity fibmanager-impl {
+        base config:module-type;
+        config:java-name-prefix FibmanagerImpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case fibmanager-impl {
+            when "/config:modules/config:module/config:type = 'fibmanager-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/fibmanager/pom.xml b/fibmanager/pom.xml
new file mode 100644 (file)
index 0000000..84d36f0
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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 INTERNAL
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+       <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>fibmanager-aggregator</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>fibmanager</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>fibmanager-api</module>
+    <module>fibmanager-impl</module>
+  </modules>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/idmanager/idmanager-api/pom.xml b/idmanager/idmanager-api/pom.xml
new file mode 100644 (file)
index 0000000..0476648
--- /dev/null
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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">
+  <parent>
+    <groupId>org.opendaylight.yangtools</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>idmanager-api</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <!-- ODL -->
+    <ietf.inet.types.version>2010.09.24.7-SNAPSHOT</ietf.inet.types.version>
+    <ietf.yang.types.version>2010.09.24.7-SNAPSHOT</ietf.yang.types.version>
+    <yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
+    <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+    <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/idmanager/idmanager-api/src/main/yang/id-manager.yang b/idmanager/idmanager-api/src/main/yang/id-manager.yang
new file mode 100644 (file)
index 0000000..7066442
--- /dev/null
@@ -0,0 +1,40 @@
+module odl-id-manager {
+    namespace "urn:opendaylight:vpnservice:idmanager";
+    prefix idmgr;
+
+    revision "2015-04-03" {
+        description "ID generator and manager Service module";
+    }
+
+    
+       list id-pool {
+               key "pool-name";
+               leaf id-start { type uint32; }
+               leaf pool-size { type uint64; }
+               leaf pool-name { type string; }
+               list generated-ids {
+                       key "id-key";
+                       leaf id-key { type string; }
+                       leaf id-value { type uint32; }
+               }
+       }
+       
+       rpc createIdPool {
+               input {
+                       leaf pool-name { type string; }
+                       leaf id-start { type uint32; }
+                       leaf pool-size { type uint64; }
+               }
+       }
+       
+       rpc getUniqueId {
+               input {
+                       leaf pool-name { type string; }
+                       leaf id-key {type string; }
+               }
+               output {
+                       leaf id-value { type uint32; }
+               }
+       }
+    
+}
diff --git a/idmanager/idmanager-impl/pom.xml b/idmanager/idmanager-impl/pom.xml
new file mode 100644 (file)
index 0000000..03ecb36
--- /dev/null
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+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
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>idmanager-impl</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <configLocation>
+            ${project.basedir}/../../commons/src/main/resources/vpns_checks.xml
+          </configLocation>
+          <failsOnError>true</failsOnError>
+          <includes>**/*.java,**/*.xml,**/*.ini,**/*.sh,**/*.bat</includes>
+          <excludes>**/yang/</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/idmanager/idmanager-impl/src/main/config/default-config.xml b/idmanager/idmanager-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..eccf8af
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:idmanager:impl?module=idmanager-impl&amp;revision=2015-03-25</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <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:prefix="urn:opendaylight:params:xml:ns:yang:idmanager:impl">prefix:idmanager-impl</type>
+          <name>idmanager-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModule.java b/idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModule.java
new file mode 100644 (file)
index 0000000..3b4cf9f
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325;
+public class IdmanagerImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325.AbstractIdmanagerImplModule {
+    public IdmanagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public IdmanagerImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325.IdmanagerImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        // TODO:implement
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+}
diff --git a/idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModuleFactory.java b/idmanager/idmanager-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/idmanager/impl/rev150325/IdmanagerImplModuleFactory.java
new file mode 100644 (file)
index 0000000..79ee499
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: idmanager-impl yang module local name: idmanager-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Apr 03 08:37:12 IST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325;
+public class IdmanagerImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.idmanager.impl.rev150325.AbstractIdmanagerImplModuleFactory {
+
+}
diff --git a/idmanager/idmanager-impl/src/main/yang/idmanager-impl.yang b/idmanager/idmanager-impl/src/main/yang/idmanager-impl.yang
new file mode 100644 (file)
index 0000000..ec07c7b
--- /dev/null
@@ -0,0 +1,35 @@
+module idmanager-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:idmanager:impl";
+    prefix "idmanager-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for idmanager project";
+
+    revision "2015-03-25" {
+        description
+            "Initial revision";
+    }
+
+    identity idmanager-impl {
+        base config:module-type;
+        config:java-name-prefix IdmanagerImpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case idmanager-impl {
+            when "/config:modules/config:module/config:type = 'idmanager-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/idmanager/pom.xml b/idmanager/pom.xml
new file mode 100644 (file)
index 0000000..fbcaa51
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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 INTERNAL
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+       <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>idmanager-aggregator</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>idmanager</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>idmanager-api</module>
+    <module>idmanager-impl</module>
+  </modules>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/interfacemgr/interfacemgr-api/pom.xml b/interfacemgr/interfacemgr-api/pom.xml
new file mode 100644 (file)
index 0000000..955f3c2
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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">
+  <parent>
+    <groupId>org.opendaylight.yangtools</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>interfacemgr-api</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <!-- ODL -->
+    <ietf.inet.types.version>2010.09.24.7-SNAPSHOT</ietf.inet.types.version>
+    <ietf.yang.types.version>2010.09.24.7-SNAPSHOT</ietf.yang.types.version>
+    <yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
+    <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+    <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-inet-types</artifactId>
+      <version>${ietf.inet.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-yang-types</artifactId>
+      <version>${ietf.yang.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-interfaces</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>iana-if-type-2014-05-08</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.model</groupId>
+      <artifactId>model-inventory</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang b/interfacemgr/interfacemgr-api/src/main/yang/odl-interface.yang
new file mode 100644 (file)
index 0000000..591f31f
--- /dev/null
@@ -0,0 +1,144 @@
+
+module odl-interface {
+       namespace "urn:opendaylight:vpnservice:interfacemgr";
+
+       prefix "odlif";
+
+       import ietf-interfaces {
+               prefix if;
+       }
+       import iana-if-type {
+               prefix ianaift;
+       }
+
+       import ietf-inet-types {
+               prefix inet;
+       }
+       revision "2015-03-31" {
+        description "ODL Interface Manager Module";
+    }
+
+       identity stacked-vlan {
+               base if:interface-type;
+               reference
+               "Q-in-Q interface";
+       }
+       
+       identity l3tunnel {
+               base if:interface-type;
+               reference
+               "l3 tunnel interface";
+       }
+
+       identity mpls {
+               base if:interface-type;
+               reference
+               "MPLS interface";
+       }
+
+       /* l3Tunnel (GRE, VxLAN) logical port */
+       identity tunnel-type-base {
+               description "Base identity for all tunnel-types";
+       }
+
+       identity tunnel-type-vxlan {
+               description "Tunnel type for vxlan tunnels";
+               base tunnel-type-base;
+       }
+
+       identity tunnel-type-gre {
+               description "Tunnel type for gre tunnels";
+               base tunnel-type-base;
+       }
+
+       /* base/common properties */
+       augment "/if:interfaces/if:interface" {
+               leaf of-port-id { 
+                       type string; 
+                       description "can be a physical switch port or virtual switch port e.g. neutron port";
+               } 
+               leaf tenant-id { 
+                       type string; 
+                       description "Tenant that owns particular interface";
+               } /* optional */
+               leaf base-interface { 
+                       type if:interface-ref; 
+                       description "some interfaces need a reference to parent interface ";
+               } 
+       }
+       
+       /* interface type specific properties */
+       
+       /* VLAN logical port */
+       augment "/if:interfaces/if:interface" {
+               when "if:type = 'ianaift:l2vlan'";
+               leaf vlan-id {
+                       type uint16 {
+                               range "1..4094";
+                       }
+                       must "../base-interface" {
+                               description
+                               "If a vlan-id is defined, a base-interface must
+                               be specified.";
+                       }
+               }
+       }
+       
+       /* Q-in-Q logical port */
+       augment "/if:interfaces/if:interface" {
+               when "if:type = 'stacked_vlan'";
+               leaf stacked_vlan-id {
+                       type uint16 {
+                               range "1..4094";
+                       }
+                       must "../base-interface" {
+                               description
+                               "If a vlan-id is defined, a base-interface must
+                               be specified.";
+                       }
+               }
+       }
+
+       augment "/if:interfaces/if:interface" {
+               when "if:type = 'ianaift:l3tunnel'";
+
+               leaf tunnel-type {
+            type identityref {
+                base tunnel-type-base;
+            }
+        }
+               leaf local-ip {
+                       type inet:ip-address;
+                       description "Local Endpoint IP address";
+               }
+               
+               leaf remote-ip {
+                       type inet:ip-address;
+                       description "Remote Endpoint IP address";
+               }
+               
+               leaf gateway-ip {
+                       type inet:ip-address;
+                       description "gateway IP address";
+               }
+                               
+       }
+
+               
+       /* MPLS logical port */
+       augment "/if:interfaces/if:interface" {
+               when "if:type = 'mpls'";
+               leaf-list labelStack {
+                       type uint32 {
+                               range "15..1048575";
+                       }
+               }
+               leaf numLabels{
+                       type uint8 {
+                               range "1..7";
+                       }
+               }               
+       }
+
+}
+
index 31f16a6..95e95dd 100644 (file)
@@ -24,6 +24,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <maven>3.1.1</maven>
   </prerequisites>
   <modules>
+    <module>interfacemgr-api</module>
     <module>interfacemgr-impl</module>
   </modules>
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
diff --git a/mdsalutil/mdsalutil-api/pom.xml b/mdsalutil/mdsalutil-api/pom.xml
new file mode 100644 (file)
index 0000000..6e68dd5
--- /dev/null
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>mdsalutil-api</artifactId>
+    <version>0.0.1-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${bundle.plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                            org.opendaylight.vpnservice.mdsalutil,
+                            org.opendaylight.vpnservice.mdsalutil.interfaces
+                        </Export-Package>
+                        <!--Import-Package>
+                            com.google.common.*,
+                            org.opendaylight.yang.*,
+                            org.opendaylight.yangtools.*,
+                            org.opendaylight.controller.sal.binding.api.*,
+                            org.opendaylight.controller.md.sal.common.api.*,
+                            org.opendaylight.controller.sal.common
+                         </Import-Package-->
+                    </instructions>
+                    <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-base</artifactId>
+        </dependency>
+       <!--  <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-inventory</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-statistics</artifactId>
+        </dependency>
+        <!--
+        <dependency>
+            <groupId>org.opendaylight.controller.adsal</groupId>
+            <artifactId>sal</artifactId>
+        </dependency>
+        -->
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-common</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-topology</artifactId>
+        </dependency>
+       
+                     
+    </dependencies>
+</project>
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/AbstractSwitchEntity.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/AbstractSwitchEntity.java
new file mode 100644 (file)
index 0000000..8ec8a99
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  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.vpnservice.mdsalutil;
+
+public class AbstractSwitchEntity {
+    private static final long serialVersionUID = 1L;
+
+    private long m_lDpnId;
+    
+
+    public AbstractSwitchEntity(long lDpnId) {
+        m_lDpnId = lDpnId;
+      
+    }
+    
+    @Override
+    public String toString() {
+        return "AbstractSwitchEntity [m_lDpnId=" + m_lDpnId + " ]";
+    }
+
+    
+    public long getDpnId() {
+        return m_lDpnId;
+    }
+
+    public void setDpnId(long lDpnId) {
+        m_lDpnId = lDpnId;
+    }
+
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionInfo.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionInfo.java
new file mode 100644 (file)
index 0000000..6bcb870
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Arrays;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+
+public class ActionInfo implements Serializable{
+
+    /**
+     *
+     */
+    private static final long serialVersionUID = 1L;
+    private final ActionType m_actionType;
+    private String[] m_asActionValues = null;
+    private BigInteger [] m_aBigIntValues;
+    private int m_actionKey = 0;
+
+    public ActionInfo(ActionInfo action) {
+        super();
+        m_actionType = action.m_actionType;
+        m_actionKey = action.m_actionKey;
+        m_asActionValues = Arrays.copyOf(action.m_asActionValues, action.m_asActionValues.length);
+    }
+
+    public ActionInfo(ActionType actionType, String[] asActionValues) {
+        m_actionType = actionType;
+        m_actionKey = 0;
+        m_asActionValues = asActionValues;
+    } 
+    
+    public ActionInfo(ActionType actionType, BigInteger[] aBigIntValues) {
+        m_actionType = actionType;
+        m_actionKey = 0;
+        m_aBigIntValues = aBigIntValues;
+    }
+
+    public void setActionKey(int key) {
+        m_actionKey = key;
+    }
+
+    public int getActionKey() {
+        return m_actionKey;
+    }
+
+    public Action buildAction() {
+        return m_actionType.buildAction(this);
+    }
+
+    public ActionType getActionType() {
+        return m_actionType;
+    }
+
+    public String[] getActionValues() {
+        return m_asActionValues;
+    }
+    
+    public BigInteger[] getBigActionValues() {
+        return m_aBigIntValues;
+    }
+}
\ No newline at end of file
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/ActionType.java
new file mode 100644 (file)
index 0000000..3744928
--- /dev/null
@@ -0,0 +1,455 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+import java.net.InetAddress;
+
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.EricFilterTypes;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.ExperimenterActionTypeBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.experimenter.action.type.action.type.FilterTypesActionBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.filter.types.group.Metadata;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.filter.types.group.MetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.GroupActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PopVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushMplsActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushPbbActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.PushVlanActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetFieldCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.group.action._case.GroupActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.output.action._case.OutputActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.mpls.action._case.PopMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.pbb.action._case.PopPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.pop.vlan.action._case.PopVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.mpls.action._case.PushMplsActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.pbb.action._case.PushPbbActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.push.vlan.action._case.PushVlanActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.field._case.SetFieldBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.OutputPortValues;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.flow.types.rev140422.EricssonPortTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.ExperimenterActionTypeBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.experimenter.action.type.action.type.VxlanPopActionBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.experimenter.action.type.action.type.VxlanPushActionBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.experimenter.action.type.action.type.GrePopActionBuilder;
+//import org.opendaylight.yang.gen.v1.urn.ericsson.experimenter.action.types.rev140228.action.types.action.action.experimenter.action.type.action.type.GrePushActionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.DropActionCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropAction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.drop.action._case.DropActionBuilder;
+
+public enum ActionType {
+    group {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            long groupId = Long.parseLong(actionInfo.getActionValues()[0]);
+
+            return new ActionBuilder().setAction(
+                            new GroupActionCaseBuilder().setGroupAction(
+                                    new GroupActionBuilder().setGroupId(groupId).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    output {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            String port = actionValues[0];
+            int maxLength = 0;
+
+            if (actionValues.length == 2) {
+                maxLength = Integer.valueOf(actionValues[1]);
+            }
+
+            return new ActionBuilder().setAction(
+                    new OutputActionCaseBuilder().setOutputAction(
+                            new OutputActionBuilder().setMaxLength(Integer.valueOf(maxLength))
+                                            .setOutputNodeConnector(new Uri(port)).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    /**
+     * The action info passed to this ActionType should have two actionValues string.
+     *
+     * The first string representing the metadata and the next string representing the metadatamask
+     */
+    /*
+    filter_equals {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            if (actionValues == null || actionValues.length != 2) {
+                throw new RuntimeException("Filter Equal set field action should have two arguments for metadata and metadata mask");
+            }
+            final BigInteger metaData = new BigInteger(actionValues[0]);
+            final BigInteger metadataMask = new BigInteger(actionValues[1]);
+            return new ActionBuilder()
+                .setAction(
+                    new ExperimenterActionTypeBuilder().setActionType(
+                        new FilterTypesActionBuilder()
+                            .setFilterType(EricFilterTypes.ERICFTEQUAL)
+                            .setMetadata(
+                                new MetadataBuilder().setMetadata(metaData).setMetadataMask(metadataMask).build())
+                        .build())//Filter Equal Action Type
+                    .build())//Experimenter Action
+                .setKey(new ActionKey(actionInfo.getActionKey()))
+                .build();
+        }
+    },
+    */
+
+    pop_mpls {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new PopMplsActionCaseBuilder().setPopMplsAction(
+                            new PopMplsActionBuilder().setEthernetType(
+                                    Integer.valueOf(NwConstants.ETHTYPE_IPV4)).build()).build())
+
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    pop_pbb {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder()
+                    .setAction(new PopPbbActionCaseBuilder().setPopPbbAction(new PopPbbActionBuilder().build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    pop_vlan {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new PopVlanActionCaseBuilder().setPopVlanAction(new PopVlanActionBuilder().build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+/*
+    pop_vxlan {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new ExperimenterActionTypeBuilder().setActionType(
+                            new VxlanPopActionBuilder().build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+    */
+/*
+    pop_gre {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new ExperimenterActionTypeBuilder().setActionType(
+                            new GrePopActionBuilder().build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+*/
+    push_mpls {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(new PushMplsActionCaseBuilder().setPushMplsAction(
+                                    new PushMplsActionBuilder().setEthernetType(
+                                            Integer.valueOf(NwConstants.ETHTYPE_MPLS_UC)).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    push_pbb {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new PushPbbActionCaseBuilder().setPushPbbAction(
+                                    new PushPbbActionBuilder()
+                                            .setEthernetType(Integer.valueOf(NwConstants.ETHTYPE_PBB)).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    push_vlan {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new PushVlanActionCaseBuilder().setPushVlanAction(
+                                    new PushVlanActionBuilder().setEthernetType(
+                                            Integer.valueOf(NwConstants.ETHTYPE_802_1Q)).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+/*
+    push_vxlan {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new ExperimenterActionTypeBuilder().setActionType(
+                                    new VxlanPushActionBuilder().setEthType(0x0800).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+    */
+/*
+    push_gre {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new ExperimenterActionTypeBuilder().setActionType(
+                            new GrePushActionBuilder().setEthType(0x0800).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+*/
+    set_field_mpls_label {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            long label = Long.valueOf(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(new SetFieldBuilder().setProtocolMatchFields(
+                                            new ProtocolMatchFieldsBuilder().setMplsLabel(label).build()).build())
+                                    .build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    set_field_pbb_isid {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            long label = Long.valueOf(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setProtocolMatchFields(
+                                            new ProtocolMatchFieldsBuilder().setPbb(
+                                                    new PbbBuilder().setPbbIsid(label).build()).build()).build())
+                                    .build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    set_field_vlan_vid {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            int vlanId = Integer.valueOf(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setVlanMatch(
+                                    new VlanMatchBuilder().setVlanId(
+                                                    new VlanIdBuilder().setVlanId(new VlanId(vlanId))
+                                                            .setVlanIdPresent(true).build()).build()).build()).build())
+                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+        }
+    },
+
+    set_field_tunnel_id {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            BigInteger [] actionValues = actionInfo.getBigActionValues();
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setTunnel(new TunnelBuilder().setTunnelId(actionValues[0])
+                                    .setTunnelMask(actionValues[1]).build()).build()).build())
+                                    .setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+
+    set_field_eth_dest {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            MacAddress mac = new MacAddress(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setEthernetMatch(
+                                    new EthernetMatchBuilder().setEthernetDestination(
+                                                    new EthernetDestinationBuilder().setAddress(mac).build()).build())
+                                            .build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+
+    set_udp_protocol {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setIpMatch(
+                                    new IpMatchBuilder().setIpProtocol((short) 17).build()).
+                                    build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+    punt_to_controller {
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            ActionBuilder ab = new ActionBuilder();
+            OutputActionBuilder output = new OutputActionBuilder();
+            output.setMaxLength(0xffff);
+            Uri value = new Uri(OutputPortValues.CONTROLLER.toString());
+            output.setOutputNodeConnector(value);
+            ab.setAction(new OutputActionCaseBuilder().setOutputAction(output.build()).build());
+            ab.setKey(new ActionKey(actionInfo.getActionKey()));
+            return ab.build();
+        }
+
+    },
+    set_destination_port_field {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            Integer portNumber = new Integer(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setLayer4Match(
+                                    new UdpMatchBuilder().setUdpDestinationPort(
+                                            new PortNumber(portNumber)).build())
+                            .build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+    set_source_port_field {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            Integer portNumber = new Integer(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setLayer4Match(
+                                    new UdpMatchBuilder().setUdpSourcePort(
+                                            new PortNumber(portNumber)).build())
+                            .build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+    set_source_ip {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            InetAddress sourceIp = null;
+            try{
+                sourceIp = InetAddress.getByName(actionValues[0]);
+            } catch (Exception e){
+                e.printStackTrace();
+            }
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setLayer3Match(
+                                    new Ipv4MatchBuilder().setIpv4Source(
+                                            new Ipv4Prefix(sourceIp.getHostAddress())).build()).
+                                            build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+    set_destination_ip {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            InetAddress sourceIp = null;
+            try{
+                sourceIp = InetAddress.getByName(actionValues[0]);
+            } catch (Exception e){
+                e.printStackTrace();
+            }
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setLayer3Match(
+                                    new Ipv4MatchBuilder().setIpv4Destination(
+                                            new Ipv4Prefix(sourceIp.getHostAddress())).build()).
+                                            build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+
+    },
+    set_field_eth_src {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            String[] actionValues = actionInfo.getActionValues();
+            MacAddress mac = new MacAddress(actionValues[0]);
+
+            return new ActionBuilder().setAction(
+                    new SetFieldCaseBuilder().setSetField(
+                            new SetFieldBuilder().setEthernetMatch(
+                                    new EthernetMatchBuilder().setEthernetSource(
+                                                    new EthernetSourceBuilder().setAddress(mac).build()).build())
+                                            .build()).build()).setKey(new ActionKey(actionInfo.getActionKey())).build();
+
+        }
+    },
+    drop_action {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            DropActionBuilder dab = new DropActionBuilder();
+            DropAction dropAction = dab.build();
+            ActionBuilder ab = new ActionBuilder();
+            ab.setAction(new DropActionCaseBuilder().setDropAction(dropAction).build());
+            return ab.build();
+        }
+    },
+    goto_table {
+
+        @Override
+        public Action buildAction(ActionInfo actionInfo) {
+            ActionBuilder ab = new ActionBuilder();
+            return null;
+        }
+    };
+
+    private static final int RADIX_HEX = 16;
+    public abstract Action buildAction(ActionInfo actionInfo);
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/BucketInfo.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/BucketInfo.java
new file mode 100644 (file)
index 0000000..2b532e4
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.io.Serializable;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+
+public class BucketInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+    private final List<ActionInfo> m_listActionInfo;
+    private Integer weight = 0;
+    private Long watchPort = 0xffffffffL;
+    private Long watchGroup = 0xffffffffL;
+
+    public BucketInfo(List<ActionInfo> listActions) {
+        m_listActionInfo = listActions;
+    }
+
+    public BucketInfo(List<ActionInfo> m_listActionInfo, Integer weight, Long watchPort, Long watchGroup) {
+        super();
+        this.m_listActionInfo = m_listActionInfo;
+        this.weight = weight;
+        this.watchPort = watchPort;
+        this.watchGroup = watchGroup;
+    }
+
+    public void buildAndAddActions(List<Action> listActionOut) {
+        int key = 0;
+        if (m_listActionInfo != null) {
+            for (ActionInfo actionInfo : m_listActionInfo) {
+                actionInfo.setActionKey(key++);
+                listActionOut.add(actionInfo.buildAction());
+            }
+        }
+    }
+
+    public void setWeight(Integer bucketWeight) {
+        weight = bucketWeight;
+    }
+
+    public Integer getWeight() {
+        return weight;
+    }
+
+    public List<ActionInfo> getActionInfoList() {
+        return m_listActionInfo;
+    }
+
+    public Long getWatchPort() {
+        return watchPort;
+    }
+
+    public void setWatchPort(Long watchPort) {
+        this.watchPort = watchPort;
+    }
+
+    public Long getWatchGroup() {
+        return watchGroup;
+    }
+
+    public void setWatchGroup(Long watchGroup) {
+        this.watchGroup = watchGroup;
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/FlowEntity.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/FlowEntity.java
new file mode 100644 (file)
index 0000000..8757f1e
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  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.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+
+public class FlowEntity extends AbstractSwitchEntity {
+    private static final long serialVersionUID = 1L;
+
+    private short m_shTableId;
+    private String m_sFlowId;
+    private int m_nPriority;
+    private String m_sFlowName;
+    private int m_nIdleTimeOut;
+    private int m_nHardTimeOut;
+    private BigInteger m_biCookie;
+    private List<MatchInfo> m_listMatchInfo;
+    private List<InstructionInfo> m_listInstructionInfo;
+
+    private boolean m_bStrictFlag;
+    private boolean m_bSendFlowRemFlag;
+
+    private transient FlowBuilder m_flowBuilder;
+
+    public FlowEntity(long lDpnId) {
+        super(lDpnId);
+    }
+
+    @Override
+    public String toString() {
+        return "FlowEntity [m_shTableId=" + m_shTableId + ", m_sFlowId=" + m_sFlowId + ", m_nPriority=" + m_nPriority
+                + ", m_sFlowName=" + m_sFlowName + ", m_nIdleTimeOut=" + m_nIdleTimeOut + ", m_nHardTimeOut="
+                + m_nHardTimeOut + ", m_biCookie=" + m_biCookie + ", m_listMatchInfo=" + m_listMatchInfo
+                + ", m_listInstructionInfo=" + m_listInstructionInfo + ", m_bStrictFlag=" + m_bStrictFlag
+                + ", m_bSendFlowRemFlag=" + m_bSendFlowRemFlag + ", toString()=" + super.toString() + "]";
+    }
+
+    public BigInteger getCookie() {
+        return m_biCookie;
+    }
+
+    public String getFlowId() {
+        return m_sFlowId;
+    }
+
+    public String getFlowName() {
+        return m_sFlowName;
+    }
+
+    public int getHardTimeOut() {
+        return m_nHardTimeOut;
+    }
+
+    public int getIdleTimeOut() {
+        return m_nIdleTimeOut;
+    }
+
+    public List<InstructionInfo> getInstructionInfoList() {
+        return m_listInstructionInfo;
+    }
+
+    public List<MatchInfo> getMatchInfoList() {
+        return m_listMatchInfo;
+    }
+
+    public int getPriority() {
+        return m_nPriority;
+    }
+
+    public boolean getSendFlowRemFlag() {
+        return m_bSendFlowRemFlag;
+    }
+
+    public boolean getStrictFlag() {
+        return m_bStrictFlag;
+    }
+
+    public short getTableId() {
+        return m_shTableId;
+    }
+
+    public void setCookie(BigInteger biCookie) {
+        m_biCookie = biCookie;
+        m_flowBuilder = null;
+    }
+
+    public FlowBuilder getFlowBuilder() {
+        if (m_flowBuilder == null) {
+            m_flowBuilder = new FlowBuilder();
+
+            m_flowBuilder.setKey(new FlowKey(new FlowId(getFlowId())));
+
+            m_flowBuilder.setTableId(getTableId());
+            m_flowBuilder.setPriority(getPriority());
+            m_flowBuilder.setFlowName(getFlowName());
+            m_flowBuilder.setIdleTimeout(getIdleTimeOut());
+            m_flowBuilder.setHardTimeout(getHardTimeOut());
+            m_flowBuilder.setCookie(new FlowCookie(getCookie()));
+            m_flowBuilder.setMatch(MDSALUtil.buildMatches(getMatchInfoList()));
+            m_flowBuilder.setInstructions(MDSALUtil.buildInstructions(getInstructionInfoList()));
+
+            m_flowBuilder.setStrict(getStrictFlag());
+            // TODO Fix Me
+            //m_flowBuilder.setResyncFlag(getResyncFlag());
+            if (getSendFlowRemFlag()) {
+                m_flowBuilder.setFlags(new FlowModFlags(false, false, false, false, true));
+            }
+
+            m_flowBuilder.setBarrier(false);
+            m_flowBuilder.setInstallHw(true);
+        }
+
+        return m_flowBuilder;
+    }
+
+    public void setFlowId(String sFlowId) {
+        m_sFlowId = sFlowId;
+        if (m_flowBuilder != null) {
+            m_flowBuilder.setKey(new FlowKey(new FlowId(sFlowId)));
+        }
+    }
+
+    public void setFlowName(String sFlowName) {
+        m_sFlowName = sFlowName;
+        m_flowBuilder = null;
+    }
+
+    public void setHardTimeOut(int nHardTimeOut) {
+        m_nHardTimeOut = nHardTimeOut;
+        m_flowBuilder = null;
+    }
+
+    public void setIdleTimeOut(int nIdleTimeOut) {
+        m_nIdleTimeOut = nIdleTimeOut;
+        m_flowBuilder = null;
+    }
+
+    public void setInstructionInfoList(List<InstructionInfo> listInstructionInfo) {
+        m_listInstructionInfo = listInstructionInfo;
+        m_flowBuilder = null;
+    }
+
+    public void setMatchInfoList(List<MatchInfo> listMatchInfo) {
+        m_listMatchInfo = listMatchInfo;
+        m_flowBuilder = null;
+    }
+
+    public void setPriority(int nPriority) {
+        m_nPriority = nPriority;
+        m_flowBuilder = null;
+    }
+
+    public void setSendFlowRemFlag(boolean bSendFlowRemFlag) {
+        m_bSendFlowRemFlag = bSendFlowRemFlag;
+        m_flowBuilder = null;
+    }
+
+    public void setStrictFlag(boolean bStrictFlag) {
+        m_bStrictFlag = bStrictFlag;
+        m_flowBuilder = null;
+    }
+
+    public void setTableId(short shTableId) {
+        m_shTableId = shTableId;
+        m_flowBuilder = null;
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/GroupEntity.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/GroupEntity.java
new file mode 100644 (file)
index 0000000..fc08f8c
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  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.vpnservice.mdsalutil;
+
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+
+public class GroupEntity extends AbstractSwitchEntity {
+    private static final long serialVersionUID = 1L;
+
+    private long m_lGroupId;
+    private String m_sGroupName;
+    private GroupTypes m_groupType;
+    private List<BucketInfo> m_listBucketInfo;
+
+    private transient GroupBuilder m_groupBuilder;
+
+    public GroupEntity(long lDpnId) {
+        super(lDpnId);
+    }
+
+    @Override
+    public String toString() {
+        return "GroupEntity [m_lGroupId=" + m_lGroupId + ", m_sGroupName=" + m_sGroupName + ", m_groupType="
+                + m_groupType + ", m_listBucketInfo=" + m_listBucketInfo + ", toString()=" + super.toString() + "]";
+    }
+
+    public List<BucketInfo> getBucketInfoList() {
+        return m_listBucketInfo;
+    }
+
+    public GroupBuilder getGroupBuilder() {
+        if (m_groupBuilder == null) {
+            m_groupBuilder = new GroupBuilder();
+
+            GroupId groupId = new GroupId(getGroupId());
+            m_groupBuilder.setKey(new GroupKey(groupId));
+            m_groupBuilder.setGroupId(groupId);
+
+            m_groupBuilder.setGroupName(getGroupName());
+            m_groupBuilder.setGroupType(getGroupType());
+            m_groupBuilder.setBuckets(MDSALUtil.buildBuckets(getBucketInfoList()));
+
+           // m_groupBuilder.setResyncFlag(getResyncFlag());
+        }
+
+        return m_groupBuilder;
+    }
+
+    public long getGroupId() {
+        return m_lGroupId;
+    }
+
+    public String getGroupName() {
+        return m_sGroupName;
+    }
+
+    public GroupTypes getGroupType() {
+        return m_groupType;
+    }
+
+    public void setBucketInfoList(List<BucketInfo> listBucketInfo) {
+        m_listBucketInfo = listBucketInfo;
+    }
+
+    public void setGroupId(long lGroupId) {
+        m_lGroupId = lGroupId;
+        if (m_groupBuilder != null) {
+            GroupId groupId = new GroupId(getGroupId());
+            m_groupBuilder.setKey(new GroupKey(groupId));
+            m_groupBuilder.setGroupId(groupId);
+        }
+    }
+
+    public void setGroupName(String sGroupName) {
+        m_sGroupName = sGroupName;
+        m_groupBuilder = null;
+    }
+
+    public void setGroupType(GroupTypes groupType) {
+        m_groupType = groupType;
+        m_groupBuilder = null;
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionInfo.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionInfo.java
new file mode 100644 (file)
index 0000000..b46b366
--- /dev/null
@@ -0,0 +1,65 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+
+public class InstructionInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final InstructionType m_instructionType;
+    private long[] m_alInstructionValues;
+    private BigInteger[] m_alBigInstructionValues;
+    private List<ActionInfo> m_actionInfos;
+
+    // This constructor should be used incase of clearAction
+    public InstructionInfo(InstructionType instructionType) {
+        m_instructionType = instructionType;
+    }
+
+    public InstructionInfo(InstructionType instructionType, long[] instructionValues) {
+        m_instructionType = instructionType;
+        m_alInstructionValues = instructionValues;
+    }
+
+    public InstructionInfo(InstructionType instructionType, BigInteger[] instructionValues) {
+        m_instructionType = instructionType;
+        m_alBigInstructionValues = instructionValues;
+    }
+
+    public InstructionInfo(InstructionType instructionType, List<ActionInfo> actionInfos) {
+        m_instructionType = instructionType;
+        m_actionInfos = actionInfos;
+    }
+
+    public Instruction buildInstruction(int instructionKey) {
+        return m_instructionType.buildInstruction(this, instructionKey);
+    }
+
+    public InstructionType getInstructionType() {
+        return m_instructionType;
+    }
+
+    public long[] getInstructionValues() {
+        return m_alInstructionValues;
+    }
+
+    public BigInteger[] getBigInstructionValues() {
+        return m_alBigInstructionValues;
+    }
+
+    public List<ActionInfo> getActionInfos() {
+        return m_actionInfos;
+    }
+
+    public void setInstructionValues(long[] m_alInstructionValues) {
+        this.m_alInstructionValues = m_alInstructionValues;
+    }
+
+}
\ No newline at end of file
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionType.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/InstructionType.java
new file mode 100644 (file)
index 0000000..96fd52f
--- /dev/null
@@ -0,0 +1,115 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCase;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey;
+
+public enum InstructionType {
+    apply_actions {
+        @Override
+        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
+            List<ActionInfo> mkActions = instructionInfo.getActionInfos();
+            List<Action> listAction = new ArrayList <Action> ();
+            for(ActionInfo mkAction: mkActions) {
+                ActionType actionType = mkAction.getActionType();
+                listAction.add(actionType.buildAction(mkAction));
+            }
+            ApplyActions applyActions = new ApplyActionsBuilder().setAction(listAction).build();
+            ApplyActionsCase applyActionsCase = new ApplyActionsCaseBuilder().setApplyActions(applyActions).build();
+            InstructionBuilder instructionBuilder = new InstructionBuilder();
+
+            instructionBuilder.setInstruction(applyActionsCase);
+            instructionBuilder.setKey(new InstructionKey(instructionKey));
+
+            return instructionBuilder.build();
+        }
+    },
+
+    goto_table {
+        @Override
+        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
+            short tableId = (short) instructionInfo.getInstructionValues()[0];
+
+            return new InstructionBuilder()
+                    .setInstruction(
+                            new GoToTableCaseBuilder().setGoToTable(
+                                    new GoToTableBuilder().setTableId(Short.valueOf(tableId)).build()).build())
+                    .setKey(new InstructionKey(instructionKey)).build();
+        }
+    },
+
+    write_actions {
+        @Override
+        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
+            List<ActionInfo> mkActions = instructionInfo.getActionInfos();
+            List<Action> listAction = new ArrayList <Action> ();
+            for(ActionInfo mkAction: mkActions) {
+                ActionType actionType = mkAction.getActionType();
+                listAction.add(actionType.buildAction(mkAction));
+            }
+            WriteActions writeActions = new WriteActionsBuilder().setAction(listAction).build();
+            WriteActionsCase writeActionsCase = new WriteActionsCaseBuilder().setWriteActions(writeActions).build();
+            InstructionBuilder instructionBuilder = new InstructionBuilder();
+
+            instructionBuilder.setInstruction(writeActionsCase);
+            instructionBuilder.setKey(new InstructionKey(instructionKey));
+
+            return instructionBuilder.build();
+        }
+    },
+
+    clear_actions {
+        @Override
+        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
+            // ClearActions clearActions = new
+            // ClearActionsBuilder().setAction(listAction).build();
+            ClearActionsCase clearActionsCase = new ClearActionsCaseBuilder().build();
+
+            InstructionBuilder instructionBuilder = new InstructionBuilder();
+            instructionBuilder.setInstruction(clearActionsCase);
+            instructionBuilder.setKey(new InstructionKey(instructionKey));
+
+            return instructionBuilder.build();
+        }
+    },
+
+    write_metadata {
+        @Override
+        public Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey) {
+            BigInteger[] metadataValues = instructionInfo.getBigInstructionValues();
+            BigInteger metadata = metadataValues[0];
+            BigInteger mask = metadataValues[1];
+
+            return new InstructionBuilder()
+                    .setInstruction(
+                            new WriteMetadataCaseBuilder().setWriteMetadata(
+                                    new WriteMetadataBuilder().setMetadata(metadata).setMetadataMask(mask).build())
+                                    .build()).setKey(new InstructionKey(instructionKey)).build();
+        }
+    };
+
+    public abstract Instruction buildInstruction(InstructionInfo instructionInfo, int instructionKey);
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MDSALUtil.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MDSALUtil.java
new file mode 100644 (file)
index 0000000..bcaf558
--- /dev/null
@@ -0,0 +1,368 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  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.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.LinkedBlockingQueue;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.statistics.rev130819.GetFlowStatisticsFromFlowTableInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowModFlags;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupStatisticsInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.BucketsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.TransmitPacketInputBuilder;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+
+import com.google.common.base.Joiner;
+import com.google.common.primitives.Bytes;
+import com.google.common.primitives.Ints;
+
+public class MDSALUtil {
+
+    public static final String NODE_PREFIX = "openflow";
+    public static final String SEPARATOR = ":"; // TODO name separtor correctly
+
+    private static final Buckets EMPTY_Buckets = new BucketsBuilder().build();
+    private static final Instructions EMPTY_Instructions = new InstructionsBuilder().setInstruction(
+            new ArrayList<Instruction>()).build();
+    private static final Match EMPTY_Matches = new MatchBuilder().build();
+
+    // public static Map<Long, SyncStatus> syncStatusMap = new
+    // ConcurrentHashMap<Long, SyncStatus>();
+    public static Map<Long, LinkedBlockingQueue<Object>> lportMap = new ConcurrentHashMap<Long, LinkedBlockingQueue<Object>>();
+    public static Map<Long, LinkedBlockingQueue<Object>> lportDownMap = new ConcurrentHashMap<Long, LinkedBlockingQueue<Object>>();
+    // public static Map<String, Boolean> ofRefMap = new
+    // ConcurrentHashMap<String, Boolean>();
+    public static Map<Long, Map<String, Boolean>> ofRefMapDpn = new ConcurrentHashMap<Long, Map<String, Boolean>>();
+    public static Map<Long, Map<Integer, String>> ofRefGroupMapDpn = new ConcurrentHashMap<Long, Map<Integer, String>>();
+    public static Map<Long, Map<String, String>> ofRefFlowMapDpn = new ConcurrentHashMap<Long, Map<String, String>>();
+
+    public static FlowEntity buildFlowEntity(long dpnId, short tableId, String flowId, int priority, String flowName,
+            int idleTimeOut, int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
+            List<InstructionInfo> listInstructionInfo) {
+
+        FlowEntity flowEntity = new FlowEntity(dpnId);
+
+        flowEntity.setTableId(tableId);
+        flowEntity.setFlowId(flowId);
+        flowEntity.setPriority(priority);
+        flowEntity.setFlowName(flowName);
+        flowEntity.setIdleTimeOut(idleTimeOut);
+        flowEntity.setHardTimeOut(hardTimeOut);
+        flowEntity.setCookie(cookie);
+        flowEntity.setMatchInfoList(listMatchInfo);
+        flowEntity.setInstructionInfoList(listInstructionInfo);
+
+        return flowEntity;
+    }
+
+    // TODO FIX ME
+    /*
+    public static Flow buildResyncFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
+            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
+            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isResync) {
+        FlowKey key = new FlowKey(new FlowId(flowId));
+        return new FlowBuilder().setMatch(buildMatches(listMatchInfo)).setKey(key)
+                .setPriority(Integer.valueOf(priority)).setInstructions(buildInstructions(listInstructionInfo))
+                .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
+                .setFlowName(flowName).setTableId(Short.valueOf(tableId)).setStrict(isStrict)
+                .setCookie(new FlowCookie(cookie)).setResyncFlag(isResync).build();
+    }
+    */
+    // TODO: CHECK IF THIS IS USED
+    public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
+            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo, List<InstructionInfo> listInstructionInfo) {
+        return MDSALUtil.buildFlow(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie,
+                listMatchInfo, listInstructionInfo, true);
+    }
+
+    public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
+            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
+            List<InstructionInfo> listInstructionInfo, boolean isStrict) {
+        FlowKey key = new FlowKey(new FlowId(flowId));
+        return new FlowBuilder().setMatch(buildMatches(listMatchInfo)).setKey(key)
+                .setPriority(Integer.valueOf(priority)).setInstructions(buildInstructions(listInstructionInfo))
+                .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
+                .setFlowName(flowName).setTableId(Short.valueOf(tableId)).setStrict(isStrict)
+                .setCookie(new FlowCookie(cookie)).build();
+    }
+
+ // TODO FIX ME
+    /*
+    public static Flow buildResyncFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
+            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
+            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isResync, boolean isSendFlowRem) {
+        FlowKey key = new FlowKey(new FlowId(flowId));
+        return new FlowBuilder().setMatch(buildMatches(listMatchInfo)).setKey(key)
+                .setPriority(Integer.valueOf(priority)).setInstructions(buildInstructions(listInstructionInfo))
+                .setBarrier(false).setInstallHw(true).setHardTimeout(hardTimeOut).setIdleTimeout(idleTimeOut)
+                .setFlowName(flowName).setTableId(Short.valueOf(tableId)).setStrict(isStrict)
+                .setCookie(new FlowCookie(cookie))
+                .setFlags(new FlowModFlags(false, false, false, false, isSendFlowRem)).setResyncFlag(isResync).build();
+
+    }
+    */
+/*
+    public static Flow buildFlow(short tableId, String flowId, int priority, String flowName, int idleTimeOut,
+            int hardTimeOut, BigInteger cookie, List<MatchInfo> listMatchInfo,
+            List<InstructionInfo> listInstructionInfo, boolean isStrict, boolean isSendFlowRem) {
+        return buildResyncFlow(tableId, flowId, priority, flowName, idleTimeOut, hardTimeOut, cookie, listMatchInfo,
+                listInstructionInfo, isStrict, false, isSendFlowRem);
+
+    }
+*/
+
+
+    public static GroupEntity buildGroupEntity(long dpnId, long groupId, String groupName, GroupTypes groupType,
+            List<BucketInfo> listBucketInfo) {
+
+        GroupEntity groupEntity = new GroupEntity(dpnId);
+
+        groupEntity.setGroupId(groupId);
+        groupEntity.setGroupName(groupName);
+        groupEntity.setGroupType(groupType);
+        groupEntity.setBucketInfoList(listBucketInfo);
+
+        return groupEntity;
+    }
+
+    // FIXME -- AS ReSync is not required for ODL VPN Service
+    /*
+    public static Group buildGroup(long groupId, String groupName, GroupTypes groupType, List<BucketInfo> listBucketInfo) {
+        return buildGroup(groupId, groupName, groupType, listBucketInfo, false);
+    }
+
+    public static Group buildGroup(long groupId, String groupName, GroupTypes groupType,
+            List<BucketInfo> listBucketInfo, boolean isResync) {
+        return new GroupBuilder().setBuckets(buildBuckets(listBucketInfo)).setKey(new GroupKey(new GroupId(groupId)))
+                .setBarrier(false).setGroupId(new GroupId(Long.valueOf(groupId))).setGroupType(groupType)
+                .setGroupName(groupName).setResyncFlag(isResync).build();
+    }
+*/
+    public static GetFlowStatisticsFromFlowTableInput buildGetFlowStatisticsFromFlowTableInput(short tableId,
+            List<MatchInfo> listMatchInfo, long dpnId) {
+        return new GetFlowStatisticsFromFlowTableInputBuilder()
+                .setTableId(Short.valueOf(tableId))
+                .setMatch(buildMatches(listMatchInfo))
+                .setNode(
+                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
+                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).build();
+
+    }
+
+    public static GetGroupStatisticsInput buildGetGroupStatistics(long groupId, long dpnId) {
+        return new GetGroupStatisticsInputBuilder()
+                .setGroupId(new GroupId(Long.valueOf(groupId)))
+                .setNode(
+                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
+                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance())).build();
+    }
+
+    public static TransmitPacketInput getPacketOutDefault(List<ActionInfo> actionInfos, byte[] payload, long dpnId) {
+        return new TransmitPacketInputBuilder()
+                .setAction(buildActions(actionInfos))
+                .setPayload(payload)
+                .setNode(
+                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
+                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance()))
+                .setIngress(getDefaultNodeConnRef(dpnId)).setEgress(getDefaultNodeConnRef(dpnId)).build();
+    }
+
+    public static TransmitPacketInput getPacketOut(List<ActionInfo> actionInfos, byte[] payload, long dpnId,
+            NodeConnectorRef ingress) {
+        return new TransmitPacketInputBuilder()
+                .setAction(buildActions(actionInfos))
+                .setPayload(payload)
+                .setNode(
+                        new NodeRef(InstanceIdentifier.builder(Nodes.class)
+                                .child(Node.class, new NodeKey(new NodeId("openflow:" + dpnId))).toInstance()))
+                .setIngress(ingress).setEgress(ingress).build();
+    }
+
+    private static List<Action> buildActions(List<ActionInfo> actions) {
+        List<Action> actionsList = new ArrayList<Action>();
+        for (ActionInfo actionInfo : actions) {
+            actionsList.add(actionInfo.buildAction());
+        }
+        return actionsList;
+    }
+
+    public static String longToIp(long ip, long mask) {
+        StringBuilder sb = new StringBuilder(15);
+        Joiner joiner = Joiner.on('.');
+
+        joiner.appendTo(sb, Bytes.asList(Ints.toByteArray((int) ip)));
+
+        sb.append("/" + mask);
+
+        return sb.toString();
+    }
+
+    protected static Buckets buildBuckets(List<BucketInfo> listBucketInfo) {
+        long i = 0;
+        if (listBucketInfo != null) {
+            BucketsBuilder bucketsBuilder = new BucketsBuilder();
+            List<Bucket> bucketList = new ArrayList<Bucket>();
+
+            for (BucketInfo bucketInfo : listBucketInfo) {
+                BucketBuilder bucketBuilder = new BucketBuilder();
+                List<Action> actionsList = new ArrayList<Action>();
+
+                bucketInfo.buildAndAddActions(actionsList);
+                bucketBuilder.setAction(actionsList);
+                bucketBuilder.setWeight(bucketInfo.getWeight());
+                bucketBuilder.setBucketId(new BucketId(i++));
+                bucketBuilder.setWeight(bucketInfo.getWeight()).setWatchPort(bucketInfo.getWatchPort())
+                        .setWatchGroup(bucketInfo.getWatchGroup());
+                bucketList.add(bucketBuilder.build());
+            }
+
+            bucketsBuilder.setBucket(bucketList);
+            return bucketsBuilder.build();
+        }
+
+        return EMPTY_Buckets;
+    }
+
+    protected static Instructions buildInstructions(List<InstructionInfo> listInstructionInfo) {
+        if (listInstructionInfo != null) {
+            List<Instruction> instructions = new ArrayList<Instruction>();
+            int instructionKey = 0;
+
+            for (InstructionInfo instructionInfo : listInstructionInfo) {
+                instructions.add(instructionInfo.buildInstruction(instructionKey));
+                instructionKey++;
+            }
+
+            return new InstructionsBuilder().setInstruction(instructions).build();
+        }
+
+        return EMPTY_Instructions;
+    }
+
+    protected static Match buildMatches(List<MatchInfo> listMatchInfo) {
+        if (listMatchInfo != null) {
+            MatchBuilder matchBuilder = new MatchBuilder();
+            Map<Class<?>, Object> mapMatchBuilder = new HashMap<Class<?>, Object>();
+
+            for (MatchInfo matchInfo : listMatchInfo) {
+                matchInfo.createInnerMatchBuilder(mapMatchBuilder);
+            }
+
+            for (MatchInfo matchInfo : listMatchInfo) {
+                matchInfo.setMatch(matchBuilder, mapMatchBuilder);
+            }
+
+            return matchBuilder.build();
+        }
+
+        return EMPTY_Matches;
+    }
+
+    // TODO: Check the port const
+    public static NodeConnectorRef getDefaultNodeConnRef(long nDpId) {
+        return getNodeConnRef(NODE_PREFIX + SEPARATOR + nDpId, "0xfffffffd");
+    }
+
+    public static NodeConnectorRef getNodeConnRef(long nDpId, String port) {
+        return getNodeConnRef(NODE_PREFIX + SEPARATOR + nDpId, port);
+    }
+
+    public static NodeConnectorRef getNodeConnRef(String sNodeId, String port) {
+        String sNodeConnectorKey;
+        StringBuilder sbTmp;
+        NodeId nodeId;
+        NodeKey nodeKey;
+        NodeConnectorId nodeConnectorId;
+        NodeConnectorKey nodeConnectorKey;
+        InstanceIdentifierBuilder<Nodes> nodesInstanceIdentifierBuilder;
+        InstanceIdentifierBuilder<Node> nodeInstanceIdentifierBuilder;
+        InstanceIdentifierBuilder<NodeConnector> nodeConnectorInstanceIdentifierBuilder;
+        InstanceIdentifier<NodeConnector> nodeConnectorInstanceIdentifier;
+        NodeConnectorRef nodeConnectorRef;
+
+        sbTmp = new StringBuilder();
+
+        sbTmp.append(sNodeId);
+        sbTmp.append(SEPARATOR);
+        sbTmp.append(port);
+
+        sNodeConnectorKey = sbTmp.toString();
+        nodeConnectorId = new NodeConnectorId(sNodeConnectorKey);
+        nodeConnectorKey = new NodeConnectorKey(nodeConnectorId);
+
+        nodeId = new NodeId(sNodeId);
+        nodeKey = new NodeKey(nodeId);
+
+        nodesInstanceIdentifierBuilder = InstanceIdentifier.<Nodes> builder(Nodes.class);
+        nodeInstanceIdentifierBuilder = nodesInstanceIdentifierBuilder.<Node, NodeKey> child(Node.class, nodeKey);
+        nodeConnectorInstanceIdentifierBuilder = nodeInstanceIdentifierBuilder.<NodeConnector, NodeConnectorKey> child(
+                NodeConnector.class, nodeConnectorKey);
+        nodeConnectorInstanceIdentifier = nodeConnectorInstanceIdentifierBuilder.toInstance();
+        nodeConnectorRef = new NodeConnectorRef(nodeConnectorInstanceIdentifier);
+        return nodeConnectorRef;
+    }
+
+    public static long getDpnIdFromNodeName(NodeId nodeId) {
+        return getDpnIdFromNodeName(nodeId.getValue());
+    }
+
+    public static long getDpnIdFromNodeName(String sMdsalNodeName) {
+        String sDpId = sMdsalNodeName.substring(sMdsalNodeName.lastIndexOf(":") + 1);
+        return Long.parseLong(sDpId);
+    }
+
+    public static long getOfPortNumberFromPortName(NodeConnectorId nodeConnectorId) {
+        return getOfPortNumberFromPortName(nodeConnectorId.getValue());
+    }
+
+    public static long getOfPortNumberFromPortName(String sMdsalPortName) {
+        String sPortNumber = sMdsalPortName.substring(sMdsalPortName.lastIndexOf(":") + 1);
+        return Long.parseLong(sPortNumber);
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchFieldType.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchFieldType.java
new file mode 100644 (file)
index 0000000..f38acf7
--- /dev/null
@@ -0,0 +1,650 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Prefix;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.PortNumber;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.EtherType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetDestinationBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetSourceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.ethernet.match.fields.EthernetTypeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.EthernetMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.IpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.MetadataBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.ProtocolMatchFieldsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.ArpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.Ipv4MatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.TcpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._4.match.UdpMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.protocol.match.fields.PbbBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpOp;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpSpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.ArpTpa;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.EthType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.InPort;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.IpProto;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Dst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Ipv4Src;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MatchField;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.Metadata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.MplsLabel;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.PbbIsid;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.SalOpenflowBasicClass;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TcpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpDst;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.UdpSrc;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.VlanVid;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatch;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.set.field.match.SetFieldMatchBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.TunnelBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.table.types.rev131026.TunnelId;
+
+public enum MatchFieldType {
+       eth_src {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return EthSrc.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .get(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder == null) {
+                               ethernetMatchBuilder = new EthernetMatchBuilder();
+                               mapMatchBuilder.put(EthernetMatchBuilder.class, ethernetMatchBuilder);
+                       }
+
+                       ethernetMatchBuilder.setEthernetSource(new EthernetSourceBuilder().setAddress(
+                                       new MacAddress(matchInfo.getStringMatchValues()[0])).build());
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .remove(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder != null) {
+                               matchBuilderInOut.setEthernetMatch(ethernetMatchBuilder.build());
+                       }
+               }
+       },
+
+       eth_dst {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return EthDst.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .get(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder == null) {
+                               ethernetMatchBuilder = new EthernetMatchBuilder();
+                               mapMatchBuilder.put(EthernetMatchBuilder.class, ethernetMatchBuilder);
+                       }
+
+                       ethernetMatchBuilder.setEthernetDestination(new EthernetDestinationBuilder().setAddress(
+                                       new MacAddress(matchInfo.getStringMatchValues()[0])).build());
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .remove(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder != null) {
+                               matchBuilderInOut.setEthernetMatch(ethernetMatchBuilder.build());
+                       }
+               }
+       },
+
+       eth_type {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return EthType.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .get(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder == null) {
+                               ethernetMatchBuilder = new EthernetMatchBuilder();
+                               mapMatchBuilder.put(EthernetMatchBuilder.class, ethernetMatchBuilder);
+                       }
+
+                       ethernetMatchBuilder.setEthernetType(new EthernetTypeBuilder().setType(
+                                       new EtherType(matchInfo.getMatchValues()[0])).build());
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       EthernetMatchBuilder ethernetMatchBuilder = (EthernetMatchBuilder) mapMatchBuilder
+                                       .remove(EthernetMatchBuilder.class);
+
+                       if (ethernetMatchBuilder != null) {
+                               matchBuilderInOut.setEthernetMatch(ethernetMatchBuilder.build());
+                       }
+               }
+       },
+
+       in_port {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return InPort.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       // NodeConnectorId format -> openflow:<dpnId>:<portId>
+                       StringBuffer nodeConnectorId = new StringBuffer().append("openflow:").append(matchInfo.getMatchValues()[0])
+                       .append(':').append(matchInfo.getMatchValues()[1]);
+                       matchBuilderInOut.setInPort(new NodeConnectorId(nodeConnectorId.toString()));
+               }
+       },
+
+       ip_proto {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return IpProto.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       IpMatchBuilder ipMatchBuilder = (IpMatchBuilder) mapMatchBuilder.get(IpMatchBuilder.class);
+
+                       if (ipMatchBuilder == null) {
+                               ipMatchBuilder = new IpMatchBuilder();
+                               mapMatchBuilder.put(IpMatchBuilder.class, ipMatchBuilder);
+                       }
+
+                       ipMatchBuilder.setIpProtocol(Short.valueOf((short) matchInfo.getMatchValues()[0])).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       IpMatchBuilder ipMatchBuilder = (IpMatchBuilder) mapMatchBuilder.remove(IpMatchBuilder.class);
+
+                       if (ipMatchBuilder != null) {
+                               matchBuilderInOut.setIpMatch(ipMatchBuilder.build());
+                       }
+               }
+       },
+
+       ipv4_dst {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return Ipv4Dst.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       Ipv4MatchBuilder ipv4MatchBuilder = (Ipv4MatchBuilder) mapMatchBuilder.get(Ipv4MatchBuilder.class);
+
+                       if (ipv4MatchBuilder == null) {
+                               ipv4MatchBuilder = new Ipv4MatchBuilder();
+                               mapMatchBuilder.put(Ipv4MatchBuilder.class, ipv4MatchBuilder);
+                       }
+
+                       long[] prefix = matchInfo.getMatchValues();
+                       ipv4MatchBuilder.setIpv4Destination(new Ipv4Prefix(MDSALUtil.longToIp(prefix[0], prefix[1]))).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       Ipv4MatchBuilder ipv4MatchBuilder = (Ipv4MatchBuilder) mapMatchBuilder.remove(Ipv4MatchBuilder.class);
+
+                       if (ipv4MatchBuilder != null) {
+                               matchBuilderInOut.setLayer3Match(ipv4MatchBuilder.build());
+                       }
+               }
+       },
+
+       ipv4_src {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return Ipv4Src.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       Ipv4MatchBuilder ipv4MatchBuilder = (Ipv4MatchBuilder) mapMatchBuilder.get(Ipv4MatchBuilder.class);
+
+                       if (ipv4MatchBuilder == null) {
+                               ipv4MatchBuilder = new Ipv4MatchBuilder();
+                               mapMatchBuilder.put(Ipv4MatchBuilder.class, ipv4MatchBuilder);
+                       }
+
+                       long[] prefix = matchInfo.getMatchValues();
+                       ipv4MatchBuilder.setIpv4Source(new Ipv4Prefix(MDSALUtil.longToIp(prefix[0], prefix[1]))).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       Ipv4MatchBuilder ipv4MatchBuilder = (Ipv4MatchBuilder) mapMatchBuilder.remove(Ipv4MatchBuilder.class);
+
+                       if (ipv4MatchBuilder != null) {
+                               matchBuilderInOut.setLayer3Match(ipv4MatchBuilder.build());
+                       }
+               }
+       },
+
+       arp_op {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return ArpOp.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.get(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder == null) {
+                               arpMatchBuilder = new ArpMatchBuilder();
+                               mapMatchBuilder.put(ArpMatchBuilder.class, arpMatchBuilder);
+                       }
+
+                       arpMatchBuilder.setArpOp(Integer.valueOf((int) matchInfo.getMatchValues()[0]));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.remove(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer3Match(arpMatchBuilder.build());
+                       }
+               }
+       },
+
+       arp_tpa {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return ArpTpa.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.get(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder == null) {
+                               arpMatchBuilder = new ArpMatchBuilder();
+                               mapMatchBuilder.put(ArpMatchBuilder.class, arpMatchBuilder);
+                       }
+
+                       long[] prefix = matchInfo.getMatchValues();
+                       arpMatchBuilder.setArpTargetTransportAddress(new Ipv4Prefix(MDSALUtil.longToIp(prefix[0], prefix[1])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.remove(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer3Match(arpMatchBuilder.build());
+                       }
+               }
+       },
+
+       arp_spa {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return ArpSpa.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.get(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder == null) {
+                               arpMatchBuilder = new ArpMatchBuilder();
+                               mapMatchBuilder.put(ArpMatchBuilder.class, arpMatchBuilder);
+                       }
+
+                       long[] prefix = matchInfo.getMatchValues();
+                       arpMatchBuilder.setArpSourceTransportAddress(new Ipv4Prefix(MDSALUtil.longToIp(prefix[0], prefix[1])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ArpMatchBuilder arpMatchBuilder = (ArpMatchBuilder) mapMatchBuilder.remove(ArpMatchBuilder.class);
+
+                       if (arpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer3Match(arpMatchBuilder.build());
+                       }
+               }
+       },
+
+       metadata {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return Metadata.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       MetadataBuilder metadataBuilder = (MetadataBuilder) mapMatchBuilder.get(MetadataBuilder.class);
+
+                       if (metadataBuilder == null) {
+                               metadataBuilder = new MetadataBuilder();
+                               mapMatchBuilder.put(MetadataBuilder.class, metadataBuilder);
+                       }
+
+                       BigInteger[] metadataValues = matchInfo.getBigMatchValues();
+                       metadataBuilder.setMetadata(metadataValues[0]).setMetadataMask(metadataValues[1]).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       MetadataBuilder metadataBuilder = (MetadataBuilder) mapMatchBuilder.remove(MetadataBuilder.class);
+
+                       if (metadataBuilder != null) {
+                               matchBuilderInOut.setMetadata(metadataBuilder.build());
+                       }
+               }
+       },
+
+       mpls_label {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return MplsLabel.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = (ProtocolMatchFieldsBuilder) mapMatchBuilder
+                                       .get(ProtocolMatchFieldsBuilder.class);
+
+                       if (protocolMatchFieldsBuilder == null) {
+                               protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
+                               mapMatchBuilder.put(ProtocolMatchFieldsBuilder.class, protocolMatchFieldsBuilder);
+                       }
+
+                       protocolMatchFieldsBuilder.setMplsLabel(Long.valueOf(matchInfo.getStringMatchValues()[0])).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = (ProtocolMatchFieldsBuilder) mapMatchBuilder
+                                       .remove(ProtocolMatchFieldsBuilder.class);
+
+                       if (protocolMatchFieldsBuilder != null) {
+                               matchBuilderInOut.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+                       }
+               }
+       },
+
+       pbb_isid {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return PbbIsid.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = (ProtocolMatchFieldsBuilder) mapMatchBuilder
+                                       .get(ProtocolMatchFieldsBuilder.class);
+
+                       if (protocolMatchFieldsBuilder == null) {
+                               protocolMatchFieldsBuilder = new ProtocolMatchFieldsBuilder();
+                               mapMatchBuilder.put(ProtocolMatchFieldsBuilder.class, protocolMatchFieldsBuilder);
+                       }
+
+                       protocolMatchFieldsBuilder.setPbb(new PbbBuilder().setPbbIsid(Long.valueOf(matchInfo.getMatchValues()[0]))
+                                       .build());
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       ProtocolMatchFieldsBuilder protocolMatchFieldsBuilder = (ProtocolMatchFieldsBuilder) mapMatchBuilder
+                                       .remove(ProtocolMatchFieldsBuilder.class);
+
+                       if (protocolMatchFieldsBuilder != null) {
+                               matchBuilderInOut.setProtocolMatchFields(protocolMatchFieldsBuilder.build());
+                       }
+               }
+       },
+
+       tcp_dst {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return TcpDst.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TcpMatchBuilder tcpMatchBuilder = (TcpMatchBuilder) mapMatchBuilder.get(TcpMatchBuilder.class);
+
+                       if (tcpMatchBuilder == null) {
+                               tcpMatchBuilder = new TcpMatchBuilder();
+                               mapMatchBuilder.put(TcpMatchBuilder.class, tcpMatchBuilder);
+                       }
+
+                       tcpMatchBuilder.setTcpDestinationPort(new PortNumber(Integer.valueOf((int) matchInfo.getMatchValues()[0])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TcpMatchBuilder tcpMatchBuilder = (TcpMatchBuilder) mapMatchBuilder.remove(TcpMatchBuilder.class);
+
+                       if (tcpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer4Match(tcpMatchBuilder.build());
+                       }
+               }
+       },
+
+       tcp_src {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return TcpSrc.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TcpMatchBuilder tcpMatchBuilder = (TcpMatchBuilder) mapMatchBuilder.get(TcpMatchBuilder.class);
+
+                       if (tcpMatchBuilder == null) {
+                               tcpMatchBuilder = new TcpMatchBuilder();
+                               mapMatchBuilder.put(TcpMatchBuilder.class, tcpMatchBuilder);
+                       }
+
+                       tcpMatchBuilder.setTcpSourcePort(new PortNumber(Integer.valueOf((int) matchInfo.getMatchValues()[0])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TcpMatchBuilder tcpMatchBuilder = (TcpMatchBuilder) mapMatchBuilder.remove(TcpMatchBuilder.class);
+
+                       if (tcpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer4Match(tcpMatchBuilder.build());
+                       }
+               }
+       },
+
+       udp_dst {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return UdpDst.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       UdpMatchBuilder udpMatchBuilder = (UdpMatchBuilder) mapMatchBuilder.get(UdpMatchBuilder.class);
+
+                       if (udpMatchBuilder == null) {
+                               udpMatchBuilder = new UdpMatchBuilder();
+                               mapMatchBuilder.put(UdpMatchBuilder.class, udpMatchBuilder);
+                       }
+
+                       udpMatchBuilder.setUdpDestinationPort(new PortNumber(Integer.valueOf((int) matchInfo.getMatchValues()[0])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       UdpMatchBuilder udpMatchBuilder = (UdpMatchBuilder) mapMatchBuilder.remove(UdpMatchBuilder.class);
+
+                       if (udpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer4Match(udpMatchBuilder.build());
+                       }
+               }
+       },
+
+       udp_src {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return UdpSrc.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       UdpMatchBuilder udpMatchBuilder = (UdpMatchBuilder) mapMatchBuilder.get(UdpMatchBuilder.class);
+
+                       if (udpMatchBuilder == null) {
+                               udpMatchBuilder = new UdpMatchBuilder();
+                               mapMatchBuilder.put(UdpMatchBuilder.class, udpMatchBuilder);
+                       }
+
+                       udpMatchBuilder.setUdpSourcePort(new PortNumber(Integer.valueOf((int) matchInfo.getMatchValues()[0])));
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       UdpMatchBuilder udpMatchBuilder = (UdpMatchBuilder) mapMatchBuilder.remove(UdpMatchBuilder.class);
+
+                       if (udpMatchBuilder != null) {
+                               matchBuilderInOut.setLayer4Match(udpMatchBuilder.build());
+                       }
+               }
+       },
+       tunnel_id {
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TunnelBuilder tunnelBuilder = (TunnelBuilder) mapMatchBuilder.get(TunnelBuilder.class);
+
+                       if (tunnelBuilder == null) {
+                               tunnelBuilder = new TunnelBuilder();
+                               mapMatchBuilder.put(TunnelBuilder.class, tunnelBuilder);
+                       }
+
+                       BigInteger[] tunnelIdValues = matchInfo.getBigMatchValues();
+                       tunnelBuilder.setTunnelId(tunnelIdValues[0]).setTunnelMask(tunnelIdValues[1]).build();
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       TunnelBuilder tunnelBuilder = (TunnelBuilder) mapMatchBuilder.remove(TunnelBuilder.class);
+
+                       if (tunnelBuilder != null) {
+                               matchBuilderInOut.setTunnel(tunnelBuilder.build());
+                       }
+               }
+
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return TunnelId.class;
+               }
+
+       },
+
+       vlan_vid {
+               @Override
+               protected Class<? extends MatchField> getMatchType() {
+                       return VlanVid.class;
+               }
+
+               @Override
+               public void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       VlanMatchBuilder vlanMatchBuilder = (VlanMatchBuilder) mapMatchBuilder.get(VlanMatchBuilder.class);
+
+                       if (vlanMatchBuilder == null) {
+                               vlanMatchBuilder = new VlanMatchBuilder();
+                               mapMatchBuilder.put(VlanMatchBuilder.class, vlanMatchBuilder);
+                       }
+
+                       vlanMatchBuilder.setVlanId(new VlanIdBuilder()
+                       .setVlanId(new VlanId(Integer.valueOf((int) matchInfo.getMatchValues()[0])))
+                       .setVlanIdPresent(((int) matchInfo.getMatchValues()[0] == 0) ? Boolean.FALSE : Boolean.TRUE)
+                       .build());
+               }
+
+               @Override
+               public void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder) {
+                       VlanMatchBuilder vlanMatchBuilder = (VlanMatchBuilder) mapMatchBuilder.remove(VlanMatchBuilder.class);
+
+                       if (vlanMatchBuilder != null) {
+                               matchBuilderInOut.setVlanMatch(vlanMatchBuilder.build());
+                       }
+               }
+       };
+
+       /*
+       public SetFieldMatch buildSetFieldMatch(XtensionType xtype) {
+               if (xtype == null || xtype.getMatchMaskType() == 
+                               SalOfaMatchMaskType.OFPMMNOMASK) {
+                       return new 
+                                       SetFieldMatchBuilder().setHasMask(false).setMatchType(getMatchType())
+                                       .setSalOxmClass(SalOpenflowBasicClass.class).build();
+               }
+
+               return new SetFieldMatchBuilder()
+               .setHasMask(true)
+               .setMatchType(getMatchType())
+               .setSalOxmClass(SalOpenflowBasicClass.class)
+               .addAugmentation(
+                               ExperimenterSetFieldMatch.class,
+                               new 
+                               ExperimenterSetFieldMatchBuilder().setMatchMaskType(xtype.getMatchMaskType())
+                               .setTlvMatchMask(xtype.getByteBuf()).build()).build();
+
+
+       }
+*/
+
+       // New one for ODL without the Extension --CHECK
+       /*
+       public SetFieldMatch buildSetFieldMatch() {
+               
+               return new SetFieldMatchBuilder().setHasMask(false).setMatchType(getMatchType())
+                                       .setSalOxmClass(SalOpenflowBasicClass.class).build();
+                                       
+               return null;
+               }
+*/
+               
+       
+       public abstract void createInnerMatchBuilder(MatchInfo matchInfo, Map<Class<?>, Object> mapMatchBuilder);
+
+       public abstract void setMatch(MatchBuilder matchBuilderInOut, MatchInfo matchInfo,
+                       Map<Class<?>, Object> mapMatchBuilder);
+
+       protected abstract Class<? extends MatchField> getMatchType();
+
+       protected boolean hasMatchFieldMask() {
+               // Override this to return true
+                               return false;
+       }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchInfo.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MatchInfo.java
new file mode 100644 (file)
index 0000000..da82c40
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.io.Serializable;
+import java.math.BigInteger;
+import java.util.Map;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder;
+
+public class MatchInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    private final MatchFieldType m_matchField;
+    private long[] m_alMatchValues;
+    private BigInteger[] m_aBigIntValues;
+    private String[] m_asMatchValues;
+
+    public MatchInfo(MatchFieldType matchField, long[] alMatchValues) {
+        m_matchField = matchField;
+        m_alMatchValues = alMatchValues;
+    }
+
+    public MatchInfo(MatchFieldType matchField, BigInteger[] alBigMatchValues) {
+        m_matchField = matchField;
+        m_aBigIntValues = alBigMatchValues;
+    }
+
+    public MatchInfo(MatchFieldType matchField, String[] alStringMatchValues) {
+        m_matchField = matchField;
+        m_asMatchValues = alStringMatchValues;
+    }
+
+    public void createInnerMatchBuilder(Map<Class<?>, Object> mapMatchBuilder) {
+        m_matchField.createInnerMatchBuilder(this, mapMatchBuilder);
+    }
+
+    public void setMatch(MatchBuilder matchBuilder, Map<Class<?>, Object> mapMatchBuilder) {
+        m_matchField.setMatch(matchBuilder, this, mapMatchBuilder);
+    }
+
+    public MatchFieldType getMatchField() {
+        return m_matchField;
+    }
+
+    public long[] getMatchValues() {
+        return m_alMatchValues;
+    }
+
+    public BigInteger[] getBigMatchValues() {
+        return m_aBigIntValues;
+    }
+
+    public String[] getStringMatchValues() {
+        return m_asMatchValues;
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataConstants.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataConstants.java
new file mode 100644 (file)
index 0000000..b1c2cf8
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+
+public class MetaDataConstants {
+    // Base cookie value
+    public static final BigInteger COOKIE_SCF_BASE = new BigInteger("7000000", 16);
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/MetaDataUtil.java
new file mode 100644 (file)
index 0000000..0628cda
--- /dev/null
@@ -0,0 +1,159 @@
+package org.opendaylight.vpnservice.mdsalutil;
+
+import java.math.BigInteger;
+
+public class MetaDataUtil {
+
+    public static final BigInteger METADATA_NO_MASK = new BigInteger("0000000000000000", 16);
+    public static final BigInteger METADATA_MASK_SCF_MATCH = new BigInteger("FF00000000000000", 16);
+    public static final BigInteger METADATA_MASK_SUBP_MATCH = new BigInteger("00000000FFFF0000", 16);
+    public static final BigInteger METADATA_MASK_APPP_MATCH = new BigInteger("000000000000FFFF", 16);
+    public static final BigInteger METADATA_MASK_LPORT_MATCH = new BigInteger("00FFFF0000000000", 16);
+    public static final BigInteger METADATA_MASK_SCID_MATCH = new BigInteger("000000000000FFFF", 16);
+    public static final BigInteger METADATA_MASK_SCID_WRITE = new BigInteger("000000000000FFFF", 16);
+    public static final BigInteger METADATA_MASK_SUBP_WRITE = new BigInteger("00000000FFFF0000", 16);
+    public static final BigInteger METADATA_MASK_APPP_WRITE = new BigInteger("000000000000FFFF", 16);
+    public static final BigInteger MASK_DMAC_WRITE = new BigInteger("0000FFFFFFFFFFFF", 16);
+    public static final BigInteger METADATA_MASK_SCF_WRITE = new BigInteger("FF00000000000000", 16);
+    public static final BigInteger METADATA_MASK_LPORT_WRITE = new BigInteger("00FFFF0000000000", 16);
+    public static final BigInteger METADATA_MASK_LPORT_TAG = new BigInteger("1FFFFF0000000000", 16);
+    public static final BigInteger METADATA_MASK_SERVICE_INDEX = new BigInteger("E000000000000000", 16);
+    public static final BigInteger METADATA_MASK_SERVICE = new BigInteger("000000FFFF000000", 16);
+    public static final BigInteger METADA_MASK_TUNNEL_ID_VNI = new BigInteger("00000000FFFFFF00", 16);
+    public static final BigInteger METADATA_MASK_LABEL_ITM = new BigInteger("40FFFFFF000000FF", 16);
+    public static final BigInteger METADA_MASK_VALID_TUNNEL_ID_BIT_AND_TUNNEL_ID = new BigInteger("08000000FFFFFF00", 16);
+    public static final BigInteger METADATA_MASK_LABEL_L3 = new BigInteger("000000FFFF000000", 16);
+    public static final BigInteger METADATA_MASK_VRFID = new BigInteger("00000000FFFFFFFF", 16);
+
+    public static BigInteger getMetadataSCF(int scfTag) {
+        return (new BigInteger("FF", 16).and(BigInteger.valueOf(scfTag))).shiftLeft(56);
+    }
+
+    public static BigInteger getMetadataSCID(int scId) {
+        return BigInteger.valueOf(scId).and(new BigInteger("FFFF", 16));
+    }
+
+    public static BigInteger getMetadataSubProfID(int subProfId) {
+        return (BigInteger.valueOf(subProfId).and(new BigInteger("FFFF", 16))).shiftLeft(16);
+    }
+
+    public static BigInteger getMetadataAppProfID(int appProfId) {
+        return BigInteger.valueOf(appProfId).and(new BigInteger("FFFF", 16));
+    }
+
+    public static BigInteger getMetadataAPPP(int appProfId) {
+        return BigInteger.valueOf(appProfId).and(new BigInteger("FFFF", 16));
+    }
+
+    public static BigInteger getCookieSCFEthTypeFilter(int scfTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0120000", 16)).add(BigInteger.valueOf(scfTag));
+    }
+
+    public static BigInteger getCookieSubFilter(int scfTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0310000", 16)).add(BigInteger.valueOf(scfTag));
+    }
+
+    public static BigInteger getCookieProfMap(int scfTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0510000", 16)).add(BigInteger.valueOf(scfTag));
+    }
+
+    public static BigInteger getCookieSCFAppFilter(int scfTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0410000", 16)).add(BigInteger.valueOf(scfTag));
+    }
+
+    public static BigInteger getEthDestForIpNextHop(int groupId) {
+        return BigInteger.valueOf(groupId).and(MASK_DMAC_WRITE);
+    }
+    public static long getIpAddress(byte[] rawIpAddress) {
+        return (((rawIpAddress[0] & 0xFF) << (3 * 8)) + ((rawIpAddress[1] & 0xFF) << (2 * 8))
+                + ((rawIpAddress[2] & 0xFF) << (1 * 8)) + (rawIpAddress[3] & 0xFF)) & 0xffffffffL;
+    }
+
+    public static BigInteger getMetadataLPort(int lPortTag) {
+        return (new BigInteger("FFFF", 16).and(BigInteger.valueOf(lPortTag))).shiftLeft(40);
+    }
+
+    public static BigInteger getMetadataScHop(int scfInstanceTag, int scfPortTag, int serviceChainId) {
+        return getMetadataSCF(scfInstanceTag).or(getMetadataLPort(scfPortTag)).or(getMetadataSCID(serviceChainId));
+    }
+
+    public static BigInteger getMetadataMaskScHop() {
+        return METADATA_MASK_SCF_WRITE.or(METADATA_MASK_LPORT_WRITE).or(METADATA_MASK_SCID_WRITE);
+    }
+
+    public static BigInteger getCookieSCHop(int scfInstanceTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0610000", 16)).add(BigInteger.valueOf(scfInstanceTag));
+    }
+
+    public static BigInteger getMetadataScfPort(int scfInstanceTag, int scfPortTag) {
+        return getMetadataSCF(scfInstanceTag).or(getMetadataLPort(scfPortTag));
+    }
+
+    public static BigInteger getMetadataMaskScfPort() {
+        return METADATA_MASK_LPORT_WRITE.or(METADATA_MASK_SCF_WRITE);
+    }
+
+    public static BigInteger getCookieSCFPort() {
+        return new BigInteger("5000000", 16);
+    }
+
+    public static BigInteger getCookieSCFIpv4EthTypeFilter(int scfInstanceTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0100000", 16)).add(BigInteger.valueOf(scfInstanceTag));
+    }
+
+    public static BigInteger getCookieSCFArpEthTypeFilter(int scfInstanceTag) {
+        return MetaDataConstants.COOKIE_SCF_BASE.add(new BigInteger("0110000", 16)).add(BigInteger.valueOf(scfInstanceTag));
+    }
+
+    public static BigInteger getLportTagMetaData(int lportTag) {
+        return new BigInteger("1FFFFF", 16).and(BigInteger.valueOf(lportTag)).shiftLeft(40);
+    }
+
+    public static BigInteger getLportFromMetadata(BigInteger metadata) {
+        return (metadata.and(METADATA_MASK_LPORT_TAG)).shiftRight(40);
+    }
+
+    public static BigInteger getServiceIndexMetaData(int serviceIndex) {
+        return new BigInteger("7", 16).and(BigInteger.valueOf(serviceIndex)).shiftLeft(61);
+    }
+
+    public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex) {
+        return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag));
+    }
+
+    public static BigInteger getMetaDataMaskForLPortDispatcher() {
+        return METADATA_MASK_SERVICE_INDEX.or(METADATA_MASK_LPORT_TAG);
+    }
+
+    public static BigInteger getWriteMetaDataMaskForServicePorts() {
+        return METADATA_MASK_SERVICE_INDEX.or(METADATA_MASK_LPORT_TAG).or(METADATA_MASK_SERVICE);
+    }
+
+    public static BigInteger getMetaDataMaskForLPortDispatcher(BigInteger metadataMaskForServiceIndex, 
+            BigInteger metadataMaskForLPortTag, BigInteger metadataMaskForService) {
+        return metadataMaskForServiceIndex.or(metadataMaskForLPortTag).or(metadataMaskForService);
+    }
+
+    public static BigInteger getMetaDataForLPortDispatcher(int lportTag, short serviceIndex,
+            BigInteger serviceMetaData) {
+        return getServiceIndexMetaData(serviceIndex).or(getLportTagMetaData(lportTag)).or(serviceMetaData);
+    }
+
+
+    public static BigInteger getVmLportTagMetaData(int vrfId) {
+        return BigInteger.valueOf(vrfId);
+    }
+
+    public static BigInteger getTunnelIdWithVni(int vni) {
+        return BigInteger.valueOf(vni).shiftLeft(8);
+    }
+
+    /**
+     * For the tunnel id with VNI and valid-vni-flag set, the most significant byte
+     * should have 08. So, shifting 08 to 7 bytes (56 bits) and the result is OR-ed with
+     * VNI being shifted to 1 byte.
+     */
+    public static BigInteger getTunnelIdWithValidVniBitAndVniSet(int vni) {
+        return BigInteger.valueOf(0X08).shiftLeft(56).or(BigInteger.valueOf(vni).shiftLeft(8));
+    }
+}
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/NwConstants.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/NwConstants.java
new file mode 100644 (file)
index 0000000..37d3586
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  All rights reserved.
+ *
+ */
+package org.opendaylight.vpnservice.mdsalutil;
+
+public class NwConstants {
+
+    // EthType Values
+    public static final int ETHTYPE_802_1Q            = 0X8100;
+    public static final int ETHTYPE_IPV4              = 0X0800;
+    public static final int ETHTYPE_ARP               = 0X0806;
+
+    public static final int ETHTYPE_MPLS_UC           = 0X8847;
+    public static final int ETHTYPE_PBB               = 0X88E7;
+    
+    //Protocol Type
+    public static final int IP_PROT_UDP = 17;
+    public static final int IP_PROT_GRE = 47;
+
+    //Default Port
+    public static final int UDP_DEFAULT_PORT = 4789;
+
+    // Table IDs
+    public static final short PRECHECK_TABLE          = 0;
+    public static final short PORT_VLAN_TABLE         = 0;
+
+    // Table Max Entries
+    public static final long INGRESS_TABLE_MAX_ENTRY  = 1000;
+    public static final long PRECHECK_TABLE_MAX_ENTRY = 100;
+
+    // Flow Actions
+    public static final int ADD_FLOW = 0;
+    public static final int DEL_FLOW = 1;
+    public static final int MOD_FLOW = 2;
+
+    // Flow Constants
+    public static final String FLOWID_SEPARATOR = ".";
+    public static final int TABLE_MISS_FLOW = 0;
+    public static final int TABLE_MISS_PRIORITY = 0;
+
+    // Misc FIXME: Find new place for this
+    public static final String DPN_STATE_CACHE = "dpn.state.cache";
+    public static final String DPN_SYNCSTATUS_CACHE = "dpn.resync.status.cache";
+    public static final String STATISTICS_LOCK_PREFIX ="scf.statistics.lock";
+    public static final String STATISTICS_LOCK_SEPARATOR =".";
+    public static final int STATISTICS_LOCK_RETRY_COUNT =1800;
+}
\ No newline at end of file
diff --git a/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/interfaces/IMdsalApiManager.java b/mdsalutil/mdsalutil-api/src/main/java/org/opendaylight/vpnservice/mdsalutil/interfaces/IMdsalApiManager.java
new file mode 100644 (file)
index 0000000..f3de364
--- /dev/null
@@ -0,0 +1,35 @@
+package org.opendaylight.vpnservice.mdsalutil.interfaces;
+
+//import java.math.BigInteger;
+import java.util.List;
+
+import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
+//import org.opendaylight.vpnservice.mdsalutil.BucketInfo;
+//import org.opendaylight.vpnservice.mdsalutil.DpnState;
+import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
+import org.opendaylight.vpnservice.mdsalutil.GroupEntity;
+//import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+//import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+//import org.opendaylight.vpnservice.mdsalutil.SyncStatus;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
+
+public interface IMdsalApiManager {
+
+    public void installFlow(FlowEntity flowEntity);
+
+    public void removeFlow(FlowEntity flowEntity);
+
+    public void installGroup(GroupEntity groupEntity);
+
+    public void modifyGroup(GroupEntity groupEntity);
+
+    public void removeGroup(GroupEntity groupEntity);
+
+    public void sendPacketOut(long lDpnId, int groupId, byte[] payload);
+
+    public void sendPacketOutWithActions(long lDpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos);
+
+    public void sendARPPacketOutWithActions(long dpid, byte[] payload, List<ActionInfo> action_info);
+
+ }
diff --git a/mdsalutil/mdsalutil-impl/pom.xml b/mdsalutil/mdsalutil-impl/pom.xml
new file mode 100644 (file)
index 0000000..933bb74
--- /dev/null
@@ -0,0 +1,115 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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">
+    
+    <parent>
+        <groupId>org.opendaylight.controller</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+        <relativePath/>
+    </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>mdsalutil-impl</artifactId>
+    <version>0.0.1-SNAPSHOT</version>    
+    <packaging>bundle</packaging>
+    
+    <properties>
+        <xtend.version>2.4.3</xtend.version>
+        <bundle.plugin.version>2.4.0</bundle.plugin.version>
+        <maven.clean.plugin.version>2.5</maven.clean.plugin.version>
+    </properties>
+    <dependencies>
+        <dependency>
+            <groupId>org.opendaylight.controller</groupId>
+            <artifactId>sal-binding-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-service</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-base</artifactId>
+        </dependency>
+        <!--<dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-flow-management</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>org.opendaylight.controller.model</groupId>
+            <artifactId>model-inventory</artifactId>
+        </dependency>
+        <!--<dependency>
+            <groupId>org.eclipse.xtend</groupId>
+            <artifactId>org.eclipse.xtend.lib</artifactId>
+            <version>${xtend.version}</version>
+        </dependency>-->
+        <!--<dependency>
+            <groupId>equinoxSDK381</groupId>
+            <artifactId>org.eclipse.osgi</artifactId>
+        </dependency>-->
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.google.guava</groupId>
+            <artifactId>guava</artifactId>
+        </dependency>
+        <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>mdsalutil-api</artifactId>
+      <version>${project.version}</version>
+      </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.felix</groupId>
+                <artifactId>maven-bundle-plugin</artifactId>
+                <version>${bundle.plugin.version}</version>
+                <extensions>true</extensions>
+                <configuration>
+                    <instructions>
+                        <Export-Package>
+                        </Export-Package>
+                        <Service-Component>
+                        </Service-Component>
+                    </instructions>
+                    <manifestLocation>${project.basedir}/META-INF</manifestLocation>
+                </configuration>
+            </plugin>
+            <!--<plugin>
+                <groupId>org.eclipse.xtend</groupId>
+                <artifactId>xtend-maven-plugin</artifactId>
+                <version>${xtend.version}</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>compile</goal>
+                        </goals>
+                        <configuration>
+                            <outputDirectory>${basedir}/src/main/xtend-gen</outputDirectory>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>-->
+            <plugin>
+                <artifactId>maven-clean-plugin</artifactId>
+                <version>${maven.clean.plugin.version}</version>
+                <configuration>
+                    <filesets>
+                        <fileset>
+                            <directory>${basedir}/src/main/xtend-gen</directory>
+                            <includes>
+                                <include>**</include>
+                            </includes>
+                        </fileset>
+                    </filesets>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/mdsalutil/mdsalutil-impl/src/main/config/default-config.xml b/mdsalutil/mdsalutil-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..2d687c9
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:impl?module=mdsalutil-impl&amp;revision=2015-04-03</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <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:prefix="urn:opendaylight:params:xml:ns:yang:mdsalutil:impl">prefix:mdsalutil-impl</type>
+          <name>mdsalutil-default</name>
+           <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/vpnservice/mdsalutil/internal/MDSALManager.java b/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/vpnservice/mdsalutil/internal/MDSALManager.java
new file mode 100644 (file)
index 0000000..4c4cf05
--- /dev/null
@@ -0,0 +1,382 @@
+/*
+ * Copyright (c) 2013 Ericsson AB.  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.vpnservice.mdsalutil.internal;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+import org.opendaylight.controller.md.sal.common.api.TransactionStatus;
+//import org.opendaylight.controller.md.sal.common.api.data.DataModification;
+import org.opendaylight.vpnservice.mdsalutil.ActionInfo;
+import org.opendaylight.vpnservice.mdsalutil.ActionType;
+import org.opendaylight.vpnservice.mdsalutil.BucketInfo;
+import org.opendaylight.vpnservice.mdsalutil.FlowEntity;
+import org.opendaylight.vpnservice.mdsalutil.GroupEntity;
+import org.opendaylight.vpnservice.mdsalutil.InstructionInfo;
+import org.opendaylight.vpnservice.mdsalutil.MDSALUtil;
+import org.opendaylight.vpnservice.mdsalutil.MatchInfo;
+import org.opendaylight.vpnservice.mdsalutil.MatchFieldType;
+import org.opendaylight.vpnservice.mdsalutil.MetaDataUtil;
+import org.opendaylight.vpnservice.mdsalutil.InstructionType;
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ConsumerContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareConsumer;
+import org.opendaylight.controller.sal.binding.api.data.DataBrokerService;
+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.flow.inventory.rev130819.FlowCapableNode;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowTableRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev131103.TransactionId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
+//import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.OpendaylightInventoryService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.packet.service.rev130709.PacketProcessingService;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
+import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+
+import com.google.common.util.concurrent.CheckedFuture;
+import com.google.common.util.concurrent.FutureCallback;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
+
+public class MDSALManager implements IMdsalApiManager,BindingAwareConsumer, AutoCloseable {
+
+    private static final Logger s_logger = LoggerFactory.getLogger(MDSALManager.class);
+
+    private DataBroker m_dataBroker;
+
+    // TODO: CHECK IF RQD
+    
+    private ConsumerContext m_consumerContext = null;
+    
+    // TODO Remove this later
+    private DataBrokerService m_dataBrokerService;
+    
+    private PacketProcessingService m_packetProcessingService;
+
+      
+    private final AtomicInteger m_atomicInteger = new AtomicInteger();
+
+    //TODO : IF ID MANAGER IS RQD
+    
+    public void setDataProvider(final DataBroker salDataProvider) {
+        this.m_dataBroker = salDataProvider;
+        
+    }
+    
+
+    @Override
+    public void onSessionInitialized(ConsumerContext session) {
+       
+       s_logger.debug( " Session Initiated for MD SAL Manager") ;
+       
+        m_consumerContext = session;
+        
+       m_dataBroker = session.getSALService(DataBroker.class);
+              
+        // TODO - Verify this.
+       // m_packetProcessingService = session.getRpcService(PacketProcessingService.class);
+            
+    }
+    
+    
+    @Override
+    public void close() throws Exception {
+       s_logger.info("MDSAL Manager Closed");
+    }
+    
+    
+    @Override
+    public void installFlow(FlowEntity flowEntity) {
+        try {
+            s_logger.info("within installFlowX {}", flowEntity.getDpnId());
+            System.out.println( " Insie installFlow -- ") ;
+
+            if (flowEntity.getCookie() == null) {
+                s_logger.info("Helium_sync: Cookie is null");
+                flowEntity.setCookie(new BigInteger("0110000", 16));
+            }
+
+            Flow flow = flowEntity.getFlowBuilder().build();
+
+            Node nodeDpn = buildDpnNode(flowEntity.getDpnId());
+            InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).build();
+            InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flow.getKey()).build();
+
+            String sTransactionUri = generateTransactionUri();
+            // Helium Way
+                       
+            WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+            
+            modification.put(LogicalDatastoreType.CONFIGURATION, nodeInstanceId, nodeDpn, true);
+            
+            modification.put(LogicalDatastoreType.CONFIGURATION, flowInstanceId, flow);
+            
+            ListenableFuture<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+            
+            Futures.addCallback(commitFuture, new FutureCallback<RpcResult<TransactionStatus>>() {
+                @Override
+                public void onSuccess(RpcResult<TransactionStatus> result) {
+                       if( result.getResult() != TransactionStatus.COMMITED ) {
+                               s_logger.debug("Failed to commit the Flow Data " + result.getErrors());
+                       
+                    }
+                
+                }
+
+                @Override
+                public void onFailure(Throwable throwable) {
+                       s_logger.error(throwable.getMessage(), throwable);
+                    s_logger.debug(String.format("Status of Flow Data Loaded Transaction : failure. Reason : %s", throwable));
+                    
+                }
+            });
+        } catch (Exception e) {
+            s_logger.error("Could not install flow: {}, exception: {}", flowEntity, e.getMessage());
+        }
+
+    }
+    @Override
+    public void installGroup(GroupEntity groupEntity) {
+        try {
+            Group group = groupEntity.getGroupBuilder().build();
+
+            Node nodeDpn = buildDpnNode(groupEntity.getDpnId());
+            InstanceIdentifier<Node> nodeInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).build();
+            InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Group.class, new GroupKey(new GroupId(groupEntity.getGroupId()))).build();
+
+                       
+         // Helium
+            WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+            
+            modification.put(LogicalDatastoreType.CONFIGURATION, nodeInstanceId, nodeDpn);
+            modification.put(LogicalDatastoreType.CONFIGURATION, groupInstanceId, group);
+                              
+            ListenableFuture<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+            
+            Futures.addCallback(commitFuture, new FutureCallback<RpcResult<TransactionStatus>>() {
+                @Override
+                public void onSuccess(RpcResult<TransactionStatus> result) {
+                       if( result.getResult() != TransactionStatus.COMMITED ) {
+                               s_logger.debug("Failed to commit the group Data " + result.getErrors());
+                       
+                    }
+                
+                }
+
+                @Override
+                public void onFailure(Throwable throwable) {
+                       s_logger.error(throwable.getMessage(), throwable);
+                    s_logger.debug(String.format("Status of Group Data Loaded Transaction : failure. Reason : %s", throwable));
+                    
+                }
+            });
+                        
+        } catch (Exception e) {
+            s_logger.error("Could not install Group: {}, exception: {}", groupEntity, e.getMessage());
+            throw e;
+        }
+    }
+
+    @Override
+    public void removeFlow(FlowEntity flowEntity) {
+        try {
+            Node nodeDpn = buildDpnNode(flowEntity.getDpnId());
+            FlowKey flowKey = new FlowKey(new FlowId(flowEntity.getFlowId()));
+            InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Table.class, new TableKey(flowEntity.getTableId())).child(Flow.class, flowKey).build();
+
+
+                WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+                modification.delete(LogicalDatastoreType.CONFIGURATION,flowInstanceId );
+
+                ListenableFuture<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+                
+                Futures.addCallback(commitFuture, new FutureCallback<RpcResult<TransactionStatus>>() {
+                    @Override
+                    public void onSuccess(RpcResult<TransactionStatus> result) {
+                       if( result.getResult() != TransactionStatus.COMMITED ) {
+                               s_logger.debug("Failed to remove the Flow Data " + result.getErrors());
+                               
+                        }
+                    
+                    }
+
+                    @Override
+                    public void onFailure(Throwable throwable) {
+                       s_logger.error(throwable.getMessage(), throwable);
+                        s_logger.debug(String.format("Status of Flow Data remove Transaction : failure. Reason : %s", throwable));
+                        
+                    }
+                });
+        } catch (Exception e) {
+            s_logger.error("Could not remove Flow: {}, exception: {}", flowEntity, e.getMessage());
+        }
+    }
+
+    @Override
+    public void removeGroup(GroupEntity groupEntity) {
+        try {
+            Node nodeDpn = buildDpnNode(groupEntity.getDpnId());
+            InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class)
+                    .child(Node.class, nodeDpn.getKey()).augmentation(FlowCapableNode.class)
+                    .child(Group.class, new GroupKey(new GroupId(groupEntity.getGroupId()))).build();
+
+
+            WriteTransaction modification = m_dataBroker.newWriteOnlyTransaction();
+            
+            modification.delete(LogicalDatastoreType.CONFIGURATION,groupInstanceId );
+
+            ListenableFuture<RpcResult<TransactionStatus>> commitFuture = modification.commit();
+            
+            Futures.addCallback(commitFuture, new FutureCallback<RpcResult<TransactionStatus>>() {
+                @Override
+                public void onSuccess(RpcResult<TransactionStatus> result) {
+                       if( result.getResult() != TransactionStatus.COMMITED ) {
+                               s_logger.debug("Failed to remove the group Data " + result.getErrors());
+                       
+                    }
+                
+                }
+
+                @Override
+                public void onFailure(Throwable throwable) {
+                       s_logger.error(throwable.getMessage(), throwable);
+                    s_logger.debug(String.format("Status of group Data remove Transaction : failure. Reason : %s", throwable));
+                    
+                }
+            });
+
+                
+
+        } catch (Exception e) {
+            s_logger.error("Could not remove Group: {}, exception: {}", groupEntity, e.getMessage());
+        }
+    }
+
+    @Override
+    public void modifyGroup(GroupEntity groupEntity) {
+
+        installGroup(groupEntity);
+    }
+
+    private String generateTransactionUri() {
+        long lTransactionIdOut = m_atomicInteger.incrementAndGet();
+
+        // TO DO Introduce this later
+      //  return "" + (lTransactionIdOut | m_lTransactionIdPrefix);
+        return "" + (lTransactionIdOut );
+    }
+/*
+    private String generateTransactionUriForFlow(long nTransactionId) {
+        long lTransactionIdOut = m_atomicInteger.incrementAndGet();
+        return Long.toString((lTransactionIdOut | m_lTransactionIdPrefix)) + EUtil.TRANSACTION_ID_SEPARATOR
+                + Long.toString(nTransactionId);
+    }
+*/
+    
+    @Override
+    public void sendPacketOut(long lDpnId, int groupId, byte[] payload) {
+
+        List<ActionInfo> actionInfos = new ArrayList<ActionInfo>();
+        actionInfos.add(new ActionInfo(ActionType.group, new String[] { String.valueOf(groupId) }));
+
+        sendPacketOutWithActions(lDpnId, groupId, payload, actionInfos);
+    }
+
+    @Override
+    public void sendPacketOutWithActions(long lDpnId, long groupId, byte[] payload, List<ActionInfo> actionInfos) {
+
+        m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actionInfos, payload, lDpnId,
+                getNodeConnRef("openflow:" + lDpnId, "0xfffffffd")));
+    }
+
+    @Override
+    public void sendARPPacketOutWithActions(long lDpnId, byte[] payload, List<ActionInfo> actions) {
+
+        m_packetProcessingService.transmitPacket(MDSALUtil.getPacketOut(actions, payload, lDpnId,
+                getNodeConnRef("openflow:" + lDpnId, "0xfffffffd")));
+    }
+
+    private NodeKey getNodeKey(long dpId) {
+        String nodeId = "openflow:" + dpId;
+        NodeKey nodeKey = new NodeKey(new NodeId(nodeId));
+        return nodeKey;
+    }
+
+    public InstanceIdentifier<Node> nodeToInstanceId(Node node) {
+        return InstanceIdentifier.builder(Nodes.class).child(Node.class, node.getKey()).toInstance();
+    }
+
+    private static NodeConnectorRef getNodeConnRef(final String nodeId, final String port) {
+        StringBuilder _stringBuilder = new StringBuilder(nodeId);
+        StringBuilder _append = _stringBuilder.append(":");
+        StringBuilder sBuild = _append.append(port);
+        String _string = sBuild.toString();
+        NodeConnectorId _nodeConnectorId = new NodeConnectorId(_string);
+        NodeConnectorKey _nodeConnectorKey = new NodeConnectorKey(_nodeConnectorId);
+        NodeConnectorKey nConKey = _nodeConnectorKey;
+        InstanceIdentifierBuilder<Nodes> _builder = InstanceIdentifier.<Nodes> builder(Nodes.class);
+        NodeId _nodeId = new NodeId(nodeId);
+        NodeKey _nodeKey = new NodeKey(_nodeId);
+        InstanceIdentifierBuilder<Node> _child = _builder.<Node, NodeKey> child(Node.class, _nodeKey);
+        InstanceIdentifierBuilder<NodeConnector> _child_1 = _child.<NodeConnector, NodeConnectorKey> child(
+                NodeConnector.class, nConKey);
+        InstanceIdentifier<NodeConnector> path = _child_1.toInstance();
+        NodeConnectorRef _nodeConnectorRef = new NodeConnectorRef(path);
+        return _nodeConnectorRef;
+    }
+
+    private long getDpnIdFromNodeName(String nodeName) {
+        String dpId = nodeName.substring(nodeName.lastIndexOf(":") + 1);
+        return Long.parseLong(dpId);
+    }
+
+    private Node buildDpnNode(long lDpnId) {
+        NodeId nodeId = new NodeId("openflow:" + lDpnId);
+        Node nodeDpn = new NodeBuilder().setId(nodeId).setKey(new NodeKey(nodeId)).build();
+
+        return nodeDpn;
+    }
+}
diff --git a/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModule.java b/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModule.java
new file mode 100644 (file)
index 0000000..9bfb8d6
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.impl.rev150403;
+public class MdsaluttilimplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.impl.rev150403.AbstractMdsaluttilimplModule {
+    public MdsaluttilimplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public MdsaluttilimplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.impl.rev150403.MdsaluttilimplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        // TODO:implement
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+}
diff --git a/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModuleFactory.java b/mdsalutil/mdsalutil-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/mdsalutil/impl/rev150403/MdsaluttilimplModuleFactory.java
new file mode 100644 (file)
index 0000000..ba90fab
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: mdsalutil-impl yang module local name: mdsalutil-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Apr 03 21:19:12 IST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.impl.rev150403;
+public class MdsaluttilimplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.mdsalutil.impl.rev150403.AbstractMdsaluttilimplModuleFactory {
+
+}
diff --git a/mdsalutil/mdsalutil-impl/src/main/yang/mdsalutil-impl.yang b/mdsalutil/mdsalutil-impl/src/main/yang/mdsalutil-impl.yang
new file mode 100644 (file)
index 0000000..d94f5a1
--- /dev/null
@@ -0,0 +1,36 @@
+module mdsalutil-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:mdsalutil:impl";
+    prefix "mdsalutil-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for mdsal project";
+
+    revision "2015-04-03" {
+        description
+            "Initial revision";
+    }
+
+    identity mdsalutil-impl {
+        base config:module-type;
+        config:java-name-prefix mdsaluttilimpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case mdsalutil-impl {
+            when "/config:modules/config:module/config:type = 'mdsalutil-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }  
+               
+        }
+    }
+}
diff --git a/mdsalutil/pom.xml b/mdsalutil/pom.xml
new file mode 100644 (file)
index 0000000..0e362dc
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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 INTERNAL
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+       <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>mdsalutil-aggregator</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>mdsalutil</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>mdsalutil-api</module>
+    <module>mdsalutil-impl</module>
+  </modules>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/nexthopmgr/nexthopmgr-api/pom.xml b/nexthopmgr/nexthopmgr-api/pom.xml
new file mode 100644 (file)
index 0000000..dec5ae4
--- /dev/null
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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
+-->
+<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">
+  <parent>
+    <groupId>org.opendaylight.yangtools</groupId>
+    <artifactId>binding-parent</artifactId>
+    <version>0.7.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>nexthopmgr-api</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+
+  <properties>
+    <!-- ODL -->
+    <ietf.inet.types.version>2010.09.24.7-SNAPSHOT</ietf.inet.types.version>
+    <ietf.yang.types.version>2010.09.24.7-SNAPSHOT</ietf.yang.types.version>
+    <yang.ext.version>2013.09.07.7-SNAPSHOT</yang.ext.version>
+    <yangtools.version>0.7.0-SNAPSHOT</yangtools.version>
+    <mdsal.version>1.2.0-SNAPSHOT</mdsal.version>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-binding</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools</groupId>
+      <artifactId>yang-common</artifactId>
+      <version>${yangtools.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-inet-types</artifactId>
+      <version>${ietf.inet.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-yang-types</artifactId>
+      <version>${ietf.yang.types.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>ietf-interfaces</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.yangtools.model</groupId>
+      <artifactId>iana-if-type-2014-05-08</artifactId>
+      <version>2014.05.08.7-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller.model</groupId>
+      <artifactId>model-inventory</artifactId>
+      <version>${mdsal.version}</version>
+    </dependency>
+  </dependencies>
+</project>
diff --git a/nexthopmgr/nexthopmgr-api/src/main/yang/l3nexthop.yang b/nexthopmgr/nexthopmgr-api/src/main/yang/l3nexthop.yang
new file mode 100644 (file)
index 0000000..cc86285
--- /dev/null
@@ -0,0 +1,40 @@
+
+
+module l3nexthop {
+       namespace "urn:opendaylight:vpnservice:l3nexthop";
+       prefix l3nexthop;
+       
+       revision "2015-03-30" {
+               description "L3 NextHop module";
+       }
+
+       container l3nexthop {
+               list vpnNexthops{
+                       key "vpnId";
+                       leaf vpnId {type uint32;}
+                       list vpnNexthop{
+                               key  "IpAddress";
+                               leaf IpAddress {type string;}
+                               leaf dpnId {type uint32;}
+                               leaf egressPointer {type uint32;}
+                       }
+               }
+               list genNexthops{
+                       key  "IpAddress";
+                       leaf IpAddress {type string;}
+                       leaf dpnId {type uint32;}
+                       leaf egressPointer {type uint32;}
+               }
+       }
+       rpc getEgressPointer {
+               description "returns egress pointer, an OF Group Id";
+               input { 
+                       leaf dpnId {type uint32;}
+                       leaf vpnId { type uint32;}  /* optional */
+                       leaf ipAddress{type string;}
+               }
+               output { 
+                       leaf egressPointer {type uint32;} 
+               }
+       }
+}
\ No newline at end of file
diff --git a/nexthopmgr/nexthopmgr-impl/pom.xml b/nexthopmgr/nexthopmgr-impl/pom.xml
new file mode 100644 (file)
index 0000000..3078bc2
--- /dev/null
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
+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
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.controller</groupId>
+    <artifactId>config-parent</artifactId>
+    <version>0.3.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>nexthopmgr-impl</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>bundle</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>nexthopmgr-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>${project.groupId}</groupId>
+      <artifactId>vpnmanager-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <!-- Testing Dependencies -->
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-all</artifactId>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-checkstyle-plugin</artifactId>
+        <configuration>
+          <configLocation>
+            ${project.basedir}/../../commons/src/main/resources/vpns_checks.xml
+          </configLocation>
+          <failsOnError>true</failsOnError>
+          <includes>**/*.java,**/*.xml,**/*.ini,**/*.sh,**/*.bat</includes>
+          <excludes>**/yang/</excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/config/default-config.xml b/nexthopmgr/nexthopmgr-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..c44c0b3
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- vi: set et smarttab sw=4 tabstop=4: -->
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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>
+  <required-capabilities>
+      <capability>urn:opendaylight:params:xml:ns:yang:nexthopmgr:impl?module=nexthopmgr-impl&amp;revision=2015-03-25</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+  </required-capabilities>
+  <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:prefix="urn:opendaylight:params:xml:ns:yang:nexthopmgr:impl">prefix:nexthopmgr-impl</type>
+          <name>nexthopmgr-default</name>
+          <broker>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-broker-osgi-registry</type>
+            <name>binding-osgi-broker</name>
+          </broker>
+        </module>
+      </modules>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/AbstractDataChangeListener.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/AbstractDataChangeListener.java
new file mode 100644 (file)
index 0000000..bca90b6
--- /dev/null
@@ -0,0 +1,110 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.nexthopmgr;
+
+import com.google.common.base.Optional;
+import com.google.common.base.Preconditions;
+
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataChangeEvent;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * AbstractDataChangeListener implemented basic {@link DataChangeListener} processing for
+ * VPN related Data Objects.
+ */
+public abstract class AbstractDataChangeListener <T extends DataObject> implements DataChangeListener {
+
+    protected final Class<T> clazz;
+
+    public AbstractDataChangeListener(Class<T> clazz) {
+        this.clazz = Preconditions.checkNotNull(clazz, "Class can not be null!");
+    }
+
+    @Override
+    public void onDataChanged(final AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> changeEvent) {
+        Preconditions.checkNotNull(changeEvent,"Async ChangeEvent can not be null!");
+
+        /* All DataObjects for create */
+        final Map<InstanceIdentifier<?>, DataObject> createdData = changeEvent.getCreatedData() != null
+                ? changeEvent.getCreatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+        /* All DataObjects for remove */
+        final Set<InstanceIdentifier<?>> removeData = changeEvent.getRemovedPaths() != null
+                ? changeEvent.getRemovedPaths() : Collections.<InstanceIdentifier<?>> emptySet();
+        /* All DataObjects for updates */
+        final Map<InstanceIdentifier<?>, DataObject> updateData = changeEvent.getUpdatedData() != null
+                ? changeEvent.getUpdatedData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+        /* All Original DataObjects */
+        final Map<InstanceIdentifier<?>, DataObject> originalData = changeEvent.getOriginalData() != null
+                ? changeEvent.getOriginalData() : Collections.<InstanceIdentifier<?>, DataObject> emptyMap();
+
+        this.createData(createdData);
+        this.updateData(updateData, originalData);
+        this.removeData(removeData, originalData);
+    }
+
+    @SuppressWarnings("unchecked")
+    private void createData(final Map<InstanceIdentifier<?>, DataObject> createdData) {
+        final Set<InstanceIdentifier<?>> keys = createdData.keySet() != null
+                ? createdData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+        for (InstanceIdentifier<?> key : keys) {
+            if (clazz.equals(key.getTargetType())) {
+                 InstanceIdentifier<T> createKeyIdent = key.firstIdentifierOf(clazz);
+                 final Optional<DataObject> value = Optional.of(createdData.get(key));
+                 if (value.isPresent()) {
+                     this.add(createKeyIdent, (T)value.get());
+                 }
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void updateData(final Map<InstanceIdentifier<?>, DataObject> updateData,
+            final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+        final Set<InstanceIdentifier<?>> keys = updateData.keySet() != null
+                ? updateData.keySet() : Collections.<InstanceIdentifier<?>> emptySet();
+        for (InstanceIdentifier<?> key : keys) {
+          if (clazz.equals(key.getTargetType())) {
+              InstanceIdentifier<T> updateKeyIdent = key.firstIdentifierOf(clazz);
+              final Optional<DataObject> value = Optional.of(updateData.get(key));
+              final Optional<DataObject> original = Optional.of(originalData.get(key));
+              if (value.isPresent() && original.isPresent()) {
+                this.update(updateKeyIdent, (T)original.get(), (T)value.get());
+              }
+          }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void removeData(final Set<InstanceIdentifier<?>> removeData,
+            final Map<InstanceIdentifier<?>, DataObject> originalData) {
+
+        for (InstanceIdentifier<?> key : removeData) {
+            if (clazz.equals(key.getTargetType())) {
+                   final InstanceIdentifier<T> ident = key.firstIdentifierOf(clazz);
+                    final DataObject removeValue = originalData.get(key);
+                    this.remove(ident, (T)removeValue);
+            }
+        }
+    }
+
+    protected abstract void remove(InstanceIdentifier<T> identifier, T del);
+
+    protected abstract void update(InstanceIdentifier<T> identifier, T original, T update);
+
+    protected abstract void add(InstanceIdentifier<T> identifier, T add);
+
+}
+
+
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopManager.java
new file mode 100644 (file)
index 0000000..71cfad7
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.nexthopmgr;
+/**********************************************************************************
+** NextHop MD-SAL DS 
+** ------------------------------------------------
+** DP_ID  |  VPN   |   IP Address  |  GroupId     |
+** ------------------------------------------------
+** 
+** Listen to DCNs from vpn-inetrfaces
+** if a next-hop is added/removed in vpn-interfaces DS
+**     call add/removeNextHop(interface.dpn, interface.port, vpn_instance.vpnId, AdjacencyIpAddress);
+** 
+** if a tunnel-interface is added inn interfaces DS --
+**     call add/removeNextHop(interface.dpn, interface.port, 00, RemoteIpAddress);
+*************************************************************************************/
+import java.util.Collections;
+import java.util.Map;
+import java.util.Set;
+
+import java.util.List;
+import com.google.common.base.Optional;
+import com.google.common.collect.FluentIterable;
+
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.DataChangeListener;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.InstanceIdentifierBuilder;
+import org.opendaylight.controller.md.sal.binding.api.ReadOnlyTransaction;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.Interfaces;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey;
+/*import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.NextHopList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.next.hop.list.L3NextHops;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.VpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.l3vpn.rev130911.VpnInterface1;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface;
+import org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterfaceKey;
+*/
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150330.L3nexthop;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.l3nexthop.rev150330.l3nexthop.VpnNexthops;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NexthopManager extends AbstractDataChangeListener<L3nexthop> implements AutoCloseable{
+    private static final Logger LOG = LoggerFactory.getLogger(L3nexthop.class);
+    private ListenerRegistration<DataChangeListener> listenerRegistration;
+    private final DataBroker broker;
+
+    public NexthopManager(final DataBroker db) {
+        super(L3nexthop.class);
+        broker = db;
+        registerListener(db);
+    }
+
+       @Override
+    public void close() throws Exception {
+        if (listenerRegistration != null) {
+            try {
+                listenerRegistration.close();
+            } catch (final Exception e) {
+                LOG.error("Error when cleaning up DataChangeListener.", e);
+            }
+            listenerRegistration = null;
+        }
+        LOG.info("VPN Interface Manager Closed");
+    }
+
+
+    private void registerListener(final DataBroker db) {
+        try {
+            listenerRegistration = db.registerDataChangeListener(LogicalDatastoreType.CONFIGURATION,
+                    getWildCardPath(), NexthopManager.this, DataChangeScope.SUBTREE);
+        } catch (final Exception e) {
+            LOG.error("Nexthop Manager DataChange listener registration fail!", e);
+            throw new IllegalStateException("Nexthop Manager registration Listener failed.", e);
+        }
+    }
+    
+       public void addNextHop(long dpnId, int port, String vpnRD, String IpAddress)
+       {
+               String nhKey = new String("nexthop"+vpnRD+IpAddress);
+               
+               int groupId = 1;//getIdManager().getUniqueId("nextHopGroupIdPool", nhKey);
+
+/*             if (getNextHop(groupId) == Null){
+                       List<BucketInfo> listBucketInfo = new ArrayList<BucketInfo>();
+                       List<ActionInfo> listActionInfo = null;//nextHop.getActions({output to port}); 
+                       BucketInfo bucket = new BucketInfo(listActionInfo);
+                       listBucketInfo.add(bucket);
+                       //GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpId, groupId, IPAddress, GroupTypes.GroupIndirect, listBucketInfo);
+                       //getMdsalApiManager().installGroup(groupEntity, objTransaction???);
+                       
+                       //update MD-SAL DS
+                       addNextHopToDS(dpId, vpn, ipAddress, groupId);
+               }else{
+                       //check update
+               }*/
+       }       
+
+       public void removeNextHop(long dpnId, int port, String vpnRD, String IpAddress)
+       {
+               String nhKey = new String("nexthop"+vpnRD+IpAddress);
+               int groupId = 1;//getIdManager().getUniqueId(L3Constants.L3NEXTHOP_GROUPID_POOL, nhKey);
+
+/*             if (getNextHop(groupId) != Null){
+                       List<BucketInfo> listBucketInfo = new ArrayList<BucketInfo>();
+                       List<ActionInfo> listActionInfo = null;//nextHop.getActions({output to port}); 
+                       BucketInfo bucket = new BucketInfo(listActionInfo);
+                       listBucketInfo.add(bucket);
+                       //GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpId, groupId, IPAddress, GroupTypes.GroupIndirect, listBucketInfo);
+                       //getMdsalApiManager().removeGroup(groupEntity, objTransaction???);
+                       
+                       //update MD-SAL DS
+                       removeNextHopFromDS(dpId, vpn, ipAddress);
+               }else{
+                       //check update
+               }*/
+       }       
+               
+       public long getNextHopPointer(long dpnId, int vpnId, String prefixIp, String nxetHopIp)
+       {
+/*             String endpointIp = interfaceManager.getLocalEndpointIp(dpnId);
+               if (nextHopIp.equals(endpointIp)) {
+                       return getGidFromDS(dpnId, vpnId, prefixIp);
+               } else {
+                       return getGidFromDS(dpnId, 00, nextHopIp);
+               }*/
+               return 0;
+       }
+
+    private InstanceIdentifier<L3nexthop> getWildCardPath() {
+        return InstanceIdentifier.create(L3nexthop.class);//.child(l3nexthop.vpnNexthops.class);
+    }
+
+       private void addNextHopToDS(long dpId, int vpnId, String ipAddress, long groupId)
+       {
+               
+       }
+
+       private long getGidFromDS(String ipaddress)
+       {
+               return 0;
+               
+       }
+
+       @Override
+       protected void remove(InstanceIdentifier<L3nexthop> identifier,
+                       L3nexthop del) {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected void update(InstanceIdentifier<L3nexthop> identifier,
+                       L3nexthop original, L3nexthop update) {
+               // TODO Auto-generated method stub
+               
+       }
+
+       @Override
+       protected void add(InstanceIdentifier<L3nexthop> identifier, L3nexthop add) {
+               // TODO Auto-generated method stub
+               
+       }
+
+}
\ No newline at end of file
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/vpnservice/nexthopmgr/NexthopmgrProvider.java
new file mode 100644 (file)
index 0000000..23397f7
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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.vpnservice.nexthopmgr;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class NexthopmgrProvider implements BindingAwareProvider, 
+                                                                                                               AutoCloseable {
+
+    private static final Logger LOG = LoggerFactory.getLogger(NexthopmgrProvider.class);
+  //  private nexthopmgr nhManager;
+
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        final  DataBroker dataBroker = session.getSALService(DataBroker.class);
+   //     nhManager = new nexthopManager(dataBroker);
+               LOG.info("NexthopmgrProvider Session Initiated");
+    }
+
+    @Override
+    public void close() throws Exception {
+               //nhManager.close();
+               LOG.info("NexthopmgrProvider Closed");
+    }
+
+}
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModule.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModule.java
new file mode 100644 (file)
index 0000000..66ae335
--- /dev/null
@@ -0,0 +1,22 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nexthopmgr.impl.rev150325;
+public class NexthopmgrImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nexthopmgr.impl.rev150325.AbstractNexthopmgrImplModule {
+    public NexthopmgrImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public NexthopmgrImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nexthopmgr.impl.rev150325.NexthopmgrImplModule oldModule, java.lang.AutoCloseable oldInstance) {
+        super(identifier, dependencyResolver, oldModule, oldInstance);
+    }
+
+    @Override
+    public void customValidation() {
+        // add custom validation form module attributes here.
+    }
+
+    @Override
+    public java.lang.AutoCloseable createInstance() {
+        // TODO:implement
+        throw new java.lang.UnsupportedOperationException();
+    }
+
+}
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModuleFactory.java b/nexthopmgr/nexthopmgr-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/nexthopmgr/impl/rev150325/NexthopmgrImplModuleFactory.java
new file mode 100644 (file)
index 0000000..8ea7235
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: nexthopmgr-impl yang module local name: nexthopmgr-impl
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Wed Apr 01 23:18:39 IST 2015
+*
+* Do not modify this file unless it is present under src/main directory
+*/
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nexthopmgr.impl.rev150325;
+public class NexthopmgrImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.nexthopmgr.impl.rev150325.AbstractNexthopmgrImplModuleFactory {
+
+}
diff --git a/nexthopmgr/nexthopmgr-impl/src/main/yang/nexthopmgr-impl.yang b/nexthopmgr/nexthopmgr-impl/src/main/yang/nexthopmgr-impl.yang
new file mode 100644 (file)
index 0000000..8c60aba
--- /dev/null
@@ -0,0 +1,35 @@
+module nexthopmgr-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:nexthopmgr:impl";
+    prefix "nexthopmgr-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+
+    description
+        "Service definition for nexthopmgr project";
+
+    revision "2015-03-25" {
+        description
+            "Initial revision";
+    }
+
+    identity nexthopmgr-impl {
+        base config:module-type;
+        config:java-name-prefix NexthopmgrImpl;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case nexthopmgr-impl {
+            when "/config:modules/config:module/config:type = 'nexthopmgr-impl'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/nexthopmgr/pom.xml b/nexthopmgr/pom.xml
new file mode 100644 (file)
index 0000000..5c0be22
--- /dev/null
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. 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 INTERNAL
+-->
+<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">
+
+  <parent>
+    <groupId>org.opendaylight.odlparent</groupId>
+    <artifactId>odlparent</artifactId>
+    <version>1.5.0-SNAPSHOT</version>
+       <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>nexthopmgr-aggregator</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <name>nexthopmgr</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>nexthopmgr-api</module>
+    <module>nexthopmgr-impl</module>
+  </modules>
+  <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-deploy-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-install-plugin</artifactId>
+        <configuration>
+          <skip>true</skip>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/pom.xml b/pom.xml
index 8214f57..b3fd537 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -8,7 +8,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
 <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">
   <groupId>org.opendaylight.vpnservice</groupId>
   <artifactId>vpnservice</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <version>0.0.1-SNAPSHOT</version>
   <name>${project.artifactId}</name>
   <packaging>pom</packaging>
   <modelVersion>4.0.0</modelVersion>
@@ -16,13 +16,17 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <maven>3.1.1</maven>
   </prerequisites>
   <modules>
-    <module>model-bgp</module>
+       <module>model-bgp</module>
     <module>vpnmanager-api</module>
     <module>vpnmanager-impl</module>
     <module>distribution/karaf</module>
     <module>features</module>
     <module>vpnservice-artifacts</module>
     <module>interfacemgr</module>
+    <module>nexthopmgr</module>
+    <module>idmanager</module>
+    <module>fibmanager</module>
+    <module>mdsalutil</module>
   </modules>
 
   <!-- DO NOT install or deploy the repo root pom as it's only needed to initiate a build -->
index 89dac84..5c724a9 100644 (file)
@@ -17,7 +17,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <modelVersion>4.0.0</modelVersion>
   <groupId>org.opendaylight.vpnservice</groupId>
   <artifactId>vpnmanager-api</artifactId>
-  <version>1.0-SNAPSHOT</version>
+  <version>0.0.1-SNAPSHOT</version>
   <packaging>bundle</packaging>
 
   <properties>
@@ -60,11 +60,6 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
       <artifactId>iana-if-type-2014-05-08</artifactId>
       <version>2014.05.08.7-SNAPSHOT</version>
     </dependency>
-    <dependency>
-      <groupId>org.opendaylight.controller.model</groupId>
-      <artifactId>model-inventory</artifactId>
-      <version>${mdsal.version}</version>
-    </dependency>
     <dependency>
       <groupId>org.opendaylight.vpnservice</groupId>
       <artifactId>model-bgp</artifactId>
diff --git a/vpnmanager-api/src/main/yang/bgp-l3vpn.yang b/vpnmanager-api/src/main/yang/bgp-l3vpn.yang
deleted file mode 100644 (file)
index 423523f..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-module bgp-l3vpn {
-    namespace "urn:opendaylight:l3vpn:bgp";
-    prefix bgp-l3vpn;
-    
-    import l3vpn { prefix l3vpn; revision-date "2014-08-15";}
-
-    revision "2013-09-11" {
-        description "L3 VPN Service module";
-    }
-
-    grouping bgp-neighbors {
-        description
-           "The top level container for the list of neighbours of the BGP router.";
-        list bgp-neighbor {
-            key "ip-address";
-            leaf as-number { type uint32; }
-            leaf ip-address { type string; mandatory true; }
-       }
-    }
-
-    grouping bgp-config {
-       description
-           "The top level container for BGP configuration";
-       leaf bgp-ip-address { type string; }
-       leaf bgp-router-id { type string; }
-       leaf bgp-as { type uint32; mandatory true; } 
-    }
-
-    augment "/l3vpn:vpn-instances" {
-        container bgp-config { 
-            uses bgp-config;
-        }
-        container bgp-neighbors { 
-            uses bgp-neighbors;
-        }
-    }
-}
-
index 5d329a0..94bee41 100644 (file)
@@ -3,10 +3,6 @@ module odl-l3vpn {
     prefix odl-l3vpn;
 
     import l3vpn { prefix l3vpn; revision-date "2014-08-15"; }
-    import ietf-interfaces { prefix if; }
-    import iana-if-type { prefix ianaift; }
-    import ietf-inet-types { prefix inet; }
-    import opendaylight-inventory { prefix inv; revision-date "2013-08-19"; }
 
     revision "2013-09-11" {
         description "L3 VPN Service module";
@@ -21,82 +17,20 @@ module odl-l3vpn {
             leaf mac_address {type string;} /* optional */
         }
     }
-
-    grouping fib-list{
-        list fib-entry{
-            key "dst_prefix";
-            leaf nextHopId { type uint32;}
-            leaf dst_prefix {type inet:ipv4-prefix;}
-            leaf label {type uint32;} /* optional */
-        }
-    }
+       
+       grouping vpn-route-list{
+               leaf-list route-entry-id{
+                       type uint32;
+               }
+       }
 
     augment "/l3vpn:vpn-interfaces/l3vpn:vpn-interface" {
         uses next-hop-list;
     }
 
     augment "/l3vpn:vpn-instances/l3vpn:vpn-instance" {
-        uses fib-list;
-    }
-
-    augment "/if:interfaces/if:interface" {
-        leaf portId { type inv:node-connector-id; }
-    }
-
-    identity tunnel-type-base {
-        description "Base identity for all tunnel-types";
-    }
-
-    identity tunnel-type-vxlan {
-        description "Tunnel type for vxlan tunnels";
-        base tunnel-type-base;
-    }
-
-    identity tunnel-type-gre {
-        description "Tunnel type for gre tunnels";
-        base tunnel-type-base;
-    }
-
-    grouping tunnel-type-attributes {
-        description "Common leaf for expressing tunnel-type";
-        leaf tunnel-type {
-            type identityref {
-                base tunnel-type-base;
-            }
-        }
-    }
-
-    grouping tunnel-endpoint {
-      description
-        "Tunnel Endpoint: IP address and L4 port";
-      leaf local-ip {
-        type inet:ip-address;
-        description "Local Endpoint IP address";
-      }
-      leaf remote-ip {
-        type inet:ip-address;
-        description "Remote Endpoint IP address";
-      }
-      leaf port {
-        type inet:port-number;
-        description "Data-plane port number";
-      }
-    }
-
-    augment "/if:interfaces/if:interface" {
-        when "if:type = ianaift:tunnel";
-        uses tunnel-type-attributes;
-        uses tunnel-endpoint;
-    }
-
-    augment "/if:interfaces/if:interface" {
-        when "if:type = ianaift:l2vlan";
-        leaf vlan-id {
-          type uint16 {
-            range "1..4094";
-          }
-          description "VLAN Id to be used in VLAN Tag";
-        }
+        leaf vpn-id { type uint32;}
+               uses vpn-route-list;
     }
 
 }
\ No newline at end of file
index 5d02077..5c87523 100644 (file)
@@ -18,7 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
   <modelVersion>4.0.0</modelVersion>\r
   <groupId>org.opendaylight.vpnservice</groupId>\r
   <artifactId>vpnmanager-impl</artifactId>\r
-  <version>1.0-SNAPSHOT</version>\r
+  <version>0.0.1-SNAPSHOT</version>\r
   <packaging>bundle</packaging>\r
   <dependencies>\r
     <dependency>\r