See in-line comments.
Change-Id: Ie0dce5f21dee80b9c02405b7636e55a4a8347887
Signed-off-by: Tom Pantelis <tompantelis@gmail.com>
.metadata
.recommenders
/.gitignore
+.fbExcludeFilterFile
<groupId>org.apache.aries.blueprint</groupId>
<artifactId>blueprint-maven-plugin</artifactId>
</plugin>
+ <plugin>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>findbugs-maven-plugin</artifactId>
+ <configuration>
+ <failOnError>true</failOnError>
+ </configuration>
+ </plugin>
</plugins>
</build>
if (rd == null || rd.isEmpty()) {
// generate new RD
- rd = generateNewRD(input.getUuid());
+ // TODO - commented out for now to avoid "Dead store to rd" violation.
+ //rd = generateNewRD(input.getUuid());
} else {
String[] rdParams = rd.get(0).split(":");
if (rdParams[0].trim().equals(adminRDValue)) {
}
}
- private List<String> generateNewRD(Uuid vpn) {
- if (adminRDValue != null) {
- Integer rdId = neutronvpnUtils.getUniqueRDId(NeutronConstants.RD_IDPOOL_NAME, vpn.toString());
- if (rdId != null) {
- String rd = adminRDValue + ":" + rdId;
- LOG.debug("Generated RD {} for L3VPN {}", rd, vpn);
- return Collections.singletonList(rd);
- }
- }
- return Collections.emptyList();
- }
-
@Override
protected void remove(InstanceIdentifier<Bgpvpn> identifier, Bgpvpn input) {
LOG.trace("Removing Bgpvpn : key: {}, value={}", identifier, input);
MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifier,
routerPortsBuilder.build());
LOG.debug("FloatingIpInfo DS updated for floating IP {} ", floatingIpAddress);
- } catch (Exception e) {
+ } catch (ReadFailedException | RuntimeException e) {
LOG.error("addToFloatingIpInfo failed for floating IP: {} ", floatingIpAddress, e);
} finally {
if (isLockAcquired) {
} else {
LOG.warn("routerPorts for router {} - fixedIp {} not found", routerName, fixedIpAddress);
}
- } catch (Exception e) {
+ } catch (RuntimeException | ReadFailedException e) {
LOG.error("Failed to delete internal-to-external-port-map from FloatingIpInfo DS for fixed Ip {}",
fixedIpAddress, e);
}
package org.opendaylight.netvirt.neutronvpn;
import java.util.HashMap;
+import java.util.Locale;
import java.util.Map;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
// suffix OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length()
String hostType = openvswitchExternalIds.getExternalIdKey().substring(
OS_HOST_CONFIG_CONFIG_KEY_PREFIX.length());
- if (null != hostType && hostType.length() > 0) {
+ if (hostType.length() > 0) {
if (hostType.length() > HOST_TYPE_STR_LEN) {
hostType = hostType.substring(0, HOST_TYPE_STR_LEN);
}
- hostType = "ODL " + hostType.toUpperCase();
+ hostType = "ODL " + hostType.toUpperCase(Locale.getDefault());
if (null != openvswitchExternalIds.getExternalIdValue()) {
config.put(hostType, openvswitchExternalIds.getExternalIdValue());
}
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import javax.annotation.Nonnull;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
import javax.inject.Singleton;
}
}
+ @Nonnull
private List<ElanSegments> buildSegments(Network input) {
Long numSegments = NeutronUtils.getNumberSegmentsFromNeutronNetwork(input);
Long index = 0L;
elanInstanceBuilder.setPhysicalNetworkName(physicalNetworkName);
}
}
- if (segments != null) {
- elanInstanceBuilder.setElanSegments(segments);
- }
+
+ elanInstanceBuilder.setElanSegments(segments);
elanInstanceBuilder.setExternal(isExternal);
elanInstanceBuilder.setKey(new ElanInstanceKey(elanInstanceName));
return elanInstanceBuilder;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan;
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.InterfaceBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.PhysAddress;
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.rev160406.IfL2vlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlanBuilder;
String portInterfaceName = createOfPortInterface(routerPort, wrtConfigTxn);
createElanInterface(routerPort, portInterfaceName, wrtConfigTxn);
wrtConfigTxn.submit();
- PhysAddress mac = new PhysAddress(routerPort.getMacAddress().getValue());
} else {
LOG.error("Neutron network {} corresponding to router interface port {} for neutron router {}"
+ " already associated to VPN {}", infNetworkId.getValue(), routerPort.getUuid().getValue(),
private void handleNeutronPortUpdated(final Port portoriginal, final Port portupdate) {
final List<FixedIps> portoriginalIps = portoriginal.getFixedIps();
final List<FixedIps> portupdateIps = portupdate.getFixedIps();
- LOG.trace("PORT ORIGINAL: {} from network {} with fixed IPs: {}; "
- + "PORT UPDATE: {} from network {} with fixed IPs: {}",
- portoriginal.getName(), portoriginal.getNetworkId().toString(), portoriginalIps.toString(),
- portupdate.getName(), portupdate.getNetworkId().toString(), portupdateIps.toString());
if (portoriginalIps == null || portoriginalIps.isEmpty()) {
handleNeutronPortCreated(portupdate);
return;
import javax.inject.Singleton;
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.ReadFailedException;
import org.opendaylight.genius.datastoreutils.AsyncDataTreeChangeListenerBase;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
import org.opendaylight.genius.mdsalutil.MDSALUtil;
nvpnManager.createSubnetmapNode(subnetId, String.valueOf(subnet.getCidr().getValue()),
subnet.getTenantId(), networkId,
providerType != null ? NetworkAttributes.NetworkType.valueOf(providerType.getName()) : null,
- segmentationId != null ? Long.valueOf(segmentationId) : 0L);
+ segmentationId != null ? Long.parseLong(segmentationId) : 0L);
createSubnetToNetworkMapping(subnetId, networkId);
}
.build());
LOG.debug("Created subnet-network mapping for subnet {} network {}", subnetId.getValue(),
networkId.getValue());
- } catch (Exception e) {
+ } catch (ReadFailedException | RuntimeException e) {
LOG.error("Create subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
networkId.getValue());
}
} else {
LOG.error("network {} not present for subnet {} ", networkId, subnetId);
}
- } catch (Exception e) {
+ } catch (ReadFailedException | RuntimeException e) {
LOG.error("Delete subnet-network mapping failed for subnet {} network {}", subnetId.getValue(),
networkId.getValue());
}
package org.opendaylight.netvirt.neutronvpn;
+import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import java.math.BigInteger;
import java.util.Collections;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.genius.arputil.api.ArpConstants;
+import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.vpnmanager.api.ICentralizedSwitchProvider;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress;
SendArpRequestInput sendArpRequestInput = new SendArpRequestInputBuilder().setIpaddress(dstIpAddress)
.setInterfaceAddress(Collections.singletonList(interfaceAddress)).build();
- arpUtilService.sendArpRequest(sendArpRequestInput);
+
+ ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(
+ arpUtilService.sendArpRequest(sendArpRequestInput)), LOG, "Send ARP request");
} catch (Exception e) {
LOG.error("Failed to send ARP request to external GW {} from interface {}",
dstIpAddress.getIpv4Address().getValue(), interfaceName, e);
import static org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker.syncReadOptional;
import com.google.common.base.Optional;
+import com.google.common.util.concurrent.JdkFutureAdapters;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.SettableFuture;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
+import java.util.Map.Entry;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.opendaylight.controller.md.sal.common.api.data.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.infrautils.jobcoordinator.JobCoordinator;
+import org.opendaylight.infrautils.utils.concurrent.ListenableFutures;
import org.opendaylight.netvirt.elanmanager.api.IElanService;
import org.opendaylight.netvirt.fibmanager.api.FibHelper;
import org.opendaylight.netvirt.neutronvpn.api.enums.IpVersionChoice;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstances;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.getl3vpn.output.L3vpnInstancesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfaces;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.RouterInterfacesKey;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.Interfaces;
import org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.neutronvpn.rev150602.router.interfaces.map.router.interfaces.InterfacesBuilder;
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
subnetMapIdentifier, subnetmapBuilder.build());
}
- } catch (Exception e) {
+ } catch (TransactionCommitFailedException | ReadFailedException e) {
LOG.error("createSubnetmapNode: Creating subnetmap node failed for subnet {}", subnetId.getValue());
}
// check if there are ports to update for already created Subnetmap node
SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
subnetMapIdentifier);
}
- } catch (Exception e) {
+ } catch (TransactionCommitFailedException e) {
LOG.error("Delete subnetMap node failed for subnet : {} ", subnetId.getValue());
}
}
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void updateVpnInstanceNode(String vpnName, List<String> rd, List<String> irt, List<String> ert,
VpnInstance.Type type, long l3vni, IpVersionChoice ipVersion) {
VpnInstanceBuilder builder = null;
VpnInstance newVpn = builder.build();
isLockAcquired = NeutronUtils.lock(vpnName);
LOG.debug("Creating/Updating vpn-instance for {} ", vpnName);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier, newVpn);
- } catch (Exception e) {
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier,
+ newVpn);
+ } catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Update VPN Instance node failed for node: {} {} {} {}", vpnName, rd, irt, ert);
} finally {
if (isLockAcquired) {
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void deleteVpnMapsNode(Uuid vpnid) {
boolean isLockAcquired = false;
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
LOG.debug("removing vpnMaps node: {} ", vpnid.getValue());
try {
isLockAcquired = NeutronUtils.lock(vpnid.getValue());
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
- } catch (Exception e) {
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
+ } catch (TransactionCommitFailedException e) {
LOG.error("Delete vpnMaps node failed for vpn : {} ", vpnid.getValue());
} finally {
if (isLockAcquired) {
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void updateVpnMaps(Uuid vpnId, String name, Uuid router, Uuid tenantId, List<Uuid> networks) {
VpnMapBuilder builder;
boolean isLockAcquired = false;
isLockAcquired = NeutronUtils.lock(vpnId.getValue());
LOG.debug("Creating/Updating vpnMaps node: {} ", vpnId.getValue());
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier, builder.build());
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier,
+ builder.build());
LOG.debug("VPNMaps DS updated for VPN {} ", vpnId.getValue());
- } catch (Exception e) {
+ } catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("UpdateVpnMaps failed for node: {} ", vpnId.getValue());
} finally {
if (isLockAcquired) {
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void clearFromVpnMaps(Uuid vpnId, Uuid routerId, List<Uuid> networkIds) {
boolean isLockAcquired = false;
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class)
// remove entire node in case of internal VPN
isLockAcquired = NeutronUtils.lock(vpnId.getValue());
LOG.debug("removing vpnMaps node: {} ", vpnId);
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
- } catch (Exception e) {
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ vpnMapIdentifier);
+ } catch (TransactionCommitFailedException e) {
LOG.error("Deletion of vpnMaps node failed for vpn {}", vpnId.getValue());
} finally {
if (isLockAcquired) {
try {
isLockAcquired = NeutronUtils.lock(vpnId.getValue());
LOG.debug("clearing from vpnMaps node: {} ", vpnId.getValue());
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier,
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier,
vpnMapBuilder.build());
- } catch (Exception e) {
+ } catch (TransactionCommitFailedException e) {
LOG.error("Clearing from vpnMaps node failed for vpn {}", vpnId.getValue());
} finally {
if (isLockAcquired) {
LOG.debug("Clear from VPNMaps DS successful for VPN {} ", vpnId.getValue());
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void deleteVpnInstance(Uuid vpnId) {
boolean isLockAcquired = false;
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class)
try {
isLockAcquired = NeutronUtils.lock(vpnId.getValue());
LOG.debug("Deleting vpnInstance {}", vpnId.getValue());
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
- } catch (Exception e) {
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
+ } catch (TransactionCommitFailedException e) {
LOG.error("Deletion of VPNInstance node failed for VPN {}", vpnId.getValue());
} finally {
if (isLockAcquired) {
// because router can have IPv4 and IPv6 subnet ports, or can have
// more that one IPv4 subnet port or more than one IPv6 subnet port
List<Adjacency> erAdjList = getAdjacencyforExtraRoute(vpnId, routeList, ipValue);
- if (erAdjList != null && !erAdjList.isEmpty()) {
+ if (!erAdjList.isEmpty()) {
adjList.addAll(erAdjList);
}
}
}
protected void withdrawPortIpFromVpnIface(Uuid vpnId, Port port, Subnetmap sn, WriteTransaction wrtConfigTxn) {
- boolean isLockAcquired = false;
String infName = port.getUuid().getValue();
InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
Optional<VpnInterface> optionalVpnInterface = null;
LOG.trace("withdraw adjacencies for Port: {} subnet {}", port.getUuid().getValue(),
sn != null ? sn.getSubnetIp() : "null");
List<Adjacency> vpnAdjsList = optionalVpnInterface.get().getAugmentation(Adjacencies.class).getAdjacency();
- List<Adjacency> updatedAdjsList = new ArrayList();
+ List<Adjacency> updatedAdjsList = new ArrayList<>();
boolean isIpFromAnotherSubnet = false;
for (Adjacency adj : vpnAdjsList) {
- String adjString = FibHelper.getIpFromPrefix(adj.getIpAddress().toString());
+ String adjString = FibHelper.getIpFromPrefix(adj.getIpAddress());
if (sn == null || !adj.getSubnetId().equals(sn.getId())) {
if (adj.getAdjacencyType() == AdjacencyType.PrimaryAdjacency) {
isIpFromAnotherSubnet = true;
if (port.getDeviceOwner()
.equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF) && sn.getRouterId() != null) {
Router rtr = neutronvpnUtils.getNeutronRouter(sn.getRouterId());
- if (rtr == null && rtr.getRoutes() != null) {
+ if (rtr != null && rtr.getRoutes() != null) {
List<Routes> extraRoutesToRemove = new ArrayList<>();
for (Routes rt: rtr.getRoutes()) {
if (rt.getNexthop().toString().equals(adjString)) {
}
if (networks != null) {
List<String> failStrings = associateNetworksToVpn(vpn, networks);
- if (failStrings != null && !failStrings.isEmpty()) {
+ if (!failStrings.isEmpty()) {
LOG.error("VPN {} association to networks failed for networks: {}. ",
vpn.getValue(), failStrings.toString());
throw new Exception(failStrings.toString());
List<Uuid> portList = sn.getPortList();
if (portList != null) {
for (final Uuid portId : portList) {
- LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp().toString(),
- portId.getValue());
+ LOG.debug("withdrawing subnet IP {} from vpn-interface {}", sn.getSubnetIp(), portId.getValue());
final Port port = neutronvpnUtils.getNeutronPort(portId);
jobCoordinator.enqueueJob("PORT-" + portId.getValue(), () -> {
WriteTransaction wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
Interfaces routerInterface = new InterfacesBuilder().setKey(new InterfacesKey(interfaceName))
.setInterfaceId(interfaceName).build();
if (optRouterInterfaces.isPresent()) {
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)),
routerInterface);
} else {
- RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
- List<Interfaces> interfaces = new ArrayList<>();
- interfaces.add(routerInterface);
// TODO Shouldn't we be doing something with builder and interfaces?
- MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION,
+// RouterInterfacesBuilder builder = new RouterInterfacesBuilder().setRouterId(routerId);
+// List<Interfaces> interfaces = new ArrayList<>();
+// interfaces.add(routerInterface);
+
+ SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION,
routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)),
routerInterface);
}
- } catch (ReadFailedException e) {
+ } catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Error reading router interfaces for {}", routerInterfacesId, e);
}
}
List<Interfaces> interfaces = routerInterfaces.getInterfaces();
if (interfaces != null && interfaces.remove(routerInterface)) {
if (interfaces.isEmpty()) {
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routerInterfacesId);
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ routerInterfacesId);
} else {
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
routerInterfacesId.child(Interfaces.class, new InterfacesKey(interfaceName)));
}
}
}
- } catch (ReadFailedException e) {
+ } catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Error reading the router interfaces for {}", routerInterfacesId, e);
}
}
new RemoveStaticRouteInputBuilder().setDestination(destination).setNexthop(nexthop)
.setVpnInstanceName(vpnName.getValue())
.build();
- vpnRpcService.removeStaticRoute(rpcInput);
+
+ ListenableFutures.addErrorLogging(JdkFutureAdapters.listenInPoolThread(
+ vpnRpcService.removeStaticRoute(rpcInput)), LOG, "Remove VPN routes");
} else {
// Any other case is a fault.
LOG.warn("route with destination {} and nexthop {} does not apply to any InterVpnLink",
&& interVpnLink.getFirstEndpoint().getIpAddress().getValue().equals(nexthop));
}
+ @Nonnull
protected List<Adjacency> getAdjacencyforExtraRoute(Uuid vpnId, List<Routes> routeList, String fixedIp) {
List<Adjacency> adjList = new ArrayList<>();
Map<String, List<String>> adjMap = new HashMap<>();
}
}
- for (String destination : adjMap.keySet()) {
+ for (Entry<String, List<String>> entry : adjMap.entrySet()) {
+ final String destination = entry.getKey();
+ final List<String> ipList = entry.getValue();
Adjacency erAdj = new AdjacencyBuilder().setIpAddress(destination)
- .setAdjacencyType(AdjacencyType.ExtraRoute).setNextHopIpList(adjMap.get(destination))
+ .setAdjacencyType(AdjacencyType.ExtraRoute).setNextHopIpList(ipList)
.setKey(new AdjacencyKey(destination)).build();
adjList.add(erAdj);
}
return adjList;
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
protected void updateVpnInterfaceWithExtraRouteAdjacency(Uuid vpnId, List<Routes> routeList) {
for (Routes route : routeList) {
if (route == null || route.getNexthop() == null || route.getDestination() == null) {
.setNextHopIpList(Collections.singletonList(nextHop)).setKey(new AdjacencyKey(destination))
.setAdjacencyType(AdjacencyType.ExtraRoute).build();
isLockAcquired = NeutronUtils.lock(infName);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, path, erAdj);
- } catch (Exception e) {
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ path, erAdj);
+ } catch (TransactionCommitFailedException e) {
LOG.error("exception in adding extra route with destination: {}, next hop: {}",
destination, nextHop, e);
} finally {
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
protected void removeAdjacencyforExtraRoute(Uuid vpnId, List<Routes> routeList) {
for (Routes route : routeList) {
if (route != null && route.getNexthop() != null && route.getDestination() != null) {
.child(Adjacency.class, new AdjacencyKey(destination))
.build();
- // Looking for existing prefix in MDSAL database
- Optional<Adjacency> adjacency = MDSALUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION,
- adjacencyIdentifier);
- boolean updateNextHops = false;
- List<String> nextHopList = new ArrayList<>();
- if (adjacency.isPresent()) {
- List<String> nhListRead = adjacency.get().getNextHopIpList();
- if (nhListRead.size() > 1) { // ECMP case
- for (String nextHopRead : nhListRead) {
- if (nextHopRead.equals(nextHop)) {
- updateNextHops = true;
- } else {
- nextHopList.add(nextHopRead);
+ try {
+ // Looking for existing prefix in MDSAL database
+ Optional<Adjacency> adjacency = SingleTransactionDataBroker.syncReadOptional(dataBroker,
+ LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
+ boolean updateNextHops = false;
+ List<String> nextHopList = new ArrayList<>();
+ if (adjacency.isPresent()) {
+ List<String> nhListRead = adjacency.get().getNextHopIpList();
+ if (nhListRead.size() > 1) { // ECMP case
+ for (String nextHopRead : nhListRead) {
+ if (nextHopRead.equals(nextHop)) {
+ updateNextHops = true;
+ } else {
+ nextHopList.add(nextHopRead);
+ }
}
}
}
- }
- try {
isLockAcquired = NeutronUtils.lock(infName);
if (updateNextHops) {
// An update must be done, not including the current next hop
new AdjacenciesBuilder().setAdjacency(Collections.singletonList(newAdj)).build();
VpnInterface vpnIf = new VpnInterfaceBuilder().setKey(new VpnInterfaceKey(infName))
.addAugmentation(Adjacencies.class, erAdjs).build();
- MDSALUtil.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIfIdentifier, vpnIf);
+ SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ vpnIfIdentifier, vpnIf);
} else {
// Remove the whole route
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, adjacencyIdentifier);
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ adjacencyIdentifier);
LOG.trace("extra route {} deleted successfully", route);
}
- } catch (Exception e) {
+ } catch (TransactionCommitFailedException | ReadFailedException e) {
LOG.error("exception in deleting extra route with destination {} for interface {}",
destination, infName, e);
} finally {
updateVpnMaps(vpnId, null, routerId, null, null);
LOG.debug("Updating association of subnets to external vpn {}", vpnId.getValue());
List<Uuid> routerSubnets = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
- if (routerSubnets != null) {
- for (Uuid subnetId : routerSubnets) {
- Subnetmap sn = updateVpnForSubnet(routerId, vpnId, subnetId, true);
- if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToAdd(sn, vpnId)) {
- neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(),
- NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp()), true);
- }
+ for (Uuid subnetId : routerSubnets) {
+ Subnetmap sn = updateVpnForSubnet(routerId, vpnId, subnetId, true);
+ if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToAdd(sn, vpnId)) {
+ neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(),
+ NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp()), true);
}
}
+
try {
checkAndPublishRouterAssociatedtoVpnNotification(routerId, vpnId);
LOG.debug("notification upon association of router {} to VPN {} published", routerId.getValue(),
List<Uuid> routerSubnets = neutronvpnUtils.getNeutronRouterSubnetIds(routerId);
boolean vpnInstanceIpVersionsRemoved = false;
IpVersionChoice vpnInstanceIpVersionsToRemove = IpVersionChoice.UNDEFINED;
- if (routerSubnets != null) {
- for (Uuid subnetId : routerSubnets) {
- Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
- if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
- vpnInstanceIpVersionsToRemove.addVersion(NeutronvpnUtils
+ for (Uuid subnetId : routerSubnets) {
+ Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
+ if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpnId)) {
+ vpnInstanceIpVersionsToRemove = vpnInstanceIpVersionsToRemove.addVersion(NeutronvpnUtils
.getIpVersionFromString(sn.getSubnetIp()));
- vpnInstanceIpVersionsRemoved = true;
- }
- LOG.debug("Updating association of subnets to internal vpn {}", routerId.getValue());
- updateVpnForSubnet(vpnId, routerId, subnetId, false);
+ vpnInstanceIpVersionsRemoved = true;
}
+ LOG.debug("Updating association of subnets to internal vpn {}", routerId.getValue());
+ updateVpnForSubnet(vpnId, routerId, subnetId, false);
}
+
if (vpnInstanceIpVersionsRemoved) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), vpnInstanceIpVersionsToRemove, false);
}
}
}
+ @Nonnull
protected List<String> associateNetworksToVpn(Uuid vpn, List<Uuid> networks) {
List<String> failedNwList = new ArrayList<>();
List<Uuid> passedNwList = new ArrayList<>();
// process corresponding subnets for VPN
for (Uuid nw : networks) {
Network network = neutronvpnUtils.getNeutronNetwork(nw);
+ if (network == null) {
+ failedNwList.add(String.format("network %s not found", nw.getValue()));
+ continue;
+ }
+
NetworkProviderExtension providerExtension = network.getAugmentation(NetworkProviderExtension.class);
if (providerExtension.getSegments() != null && providerExtension.getSegments().size() > 1) {
LOG.error("MultiSegmented networks not supported in VPN. Failed to associate network {} on vpn {}",
}
try {
Uuid vpnId = neutronvpnUtils.getVpnForNetwork(nw);
- if (network == null) {
- failedNwList.add(String.format("network %s not found", nw.getValue()));
- } else if (vpnId != null) {
+ if (vpnId != null) {
failedNwList.add(String.format("network %s already associated to another VPN %s", nw.getValue(),
vpnId.getValue()));
} else if (isVpnOfTypeL2(vpnInstance)
for (Uuid subnet : networkSubnets) {
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnet);
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, vpn)) {
- vpnInstanceIpVersionsToRemove.addVersion(NeutronvpnUtils
- .getIpVersionFromString(sn.getSubnetIp()));
+ vpnInstanceIpVersionsToRemove = vpnInstanceIpVersionsToRemove.addVersion(
+ NeutronvpnUtils.getIpVersionFromString(sn.getSubnetIp()));
vpnInstanceIpVersionsRemoved = true;
}
removeSubnetFromVpn(vpn, subnet);
}
protected List<Uuid> getNetworksForVpn(Uuid vpnId) {
- return neutronvpnUtils.getNetworksforVpn(vpnId);
+ return neutronvpnUtils.getNetworksForVpn(vpnId);
}
/**
LOG.error("vpn id or interface is null");
return;
}
- Boolean wrtConfigTxnPresent = true;
+
if (wrtConfigTxn == null) {
- wrtConfigTxnPresent = false;
wrtConfigTxn = dataBroker.newWriteOnlyTransaction();
}
InstanceIdentifier<VpnInterface> vpnIfIdentifier = NeutronvpnUtils.buildVpnInterfaceIdentifier(infName);
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
+import java.util.Objects;
import java.util.Set;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import javax.inject.Singleton;
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.ReadFailedException;
import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
import org.opendaylight.genius.datastoreutils.SingleTransactionDataBroker;
-import org.opendaylight.genius.mdsalutil.MDSALUtil;
import org.opendaylight.netvirt.neutronvpn.api.utils.NeutronConstants;
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.netvirt.natservice.rev160111.ExternalNetworks;
if (newExtGw != null) {
return true;
}
- } else if (newExtGw == null || origExtGw.isEnableSnat() != newExtGw.isEnableSnat()) {
+ } else if (newExtGw == null || !Objects.equals(origExtGw.isEnableSnat(), newExtGw.isEnableSnat())) {
return true;
}
return false;
return false;
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void addExternalNetwork(Network net) {
Uuid extNetId = net.getUuid();
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Creating externalnetworks {}", networkss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier,
+ networkss);
LOG.trace("Wrote externalnetwork successfully to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Creation of External Network {} failed", extNetId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void removeExternalNetwork(Network net) {
Uuid extNetId = net.getUuid();
}
// Delete Networks object from the ExternalNetworks list
LOG.trace("Deleting External Network {}", extNetId.getValue());
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier);
LOG.trace("Deleted External Network {} successfully from CONFIG Datastore", extNetId.getValue());
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Deletion of External Network {} failed", extNetId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void addExternalNetworkToRouter(Router update) {
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Updating externalnetworks {}", networkss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier,
+ networkss);
LOG.trace("Updated externalnetworks successfully to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Creation of externalnetworks failed for {}",
extNetId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void removeExternalNetworkFromRouter(Uuid origExtNetId, Router update,
List<ExternalFixedIps> origExtFixedIps) {
Uuid routerId = update.getUuid();
rtrList.remove(routerId);
builder.setRouterIds(rtrList);
Networks networkss = builder.build();
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ netsIdentifier, networkss);
LOG.trace("Removed router {} from externalnetworks {}", routerId, origExtNetId.getValue());
}
}
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Removing externalnetwork {} from router {} failed", origExtNetId.getValue(),
routerId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void addExternalNetworkToVpn(Network network, Uuid vpnId) {
Uuid extNetId = network.getUuid();
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Setting VPN-ID for externalnetworks {}", networkss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier,
+ networkss);
LOG.trace("Wrote with VPN-ID successfully to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Attaching VPN-ID to externalnetwork {} failed", extNetId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void removeExternalNetworkFromVpn(Network network) {
Uuid extNetId = network.getUuid();
Networks networkss = builder.build();
// Add Networks object to the ExternalNetworks list
LOG.trace("Remove vpn-id for externalnetwork {}", networkss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier, networkss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, netsIdentifier,
+ networkss);
LOG.trace("Updated extnetworks successfully to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Removing VPN-ID from externalnetworks {} failed", extNetId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void addExternalRouter(Router update) {
Uuid routerId = update.getUuid();
Uuid extNetId = update.getExternalGatewayInfo().getExternalNetworkId();
Routers routers = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Creating extrouters {}", routers);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, builder.build());
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier,
+ builder.build());
LOG.trace("Wrote successfully Routers to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (ReadFailedException | TransactionCommitFailedException ex) {
LOG.error("Creation of extrouters failed for router {} failed",
routerId.getValue(), ex);
}
RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
builder.setExternalIps(null);
builder.setSubnetIds(null);
- MDSALUtil.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier);
+ SingleTransactionDataBroker.syncDelete(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ routersIdentifier);
LOG.trace("Removed router {} from extrouters", routerId.getValue());
}
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Removing extrouter {} from extrouters failed", routerId.getValue(), ex);
}
}
- @SuppressWarnings("checkstyle:IllegalCatch")
private void removeRouterFromFloatingIpInfo(Router update, DataBroker broker) {
Uuid routerId = update.getUuid();
InstanceIdentifier.InstanceIdentifierBuilder<RouterPorts> routerPortsIdentifierBuilder = InstanceIdentifier
SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION,
routerPortsIdentifierBuilder.build());
if (optionalRouterPorts.isPresent()) {
- MDSALUtil.syncDelete(broker, LogicalDatastoreType.CONFIGURATION, routerPortsIdentifierBuilder.build());
+ SingleTransactionDataBroker.syncDelete(broker, LogicalDatastoreType.CONFIGURATION,
+ routerPortsIdentifierBuilder.build());
}
- } catch (Exception e) {
+ } catch (ReadFailedException | TransactionCommitFailedException e) {
LOG.error("Failed to read from FloatingIpInfo DS for routerid {}", routerId, e);
}
}
LOG.trace("Updating External Fixed IPs Routers node {}", routerId.getValue());
if (optionalRouters.isPresent()) {
RoutersBuilder builder = new RoutersBuilder(optionalRouters.get());
- if (builder != null) {
- ArrayList<ExternalIps> externalIps = new ArrayList<>();
- for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().getExternalFixedIps()) {
- addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
- }
-
- builder.setExternalIps(externalIps);
+ List<ExternalIps> externalIps = new ArrayList<>();
+ for (ExternalFixedIps fixedIps : update.getExternalGatewayInfo().getExternalFixedIps()) {
+ addExternalFixedIpToExternalIpsList(externalIps, fixedIps);
}
+ builder.setExternalIps(externalIps);
+
updateExternalSubnetsForRouter(routerId, update.getExternalGatewayInfo().getExternalNetworkId(),
update.getExternalGatewayInfo().getExternalFixedIps());
Routers routerss = builder.build();
LOG.trace("Updating external fixed ips for router {} with value {}", routerId.getValue(), routerss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier,
+ routerss);
LOG.trace("Added External Fixed IPs successfully for Routers to CONFIG Datastore");
}
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Updating extfixedips for {} in extrouters failed", routerId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
public void handleSubnetsForExternalRouter(Uuid routerId) {
InstanceIdentifier<Routers> routersIdentifier = NeutronvpnUtils.buildExtRoutersIdentifier(routerId);
Routers routerss = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Updating extrouters {}", routerss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ routersIdentifier, routerss);
LOG.trace("Updated successfully Routers to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Updation of internal subnets for extrouters failed for router {}",
routerId.getValue(), ex);
}
}
- // TODO Clean up the exception handling
- @SuppressWarnings("checkstyle:IllegalCatch")
private void handleSnatSettingChangeForRouter(Router update) {
Uuid routerId = update.getUuid();
Routers routerss = builder.build();
// Add Routers object to the ExtRouters list
LOG.trace("Updating extrouters for snat change {}", routerss);
- MDSALUtil.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION, routersIdentifier, routerss);
+ SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.CONFIGURATION,
+ routersIdentifier, routerss);
LOG.trace("Updated successfully Routers to CONFIG Datastore");
- } catch (Exception ex) {
+ } catch (TransactionCommitFailedException | ReadFailedException ex) {
LOG.error("Updation of snat for extrouters failed for router {}", routerId.getValue(), ex);
}
}
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
+import javax.annotation.Nonnull;
import javax.inject.Inject;
import javax.inject.Singleton;
import org.apache.commons.lang3.StringUtils;
// @param external vpn - true if external vpn being fetched, false for internal vpn
protected Uuid getVpnForRouter(Uuid routerId, Boolean externalVpn) {
+ if (routerId == null) {
+ return null;
+ }
+
InstanceIdentifier<VpnMaps> vpnMapsIdentifier = InstanceIdentifier.builder(VpnMaps.class).build();
Optional<VpnMaps> optionalVpnMaps = read(LogicalDatastoreType.CONFIGURATION, vpnMapsIdentifier);
if (optionalVpnMaps.isPresent() && optionalVpnMaps.get().getVpnMap() != null) {
List<VpnMap> allMaps = optionalVpnMaps.get().getVpnMap();
- if (routerId != null) {
- for (VpnMap vpnMap : allMaps) {
- if (routerId.equals(vpnMap.getRouterId())) {
- if (externalVpn) {
- if (!routerId.equals(vpnMap.getVpnId())) {
- return vpnMap.getVpnId();
- }
- } else {
- if (routerId.equals(vpnMap.getVpnId())) {
- return vpnMap.getVpnId();
- }
+ for (VpnMap vpnMap : allMaps) {
+ if (routerId.equals(vpnMap.getRouterId())) {
+ if (externalVpn) {
+ if (!routerId.equals(vpnMap.getVpnId())) {
+ return vpnMap.getVpnId();
+ }
+ } else {
+ if (routerId.equals(vpnMap.getVpnId())) {
+ return vpnMap.getVpnId();
}
}
}
return null;
}
- protected List<Uuid> getNetworksforVpn(Uuid vpnId) {
+ protected List<Uuid> getNetworksForVpn(Uuid vpnId) {
InstanceIdentifier<VpnMap> vpnMapIdentifier = InstanceIdentifier.builder(VpnMaps.class).child(VpnMap.class,
new VpnMapKey(vpnId)).build();
Optional<VpnMap> optionalVpnMap = read(LogicalDatastoreType.CONFIGURATION, vpnMapIdentifier);
return subnet;
}
+ @Nonnull
protected List<Uuid> getNeutronRouterSubnetIds(Uuid routerId) {
LOG.debug("getNeutronRouterSubnetIds for {}", routerId.getValue());
List<Uuid> subnetIdList = new ArrayList<>();
if (sn.getSubnetIp() != null) {
IpVersionChoice ipVers = getIpVersionFromString(sn.getSubnetIp());
if (rep.choice != ipVers.choice) {
- rep.addVersion(ipVers);
+ rep = rep.addVersion(ipVers);
}
if (rep.choice == IpVersionChoice.IPV4AND6.choice) {
return rep;
*/
public static IpVersionChoice getIpVersionFromString(String ipAddress) {
IpVersionChoice ipchoice = IpVersionChoice.UNDEFINED;
- if (ipAddress.indexOf("/") > 0) {
+ if (ipAddress.indexOf("/") >= 0) {
ipAddress = ipAddress.substring(0, ipAddress.indexOf("/"));
}
try {
List<Evpn> vpns = input.getEvpn();
for (Evpn vpn : vpns) {
- RpcError error = null;
- String msg;
-
if (vpn.getRouteDistinguisher() == null || vpn.getImportRT() == null || vpn.getExportRT() == null) {
- msg = String.format("Creation of EVPN failed for VPN %s due to absence of RD/iRT/eRT input",
+ String msg = String.format("Creation of EVPN failed for VPN %s due to absence of RD/iRT/eRT input",
vpn.getId().getValue());
LOG.warn(msg);
- error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
+ RpcError error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
errorList.add(error);
warningcount++;
continue;
}
VpnInstance.Type vpnInstanceType = VpnInstance.Type.L2;
if (vpn.getRouteDistinguisher().size() > 1) {
- msg = String.format("Creation of EVPN failed for VPN %s due to multiple RD input %s",
+ String msg = String.format("Creation of EVPN failed for VPN %s due to multiple RD input %s",
vpn.getId().getValue(), vpn.getRouteDistinguisher());
LOG.warn(msg);
- error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
+ RpcError error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
errorList.add(error);
warningcount++;
continue;
}
if (existingRDs.contains(vpn.getRouteDistinguisher().get(0))) {
- msg = String.format("Creation of EVPN failed for VPN %s as another VPN with",
- "the same RD %s is already configured",
+ String msg = String.format("Creation of EVPN failed for VPN %s as another VPN with "
+ + "the same RD %s is already configured",
vpn.getId().getValue(), vpn.getRouteDistinguisher().get(0));
LOG.warn(msg);
- error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
+ RpcError error = RpcResultBuilder.newWarning(RpcError.ErrorType.PROTOCOL, "invalid-input", msg);
errorList.add(error);
warningcount++;
continue;
vpn.getImportRT(), vpn.getExportRT(), null /*router-id*/, null /*network-id*/,
vpnInstanceType, 0 /*l2vni*/);
} catch (Exception ex) {
- msg = String.format("Creation of EVPN failed for VPN %s", vpn.getId().getValue());
+ String msg = String.format("Creation of EVPN failed for VPN %s", vpn.getId().getValue());
LOG.error(msg, ex);
- error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, msg, ex.getMessage());
+ RpcError error = RpcResultBuilder.newError(RpcError.ErrorType.APPLICATION, msg, ex.getMessage());
errorList.add(error);
failurecount++;
}
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.l2gateways.rev150712.l2gateways.attributes.l2gateways.L2gateway;
import org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.rev150712.Neutron;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-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;
@Singleton
-public class L2GatewayListener extends AsyncClusteredDataTreeChangeListenerBase<L2gateway, L2GatewayListener>
- implements AutoCloseable {
+public class L2GatewayListener extends AsyncClusteredDataTreeChangeListenerBase<L2gateway, L2GatewayListener> {
private static final Logger LOG = LoggerFactory.getLogger(L2GatewayListener.class);
private final DataBroker dataBroker;
private final ItmRpcService itmRpcService;
l2GwDevice.removeL2GatewayId(input.getUuid());
// Delete ITM tunnels
final String hwvtepId = l2GwDevice.getHwvtepNodeId();
- InstanceIdentifier<Node> iid = HwvtepSouthboundUtils.createInstanceIdentifier(new NodeId(hwvtepId));
final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
jobCoordinator.enqueueJob(hwvtepId, () -> {
*/
@Singleton
public class L2GwTransportZoneListener
- extends AsyncDataTreeChangeListenerBase<TransportZone, L2GwTransportZoneListener>
- implements AutoCloseable {
+ extends AsyncDataTreeChangeListenerBase<TransportZone, L2GwTransportZoneListener> {
private static final Logger LOG = LoggerFactory.getLogger(L2GwTransportZoneListener.class);
private final DataBroker dataBroker;
private final ItmRpcService itmRpcService;