From 0a2b4b7ada462bbbfa5ad07ea104b82fc2f2a497 Mon Sep 17 00:00:00 2001 From: HemaTG Date: Fri, 4 Dec 2015 14:29:38 +0530 Subject: [PATCH] Initial checkin for ITM module Change-Id: Ib79a940816091af1eee927c5f2c5b26f934278f9 Signed-off-by: HemaTG --- features/pom.xml | 13 ++ features/src/main/features/features.xml | 6 +- itm/itm-api/pom.xml | 37 ++++++ .../vpnservice/itm/api/IITMProvider.java | 12 ++ .../vpnservice/itm/globals/ITMConstants.java | 13 ++ itm/itm-api/src/main/yang/itm-state.yang | 124 ++++++++++++++++++ itm/itm-api/src/main/yang/itm.yang | 63 +++++++++ itm/itm-impl/pom.xml | 80 +++++++++++ .../src/main/config/default-config.xml | 63 +++++++++ .../vpnservice/itm/impl/ITMManager.java | 55 ++++++++ .../vpnservice/itm/impl/ItmProvider.java | 91 +++++++++++++ .../ns/yang/itm/impl/rev141210/ItmModule.java | 28 ++++ .../itm/impl/rev141210/ItmModuleFactory.java | 13 ++ itm/itm-impl/src/main/yang/itm-impl.yang | 80 +++++++++++ .../vpnservice/itm/impl/ItmProviderTest.java | 34 +++++ .../impl/rev141210/ItmModuleFactoryTest.java | 18 +++ .../itm/impl/rev141210/ItmModuleTest.java | 54 ++++++++ itm/pom.xml | 49 +++++++ pom.xml | 1 + 19 files changed, 832 insertions(+), 2 deletions(-) create mode 100644 itm/itm-api/pom.xml create mode 100644 itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/api/IITMProvider.java create mode 100644 itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java create mode 100644 itm/itm-api/src/main/yang/itm-state.yang create mode 100644 itm/itm-api/src/main/yang/itm.yang create mode 100644 itm/itm-impl/pom.xml create mode 100644 itm/itm-impl/src/main/config/default-config.xml create mode 100644 itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ITMManager.java create mode 100644 itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java create mode 100644 itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModule.java create mode 100644 itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactory.java create mode 100644 itm/itm-impl/src/main/yang/itm-impl.yang create mode 100644 itm/itm-impl/src/test/java/org/opendaylight/vpnservice/itm/impl/ItmProviderTest.java create mode 100644 itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactoryTest.java create mode 100644 itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleTest.java create mode 100644 itm/pom.xml diff --git a/features/pom.xml b/features/pom.xml index 298fc804..4b109efe 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -34,6 +34,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL ${vpnservices.version} ${vpnservices.version} ${vpnservices.version} + ${vpnservices.version} @@ -225,6 +226,18 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL ${project.groupId} idmanager-api ${idmanager.version} + + + org.opendaylight.vpnservice + itm-impl + ${itm.version} + + + org.opendaylight.vpnservice + itm-impl + ${itm.version} + config + xml org.apache.thrift diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index e03ef333..4ffb0e3c 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -25,7 +25,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.vpnservice/vpnmanager-api/${vpnmanager.version} mvn:org.opendaylight.vpnservice/nexthopmgr-api/${nexthopmgr.version} mvn:org.opendaylight.vpnservice/fibmanager-api/${fibmanager.version} - + mvn:org.opendaylight.vpnservice/itm-api/${itm.version} odl-mdsal-broker @@ -43,7 +43,8 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version} mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version} mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version} - + mvn:org.opendaylight.vpnservice/itm-impl/${itm.version} + wrap:mvn:org.apache.thrift/libthrift/0.9.1$overwrite=merge&Bundle-Version=0.9.1&Export-Package=*;-noimport:=true;version="0.9.1" @@ -54,6 +55,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.vpnservice/vpnmanager-impl/${vpnmanager.version}/xml/config mvn:org.opendaylight.vpnservice/nexthopmgr-impl/${nexthopmgr.version}/xml/config mvn:org.opendaylight.vpnservice/fibmanager-impl/${fibmanager.version}/xml/config + mvn:org.opendaylight.vpnservice/itm-impl/${itm.version}/xml/config diff --git a/itm/itm-api/pom.xml b/itm/itm-api/pom.xml new file mode 100644 index 00000000..4003b968 --- /dev/null +++ b/itm/itm-api/pom.xml @@ -0,0 +1,37 @@ + + + + + org.opendaylight.vpnservice + config-parent + 0.2.0-SNAPSHOT + ../../commons/config-parent + + + 4.0.0 + org.opendaylight.vpnservice + itm-api + 0.2.0-SNAPSHOT + bundle + + + + org.opendaylight.vpnservice + interfacemgr-api + ${vpnservices.version} + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + + org.opendaylight.mdsal.model + ietf-interfaces + + + 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 index 00000000..5610422d --- /dev/null +++ b/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/api/IITMProvider.java @@ -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 index 00000000..d60c72b7 --- /dev/null +++ b/itm/itm-api/src/main/java/org/opendaylight/vpnservice/itm/globals/ITMConstants.java @@ -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 index 00000000..f3951241 --- /dev/null +++ b/itm/itm-api/src/main/yang/itm-state.yang @@ -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 index 00000000..bbc1273b --- /dev/null +++ b/itm/itm-api/src/main/yang/itm.yang @@ -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 index 00000000..ca5e9074 --- /dev/null +++ b/itm/itm-impl/pom.xml @@ -0,0 +1,80 @@ + + + + + org.opendaylight.vpnservice + config-parent + 0.2.0-SNAPSHOT + ../../commons/config-parent + + 4.0.0 + org.opendaylight.vpnservice + itm-impl + 0.2.0-SNAPSHOT + bundle + + + 2.4.3 + + + + org.opendaylight.vpnservice + itm-api + ${project.version} + + + org.opendaylight.vpnservice + interfacemgr-api + ${vpnservices.version} + + + org.opendaylight.vpnservice + interfacemgr-impl + ${vpnservices.version} + + + org.opendaylight.vpnservice + mdsalutil-api + ${vpnservices.version} + + + org.opendaylight.controller + sal-binding-broker-impl + + + org.opendaylight.mdsal.model + ietf-interfaces + + + + junit + junit + test + + + org.mockito + mockito-all + test + + + org.opendaylight.vpnservice + interfacemgr-api + ${vpnservices.version} + + + org.opendaylight.vpnservice + mdsalutil-api + ${vpnservices.version} + + + com.google.guava + guava + 18.0 + + + commons-net + commons-net + + + 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 index 00000000..cb063605 --- /dev/null +++ b/itm/itm-impl/src/main/config/default-config.xml @@ -0,0 +1,63 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:itm?module=itm&revision=2015-07-01 + urn:opendaylight:params:xml:ns:yang:itm:impl?module=itm-impl&revision=2014-12-10 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding:impl?module=opendaylight-sal-binding-broker-impl&revision=2013-10-28 + urn:opendaylight:params:xml:ns:yang:mdsalutil:api?module=odl-mdsalutil&revision=2015-04-10 + urn:opendaylight:vpnservice:interfacemgr?module=odl-interface&revision=2015-03-31 + + + + + + + prefix:itm + itm-default + + binding:binding-broker-osgi-registry + binding-osgi-broker + + + odlif:odl-interface + interfacemgr-service + + + binding:binding-rpc-registry + binding-rpc-broker + + + mdsalutil:odl-mdsalutil + mdsalutil-service + + + bindingimpl:binding-new-notification-publish-service + binding-notification-publish-adapter + + + bindingimpl:binding-new-notification-service + binding-notification-adapter + + + + + + prefix:itm + + itm + /modules/module[type='itm'][name='itm-default'] + + + + + + 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 index 00000000..7aa7ead9 --- /dev/null +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ITMManager.java @@ -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 index 00000000..a53b760e --- /dev/null +++ b/itm/itm-impl/src/main/java/org/opendaylight/vpnservice/itm/impl/ItmProvider.java @@ -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> 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 index 00000000..1c0a52a7 --- /dev/null +++ b/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModule.java @@ -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 index 00000000..cb3805e7 --- /dev/null +++ b/itm/itm-impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactory.java @@ -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 index 00000000..896e5d1a --- /dev/null +++ b/itm/itm-impl/src/main/yang/itm-impl.yang @@ -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 index 00000000..537d0ace --- /dev/null +++ b/itm/itm-impl/src/test/java/org/opendaylight/vpnservice/itm/impl/ItmProviderTest.java @@ -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 index 00000000..5412e807 --- /dev/null +++ b/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleFactoryTest.java @@ -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 index 00000000..be7420fc --- /dev/null +++ b/itm/itm-impl/src/test/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/itm/impl/rev141210/ItmModuleTest.java @@ -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 index 00000000..07e50df6 --- /dev/null +++ b/itm/pom.xml @@ -0,0 +1,49 @@ + + + + + + org.opendaylight.odlparent + odlparent + 1.6.0-SNAPSHOT + + + + org.opendaylight.vpnservice + itm-aggregator + 0.2.0-SNAPSHOT + itm + pom + 4.0.0 + + 3.1.1 + + + itm-api + itm-impl + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + diff --git a/pom.xml b/pom.xml index b7fbb630..561d19de 100644 --- a/pom.xml +++ b/pom.xml @@ -26,6 +26,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL idmanager fibmanager bgpmanager + itm distribution/karaf features vpnservice-artifacts -- 2.36.6