From: Icaro Camelo Date: Wed, 9 Dec 2015 23:02:45 +0000 (-0500) Subject: Added support for VPN Intent X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?p=vpnservice.git;a=commitdiff_plain;h=e5f09d80ab141403030ed9e626930b75afdfbab3 Added support for VPN Intent Change-Id: I85edca79213c6f20413b66f23003248575d7042a Signed-off-by: Icaro Camelo Signed-off-by: Rashmi Pujar --- diff --git a/features/pom.xml b/features/pom.xml index 067f4bb0..2508f3ce 100644 --- a/features/pom.xml +++ b/features/pom.xml @@ -30,6 +30,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL 1.3.0-SNAPSHOT 0.11.0-SNAPSHOT 0.7.0-SNAPSHOT + 1.2.0-SNAPSHOT ${vpnservices.version} ${vpnservices.version} ${vpnservices.version} @@ -86,6 +87,14 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL xml runtime + + org.opendaylight.nic + features-nic + features + ${nic.version} + xml + runtime + org.opendaylight.ovsdb features-ovsdb @@ -377,5 +386,22 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL commons-net ${commons.net.version} + + ${project.groupId} + vpnintent-api + ${vpnservices.version} + + + ${project.groupId} + vpnintent-impl + ${vpnservices.version} + + + ${project.groupId} + vpnintent-impl + ${vpnservices.version} + config + xml + diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index cfebda44..74e321ff 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -18,6 +18,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.netconf/features-restconf/${restconf.version}/xml/features mvn:org.opendaylight.ovsdb/features-ovsdb/${ovsdb.version}/xml/features mvn:org.opendaylight.neutron/features-neutron/${neutron.version}/xml/features + mvn:org.opendaylight.nic/features-nic/{{VERSION}}/xml/features odl-mdsal-broker odl-mdsal-models @@ -66,6 +67,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.vpnservice/elanmanager-impl/${elanmgr.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" mvn:org.opendaylight.vpnservice/lockmanager-impl/${lockmanager.version}/xml/config @@ -101,4 +103,13 @@ and is available at http://www.eclipse.org/legal/epl-v10.html odl-vpnservice-impl + + odl-mdsal-broker + odl-nic-core-service-mdsal + odl-nic-core + odl-nic-listeners + mvn:org.opendaylight.vpnservice/vpnintent-api/{{VERSION}} + mvn:org.opendaylight.vpnservice/vpnintent-impl/{{VERSION}} + mvn:org.opendaylight.vpnservice/vpnintent-impl/{{VERSION}}/xml/config + diff --git a/pom.xml b/pom.xml index 591652c6..e29557e9 100644 --- a/pom.xml +++ b/pom.xml @@ -4,8 +4,7 @@ Copyright (c) 2015 - 2016 Ericsson India Global Services Pvt Ltd. and others. A 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 ---> - +--> org.opendaylight.vpnservice vpnservice 0.3.0-SNAPSHOT @@ -35,6 +34,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL distribution/karaf features vpnservice-artifacts + vpnintent @@ -62,4 +62,4 @@ and is available at http://www.eclipse.org/legal/epl-v10.html INTERNAL https://wiki.opendaylight.org/view/VPNService:Main HEAD - + \ No newline at end of file diff --git a/vpnintent/api/pom.xml b/vpnintent/api/pom.xml new file mode 100644 index 00000000..24f8d542 --- /dev/null +++ b/vpnintent/api/pom.xml @@ -0,0 +1,34 @@ + + + + + org.opendaylight.vpnservice + binding-parent + 0.3.0-SNAPSHOT + ../../commons/binding-parent + + + 4.0.0 + org.opendaylight.vpnservice + vpnintent-api + ${vpnservices.version} + bundle + + + + org.opendaylight.mdsal.model + ietf-inet-types + + + org.opendaylight.mdsal.model + ietf-yang-types + + + + diff --git a/vpnintent/api/src/main/yang/vpnintent.yang b/vpnintent/api/src/main/yang/vpnintent.yang new file mode 100644 index 00000000..bb2528f2 --- /dev/null +++ b/vpnintent/api/src/main/yang/vpnintent.yang @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2016 Inocybe Technologies 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 + */ +module vpnintent { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:vpnintent"; + prefix "vpnintent"; + + import ietf-inet-types { prefix inet; revision-date 2010-09-24;} + + revision "2015-01-05" { + description "Initial revision of VPN intent model. + Create VPN via Intent, keep VPN state and manage MPLS labels"; + } + + container vpns{ + list vpn-intents { + key "vpn-name"; + uses vpn-intent; + } + } + + grouping vpn-intent { + leaf vpn-name { + type string; + description "VPN name"; + mandatory true; + } + list endpoint { + key "site-name"; + uses endpoint-fields; + description "List to keep track site name and endpoint."; + } + } + + grouping endpoint-fields { + leaf site-name{ + type string; + description "VPN member site name."; + } + + leaf ip-prefix { + type inet:ip-prefix; + description "VPN member IP prefix."; + } + + leaf switch-port-id { + type string; + description "Switch and port ID that VPN member is connected to."; + } + } + + grouping labels { + list label { + key "label-id"; + leaf "label-id"{ + type uint64; + description "MPLS or other label ID."; + mandatory true; + } + uses endpoint-fields; + description "Keep track of MPLS/other label endpoint relation."; + } + } + } diff --git a/vpnintent/impl/pom.xml b/vpnintent/impl/pom.xml new file mode 100644 index 00000000..51cb833d --- /dev/null +++ b/vpnintent/impl/pom.xml @@ -0,0 +1,41 @@ + + + + + + org.opendaylight.vpnservice + config-parent + 0.3.0-SNAPSHOT + ../../commons/config-parent + + + 4.0.0 + vpnintent-impl + ${vpnservices.version} + bundle + + + ${project.groupId} + vpnintent-api + ${project.version} + + + + junit + junit + test + + + + org.mockito + mockito-all + test + + + + diff --git a/vpnintent/impl/src/main/config/default-config.xml b/vpnintent/impl/src/main/config/default-config.xml new file mode 100644 index 00000000..0b6f6a68 --- /dev/null +++ b/vpnintent/impl/src/main/config/default-config.xml @@ -0,0 +1,34 @@ + + + + + + urn:opendaylight:params:xml:ns:yang:vpnintent:impl?module=vpnintent-impl&revision=2014-12-10 + urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding?module=opendaylight-md-sal-binding&revision=2013-10-28 + + + + + + + prefix:vpnintent-impl + vpnintent-impl-default + + binding:binding-broker-osgi-registry + binding-osgi-broker + + + binding:binding-rpc-registry + binding-rpc-broker + + + + + + diff --git a/vpnintent/impl/src/main/java/org/opendaylight/vpnservice/impl/VpnintentProvider.java b/vpnintent/impl/src/main/java/org/opendaylight/vpnservice/impl/VpnintentProvider.java new file mode 100644 index 00000000..637d8150 --- /dev/null +++ b/vpnintent/impl/src/main/java/org/opendaylight/vpnservice/impl/VpnintentProvider.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016 Inocybe Technologies 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.impl; + +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +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.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpnintent.rev150105.Vpns; +import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpnintent.rev150105.VpnsBuilder; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import com.google.common.util.concurrent.FutureCallback; +import com.google.common.util.concurrent.Futures; + +public class VpnintentProvider implements BindingAwareProvider, AutoCloseable { + + private static final Logger LOG = LoggerFactory.getLogger(VpnintentProvider.class); + public static final InstanceIdentifier VPN_INTENT_IID = InstanceIdentifier.builder(Vpns.class).build(); + + private DataBroker dataBroker; + + @Override + public void onSessionInitiated(ProviderContext session) { + LOG.info("VpnintentProvider Session Initiated"); + dataBroker = session.getSALService(DataBroker.class); + + Vpns vpns = new VpnsBuilder().build(); + + // Initialize default config data in MD-SAL data store + initDatastore(LogicalDatastoreType.CONFIGURATION, VPN_INTENT_IID, vpns); + } + + @Override + public void close() throws Exception { + LOG.info("VpnintentProvider Closed"); + } + + private void initDatastore(LogicalDatastoreType store, InstanceIdentifier iid, Vpns mappings) { + // Put the Mapping data to MD-SAL data store + WriteTransaction transaction = dataBroker.newWriteOnlyTransaction(); + transaction.put(store, iid, mappings); + + // Perform the tx.submit asynchronously + Futures.addCallback(transaction.submit(), new FutureCallback() { + @Override + public void onSuccess(final Void result) { + LOG.info("initDatastore for VPN-Intents: transaction succeeded"); + } + + @Override + public void onFailure(final Throwable throwable) { + LOG.error("initDatastore for VPN-Intents: transaction failed"); + } + }); + LOG.info("initDatastore: VPN-Intents data populated: {}", store, iid, mappings); + } +} diff --git a/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModule.java b/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModule.java new file mode 100644 index 00000000..7d0cfb17 --- /dev/null +++ b/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModule.java @@ -0,0 +1,26 @@ +package org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpnintent.impl.rev141210; + +import org.opendaylight.vpnservice.impl.VpnintentProvider; + +public class VpnintentImplModule extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpnintent.impl.rev141210.AbstractVpnintentImplModule { + public VpnintentImplModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) { + super(identifier, dependencyResolver); + } + + public VpnintentImplModule(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.vpnintent.impl.rev141210.VpnintentImplModule 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() { + VpnintentProvider provider = new VpnintentProvider(); + getBrokerDependency().registerProvider(provider); + return provider; + } + +} diff --git a/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModuleFactory.java b/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModuleFactory.java new file mode 100644 index 00000000..a369ccc4 --- /dev/null +++ b/vpnintent/impl/src/main/java/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/vpnintent/impl/rev141210/VpnintentImplModuleFactory.java @@ -0,0 +1,13 @@ +/* +* Generated file +* +* Generated from: yang module name: vpnintent-impl yang module local name: vpnintent-impl +* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator +* Generated at: Wed Dec 16 22:44:32 EST 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.vpnintent.impl.rev141210; +public class VpnintentImplModuleFactory extends org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.vpnintent.impl.rev141210.AbstractVpnintentImplModuleFactory { + +} diff --git a/vpnintent/impl/src/main/yang/vpnintent-impl.yang b/vpnintent/impl/src/main/yang/vpnintent-impl.yang new file mode 100644 index 00000000..1016f7e4 --- /dev/null +++ b/vpnintent/impl/src/main/yang/vpnintent-impl.yang @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2016 Inocybe Technologies 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 + */ +module vpnintent-impl { + yang-version 1; + namespace "urn:opendaylight:params:xml:ns:yang:vpnintent:impl"; + prefix "vpnintent-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 vpnintent project"; + + revision "2014-12-10" { + description + "Initial revision"; + } + + identity vpnintent-impl { + base config:module-type; + config:java-name-prefix VpnintentImpl; + } + + augment "/config:modules/config:module/config:configuration" { + case vpnintent-impl { + when "/config:modules/config:module/config:type = 'vpnintent-impl'"; + container broker { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-broker-osgi-registry; + } + } + } + container rpc-registry { + uses config:service-ref { + refine type { + mandatory true; + config:required-identity md-sal-binding:binding-rpc-registry; + } + } + } + } + } +} diff --git a/vpnintent/impl/src/test/java/org/opendaylight/vpnservice/impl/VpnintentProviderTest.java b/vpnintent/impl/src/test/java/org/opendaylight/vpnservice/impl/VpnintentProviderTest.java new file mode 100644 index 00000000..a23d8ae2 --- /dev/null +++ b/vpnintent/impl/src/test/java/org/opendaylight/vpnservice/impl/VpnintentProviderTest.java @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2016 Inocybe Technologies 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.impl; + +import static org.mockito.Mockito.mock; + +import org.junit.Ignore; +import org.junit.Test; +import org.opendaylight.controller.sal.binding.api.BindingAwareBroker; + +public class VpnintentProviderTest { + @Ignore + @Test + public void testOnSessionInitiated() { + VpnintentProvider provider = new VpnintentProvider(); + + // ensure no exceptions + // currently this method is empty + provider.onSessionInitiated(mock(BindingAwareBroker.ProviderContext.class)); + } + + @Ignore + @Test + public void testClose() throws Exception { + VpnintentProvider provider = new VpnintentProvider(); + + // ensure no exceptions + // currently this method is empty + provider.close(); + } +} diff --git a/vpnintent/pom.xml b/vpnintent/pom.xml new file mode 100644 index 00000000..32d05046 --- /dev/null +++ b/vpnintent/pom.xml @@ -0,0 +1,49 @@ + + + + + + org.opendaylight.odlparent + odlparent-lite + 1.7.0-SNAPSHOT + + + org.opendaylight.vpnservice + vpnintent-aggregator + 0.3.0-SNAPSHOT + vpnintent + pom + 4.0.0 + + 3.1.1 + + + api + impl + + + + + + org.apache.maven.plugins + maven-deploy-plugin + + true + + + + org.apache.maven.plugins + maven-install-plugin + + true + + + + + +