Initial checkin for ITM module 94/30694/1
authorHemaTG <hema.gopalkrishnan@ericsson.com>
Fri, 4 Dec 2015 08:59:38 +0000 (14:29 +0530)
committerHemaTG <hema.gopalkrishnan@ericsson.com>
Fri, 4 Dec 2015 08:59:38 +0000 (14:29 +0530)
Change-Id: Ib79a940816091af1eee927c5f2c5b26f934278f9
Signed-off-by: HemaTG <hema.gopalkrishnan@ericsson.com>
19 files changed:
features/pom.xml
features/src/main/features/features.xml
itm/itm-api/pom.xml [new file with mode: 0644]
itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/api/IITMProvider.java [new file with mode: 0644]
itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java [new file with mode: 0644]
itm/itm-api/src/main/yang/itm-state.yang [new file with mode: 0644]
itm/itm-api/src/main/yang/itm.yang [new file with mode: 0644]
itm/itm-impl/pom.xml [new file with mode: 0644]
itm/itm-impl/src/main/config/default-config.xml [new file with mode: 0644]
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ITMManager.java [new file with mode: 0644]
itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java [new file with mode: 0644]
itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModule.java [new file with mode: 0644]
itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactory.java [new file with mode: 0644]
itm/itm-impl/src/main/yang/itm-impl.yang [new file with mode: 0644]
itm/itm-impl/src/test/java/org/opendaylight/vpnservice/itm/impl/ItmProviderTest.java [new file with mode: 0644]
itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactoryTest.java [new file with mode: 0644]
itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleTest.java [new file with mode: 0644]
itm/pom.xml [new file with mode: 0644]
pom.xml

index 298fc804de3533d9a234e3b63e626be72983e760..4b109efef00aba75c018f683c749296273b8de12 100644 (file)
@@ -34,6 +34,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <nexthopmgr.version>${vpnservices.version}</nexthopmgr.version>
     <fibmanager.version>${vpnservices.version}</fibmanager.version>
     <idmanager.version>${vpnservices.version}</idmanager.version>
+       <itm.version>${vpnservices.version}</itm.version>
   </properties>
   <dependencyManagement>
     <dependencies>
@@ -225,6 +226,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
       <groupId>${project.groupId}</groupId>
       <artifactId>idmanager-api</artifactId>
       <version>${idmanager.version}</version>
+    </dependency>
+       <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>itm-impl</artifactId>
+      <version>${itm.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>itm-impl</artifactId>
+      <version>${itm.version}</version>
+      <classifier>config</classifier>
+      <type>xml</type>
     </dependency>
     <dependency>
       <groupId>org.apache.thrift</groupId>
index e03ef333f3063ccf61c1ce58e24bd6f406f6afa6..4ffb0e3c7f8d628ea7ea3a41c9d2b4812bdbe11c 100644 (file)
@@ -25,7 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/vpnmanager-api/${vpnmanager.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/nexthopmgr-api/${nexthopmgr.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/fibmanager-api/${fibmanager.version}</bundle>
-
+    <bundle>mvn:org.opendaylight.vpnservice/itm-api/${itm.version}</bundle>
   </feature>
   <feature name='odl-vpnservice-impl' version='${project.version}' description='OpenDaylight :: vpnservice :: impl '>
     <feature version='${mdsal.version}'>odl-mdsal-broker</feature>
@@ -43,7 +43,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <bundle>mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}</bundle>
     <bundle>mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}</bundle>
-
+    <bundle>mvn:org.opendaylight.vpnservice/itm-impl/${itm.version}</bundle>
+    
     <!--<bundle>mvn:org.opendaylight.vpnservice.third-party/org.apache.thriftlib/1.0.1-SNAPSHOT</bundle>-->
     <bundle>wrap:mvn:org.apache.thrift/libthrift/0.9.1$overwrite=merge&amp;Bundle-Version=0.9.1&amp;Export-Package=*;-noimport:=true;version="0.9.1"</bundle>
     <!--<bundle>wrap:mvn:javax.servlet/servlet-api/2.5</bundle>-->
@@ -54,6 +55,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html
     <configfile finalname="vpnmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version}/xml/config</configfile>
     <configfile finalname="nexthopmgr-impl-default-config.xml">mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}/xml/config</configfile>
     <configfile finalname="fibmanager-impl-default-config.xml">mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}/xml/config</configfile>
