Support non-neutron networks for creation of TZ.
Listen to Elan and Vpn changes instead of NeutronPorts.
This will be used for unimgr.
Change-Id: I24ae67888352b9a5f941f74abf4db019e3cf439e
Signed-off-by: Yakir Dorani <yakir.dorani@hpe.com>
<?xml version="1.0" encoding="UTF-8"?>
-<!-- vi: set et smarttab sw=4 tabstop=4: --><!--
-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
--->
-<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">
+<!-- vi: set et smarttab sw=4 tabstop=4: --><!-- 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 -->
+<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.netvirt</groupId>
<artifactId>utils.config</artifactId>
<version>${vpns.ovsdb.version}</version>
</dependency>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>vpnmanager-api</artifactId>
+ <version>${vpnservices.version}</version>
+ </dependency>
- <!-- Only for unit-test -->
+ <!-- Only for unit-test -->
<dependency>
<groupId>org.opendaylight.yangtools</groupId>
<artifactId>testutils</artifactId>
</executions>
</plugin>
<plugin>
- <groupId>org.eclipse.xtend</groupId>
- <artifactId>xtend-maven-plugin</artifactId>
+ <groupId>org.eclipse.xtend</groupId>
+ <artifactId>xtend-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
- <!--
- Maven Site Configuration
-
- The following configuration is necessary for maven-site-plugin to
- correctly identify the correct deployment path for OpenDaylight Maven
- sites.
- -->
- <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
+ <!-- Maven Site Configuration The following configuration is necessary
+ for maven-site-plugin to correctly identify the correct deployment path for
+ OpenDaylight Maven sites. -->
+ <url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
- <distributionManagement>
- <site>
- <id>opendaylight-site</id>
- <url>${nexus.site.url}/${project.artifactId}/</url>
- </site>
- </distributionManagement>
+ <distributionManagement>
+ <site>
+ <id>opendaylight-site</id>
+ <url>${nexus.site.url}/${project.artifactId}/</url>
+ </site>
+ </distributionManagement>
</project>
--- /dev/null
+/*
+ * Copyright (c) 2017 HPE 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.netvirt.elan.internal;
+
+import java.math.BigInteger;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.netvirt.elan.utils.ElanUtils;
+import org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.ElanDpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.ElanDpnInterfacesList;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.dpn.interfaces.elan.dpn.interfaces.list.DpnInterfaces;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ElanDpnToTransportZoneListener
+ extends AsyncDataTreeChangeListenerBase<DpnInterfaces, ElanDpnToTransportZoneListener> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ElanDpnToTransportZoneListener.class);
+ private final TransportZoneNotificationUtil transportZoneNotificationUtil;
+ private final DataBroker dbx;
+ private final Boolean useTransportZone;
+
+ public ElanDpnToTransportZoneListener(final DataBroker dbx, final IInterfaceManager interfaceManager,
+ final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu) {
+ useTransportZone = elanConfig.isAutoConfigTransportZones();
+ transportZoneNotificationUtil = tznu;
+ this.dbx = dbx;
+ }
+
+ public void start() {
+ LOG.info("{} start", getClass().getSimpleName());
+
+ if (useTransportZone) {
+ registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
+ }
+ }
+
+ @Override
+ public InstanceIdentifier<DpnInterfaces> getWildCardPath() {
+ return InstanceIdentifier.builder(ElanDpnInterfaces.class).child(ElanDpnInterfacesList.class)
+ .child(DpnInterfaces.class).build();
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModificationBefore,
+ DpnInterfaces dataObjectModificationAfter) {
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
+ LOG.debug("Elan dpn {} add detected, updating transport zones", dataObjectModification.getDpId());
+
+ BigInteger dpId = dataObjectModification.getDpId();
+ String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
+
+ if (!ElanUtils.isVxlanNetwork(dbx, elanInstanceName)) {
+ return;
+ }
+
+ transportZoneNotificationUtil.updateTransportZone(elanInstanceName, dpId);
+ }
+
+ @Override
+ protected ElanDpnToTransportZoneListener getDataTreeChangeListener() {
+ return ElanDpnToTransportZoneListener.this;
+ }
+}
\ No newline at end of file
--- /dev/null
+/*
+ * Copyright (c) 2017 HPE 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.netvirt.elan.internal;
+
+import java.util.stream.Collectors;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.VpnInstanceOpData;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class VpnDpnToTransportZoneListener
+ extends AsyncDataTreeChangeListenerBase<VpnToDpnList, VpnDpnToTransportZoneListener> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(VpnDpnToTransportZoneListener.class);
+ private TransportZoneNotificationUtil transportZoneNotificationUtil;
+ private DataBroker dbx;
+ private Boolean useTransportZone;
+
+ public VpnDpnToTransportZoneListener(final DataBroker dbx, final IInterfaceManager interfaceManager,
+ final ElanConfig elanConfig, final TransportZoneNotificationUtil tznu) {
+ useTransportZone = elanConfig.isAutoConfigTransportZones();
+ transportZoneNotificationUtil = tznu;
+ this.dbx = dbx;
+ }
+
+ public void start() {
+ LOG.info("{} start", getClass().getSimpleName());
+
+ if (useTransportZone) {
+ registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
+ }
+ }
+
+ @Override
+ protected InstanceIdentifier<VpnToDpnList> getWildCardPath() {
+ return InstanceIdentifier.builder(VpnInstanceOpData.class).child(VpnInstanceOpDataEntry.class)
+ .child(VpnToDpnList.class).build();
+ }
+
+ @Override
+ protected void remove(InstanceIdentifier<VpnToDpnList> identifier, VpnToDpnList del) {
+ }
+
+ @Override
+ protected void update(InstanceIdentifier<VpnToDpnList> identifier, VpnToDpnList original, VpnToDpnList update) {
+ LOG.debug("Vpn dpn {} update detected, updating transport zones", update.getDpnId());
+
+ if (update.getVpnInterfaces() == null || update.getVpnInterfaces().isEmpty()) {
+ LOG.debug("Vpn dpn {} doesn't contain any vpn interfaces", update.getDpnId());
+ return;
+ }
+
+ boolean shouldCreateVtep;
+ if (original.getVpnInterfaces() != null || original.getVpnInterfaces().isEmpty()) {
+ shouldCreateVtep = transportZoneNotificationUtil.shouldCreateVtep(update.getVpnInterfaces().stream()
+ .filter(vi -> !original.getVpnInterfaces().contains(vi)).collect(Collectors.toList()));
+ } else {
+ shouldCreateVtep = transportZoneNotificationUtil.shouldCreateVtep(update.getVpnInterfaces());
+ }
+
+ if (shouldCreateVtep) {
+ String vrfId = identifier.firstKeyOf(VpnInstanceOpDataEntry.class).getVrfId();
+ transportZoneNotificationUtil.updateTransportZone(vrfId, update.getDpnId());
+ }
+ }
+
+ @Override
+ protected void add(InstanceIdentifier<VpnToDpnList> identifier, VpnToDpnList add) {
+ LOG.debug("Vpn dpn {} add detected, updating transport zones", add.getDpnId());
+
+ boolean shouldCreateVtep = transportZoneNotificationUtil.shouldCreateVtep(add.getVpnInterfaces());
+ if (shouldCreateVtep) {
+ String vrfId = identifier.firstKeyOf(VpnInstanceOpDataEntry.class).getVrfId();
+ transportZoneNotificationUtil.updateTransportZone(vrfId, add.getDpnId());
+ }
+ }
+
+ @Override
+ protected VpnDpnToTransportZoneListener getDataTreeChangeListener() {
+ return VpnDpnToTransportZoneListener.this;
+ }
+}
&& elanInstance.getSegmentationId() != null && elanInstance.getSegmentationId() != 0;
}
+ public static boolean isVxlanNetwork(DataBroker broker, String elanInstanceName) {
+ ElanInstance elanInstance = getElanInstanceByName(broker, elanInstanceName);
+ return (elanInstance != null && isVxlan(elanInstance));
+ }
+
public static boolean isVxlanSegment(ElanInstance elanInstance) {
if (elanInstance != null) {
List<ElanSegments> elanSegments = elanInstance.getElanSegments();
--- /dev/null
+/*
+ * Copyright (c) 2017 HPE 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.netvirt.elan.utils;
+
+import com.google.common.base.Optional;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
+import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
+import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
+import org.opendaylight.genius.interfacemanager.interfaces.IInterfaceManager;
+import org.opendaylight.netvirt.elanmanager.api.IElanService;
+import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
+import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.BridgeRefInfo;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntryKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.interfaces.ElanInterface;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
+import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TransportZoneNotificationUtil {
+ private static final Logger LOG = LoggerFactory.getLogger(TransportZoneNotificationUtil.class);
+ private static final String TUNNEL_PORT = "tunnel_port";
+ private static final String LOCAL_IP = "local_ip";
+ private static final String ALL_SUBNETS_GW = "0.0.0.0";
+ private static final String ALL_SUBNETS = "0.0.0.0/0";
+ private final DataBroker dataBroker;
+ private final MdsalUtils mdsalUtils;
+ private final SouthboundUtils southBoundUtils;
+ private final IElanService elanService;
+ private final ElanConfig elanConfig;
+
+ public TransportZoneNotificationUtil(final DataBroker dbx, final IInterfaceManager interfaceManager,
+ final IElanService elanService, final ElanConfig elanConfig) {
+ this.dataBroker = dbx;
+ this.mdsalUtils = new MdsalUtils(dbx);
+ this.elanService = elanService;
+ this.elanConfig = elanConfig;
+ southBoundUtils = new SouthboundUtils(mdsalUtils);
+ }
+
+ public boolean shouldCreateVtep(List<VpnInterfaces> vpnInterfaces) {
+ if (vpnInterfaces == null || vpnInterfaces.isEmpty()) {
+ return false;
+ }
+
+ for (VpnInterfaces vpnInterface : vpnInterfaces) {
+ String interfaceName = vpnInterface.getInterfaceName();
+
+ ElanInterface elanInt = elanService.getElanInterfaceByElanInterfaceName(interfaceName);
+ if (elanInt == null) {
+ continue;
+ }
+
+ if (ElanUtils.isVxlanNetwork(dataBroker, elanInt.getElanInstanceName())) {
+ return true;
+ } else {
+ LOG.debug("Non-VXLAN elanInstance: " + elanInt.getElanInstanceName());
+ }
+ }
+
+ return false;
+ }
+
+ private TransportZone createZone(String subnetIp, String zoneName) {
+ List<Subnets> subnets = new ArrayList<>();
+ subnets.add(buildSubnets(subnetIp));
+ TransportZoneBuilder tzb = new TransportZoneBuilder().setKey(new TransportZoneKey(zoneName))
+ .setTunnelType(TunnelTypeVxlan.class).setZoneName(zoneName).setSubnets(subnets);
+ return tzb.build();
+ }
+
+ private void updateTransportZone(TransportZone zone, BigInteger dpnId) throws TransactionCommitFailedException {
+ InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(zone.getZoneName())).build();
+
+ SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, path, zone);
+ LOG.info("Transport zone {} updated due to dpn {} handling.", zone.getZoneName(), dpnId);
+ }
+
+ @SuppressWarnings("checkstyle:IllegalCatch")
+ public void updateTransportZone(String zoneName, BigInteger dpnId) {
+ InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class)
+ .child(TransportZone.class, new TransportZoneKey(zoneName));
+
+ // FIXME: Read this through a cache
+ TransportZone zone = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, inst);
+
+ if (zone == null) {
+ zone = createZone(ALL_SUBNETS, zoneName);
+ }
+
+ try {
+ if (addVtep(zone, ALL_SUBNETS, dpnId)) {
+ updateTransportZone(zone, dpnId);
+ }
+ } catch (Exception e) {
+ LOG.error("Failed to add tunnels for dpn {} in zone {}", dpnId, zoneName, e);
+ }
+ }
+
+ /**
+ * Tries to add a vtep for a transport zone.
+ *
+ * @return Whether a vtep was added or not.
+ */
+ private boolean addVtep(TransportZone zone, String subnetIp, BigInteger dpnId) throws Exception {
+ Subnets subnets = getOrAddSubnet(zone.getSubnets(), subnetIp);
+ for (Vteps existingVtep : subnets.getVteps()) {
+ if (existingVtep.getDpnId().equals(dpnId)) {
+ return false;
+ }
+ }
+
+ Optional<IpAddress> nodeIp = getNodeIP(dpnId);
+
+ if (nodeIp.isPresent()) {
+ VtepsBuilder vtepsBuilder =
+ new VtepsBuilder().setDpnId(dpnId).setIpAddress(nodeIp.get()).setPortname(TUNNEL_PORT)
+ .setOptionOfTunnel(elanConfig.isUseOfTunnels());
+ subnets.getVteps().add(vtepsBuilder.build());
+
+ return true;
+ }
+
+ return false;
+ }
+
+ // search for relevant subnets for the given subnetIP, add one if it is
+ // necessary
+ private Subnets getOrAddSubnet(List<Subnets> subnets, String subnetIp) {
+ IpPrefix subnetPrefix = new IpPrefix(subnetIp.toCharArray());
+
+ if (subnets != null) {
+ for (Subnets subnet : subnets) {
+ if (subnet.getPrefix().equals(subnetPrefix)) {
+ return subnet;
+ }
+ }
+ }
+
+ Subnets retSubnet = buildSubnets(subnetIp);
+ subnets.add(retSubnet);
+
+ return retSubnet;
+ }
+
+ private Subnets buildSubnets(String subnetIp) {
+ SubnetsBuilder subnetsBuilder = new SubnetsBuilder().setDeviceVteps(new ArrayList<>())
+ .setGatewayIp(new IpAddress(ALL_SUBNETS_GW.toCharArray()))
+ .setKey(new SubnetsKey(new IpPrefix(subnetIp.toCharArray()))).setVlanId(0)
+ .setVteps(new ArrayList<Vteps>());
+ return subnetsBuilder.build();
+ }
+
+ private Optional<IpAddress> getNodeIP(BigInteger dpId) throws Exception {
+ Optional<Node> node = getPortsNode(dpId);
+
+ if (node.isPresent()) {
+ String localIp = southBoundUtils.getOpenvswitchOtherConfig(node.get(), LOCAL_IP);
+ if (localIp == null) {
+ LOG.error("missing local_ip key in ovsdb:openvswitch-other-configs in operational"
+ + " network-topology for node: " + node.get().getNodeId().getValue());
+ } else {
+ return Optional.of(new IpAddress(localIp.toCharArray()));
+ }
+ }
+
+ return Optional.absent();
+ }
+
+ @SuppressWarnings("unchecked")
+ private Optional<Node> getPortsNode(BigInteger dpnId) throws Exception {
+ InstanceIdentifier<BridgeRefEntry> bridgeRefInfoPath = InstanceIdentifier.create(BridgeRefInfo.class)
+ .child(BridgeRefEntry.class, new BridgeRefEntryKey(dpnId));
+
+ // FIXME: Read this through a cache
+ BridgeRefEntry bridgeRefEntry = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeRefInfoPath);
+ if (bridgeRefEntry == null) {
+ LOG.error("no bridge ref entry found for dpnId: " + dpnId);
+ return Optional.absent();
+ }
+
+ InstanceIdentifier<Node> nodeId =
+ ((InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry.getBridgeReference().getValue())
+ .firstIdentifierOf(Node.class);
+
+ // FIXME: Read this through a cache
+ Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodeId);
+
+ if (node == null) {
+ LOG.error("missing node for dpnId: " + dpnId);
+ return Optional.absent();
+ }
+
+ return Optional.of(node);
+ }
+}
<controller-max-backoff>5000</controller-max-backoff>
<controller-inactivity-probe>5000</controller-inactivity-probe>
-->
+ <auto-config-transport-zones>true</auto-config-transport-zones>
+ <use-of-tunnels>false</use-of-tunnels>
</elanmanager-config>
interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.IdManagerService" />
<odl:clustered-app-config id="elanConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig"
- default-config-file-name="netvirt-elanmanager-config.xml"
- update-strategy="none">
+ binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.config.rev150710.ElanConfig"
+ default-config-file-name="netvirt-elanmanager-config.xml"
+ update-strategy="none">
</odl:clustered-app-config>
- <bean id="elanBridgeManager" class="org.opendaylight.netvirt.elan.internal.ElanBridgeManager">
+ <bean id="elanBridgeManager"
+ class="org.opendaylight.netvirt.elan.internal.ElanBridgeManager">
<argument ref="dataBroker" />
<argument ref="elanConfig" />
<argument ref="interfaceManager" />
</bean>
- <bean id="elanForwardingEntriesHandler" class="org.opendaylight.netvirt.elan.utils.ElanForwardingEntriesHandler">
+ <bean id="elanForwardingEntriesHandler"
+ class="org.opendaylight.netvirt.elan.utils.ElanForwardingEntriesHandler">
<argument ref="dataBroker" />
</bean>
<argument ref="interfaceManager" />
</bean>
- <bean id="elanStatisticsImpl" class="org.opendaylight.netvirt.elan.statisitcs.ElanStatisticsImpl">
+ <bean id="elanStatisticsImpl"
+ class="org.opendaylight.netvirt.elan.statisitcs.ElanStatisticsImpl">
<argument ref="dataBroker" />
<argument ref="interfaceManager" />
</bean>
<argument ref="elanUtils" />
</bean>
- <bean id="elanService" class="org.opendaylight.netvirt.elan.internal.ElanServiceProvider"
+ <bean id="elanService"
+ class="org.opendaylight.netvirt.elan.internal.ElanServiceProvider"
init-method="init">
<argument ref="idManagerService" />
<argument ref="interfaceManager" />
<argument ref="elanUtils" />
<argument ref="entityOwnershipService" />
</bean>
- <service ref="elanService" odl:type="default" interface="org.opendaylight.netvirt.elanmanager.api.IElanService" />
+ <service ref="elanService" odl:type="default"
+ interface="org.opendaylight.netvirt.elanmanager.api.IElanService" />
- <bean id="cacheElanInterfaceListener" class="org.opendaylight.netvirt.elan.utils.CacheElanInterfaceListener"
+ <bean id="cacheElanInterfaceListener"
+ class="org.opendaylight.netvirt.elan.utils.CacheElanInterfaceListener"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
</bean>
- <bean id="cacheElanInstanceListener" class="org.opendaylight.netvirt.elan.utils.CacheElanInstanceListener"
+ <bean id="cacheElanInstanceListener"
+ class="org.opendaylight.netvirt.elan.utils.CacheElanInstanceListener"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
</bean>
- <bean id="hwvtepLocalUcastMacListener" class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLocalUcastMacListener"
+ <bean id="hwvtepLocalUcastMacListener"
+ class="org.opendaylight.netvirt.elan.l2gw.listeners.HwvtepLocalUcastMacListener"
init-method="init" destroy-method="close">
<argument ref="dataBroker" />
<argument ref="elanUtils" />
</bean>
- <bean id="elanStatusMonitor" class="org.opendaylight.netvirt.elan.statusanddiag.ElanStatusMonitorJMX"
+ <bean id="elanStatusMonitor"
+ class="org.opendaylight.netvirt.elan.statusanddiag.ElanStatusMonitorJMX"
init-method="init" destroy-method="close" />
<bean id="l2GatewayConnectionListener"
<argument ref="entityOwnershipService" />
</bean>
- <bean id="haEventHandler" class="org.opendaylight.netvirt.elan.l2gw.ha.handlers.HAEventHandler">
+ <bean id="haEventHandler"
+ class="org.opendaylight.netvirt.elan.l2gw.ha.handlers.HAEventHandler">
<argument ref="dataBroker" />
</bean>
- <bean id="hAListeners" class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAListeners">
+ <bean id="hAListeners"
+ class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAListeners">
<argument ref="dataBroker" />
</bean>
- <bean id="haConfigNodeListener" class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAConfigNodeListener">
+ <bean id="haConfigNodeListener"
+ class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAConfigNodeListener">
<argument ref="dataBroker" />
<argument ref="haEventHandler" />
</bean>
- <bean id="haOpClusteredListener" class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener">
+ <bean id="haOpClusteredListener"
+ class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpClusteredListener">
<argument ref="dataBroker" />
</bean>
- <bean id="haOpNodeListener" class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpNodeListener">
+ <bean id="haOpNodeListener"
+ class="org.opendaylight.netvirt.elan.l2gw.ha.listeners.HAOpNodeListener">
<argument ref="dataBroker" />
<argument ref="haEventHandler" />
</bean>
<bean id="ElanOvsdbNodeListener"
- class="org.opendaylight.netvirt.elan.internal.ElanOvsdbNodeListener"
- init-method="init" destroy-method="close">
+ class="org.opendaylight.netvirt.elan.internal.ElanOvsdbNodeListener"
+ init-method="init" destroy-method="close">
<argument ref="dataBroker" />
<argument ref="elanConfig" />
<argument ref="elanBridgeManager" />
</bean>
<bean id="elanGroupListener"
- class="org.opendaylight.netvirt.elan.l2gw.listeners.ElanGroupListener">
+ class="org.opendaylight.netvirt.elan.l2gw.listeners.ElanGroupListener">
<argument ref="elanInterfaceManager" />
<argument ref="dataBroker" />
<argument ref="elanUtils" />
<argument ref="entityOwnershipService" />
</bean>
+
+ <bean id="TransportZoneNotificationUtil"
+ class="org.opendaylight.netvirt.elan.utils.TransportZoneNotificationUtil">
+ <argument ref="dataBroker" />
+ <argument ref="interfaceManager" />
+ <argument ref="elanService" />
+ <argument ref="elanConfig" />
+ </bean>
+
+ <bean id="ElanDpnToTransportZoneListener"
+ class="org.opendaylight.netvirt.elan.internal.ElanDpnToTransportZoneListener"
+ init-method="start" destroy-method="close">
+ <argument ref="dataBroker" />
+ <argument ref="interfaceManager" />
+ <argument ref="elanConfig" />
+ <argument ref="TransportZoneNotificationUtil" />
+ </bean>
+
+ <bean id="VpnDpnToTransportZoneListener"
+ class="org.opendaylight.netvirt.elan.internal.VpnDpnToTransportZoneListener"
+ init-method="start" destroy-method="close">
+ <argument ref="dataBroker" />
+ <argument ref="interfaceManager" />
+ <argument ref="elanConfig" />
+ <argument ref="TransportZoneNotificationUtil" />
+ </bean>
+
</blueprint>
type boolean;
default false;
}
+ leaf auto-config-transport-zones {
+ description "Determines whether transport zones should be automatically created/updated";
+ type boolean;
+ default true;
+ }
+ leaf use-of-tunnels {
+ type boolean;
+ default false;
+ }
}
}
<?xml version="1.0" encoding="UTF-8"?>
-<!--
-Copyright (c) 2015 - 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 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">
+<!-- Copyright (c) 2015 - 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
+ 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>features-parent</artifactId>
<version>1.8.0-SNAPSHOT</version>
- <relativePath/>
+ <relativePath />
</parent>
<groupId>org.opendaylight.netvirt</groupId>
<artifactId>vpnservice-features</artifactId>
<version>${elanmgr.version}</version>
</dependency>
<dependency>
- <groupId>org.opendaylight.controller</groupId>
- <artifactId>liblldp</artifactId>
- <version>${liblldp.version}</version>
+ <groupId>org.opendaylight.controller</groupId>
+ <artifactId>liblldp</artifactId>
+ <version>${liblldp.version}</version>
</dependency>
<dependency>
<groupId>org.opendaylight.genius</groupId>
<artifactId>vpnmanager-shell</artifactId>
<version>${vpnmanager.version}</version>
</dependency>
- <dependency>
- <groupId>${project.groupId}</groupId>
- <artifactId>neutronvpn-impl</artifactId>
- <version>${project.version}</version>
- <type>xml</type>
- <classifier>config</classifier>
- </dependency>
<dependency>
<groupId>org.apache.thrift</groupId>
<artifactId>libthrift</artifactId>
<version>${ovsdb.version}</version>
</dependency>
<dependency>
- <!-- TODO Remove when https://git.opendaylight.org/gerrit/#/c/44502/ is merged -->
+ <!-- TODO Remove when https://git.opendaylight.org/gerrit/#/c/44502/
+ is merged -->
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
- <!--
- Maven Site Configuration
-
- The following configuration is necessary for maven-site-plugin to
- correctly identify the correct deployment path for OpenDaylight Maven
- sites.
- -->
+ <!-- Maven Site Configuration The following configuration is necessary
+ for maven-site-plugin to correctly identify the correct deployment path for
+ OpenDaylight Maven sites. -->
<url>${odl.site.url}/${project.groupId}/${stream}/${project.artifactId}/</url>
<distributionManagement>
<configfile finalname="etc/opendaylight/datastore/initial/config/netvirt-aclservice-config.xml">mvn:org.opendaylight.netvirt/aclservice-impl/{{VERSION}}/xml/config</configfile>
<configfile finalname="etc/opendaylight/datastore/initial/config/netvirt-dhcpservice-config.xml">mvn:org.opendaylight.netvirt/dhcpservice-impl/{{VERSION}}/xml/config</configfile>
<configfile finalname="etc/opendaylight/datastore/initial/config/netvirt-elanmanager-config.xml">mvn:org.opendaylight.netvirt/elanmanager-impl/{{VERSION}}/xml/config</configfile>
- <configfile finalname="etc/opendaylight/datastore/initial/config/netvirt-neutronvpn-config.xml">mvn:org.opendaylight.netvirt/neutronvpn-impl/{{VERSION}}/xml/config</configfile>
</feature>
<feature name='odl-netvirt-openstack' version='${project.version}' description='OpenDaylight :: NetVirt :: OpenStack'>
<propertyExpansion>checkstyle.violationSeverity=error</propertyExpansion>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>build-helper-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>attach-artifacts</id>
- <goals>
- <goal>attach-artifact</goal>
- </goals>
- <phase>package</phase>
- <configuration>
- <artifacts>
- <artifact>
- <file>${project.build.directory}/classes/initial/netvirt-neutronvpn-config.xml</file>
- <type>xml</type>
- <classifier>config</classifier>
- </artifact>
- </artifacts>
- </configuration>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
+++ /dev/null
-/*
- * Copyright (c) 2015 - 2016 HPE 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.netvirt.neutronvpn;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.BridgeRefInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class BridgeRefEntryToTransportZoneListener extends AsyncDataTreeChangeListenerBase<BridgeRefEntry,
- BridgeRefEntryToTransportZoneListener> implements ClusteredDataTreeChangeListener<BridgeRefEntry>, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(BridgeRefEntryToTransportZoneListener.class);
- private TransportZoneNotificationUtil ism;
- private DataBroker dbx;
-
- public BridgeRefEntryToTransportZoneListener(DataBroker dbx, NeutronvpnManager nvManager) {
- super(BridgeRefEntry.class, BridgeRefEntryToTransportZoneListener.class);
- this.dbx = dbx;
- ism = new TransportZoneNotificationUtil(dbx, nvManager);
- }
-
- public void start() {
- LOG.info("{} start", getClass().getSimpleName());
- if (ism.isAutoTunnelConfigEnabled()) {
- registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
- }
- }
-
- @Override
- protected InstanceIdentifier<BridgeRefEntry> getWildCardPath() {
- InstanceIdentifier.InstanceIdentifierBuilder<BridgeRefEntry> bridgeRefEntryInstanceIdentifierBuilder =
- InstanceIdentifier.builder(BridgeRefInfo.class)
- .child(BridgeRefEntry.class);
- return bridgeRefEntryInstanceIdentifierBuilder.build();
- }
-
-
- @Override
- protected void remove(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry del) {
- // once the TZ is declared it will stay forever
- }
-
- @Override
- protected void update(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry original,
- BridgeRefEntry update) {
- LOG.debug("handle BridgeRefEntry update notification {}", update);
- ism.updateTransportZone(update);
- }
-
- @Override
- protected void add(InstanceIdentifier<BridgeRefEntry> identifier, BridgeRefEntry add) {
- LOG.debug("handle BridgeRefEntry add notification {}", add);
- ism.updateTransportZone(add);
- }
-
- @Override
- protected BridgeRefEntryToTransportZoneListener getDataTreeChangeListener() {
- return BridgeRefEntryToTransportZoneListener.this;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2016 HPE 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.netvirt.neutronvpn;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-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.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class InterfaceToTransportZoneListener
- extends AsyncDataTreeChangeListenerBase<Interface, InterfaceToTransportZoneListener>
- implements ClusteredDataTreeChangeListener<Interface>, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(InterfaceToTransportZoneListener.class);
- private TransportZoneNotificationUtil ism;
- private DataBroker dbx;
-
- public InterfaceToTransportZoneListener(DataBroker dbx, NeutronvpnManager nvManager) {
- super(Interface.class, InterfaceToTransportZoneListener.class);
- ism = new TransportZoneNotificationUtil(dbx, nvManager);
- this.dbx = dbx;
- }
-
- public void start() {
- LOG.info("{} start", getClass().getSimpleName());
- if (ism.isAutoTunnelConfigEnabled()) {
- registerListener(LogicalDatastoreType.CONFIGURATION, dbx);
- }
- }
-
- @Override
- protected InstanceIdentifier<Interface> getWildCardPath() {
- return InstanceIdentifier.create(Interfaces.class).child(Interface.class);
- }
-
-
- @Override
- protected void remove(InstanceIdentifier<Interface> identifier, Interface del) {
- // once the TZ is declared it will stay forever
- }
-
- @Override
- protected void update(InstanceIdentifier<Interface> identifier, Interface original, Interface update) {
- ism.updateTransportZone(update);
- }
-
-
- @Override
- protected void add(InstanceIdentifier<Interface> identifier, Interface add) {
- ism.updateTransportZone(add);
- }
-
- @Override
- protected InterfaceToTransportZoneListener getDataTreeChangeListener() {
- return InterfaceToTransportZoneListener.this;
- }
-
-}
+++ /dev/null
-/*
- * Copyright (c) 2015 - 2016 HPE 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.netvirt.neutronvpn;
-
-import org.opendaylight.controller.md.sal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.NeutronRouterDpns;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NeutronRouterDpnsToTransportZoneListener extends AsyncDataTreeChangeListenerBase<RouterDpnList,
- NeutronRouterDpnsToTransportZoneListener> implements
- ClusteredDataTreeChangeListener<RouterDpnList>, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(NeutronRouterDpnsToTransportZoneListener.class);
-
- private TransportZoneNotificationUtil ism;
-
- private DataBroker dbx;
-
- public NeutronRouterDpnsToTransportZoneListener(DataBroker dbx, NeutronvpnManager nvManager) {
- super(RouterDpnList.class, NeutronRouterDpnsToTransportZoneListener.class);
- ism = new TransportZoneNotificationUtil(dbx, nvManager);
- this.dbx = dbx;
- }
-
- public void start() {
- LOG.info("{} start", getClass().getSimpleName());
- if (ism.isAutoTunnelConfigEnabled()) {
- registerListener(LogicalDatastoreType.OPERATIONAL, dbx);
- }
- }
-
- @Override
- protected InstanceIdentifier<RouterDpnList> getWildCardPath() {
- return InstanceIdentifier.create(NeutronRouterDpns.class).child(RouterDpnList.class);
- }
-
-
- @Override
- protected void remove(InstanceIdentifier<RouterDpnList> identifier, RouterDpnList del) {
- // once the TZ is declared it will stay forever
- }
-
- @Override
- protected void update(InstanceIdentifier<RouterDpnList> identifier, RouterDpnList original, RouterDpnList update) {
- ism.updateTransportZone(update);
- }
-
-
- @Override
- protected void add(InstanceIdentifier<RouterDpnList> identifier, RouterDpnList add) {
- ism.updateTransportZone(add);
- }
-
- @Override
- protected NeutronRouterDpnsToTransportZoneListener getDataTreeChangeListener() {
- return NeutronRouterDpnsToTransportZoneListener.this;
- }
-
-}
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.adjacency.list.AdjacencyKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.learnt.vpn.vip.to.port.data.LearntVpnVipToPort;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.AssociateNetworksOutputBuilder;
private final NotificationPublishService notificationPublishService;
private final VpnRpcService vpnRpcService;
private final NeutronFloatingToFixedIpMappingChangeListener floatingIpMapListener;
- private final NeutronvpnConfig neutronvpnConfig;
private final IElanService elanService;
public NeutronvpnManager(
final DataBroker dataBroker, final NotificationPublishService notiPublishService,
final NeutronvpnNatManager vpnNatMgr, final VpnRpcService vpnRpcSrv, final IElanService elanService,
- final NeutronFloatingToFixedIpMappingChangeListener neutronFloatingToFixedIpMappingChangeListener,
- final NeutronvpnConfig neutronvpnConfig) {
+ final NeutronFloatingToFixedIpMappingChangeListener neutronFloatingToFixedIpMappingChangeListener) {
this.dataBroker = dataBroker;
nvpnNatManager = vpnNatMgr;
notificationPublishService = notiPublishService;
vpnRpcService = vpnRpcSrv;
this.elanService = elanService;
floatingIpMapListener = neutronFloatingToFixedIpMappingChangeListener;
- LOG.info("neutronvpnConfig: {}", neutronvpnConfig);
- this.neutronvpnConfig = neutronvpnConfig;
}
@Override
LOG.info("{} close", getClass().getSimpleName());
}
- public NeutronvpnConfig getNeutronvpnConfig() {
- return neutronvpnConfig;
- }
-
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
protected void updateSubnetNodeWithFixedIps(Uuid subnetId, Uuid routerId,
+++ /dev/null
-/*
- * Copyright (c) 2015 - 2016 HPE 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.netvirt.neutronvpn;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Set;
-import org.opendaylight.controller.md.sal.binding.api.DataBroker;
-import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
-import org.opendaylight.ovsdb.utils.mdsal.utils.MdsalUtils;
-import org.opendaylight.ovsdb.utils.southbound.utils.SouthboundUtils;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.InterfacesState;
-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.yang.types.rev130715.Uuid;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.BridgeRefInfo;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntry;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.meta.rev160406.bridge.ref.info.BridgeRefEntryKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZonesBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.RouterDpnList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.DpnVpninterfacesList;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.neutron.router.dpns.router.dpn.list.dpn.vpninterfaces.list.RouterInterfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.NetworkTypeVxlan;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.networks.rev150712.networks.attributes.networks.Network;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.ports.Port;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class TransportZoneNotificationUtil {
-
- private static final Logger LOG = LoggerFactory.getLogger(TransportZoneNotificationUtil.class);
- private static final String OF_URI_SEPARATOR = ":";
- private static final String TUNNEL_PORT = "tunnel_port";
- private static final String LOCAL_IP = "local_ip";
- private static final String ALL_SUBNETS = "0.0.0.0/0";
- private final DataBroker dataBroker;
- private final NeutronvpnManager nvManager;
- private final MdsalUtils mdsalUtils;
- private final SouthboundUtils southBoundUtils;
- private final NeutronvpnConfig neutronvpnConfig;
-
- public TransportZoneNotificationUtil(DataBroker dbx, NeutronvpnManager nvManager) {
- this.dataBroker = dbx;
- this.nvManager = nvManager;
- this.mdsalUtils = new MdsalUtils(dbx);
- southBoundUtils = new SouthboundUtils(mdsalUtils);
- this.neutronvpnConfig = nvManager.getNeutronvpnConfig();
- }
-
-
- /**
- * Update/add TransportZone for bridheEntryRef change.<br>
- * for any update on bridge entry we are looking for all the routers which are affected and try to recreate
- * its TZ
- * @param entry - the BridgeEntryRef that was updated
- */
- public void updateTransportZone(BridgeRefEntry entry) {
- BigInteger dpid = entry.getDpid();
- Set<RouterDpnList> allRouterDpnList = NeutronvpnUtils.getAllRouterDpnList(dataBroker, dpid);
- for (RouterDpnList routerDpnList : allRouterDpnList) {
- updateTransportZone(routerDpnList);
- }
- }
-
- /**
- * Update/add TransportZone for interface config.
- * If Transport zone for given Network doesn't exist, then it will be added.
- * If the TEP of the port's node exists in the TZ, it will not be added.
- * @param iface - the interface to update
- */
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void updateTransportZone(Interface iface) {
- try {
- Uuid portUid = new Uuid(iface.getName());
- Port port = NeutronvpnUtils.getNeutronPort(dataBroker, portUid);
- if (port == null) {
- LOG.debug("No neutron port found for iface {} portUuid {}, skipping update of transport zone",
- portUid, iface.getName());
- return;
- }
- if (!checkIfVxlanNetwork(port)) {
- return;
- }
-
- String subnetIp = ALL_SUBNETS;
-
- ParentRefs parentRefs = iface.getAugmentation(ParentRefs.class);
- if (parentRefs == null || parentRefs.getParentInterface() == null) {
- // If parentRefs are missing, try to find a matching parent and update - this will trigger another DCN
- LOG.debug("parentRef is missing for interface {}, skipping update of transport zone");
- return;
- }
-
- // FIXME Use IInterfaceManager getInterfaceInfoFromConfigDataStore when refactoring into ELAN
- org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.state
- .Interface ifState = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL,
- buildStateInterfaceId(parentRefs.getParentInterface()));
-
- if (ifState == null) {
- LOG.debug("ifState is missing for parentRef {} of interface {}, skipping update of transport zone",
- parentRefs.getParentInterface(), iface.getName());
- return;
- }
-
- BigInteger dpnId = getDpnIdFromInterfaceState(ifState);
-
-
- InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(port.getNetworkId().getValue()));
- TransportZone zone = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, inst);
-
- if (zone == null) {
- zone = createZone(subnetIp, port.getNetworkId().getValue());
- }
-
- if (addVtep(zone, subnetIp, dpnId) > 0) {
- addTransportZone(zone, iface.getName());
- }
-
- } catch (Exception e) {
- LOG.warn("failed to add tunnels on interface added to subnet {}. ", iface, e);
- }
- }
-
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
- public void updateTransportZone(RouterDpnList routerDpnList) {
- try {
- InstanceIdentifier<TransportZone> inst = InstanceIdentifier.create(TransportZones.class)
- .child(TransportZone.class, new TransportZoneKey(routerDpnList.getRouterId()));
- TransportZone zone = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, inst);
-
- String subnetIp = ALL_SUBNETS;
-
- int addedTeps = 0;
- for (DpnVpninterfacesList dpnVpninterfacesList : routerDpnList.getDpnVpninterfacesList()) {
- for (RouterInterfaces routerInterfaces: dpnVpninterfacesList.getRouterInterfaces()) {
- Uuid portUid = new Uuid(routerInterfaces.getInterface());
- Port neutronPort = NeutronvpnUtils.getNeutronPort(dataBroker, portUid);
- if (neutronPort != null) {
- if (!checkIfVxlanNetwork(neutronPort)) {
- continue;
- }
- if (zone == null) {
- zone = createZone(subnetIp, routerDpnList.getRouterId());
- }
- BigInteger dpnId = dpnVpninterfacesList.getDpnId();
- addedTeps += addVtep(zone, subnetIp, dpnId);
- break;
- }
- }
- }
- if (addedTeps > 0) {
- addTransportZone(zone, "router " + routerDpnList.getRouterId());
- }
- } catch (Exception e) {
- LOG.warn("failed to add tunnels on router added of routerDpnList {}. ", routerDpnList, e);
- }
- }
-
- public boolean isAutoTunnelConfigEnabled() {
- Boolean useTZ = true;
- if (neutronvpnConfig != null && neutronvpnConfig.isUseTransportZone() != null) {
- useTZ = neutronvpnConfig.isUseTransportZone();
- }
- LOG.info("isAutoTunnelConfigEnabled: useTz: {}, neutronvpnConfig: {}", useTZ, neutronvpnConfig);
- return useTZ;
- }
-
- private boolean checkIfVxlanNetwork(Port port) {
- Network network = NeutronvpnUtils.getNeutronNetwork(dataBroker, port.getNetworkId());
- if (network == null || !NeutronvpnUtils.isNetworkOfType(network, NetworkTypeVxlan.class)) {
- LOG.debug("port in non-VXLAN network " + port.getName());
- return false;
- }
-
- return true;
- }
-
-
- private BigInteger getDpnIdFromInterfaceState(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
- .interfaces.rev140508.interfaces.state.Interface ifState) {
- String lowerLayerIf = ifState.getLowerLayerIf().get(0);
- NodeConnectorId nodeConnectorId = new NodeConnectorId(lowerLayerIf);
- BigInteger dpId = new BigInteger(getDpnFromNodeConnectorId(nodeConnectorId));
- return dpId;
- }
-
- // TODO: code is used in another places. Should be extracted into utility
- private String getDpnFromNodeConnectorId(NodeConnectorId portId) {
- String[] split = portId.getValue().split(OF_URI_SEPARATOR);
- return split[1];
- }
-
-
-
- private TransportZone createZone(String subnetIp, String zoneName) {
- TransportZoneBuilder tzb = new TransportZoneBuilder();
- tzb.setKey(new TransportZoneKey(zoneName));
- tzb.setTunnelType(TunnelTypeVxlan.class);
- tzb.setZoneName(zoneName);
- List<Subnets> subnets = new ArrayList<>();
- subnets.add(newSubnets(subnetIp));
- tzb.setSubnets(subnets);
- return tzb.build();
- }
-
-
- private void addTransportZone(TransportZone zone, String interName) {
- InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
- TransportZones zones = mdsalUtils.read(LogicalDatastoreType.CONFIGURATION, path);
- if (zones == null) {
- List<TransportZone> zoneList = new ArrayList<>();
- zoneList.add(zone);
- zones = new TransportZonesBuilder().setTransportZone(zoneList).build();
- } else {
- zones.getTransportZone().add(zone);
- }
-
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, zones);
- LOG.info("updating transport zone {} due to {} handling", zone.getZoneName(), interName);
- }
-
- private int addVtep(TransportZone zone, String subnetIp, BigInteger dpnId) throws Exception {
-
- Subnets subnets = findSubnets(zone.getSubnets(), subnetIp);
-
- for (Vteps existingVtep : subnets.getVteps()) {
- if (existingVtep.getDpnId().equals(dpnId)) {
- return 0;
- }
- }
-
- IpAddress nodeIp = getNodeIP(dpnId);
-
- VtepsBuilder vtepsBuilder = new VtepsBuilder();
- vtepsBuilder.setDpnId(dpnId);
- vtepsBuilder.setIpAddress(nodeIp);
- vtepsBuilder.setPortname(TUNNEL_PORT);
- vtepsBuilder.setOptionOfTunnel(neutronvpnConfig.isUseOfTunnels());
-
- subnets.getVteps().add(vtepsBuilder.build());
-
- return 1;
- }
-
- // search for relevant subnets for the given subnetIP, add one if it is necessary
- private Subnets findSubnets(List<Subnets> subnets, String subnetIp) {
- for (Subnets subnet : subnets) {
- IpPrefix subnetPrefix = new IpPrefix(subnetIp.toCharArray());
- if (subnet.getPrefix().equals(subnetPrefix)) {
- return subnet;
- }
- }
-
- Subnets retSubnet = newSubnets(subnetIp);
- subnets.add(retSubnet);
-
- return retSubnet;
- }
-
- private Subnets newSubnets(String subnetIp) {
- SubnetsBuilder subnetsBuilder = new SubnetsBuilder();
- subnetsBuilder.setDeviceVteps(new ArrayList<>());
- subnetsBuilder.setGatewayIp(new IpAddress("0.0.0.0".toCharArray()));
- subnetsBuilder.setKey(new SubnetsKey(new IpPrefix(subnetIp.toCharArray())));
- subnetsBuilder.setVlanId(0);
- subnetsBuilder.setVteps(new ArrayList<>());
- return subnetsBuilder.build();
- }
-
- private IpAddress getNodeIP(BigInteger dpId) throws Exception {
- Node node = getPortsNode(dpId);
- String localIp = southBoundUtils.getOpenvswitchOtherConfig(node, LOCAL_IP);
- if (localIp == null) {
- throw new Exception("missing local_ip key in ovsdb:openvswitch-other-configs in operational"
- + " network-topology for node: " + node.getNodeId().getValue());
- }
-
- return new IpAddress(localIp.toCharArray());
- }
-
- @SuppressWarnings("unchecked")
- private Node getPortsNode(BigInteger dpnId) throws Exception {
- InstanceIdentifier<BridgeRefEntry> bridgeRefInfoPath =
- InstanceIdentifier.create(BridgeRefInfo.class).child(BridgeRefEntry.class, new BridgeRefEntryKey(dpnId));
- BridgeRefEntry bridgeRefEntry = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, bridgeRefInfoPath);
- if (bridgeRefEntry == null) {
- throw new Exception("no bridge ref entry found for dpnId: " + dpnId);
- }
-
- InstanceIdentifier<Node> nodeId = ((InstanceIdentifier<OvsdbBridgeAugmentation>) bridgeRefEntry
- .getBridgeReference().getValue()).firstIdentifierOf(Node.class);
- Node node = mdsalUtils.read(LogicalDatastoreType.OPERATIONAL, nodeId);
-
- if (node == null) {
- throw new Exception("missing node for dpnId: " + dpnId);
- }
- return node;
-
- }
-
- // FIXME Remove this, duplicated from IfmUtil
- public static final InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
- .rev140508.interfaces.state.Interface> buildStateInterfaceId(String interfaceName) {
- InstanceIdentifier.InstanceIdentifierBuilder<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf
- .interfaces.rev140508.interfaces.state.Interface> idBuilder =
- InstanceIdentifier.builder(InterfacesState.class)
- .child(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
- .rev140508.interfaces.state.Interface.class,
- new org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
- .rev140508.interfaces.state.InterfaceKey(interfaceName));
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces
- .rev140508.interfaces.state.Interface> id = idBuilder.build();
- return id;
- }
-}
<odl:rpc-service id="odlArputilService"
interface="org.opendaylight.yang.gen.v1.urn.opendaylight.genius.arputil.rev160406.OdlArputilService" />
- <odl:clustered-app-config id="neutronvpnConfig"
- binding-class="org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.config.rev160806.NeutronvpnConfig"
- default-config-file-name="netvirt-neutronvpn-config.xml">
- </odl:clustered-app-config>
-
<bean id="neutronvpnNatManager"
class="org.opendaylight.netvirt.neutronvpn.NeutronvpnNatManager"
destroy-method="close">
<argument ref="vpnRpcService" />
<argument ref="elanService" />
<argument ref="neutronFloatingToFixedIpMappingChangeListener" />
- <argument ref="neutronvpnConfig" />
</bean>
<odl:rpc-implementation ref="neutronvpnManager" />
<argument ref="neutronvpnManager" />
</bean>
- <bean id="InterfaceToTransportZoneListener"
- class="org.opendaylight.netvirt.neutronvpn.InterfaceToTransportZoneListener"
- init-method="start" destroy-method="close">
- <argument ref="dataBroker" />
- <argument ref="neutronvpnManager" />
- </bean>
-
- <bean id="BridgeRefEntryToTransportZoneListener"
- class="org.opendaylight.netvirt.neutronvpn.BridgeRefEntryToTransportZoneListener"
- init-method="start" destroy-method="close">
- <argument ref="dataBroker" />
- <argument ref="neutronvpnManager" />
- </bean>
-
- <bean id="NeutronRouterDpnsToTransportZoneListener"
- class="org.opendaylight.netvirt.neutronvpn.NeutronRouterDpnsToTransportZoneListener"
- init-method="start" destroy-method="close">
- <argument ref="dataBroker" />
- <argument ref="neutronvpnManager" />
- </bean>
-
<bean id="NeutronTrunkChangeListener"
class="org.opendaylight.netvirt.neutronvpn.NeutronTrunkChangeListener"
init-method="start" destroy-method="close">
}
container neutronvpn-config {
+ status deprecated;
config true;
leaf use-transport-zone {
type boolean;