use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.
the class VpnInterfaceManager method addVpnInterfaceToVpn.
private void addVpnInterfaceToVpn(final InstanceIdentifier<VpnInterfaceOpDataEntry> vpnInterfaceOpIdentifier, final VpnInterface vpnInterface, final List<Adjacency> oldAdjs, final List<Adjacency> newAdjs, final InstanceIdentifier<VpnInterface> identifier, String vpnName) {
final VpnInterfaceKey key = identifier.firstKeyOf(VpnInterface.class, VpnInterfaceKey.class);
final String interfaceName = key.getName();
String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
if (!VpnUtil.isVpnPendingDelete(dataBroker, primaryRd)) {
Interface interfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, interfaceName);
boolean isBgpVpnInternetVpn = VpnUtil.isBgpVpnInternet(dataBroker, vpnName);
if (interfaceState != null) {
try {
final BigInteger dpnId = InterfaceUtils.getDpIdFromInterface(interfaceState);
final int ifIndex = interfaceState.getIfIndex();
jobCoordinator.enqueueJob("VPNINTERFACE-" + interfaceName, () -> {
WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
WriteTransaction writeOperTxn = dataBroker.newWriteOnlyTransaction();
WriteTransaction writeInvTxn = dataBroker.newWriteOnlyTransaction();
LOG.info("addVpnInterface: VPN Interface add event - intfName {} vpnName {} on dpn {}", vpnInterface.getName(), vpnName, vpnInterface.getDpnId());
processVpnInterfaceUp(dpnId, vpnInterface, primaryRd, ifIndex, false, writeConfigTxn, writeOperTxn, writeInvTxn, interfaceState, vpnName);
if (oldAdjs != null && !oldAdjs.equals(newAdjs)) {
LOG.info("addVpnInterface: Adjacency changed upon VPNInterface {}" + " Update for swapping VPN {} case.", interfaceName, vpnName);
if (newAdjs != null) {
for (Adjacency adj : newAdjs) {
if (oldAdjs.contains(adj)) {
oldAdjs.remove(adj);
} else {
if (!isBgpVpnInternetVpn || VpnUtil.isAdjacencyEligibleToVpnInternet(dataBroker, adj)) {
addNewAdjToVpnInterface(vpnInterfaceOpIdentifier, primaryRd, adj, dpnId, writeOperTxn, writeConfigTxn);
}
}
}
}
for (Adjacency adj : oldAdjs) {
if (!isBgpVpnInternetVpn || VpnUtil.isAdjacencyEligibleToVpnInternet(dataBroker, adj)) {
delAdjFromVpnInterface(vpnInterfaceOpIdentifier, adj, dpnId, writeOperTxn, writeConfigTxn);
}
}
}
ListenableFuture<Void> operFuture = writeOperTxn.submit();
try {
operFuture.get();
} catch (ExecutionException e) {
LOG.error("addVpnInterface: Exception encountered while submitting operational future for" + " addVpnInterface {} on vpn {}", vpnInterface.getName(), vpnName, e);
return null;
}
List<ListenableFuture<Void>> futures = new ArrayList<>();
ListenableFuture<Void> configFuture = writeConfigTxn.submit();
futures.add(configFuture);
Futures.addCallback(configFuture, new PostVpnInterfaceWorker(interfaceName, true, "Config"));
futures.add(writeInvTxn.submit());
LOG.info("addVpnInterface: Addition of interface {} in VPN {} on dpn {}" + " processed successfully", interfaceName, vpnName, dpnId);
return futures;
});
} catch (NumberFormatException | IllegalStateException e) {
LOG.error("addVpnInterface: Unable to retrieve dpnId from interface operational data store for " + "interface {}. Interface addition on vpn {} failed", interfaceName, vpnName, e);
return;
}
} else if (Boolean.TRUE.equals(vpnInterface.isRouterInterface())) {
jobCoordinator.enqueueJob("VPNINTERFACE-" + vpnInterface.getName(), () -> {
WriteTransaction writeConfigTxn = dataBroker.newWriteOnlyTransaction();
createFibEntryForRouterInterface(primaryRd, vpnInterface, interfaceName, writeConfigTxn, vpnName);
LOG.info("addVpnInterface: Router interface {} for vpn {} on dpn {}", interfaceName, vpnName, vpnInterface.getDpnId());
ListenableFuture<Void> futures = writeConfigTxn.submit();
String errorText = "addVpnInterfaceCall: Exception encountered while submitting writeConfigTxn" + " for interface " + vpnInterface.getName() + " on vpn " + vpnName;
ListenableFutures.addErrorLogging(futures, LOG, errorText);
return Collections.singletonList(futures);
});
} else {
LOG.info("addVpnInterface: Handling addition of VPN interface {} on vpn {} skipped as interfaceState" + " is not available", interfaceName, vpnName);
}
} else {
LOG.error("addVpnInterface: Handling addition of VPN interface {} on vpn {} dpn {} skipped" + " as vpn is pending delete", interfaceName, vpnName, vpnInterface.getDpnId());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.
the class VpnInterfaceManager method removeFromNeutronRouterDpnsMap.
protected void removeFromNeutronRouterDpnsMap(String routerName, String vpnInterfaceName, BigInteger dpId, WriteTransaction writeOperTxn) {
if (dpId.equals(BigInteger.ZERO)) {
LOG.error("removeFromNeutronRouterDpnsMap: Could not retrieve dp id for interface {} to handle router {}" + " dissociation model", vpnInterfaceName, routerName);
return;
}
InstanceIdentifier<DpnVpninterfacesList> routerDpnListIdentifier = getRouterDpnId(routerName, dpId);
Optional<DpnVpninterfacesList> optionalRouterDpnList = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, routerDpnListIdentifier);
if (optionalRouterDpnList.isPresent()) {
List<RouterInterfaces> routerInterfaces = optionalRouterDpnList.get().getRouterInterfaces();
RouterInterfaces routerInterface = new RouterInterfacesBuilder().setKey(new RouterInterfacesKey(vpnInterfaceName)).setInterface(vpnInterfaceName).build();
if (routerInterfaces != null && routerInterfaces.remove(routerInterface)) {
if (routerInterfaces.isEmpty()) {
writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, routerDpnListIdentifier);
} else {
writeOperTxn.delete(LogicalDatastoreType.OPERATIONAL, routerDpnListIdentifier.child(RouterInterfaces.class, new RouterInterfacesKey(vpnInterfaceName)));
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.
the class VpnManagerImpl method removeArpResponderFlowsToExternalNetworkIps.
@Override
public void removeArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId) {
if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
LOG.warn("Failed to remove arp responder flows for router {}. DPN id is missing.", id);
return;
}
String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
if (extInterfaceName == null) {
LOG.warn("Failed to remove responder flows for {}. No external interface found for DPN id {}", id, dpnId);
return;
}
Interface extInterfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, extInterfaceName);
if (extInterfaceState == null) {
LOG.debug("No interface state found for interface {}. Delaying responder flows for {}", extInterfaceName, id);
return;
}
Integer lportTag = extInterfaceState.getIfIndex();
if (lportTag == null) {
LOG.debug("No Lport tag found for interface {}. Delaying flows for router-id {}", extInterfaceName, id);
return;
}
if (macAddress == null) {
LOG.debug("Failed to remove arp responder flows for router-gateway-ip {} for router {}." + "External Gw MacAddress is missing.", fixedIps, id);
return;
}
removeArpResponderFlowsToExternalNetworkIps(id, fixedIps, dpnId, extInterfaceName, lportTag);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handlePacketFromTunnelToExternalNetwork.
private void handlePacketFromTunnelToExternalNetwork(String vpnIdVpnInstanceName, String srcIpStr, byte[] dstIp, long elanTag) throws UnknownHostException {
String routerId = VpnUtil.getAssociatedExternalRouter(dataBroker, srcIpStr);
if (null == routerId) {
LOG.debug("This ip is not associated with any external router: {}", srcIpStr);
}
handlePacketToExternalNetwork(new Uuid(vpnIdVpnInstanceName), routerId, dstIp, elanTag);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bmp.monitor.rev171207.routers.Router in project netvirt by opendaylight.
the class SubnetRoutePacketInHandler method handlePacketToExternalNetwork.
private void handlePacketToExternalNetwork(Uuid vpnInstanceNameUuid, String routerId, byte[] dstIp, long elanTag) throws UnknownHostException {
Routers externalRouter = VpnUtil.getExternalRouter(dataBroker, routerId);
if (externalRouter == null) {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.debug("{} handlePacketToExternalNetwork: Can't find external router with id {}", LOGGING_PREFIX, routerId);
return;
}
List<ExternalIps> externalIps = externalRouter.getExternalIps();
if (externalIps == null || externalIps.isEmpty()) {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.debug("{} handlePacketToExternalNetwork: Router {} doesn't have any external ips.", LOGGING_PREFIX, externalRouter.getRouterName());
return;
}
java.util.Optional<ExternalIps> externalIp = externalRouter.getExternalIps().stream().filter(eip -> vpnInstanceNameUuid.equals(eip.getSubnetId())).findFirst();
if (!externalIp.isPresent()) {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.debug("{} handlePacketToExternalNetwork: Router {} doesn't have an external ip for subnet id {}.", LOGGING_PREFIX, externalRouter.getRouterName(), vpnInstanceNameUuid);
return;
}
BigInteger dpnId = centralizedSwitchProvider.getPrimarySwitchForRouter(externalRouter.getRouterName());
if (BigInteger.ZERO.equals(dpnId)) {
VpnManagerCounters.subnet_route_packet_failed.inc();
LOG.debug("{} handlePacketToExternalNetwork: Could not find primary switch for router {}.", LOGGING_PREFIX, externalRouter.getRouterName());
return;
}
transmitArpPacket(dpnId, externalIp.get().getIpAddress(), externalRouter.getExtGwMacAddress(), dstIp, elanTag);
return;
}
Aggregations