From 39531da0e2fde8c65977dadc879d670e445dd5cf Mon Sep 17 00:00:00 2001 From: Abhinav Gupta Date: Thu, 21 Jan 2016 16:10:42 +0530 Subject: [PATCH] Bug 5046 : ELAN integration into NeutronVPN for ELAN instance/interfaces Change-Id: I30530f80c828a719c1a601af31f46c176a5d89c1 Signed-off-by: Abhinav Gupta --- neutronvpn/neutronvpn-impl/pom.xml | 5 ++++ .../NeutronNetworkChangeListener.java | 24 +++++++++++++++++++ .../neutronvpn/NeutronPortChangeListener.java | 24 +++++++++++++++++++ 3 files changed, 53 insertions(+) diff --git a/neutronvpn/neutronvpn-impl/pom.xml b/neutronvpn/neutronvpn-impl/pom.xml index 0ad31796..f4d39b74 100644 --- a/neutronvpn/neutronvpn-impl/pom.xml +++ b/neutronvpn/neutronvpn-impl/pom.xml @@ -37,6 +37,11 @@ and is available at http://www.eclipse.org/legal/epl-v10.html vpnmanager-api ${vpnservices.version} + + org.opendaylight.vpnservice + elanmanager-api + ${vpnservices.version} + org.opendaylight.vpnservice mdsalutil-api diff --git a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronNetworkChangeListener.java b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronNetworkChangeListener.java index 1e0252b0..4a474f35 100644 --- a/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronNetworkChangeListener.java +++ b/neutronvpn/neutronvpn-impl/src/main/java/org/opendaylight/vpnservice/neutronvpn/NeutronNetworkChangeListener.java @@ -14,6 +14,11 @@ import org.opendaylight.controller.md.sal.binding.api.DataChangeListener; import org.opendaylight.controller.md.sal.common.api.data.AsyncDataBroker.DataChangeScope; import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType; import org.opendaylight.vpnservice.mdsalutil.AbstractDataChangeListener; +import org.opendaylight.vpnservice.mdsalutil.MDSALUtil; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.ElanInstances; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.instances.ElanInstance; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.instances.ElanInstanceBuilder; +import org.opendaylight.yang.gen.v1.urn.opendaylight.vpnservice.elan.rev150602.elan.instances.ElanInstanceKey; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.Networks; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network; import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron; @@ -70,6 +75,8 @@ public class NeutronNetworkChangeListener extends AbstractDataChangeListener } int portVlanId = NeutronvpnUtils.getVlanFromNeutronPort(port); // Remove of-port interface for this neutron port + // ELAN interface is also implicitly deleted as part of this operation deleteOfPortInterface(port, portVlanId); } @@ -220,6 +228,22 @@ public class NeutronPortChangeListener extends AbstractDataChangeListener .getUuid()); } + private void createElanInterface(Port port, int portVlanId) { + String name = NeutronvpnUtils.uuidToTapPortName(port.getUuid()); + String interfaceName = new StringBuilder(name).append(":").append(Integer.toString(portVlanId)).toString(); + String elanInstanceName = port.getNetworkId().getValue(); + List physAddresses = new ArrayList<>(); + physAddresses.add(new PhysAddress(port.getMacAddress())); + + InstanceIdentifier id = InstanceIdentifier.builder(ElanInterfaces.class).child(ElanInterface + .class, new ElanInterfaceKey(interfaceName)).build(); + ElanInterface elanInterface = new ElanInterfaceBuilder().setElanInstanceName(elanInstanceName) + .setName(interfaceName).setStaticMacEntries(physAddresses). + setKey(new ElanInterfaceKey(interfaceName)).build(); + MDSALUtil.syncWrite(broker, LogicalDatastoreType.CONFIGURATION, id, elanInterface); + LOG.debug("Creating new ELan Interface {}", elanInterface); + } + // adds port to subnet list and creates vpnInterface private Uuid addPortToSubnets(Port port) { Uuid subnetId = null; -- 2.36.6