From 10fe581ba61a6ea7df588bd5ec410f2787648512 Mon Sep 17 00:00:00 2001 From: Faseela K Date: Mon, 25 Jan 2016 18:51:49 +0530 Subject: [PATCH] Basic Framework for HwVTEP Renderer in InterfaceManager Change-Id: I7b59e5a233e12ba12db273475957441e7bd1b382 Signed-off-by: Faseela K --- features/src/main/features/features.xml | 2 + interfacemgr/interfacemgr-impl/pom.xml | 11 +- .../listeners/HwVTEPConfigListener.java | 127 ++++++++++++++++++ .../HwVTEPConfigRemoveHelper.java | 59 ++++++++ .../HwVTEPInterfaceConfigAddHelper.java | 33 +++++ .../HwVTEPInterfaceStateAddHelper.java | 30 +++++ .../HwVTEPInterfaceStateRemoveHelper.java | 30 +++++ .../hwvtep/utilities/SouthboundUtils.java | 18 +++ 8 files changed, 307 insertions(+), 3 deletions(-) create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java create mode 100644 interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java diff --git a/features/src/main/features/features.xml b/features/src/main/features/features.xml index a831dfb6..513ae57e 100644 --- a/features/src/main/features/features.xml +++ b/features/src/main/features/features.xml @@ -19,6 +19,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html mvn:org.opendaylight.ovsdb/features-ovsdb/{{VERSION}}/xml/features mvn:org.opendaylight.neutron/features-neutron/{{VERSION}}/xml/features mvn:org.opendaylight.nic/features-nic/{{VERSION}}/xml/features + mvn:org.opendaylight.ovsdb/hwvtepsouthbound-features/{{VERSION}}/xml/features odl-mdsal-broker odl-mdsal-models @@ -43,6 +44,7 @@ and is available at http://www.eclipse.org/legal/epl-v10.html odl-mdsal-broker odl-ovsdb-southbound-impl-rest + odl-ovsdb-hwvtepsouthbound odl-vpnservice-api odl-openflowplugin-southbound odl-openflowplugin-flow-services diff --git a/interfacemgr/interfacemgr-impl/pom.xml b/interfacemgr/interfacemgr-impl/pom.xml index b9e22b40..459e9e07 100644 --- a/interfacemgr/interfacemgr-impl/pom.xml +++ b/interfacemgr/interfacemgr-impl/pom.xml @@ -55,14 +55,19 @@ and is available at http://www.eclipse.org/legal/epl-v10.html alivenessmonitor-api ${vpnservices.version} + + org.opendaylight.controller + sal-binding-broker-impl + org.opendaylight.ovsdb - southbound-api + hwvtepsouthbound-api ${vpns.ovsdb.version} - org.opendaylight.controller - sal-binding-broker-impl + org.opendaylight.ovsdb + southbound-api + ${vpns.ovsdb.version} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java new file mode 100644 index 00000000..4cb1e224 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/listeners/HwVTEPConfigListener.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2016 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.interfacemgr.listeners; + +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.vpnservice.datastoreutils.AsyncDataTreeChangeListenerBase; +import org.opendaylight.vpnservice.datastoreutils.DataStoreJobCoordinator; +import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.confighelpers.HwVTEPConfigRemoveHelper; +import org.opendaylight.vpnservice.interfacemgr.renderer.hwvtep.confighelpers.HwVTEPInterfaceConfigAddHelper; +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.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.TunnelTypeVxlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.interfaces._interface.NodeIdentifier; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.List; +import java.util.concurrent.Callable; + +public class HwVTEPConfigListener extends AsyncDataTreeChangeListenerBase { + private static final Logger LOG = LoggerFactory.getLogger(HwVTEPConfigListener.class); + private DataBroker dataBroker; + + public HwVTEPConfigListener(final DataBroker dataBroker) { + super(Interface.class, HwVTEPConfigListener.class); + this.dataBroker = dataBroker; + } + + @Override + protected InstanceIdentifier getWildCardPath() { + return InstanceIdentifier.create(Interfaces.class).child(Interface.class); + } + + @Override + protected void remove(InstanceIdentifier key, Interface interfaceOld) { + // HwVTEPs support only vxlan + IfTunnel ifTunnel = interfaceOld.getAugmentation(IfTunnel.class); + if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) { + ParentRefs parentRefs = interfaceOld.getAugmentation(ParentRefs.class); + if (parentRefs != null) { + for(NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) { + if(nodeIdentifier.getNodeId().equals("hwvtep:1")) { + DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance(); + RendererConfigRemoveWorker configWorker = new RendererConfigRemoveWorker(key, interfaceOld, parentRefs); + coordinator.enqueueJob(interfaceOld.getName(), configWorker); + } + } + } + } + } + + @Override + protected void update(InstanceIdentifier key, Interface interfaceOld, Interface interfaceNew) { + // TODO + } + + @Override + protected void add(InstanceIdentifier key, Interface interfaceNew) { + // HwVTEPs support only vxlan + IfTunnel ifTunnel = interfaceNew.getAugmentation(IfTunnel.class); + if (ifTunnel != null && ifTunnel.getTunnelInterfaceType().isAssignableFrom(TunnelTypeVxlan.class)) { + ParentRefs parentRefs = interfaceNew.getAugmentation(ParentRefs.class); + if (parentRefs != null) { + for(NodeIdentifier nodeIdentifier : parentRefs.getNodeIdentifier()) { + if(nodeIdentifier.getNodeId().equals("hwvtep:1")) { + DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance(); + RendererConfigAddWorker configWorker = new RendererConfigAddWorker(key, interfaceNew, parentRefs); + coordinator.enqueueJob(interfaceNew.getName(), configWorker); + } + } + } + } + } + + @Override + protected HwVTEPConfigListener getDataTreeChangeListener() { + return HwVTEPConfigListener.this; + } + + private class RendererConfigAddWorker implements Callable>> { + InstanceIdentifier key; + Interface interfaceNew; + IfL2vlan ifL2vlan; + ParentRefs parentRefs; + + public RendererConfigAddWorker(InstanceIdentifier key, Interface interfaceNew, + ParentRefs parentRefs) { + this.key = key; + this.interfaceNew = interfaceNew; + this.ifL2vlan = ifL2vlan; + this.parentRefs = parentRefs; + } + + @Override + public List> call() throws Exception { + return HwVTEPInterfaceConfigAddHelper.addConfiguration(dataBroker, parentRefs, interfaceNew); + } + } + + private class RendererConfigRemoveWorker implements Callable>> { + InstanceIdentifier key; + Interface interfaceOld; + ParentRefs parentRefs; + + public RendererConfigRemoveWorker(InstanceIdentifier key, Interface interfaceOld, + ParentRefs parentRefs) { + this.key = key; + this.interfaceOld = interfaceOld; + this.parentRefs = parentRefs; + } + + @Override + public List> call() throws Exception { + return HwVTEPConfigRemoveHelper.removeConfiguration(dataBroker, interfaceOld, parentRefs); + } + } +} \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java new file mode 100644 index 00000000..a5fa68af --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPConfigRemoveHelper.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2016 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.interfacemgr.renderer.hwvtep.confighelpers; + +import com.google.common.util.concurrent.ListenableFuture; +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.vpnservice.interfacemgr.IfmUtil; +import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceManagerCommonUtils; +import org.opendaylight.vpnservice.interfacemgr.commons.InterfaceMetaUtils; +import org.opendaylight.vpnservice.interfacemgr.renderer.ovs.utilities.SouthboundUtils; +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.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.Interface.OperStatus; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state.InterfaceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId; +import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info.InterfaceParentEntryKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007._interface.child.info._interface.parent.entry.InterfaceChildEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.BridgeEntryKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge._interface.info.bridge.entry.BridgeInterfaceEntryKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntry; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.meta.rev151007.bridge.ref.info.BridgeRefEntryKey; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfL2vlan; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.IfTunnel; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.node.TerminationPoint; +import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +public class HwVTEPConfigRemoveHelper { + private static final Logger LOG = LoggerFactory.getLogger(HwVTEPConfigRemoveHelper.class); + + public static List> removeConfiguration(DataBroker dataBroker, Interface interfaceOld, + ParentRefs parentRefs) { + List> futures = new ArrayList>(); + LOG.debug("removing hwvtep configuration for {}", interfaceOld.getName()); + + // TODO delete hwvtep through ovsdb plugin + return futures; + } +} \ No newline at end of file diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java new file mode 100644 index 00000000..a069302a --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/confighelpers/HwVTEPInterfaceConfigAddHelper.java @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2016 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.interfacemgr.renderer.hwvtep.confighelpers; + +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.controller.md.sal.binding.api.WriteTransaction; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +public class HwVTEPInterfaceConfigAddHelper { + private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceConfigAddHelper.class); + + public static List> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, + Interface interfaceNew) { + List> futures = new ArrayList>(); + LOG.debug("adding hwvtep configuration for {}", interfaceNew.getName()); + + // TODO create hwvtep through ovsdb plugin + return futures; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java new file mode 100644 index 00000000..3b4eca6b --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateAddHelper.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016 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.interfacemgr.renderer.hwvtep.statehelpers; + +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class HwVTEPInterfaceStateAddHelper { + private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateAddHelper.class); + + public static List> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, + Interface interfaceNew, IdManagerService idManager) { + List> futures = new ArrayList>(); + LOG.debug("HwVTEP Interface State Add Helper"); + return futures; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java new file mode 100644 index 00000000..d087e7b6 --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/statehelpers/HwVTEPInterfaceStateRemoveHelper.java @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2016 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.interfacemgr.renderer.hwvtep.statehelpers; + +import com.google.common.util.concurrent.ListenableFuture; +import org.opendaylight.controller.md.sal.binding.api.DataBroker; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.idmanager.rev150403.IdManagerService; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.interfacemgr.rev150331.ParentRefs; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.util.ArrayList; +import java.util.List; + +public class HwVTEPInterfaceStateRemoveHelper { + private static final Logger LOG = LoggerFactory.getLogger(HwVTEPInterfaceStateRemoveHelper.class); + + public static List> addConfiguration(DataBroker dataBroker, ParentRefs parentRefs, + Interface interfaceNew, IdManagerService idManager) { + List> futures = new ArrayList>(); + LOG.debug("HWvTEP state remove helper"); + return futures; + } +} diff --git a/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java new file mode 100644 index 00000000..fd72995b --- /dev/null +++ b/interfacemgr/interfacemgr-impl/src/main/java/org/opendaylight/vpnservice/interfacemgr/renderer/hwvtep/utilities/SouthboundUtils.java @@ -0,0 +1,18 @@ +/* + * Copyright (c) 2016 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.interfacemgr.renderer.hwvtep.utilities; + +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Uri; +import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class SouthboundUtils { + private static final Logger LOG = LoggerFactory.getLogger(SouthboundUtils.class); + public static final TopologyId HWVTEP_TOPOLOGY_ID = new TopologyId(new Uri("hwvtep:1")); +} \ No newline at end of file -- 2.36.6