+    <configfile finalname="itm-impl-default-config.xml">mvn:org.opendaylight.vpnservice/itm-impl/${itm.version}/xml/config</configfile>
 
   </feature>
   <feature name='odl-vpnservice-impl-rest' version='${project.version}' description='OpenDaylight :: vpnservice :: impl :: REST '>
diff --git a/itm/itm-api/pom.xml b/itm/itm-api/pom.xml
new file mode 100644 (file)
index 0000000..4003b96
--- /dev/null
@@ -0,0 +1,37 @@
+<?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.vpnservice</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.2.0-SNAPSHOT</version>
+        <relativePath>../../commons/config-parent</relativePath>
+     </parent>
+    
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>itm-api</artifactId>
+    <version>0.2.0-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+
+    <dependencies>
+    <dependency>
+          <groupId>org.opendaylight.vpnservice</groupId>
+          <artifactId>interfacemgr-api</artifactId>
+          <version>${vpnservices.version}</version>
+        </dependency>
+           <dependency>
+              <groupId>org.opendaylight.mdsal.model</groupId>
+              <artifactId>ietf-inet-types</artifactId>
+           </dependency>
+           <dependency>
+             <groupId>org.opendaylight.mdsal.model</groupId>
+             <artifactId>ietf-yang-types</artifactId>
+           </dependency>
+           <dependency>
+            <groupId>org.opendaylight.mdsal.model</groupId>
+            <artifactId>ietf-interfaces</artifactId>
+          </dependency>
+    </dependencies>
+</project>
diff --git a/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/api/IITMProvider.java b/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/api/IITMProvider.java
new file mode 100644 (file)
index 0000000..5610422
--- /dev/null
@@ -0,0 +1,12 @@
+/*
+ * 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.itm.api;
+
+public interface IITMProvider {
+
+}
diff --git a/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java b/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java
new file mode 100644 (file)
index 0000000..d60c72b
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * 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.itm.globals;
+
+
+public class ITMConstants{
+                
+}
diff --git a/itm/itm-api/src/main/yang/itm-state.yang b/itm/itm-api/src/main/yang/itm-state.yang
new file mode 100644 (file)
index 0000000..f395124
--- /dev/null
@@ -0,0 +1,124 @@
+module itm-state {
+
+      namespace "urn:opendaylight:params:xml:ns:yang:itm:op";
+
+      prefix itm-state;
+
+      import ietf-interfaces {
+          prefix if;
+      }
+
+      import ietf-yang-types {
+          prefix yang;
+      }
+
+      import ietf-inet-types {
+          prefix inet;
+      }
+
+      description "This YANG module defines operation part of the model.";
+
+      revision "2015-07-01";
+
+        /* Operational state */
+
+      container tunnels {
+
+        list DPN-TEPs-info {
+
+          key "DPN-ID";
+
+          leaf DPN-ID {
+                   type uint64;
+          }
+          leaf up {
+             type boolean;
+             config false;
+          }
+
+          /* Minimum 1 port. We may for now support only two ports */
+          list tunnel-end-points {
+
+               key "portname VLAN-ID ip-address"; /* Multiple tunnels on the same physical port but on different VLAN can be supported */
+
+                 leaf portname {
+                     type string;
+                     }
+                 leaf VLAN-ID {
+                     type uint16;
+                     }
+                 leaf ip-address {
+                     type inet:ip-address;
+                 }
+                 leaf subnet-mask {
+                     type inet:ip-prefix;
+                 }
+                 leaf gw-ip-address {
+                          type inet:ip-address;
+                 }
+                 leaf transport-zone {
+                          type string;
+                 }
+                 leaf interface-name {
+                          type string;
+                 }
+                 leaf tunnel-type {
+                      type string;
+                 }
+           }
+
+         }
+      }
+
+
+      container tunnels_state {
+             list state-tunnel-list {
+
+               key  "source-DPN destination-DPN";
+
+               leaf source-DPN {
+                   type uint64;
+               }
+
+               leaf destination-DPN {
+                   type uint64;
+               }
+
+               /* logical-group interface id */
+
+               leaf logical-tunnel-group-name {
+                    type string;
+                    config false;
+               }
+
+               leaf logical-tunnel-state {
+                    type boolean;
+                    config false;
+               }
+
+             }
+          }
+
+          rpc get-tunnel-id {
+
+             input {
+                leaf source-dpn {
+                    type uint64;
+                }
+                leaf destination-dpn {
+                    type uint64;
+                }
+             }
+
+             output {
+                     leaf logical-group-name {
+                        type string;
+                     }
+             }
+
+          }
+          
+          notification itm-tunnel-build-complete{
+          }
+
+}
diff --git a/itm/itm-api/src/main/yang/itm.yang b/itm/itm-api/src/main/yang/itm.yang
new file mode 100644 (file)
index 0000000..bbc1273
--- /dev/null
@@ -0,0 +1,63 @@
+module itm {
+
+    namespace "urn:opendaylight:params:xml:ns:yang:itm";
+
+    prefix itm;
+
+    import ietf-interfaces {
+        prefix if;
+    }
+    import ietf-yang-types {
+        prefix yang;
+    }
+    import ietf-inet-types {
+        prefix inet;
+    }
+    import config { prefix config; revision-date 2013-04-05; }
+
+    description "This YANG module defines tunnel configuration.";
+    revision "2015-07-01";
+
+    /* Configuration data */
+
+    container transport-zones {
+      list transport-zone {
+        key zone-name;
+        leaf zone-name {
+            type string;
+        }
+        leaf tunnel-type {
+             type string;
+        }
+
+        list subnets {
+            key "prefix";
+            leaf prefix {
+                type inet:ip-prefix;
+            }
+            leaf gateway-ip {
+                type inet:ip-address;
+            }
+            leaf vlan-id {
+                type uint16;
+            }
+            list vteps {
+                key "dpn-id portname";
+                leaf dpn-id {
+                    type uint64;
+                }
+                leaf portname {
+                    type string;
+                }
+                leaf ip-address {
+                    type inet:ip-address;
+                }
+            }
+        }
+      }
+    }
+    identity itm {
+        base "config:service-type";
+        config:java-class "org.opendaylight.vpnservice.itm.api.IITMProvider";
+    }
+}
\ No newline at end of file
diff --git a/itm/itm-impl/pom.xml b/itm/itm-impl/pom.xml
new file mode 100644 (file)
index 0000000..ca5e907
--- /dev/null
@@ -0,0 +1,80 @@
+<?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.vpnservice</groupId>
+        <artifactId>config-parent</artifactId>
+        <version>0.2.0-SNAPSHOT</version>
+        <relativePath>../../commons/config-parent</relativePath>
+     </parent>
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.opendaylight.vpnservice</groupId>
+    <artifactId>itm-impl</artifactId>
+    <version>0.2.0-SNAPSHOT</version>    
+    <packaging>bundle</packaging>
+    
+    <properties>
+        <xtend.version>2.4.3</xtend.version>
+    </properties>
+    <dependencies>
+        <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>itm-api</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>interfacemgr-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>interfacemgr-impl</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>mdsalutil-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.controller</groupId>
+      <artifactId>sal-binding-broker-impl</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.mdsal.model</groupId>
+      <artifactId>ietf-interfaces</artifactId>
+    </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>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>interfacemgr-api</artifactId>
+      <version>${vpnservices.version}</version>
+    </dependency>
+    <dependency>
+      <groupId>org.opendaylight.vpnservice</groupId>
+      <artifactId>mdsalutil-api</artifactId>
+      <version>${vpnservices.version}</version>
+  </dependency>
+   <dependency>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>18.0</version>
+      </dependency>
+      <dependency>
+      <groupId>commons-net</groupId>
+      <artifactId>commons-net</artifactId>
+    </dependency>
+    </dependencies>
+  </project>
diff --git a/itm/itm-impl/src/main/config/default-config.xml b/itm/itm-impl/src/main/config/default-config.xml
new file mode 100644 (file)
index 0000000..cb06360
--- /dev/null
@@ -0,0 +1,63 @@
+<?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. 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:itm?module=itm&amp;revision=2015-07-01</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:itm:impl?module=itm-impl&amp;revision=2014-12-10</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&amp;revision=2013-10-28</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&amp;revision=2013-10-28</capability>
+      <capability>urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&amp;revision=2015-04-10</capability>
+      <capability>urn:opendaylight:vpnservice:interfacemgr?module=odl-interface&amp;revision=2015-03-31</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:itm:impl">prefix:itm</type>
+          <name>itm-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>
+          <odlinterface>
+            <type xmlns:odlif="urn:opendaylight:vpnservice:interfacemgr">odlif:odl-interface</type>
+            <name>interfacemgr-service</name>
+          </odlinterface>
+          <rpcregistry>
+            <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">binding:binding-rpc-registry</type>
+            <name>binding-rpc-broker</name>
+          </rpcregistry>
+          <mdsalutil>
+            <type xmlns:mdsalutil="urn:opendaylight:params:xml:ns:yang:mdsalutil:api">mdsalutil:odl-mdsalutil</type>
+            <name>mdsalutil-service</name>
+          </mdsalutil>
+          <notification-publish-service>
+            <type xmlns:bindingimpl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">bindingimpl:binding-new-notification-publish-service</type>
+            <name>binding-notification-publish-adapter</name>
+          </notification-publish-service>
+          <notification-service>
+            <type xmlns:bindingimpl="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl">bindingimpl:binding-new-notification-service</type>
+            <name>binding-notification-adapter</name>
+          </notification-service>
+        </module>
+      </modules>
+      <services xmlns="urn:opendaylight:params:xml:ns:yang:controller:config">
+        <service>
+          <type xmlns:prefix="urn:opendaylight:params:xml:ns:yang:itm">prefix:itm</type>
+          <instance>
+            <name>itm</name>
+            <provider>/modules/module[type='itm'][name='itm-default']</provider>
+          </instance>
+        </service>
+      </services>
+    </data>
+  </configuration>
+</snapshot>
diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ITMManager.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ITMManager.java
new file mode 100644 (file)
index 0000000..7aa7ead
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * 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.itm.impl;
+
+import java.math.BigInteger;
+import java.net.InetAddress;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.apache.commons.net.util.SubnetUtils;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+
+import org.opendaylight.vpnservice.itm.globals.ITMConstants;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+
+
+public class ITMManager implements AutoCloseable {
+    private static final Logger LOG = LoggerFactory.getLogger(ITMManager.class);
+
+    private final DataBroker broker;
+    private IMdsalApiManager mdsalManager;
+    private NotificationPublishService notificationPublishService;
+
+    @Override
+    public void close() throws Exception {
+        LOG.info("ITMManager Closed");
+    }
+
+    public ITMManager(final DataBroker db) {
+        broker = db;
+    }
+
+    public void setMdsalManager(IMdsalApiManager mdsalManager) {
+        this.mdsalManager = mdsalManager;
+    }
+
+    public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+    }
+
+}
diff --git a/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java
new file mode 100644 (file)
index 0000000..a53b760
--- /dev/null
@@ -0,0 +1,91 @@
+/*
+ * 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.itm.impl;
+
+import java.math.BigInteger;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.md.sal.binding.api.NotificationService;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext;
+import org.opendaylight.controller.sal.binding.api.BindingAwareProvider;
+import org.opendaylight.vpnservice.interfacemgr.interfaces.IInterfaceManager;
+import org.opendaylight.vpnservice.itm.api.IITMProvider;
+
+import org.opendaylight.vpnservice.mdsalutil.interfaces.IMdsalApiManager;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.GetTunnelIdOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.ItmStateService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.op.rev150701.TunnelsState;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.rev150701.TransportZones;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ItmProvider implements BindingAwareProvider, AutoCloseable, IITMProvider,ItmStateService {
+
+    private static final Logger LOG = LoggerFactory.getLogger(ItmProvider.class);
+    private IInterfaceManager interfaceManager;
+    private ITMManager itmManager;
+    private IMdsalApiManager mdsalManager;
+    private DataBroker dataBroker;
+    private NotificationPublishService notificationPublishService;
+    private NotificationService notificationService;
+        
+    @Override
+    public void onSessionInitiated(ProviderContext session) {
+        LOG.info("ItmProvider Session Initiated");
+        try {
+            dataBroker = session.getSALService(DataBroker.class);
+           
+            itmManager = new ITMManager(dataBroker);
+            
+            itmManager.setMdsalManager(mdsalManager);
+            itmManager.setNotificationPublishService(notificationPublishService);
+            itmManager.setMdsalManager(mdsalManager);
+                       
+        } catch (Exception e) {
+            LOG.error("Error initializing services", e);
+        }
+    }
+
+    public void setInterfaceManager(IInterfaceManager interfaceManager) {
+        this.interfaceManager = interfaceManager;
+    }
+
+    public void setNotificationPublishService(NotificationPublishService notificationPublishService) {
+        this.notificationPublishService = notificationPublishService;
+    }
+    
+    public void setMdsalApiManager(IMdsalApiManager mdsalMgr) {
+        this.mdsalManager = mdsalMgr;
+    }
+    public void setNotificationService(NotificationService notificationService) {
+        this.notificationService = notificationService;
+    }
+
+    @Override
+    public void close() throws Exception {
+        if (itmManager != null) {
+            itmManager.close();
+        }
+                
+        LOG.info("ItmProvider Closed");
+    }
+
+       @Override
+       public Future<RpcResult<GetTunnelIdOutput>> getTunnelId(
+                       GetTunnelIdInput input) {
+               // TODO Auto-generated method stub
+               return null;
+       }
+
+}
diff --git a/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModule.java b/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModule.java
new file mode 100644 (file)
index 0000000..1c0a52a
--- /dev/null
@@ -0,0 +1,28 @@
+package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.impl.rev141210;
+
+import org.opendaylight.vpnservice.itm.impl.ItmProvider;
+public class ItmModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.impl.rev141210.AbstractItmModule {
+    public ItmModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
+        super(identifier, dependencyResolver);
+    }
+
+    public ItmModule(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.itm.impl.rev141210.ItmModule 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() {
+       ItmProvider provider = new ItmProvider();
+        provider.setMdsalApiManager(getMdsalutilDependency());
+        provider.setNotificationPublishService(getNotificationPublishServiceDependency());
+        provider.setNotificationService(getNotificationServiceDependency());
+        getBrokerDependency().registerProvider(provider);
+        return provider;
+    }
+
+}
diff --git a/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactory.java b/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactory.java
new file mode 100644 (file)
index 0000000..cb3805e
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+* Generated file
+*
+* Generated from: yang module name: itm-impl yang module local name: itm
+* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
+* Generated at: Fri Nov 27 15:43: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.itm.impl.rev141210;
+public class ItmModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.impl.rev141210.AbstractItmModuleFactory {
+
+}
diff --git a/itm/itm-impl/src/main/yang/itm-impl.yang b/itm/itm-impl/src/main/yang/itm-impl.yang
new file mode 100644 (file)
index 0000000..896e5d1
--- /dev/null
@@ -0,0 +1,80 @@
+module itm-impl {
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:itm:impl";
+    prefix "itm-impl";
+
+    import config { prefix config; revision-date 2013-04-05; }
+    import opendaylight-md-sal-binding { prefix md-sal-binding; revision-date 2013-10-28;}
+    import opendaylight-sal-binding-broker-impl { prefix md-sal-binding-impl; revision-date 2013-10-28;}
+    import odl-mdsalutil { prefix odl-mdsal; revision-date 2015-04-10;}
+    import odl-interface {prefix odlif; revision-date 2015-03-31;}
+    import itm { prefix itm; revision-date 2015-07-01;}
+
+    description
+        "Service definition for itm project";
+
+    revision "2014-12-10" {
+        description
+            "Initial revision";
+    }
+
+    identity itm {
+        base config:module-type;
+        config:provided-service itm:itm;
+        config:java-name-prefix Itm;
+    }
+
+    augment "/config:modules/config:module/config:configuration" {
+        case itm {
+            when "/config:modules/config:module/config:type = 'itm'";
+            container broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding:binding-broker-osgi-registry;
+                    }
+                }
+            }
+            container odlinterface {
+                 uses config:service-ref {
+                     refine type {
+                         mandatory true;
+                         config:required-identity odlif:odl-interface;
+                     }
+                 }
+            }
+            container mdsalutil {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity odl-mdsal:odl-mdsalutil;
+                        }
+                    }
+                }
+                container notification-publish-service {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity md-sal-binding-impl:binding-new-notification-publish-service;
+                        }
+                    }
+                }
+                container rpcregistry {
+                    uses config:service-ref {
+                        refine type {
+                            mandatory true;
+                            config:required-identity md-sal-binding:binding-rpc-registry;
+                        }
+                    }
+            }
+                container notification-service {
+                    uses config:service-ref {
+                        refine type {
+                        mandatory true;
+                        config:required-identity md-sal-binding-impl:binding-new-notification-service;
+                    }
+                }
+            }
+        }
+    }
+}
diff --git a/itm/itm-impl/src/test/java/org/opendaylight/vpnservice/itm/impl/ItmProviderTest.java b/itm/itm-impl/src/test/java/org/opendaylight/vpnservice/itm/impl/ItmProviderTest.java
new file mode 100644 (file)
index 0000000..537d0ac
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved. 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.itm.impl;
+
+import org.junit.Test;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.vpnservice.itm.impl.ItmProvider;
+
+import static org.mockito.Mockito.mock;
+
+public class ItmProviderTest {
+    @Test
+    public void testOnSessionInitiated() {
+        ItmProvider provider = new ItmProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class));
+    }
+
+    @Test
+    public void testClose() throws Exception {
+        ItmProvider provider = new ItmProvider();
+
+        // ensure no exceptions
+        // currently this method is empty
+        provider.close();
+    }
+}
diff --git a/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactoryTest.java b/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactoryTest.java
new file mode 100644 (file)
index 0000000..5412e80
--- /dev/null
@@ -0,0 +1,18 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved. 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.impl.rev141210;
+
+import org.junit.Test;
+
+public class ItmModuleFactoryTest {
+    @Test
+    public void testFactoryConstructor() {
+        // ensure no exceptions on construction
+        new ItmModuleFactory();
+    }
+}
diff --git a/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleTest.java b/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleTest.java
new file mode 100644 (file)
index 0000000..be7420f
--- /dev/null
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2015 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved. 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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.itm.impl.rev141210;
+
+import org.junit.Test;
+import org.opendaylight.controller.config.api.DependencyResolver;
+import org.opendaylight.controller.config.api.JmxAttribute;
+import org.opendaylight.controller.config.api.ModuleIdentifier;
+import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
+import org.opendaylight.vpnservice.itm.impl.ItmProvider;
+
+import javax.management.ObjectName;
+
+import static org.mockito.Matchers.any;
+import static org.mockito.Matchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+public class ItmModuleTest {
+    @Test
+    public void testCustomValidation() {
+        ItmModule module = new ItmModule(mock(ModuleIdentifier.class), mock(DependencyResolver.class));
+
+        // ensure no exceptions on validation
+        // currently this method is empty
+        module.customValidation();
+    }
+
+    @Test
+    public void testCreateInstance() throws Exception {
+        // configure mocks
+        DependencyResolver dependencyResolver = mock(DependencyResolver.class);
+        BindingAwareBroker broker = mock(BindingAwareBroker.class);
+        when(dependencyResolver.resolveInstance(eq(BindingAwareBroker.class), any(ObjectName.class), any(JmxAttribute.class))).thenReturn(broker);
+
+        // create instance of module with injected mocks
+        ItmModule module = new ItmModule(mock(ModuleIdentifier.class), dependencyResolver);
+
+        // getInstance calls resolveInstance to get the broker dependency and then calls createInstance
+        AutoCloseable closeable = module.getInstance();
+
+        // verify that the module registered the returned provider with the broker
+        verify(broker).registerProvider((ItmProvider)closeable);
+
+        // ensure no exceptions on close
+        closeable.close();
+    }
+}
diff --git a/itm/pom.xml b/itm/pom.xml
new file mode 100644 (file)
index 0000000..07e50df
--- /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.6.0-SNAPSHOT</version>
+    <relativePath/>
+  </parent>
+
+  <groupId>org.opendaylight.vpnservice</groupId>
+  <artifactId>itm-aggregator</artifactId>
+  <version>0.2.0-SNAPSHOT</version>
+  <name>itm</name>
+  <packaging>pom</packaging>
+  <modelVersion>4.0.0</modelVersion>
+  <prerequisites>
+    <maven>3.1.1</maven>
+  </prerequisites>
+  <modules>
+    <module>itm-api</module>
+    <module>itm-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 b7fbb63042af7187b1f73b97f08b0456ab451c75..561d19de90ffb13d864810c26326976249ac951a 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -26,6 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL
     <module>idmanager</module>
     <module>fibmanager</module>
     <module>bgpmanager</module>
+    <module>itm</module>
     <module>distribution/karaf</module>
     <module>features</module>
     <module>vpnservice-artifacts</module>