use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.
the class DpnInVpnChangeListener method onRemoveDpnEvent.
@Override
public void onRemoveDpnEvent(RemoveDpnEvent notification) {
RemoveEventData eventData = notification.getRemoveEventData();
final String rd = eventData.getRd();
final String vpnName = eventData.getVpnName();
BigInteger dpnId = eventData.getDpnId();
LOG.trace("Remove Dpn Event notification received for rd {} VpnName {} DpnId {}", rd, vpnName, dpnId);
synchronized (vpnName.intern()) {
InstanceIdentifier<VpnInstanceOpDataEntry> id = VpnUtil.getVpnInstanceOpDataIdentifier(rd);
Optional<VpnInstanceOpDataEntry> vpnOpValue = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (vpnOpValue.isPresent()) {
VpnInstanceOpDataEntry vpnInstOpData = vpnOpValue.get();
List<VpnToDpnList> vpnToDpnList = vpnInstOpData.getVpnToDpnList();
boolean flushDpnsOnVpn = true;
for (VpnToDpnList dpn : vpnToDpnList) {
if (dpn.getDpnState() == VpnToDpnList.DpnState.Active) {
flushDpnsOnVpn = false;
break;
}
}
if (flushDpnsOnVpn) {
WriteTransaction writeTxn = dataBroker.newWriteOnlyTransaction();
deleteDpn(vpnToDpnList, rd, writeTxn);
try {
writeTxn.submit().get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Error removing dpnToVpnList for vpn {} ", vpnName);
throw new RuntimeException(e.getMessage(), e);
}
}
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.
the class DpnInVpnChangeListener method deleteDpn.
protected void deleteDpn(Collection<VpnToDpnList> vpnToDpnList, String rd, WriteTransaction writeTxn) {
for (final VpnToDpnList curDpn : vpnToDpnList) {
InstanceIdentifier<VpnToDpnList> vpnToDpnId = VpnUtil.getVpnToDpnListIdentifier(rd, curDpn.getDpnId());
writeTxn.delete(LogicalDatastoreType.OPERATIONAL, vpnToDpnId);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.
the class NatUtil method isFloatingIpPresentForDpn.
public static Boolean isFloatingIpPresentForDpn(DataBroker dataBroker, BigInteger dpnId, String rd, String vpnName, String externalIp, Boolean isMoreThanOneFipCheckOnDpn) {
InstanceIdentifier<VpnToDpnList> id = getVpnToDpnListIdentifier(rd, dpnId);
Optional<VpnToDpnList> dpnInVpn = MDSALUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (dpnInVpn.isPresent()) {
LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list is not empty for vpnName {}, dpn id {}, " + "rd {} and floatingIp {}", vpnName, dpnId, rd, externalIp);
try {
List<IpAddresses> ipAddressList = dpnInVpn.get().getIpAddresses();
if (ipAddressList != null && !ipAddressList.isEmpty()) {
int floatingIpPresentCount = 0;
for (IpAddresses ipAddress : ipAddressList) {
if (!ipAddress.getIpAddress().equals(externalIp) && IpAddresses.IpAddressSource.FloatingIP.equals(ipAddress.getIpAddressSource())) {
floatingIpPresentCount++;
// Add tunnel table check
if (isMoreThanOneFipCheckOnDpn && floatingIpPresentCount > 1) {
return Boolean.TRUE;
}
// Remove tunnel table check
if (!isMoreThanOneFipCheckOnDpn) {
return Boolean.TRUE;
}
}
}
} else {
LOG.debug("isFloatingIpPresentForDpn : vpn-to-dpn-list does not contain any floating IP for DPN {}", dpnId);
return Boolean.FALSE;
}
} catch (NullPointerException e) {
LOG.error("isFloatingIpPresentForDpn: Exception occurred on getting external IP address from " + "vpn-to-dpn-list on Dpn {}", dpnId, e);
return Boolean.FALSE;
}
}
return Boolean.FALSE;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.
the class SNATDefaultRouteProgrammer method addOrDelDefaultFibRouteToSNATForSubnet.
void addOrDelDefaultFibRouteToSNATForSubnet(Subnets subnet, String networkId, int flowAction, long vpnId) {
String subnetId = subnet.getId().getValue();
InstanceIdentifier<VpnInstanceOpDataEntry> networkVpnInstanceIdentifier = NatUtil.getVpnInstanceOpDataIdentifier(networkId);
Optional<VpnInstanceOpDataEntry> networkVpnInstanceOp = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(dataBroker, LogicalDatastoreType.OPERATIONAL, networkVpnInstanceIdentifier);
if (!networkVpnInstanceOp.isPresent()) {
LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Cannot create/remove default FIB route to SNAT flow " + "for subnet {} vpn-instance-op-data entry for network {} does not exist", subnetId, networkId);
return;
}
List<VpnToDpnList> dpnListInVpn = networkVpnInstanceOp.get().getVpnToDpnList();
if (dpnListInVpn == null) {
LOG.debug("addOrDelDefaultFibRouteToSNATForSubnet : Will not add/remove default NAT flow for subnet {} " + "no dpn set for vpn instance {}", subnetId, networkVpnInstanceOp.get());
return;
}
for (VpnToDpnList dpn : dpnListInVpn) {
String macAddress = NatUtil.getSubnetGwMac(dataBroker, subnet.getId(), networkId);
extNetGroupInstaller.installExtNetGroupEntry(new Uuid(networkId), subnet.getId(), dpn.getDpnId(), macAddress);
FlowEntity flowEntity = NatUtil.buildDefaultNATFlowEntityForExternalSubnet(dpn.getDpnId(), vpnId, subnetId, idManager);
if (flowAction == NwConstants.ADD_FLOW || flowAction == NwConstants.MOD_FLOW) {
LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Installing flow {} for subnetId {}," + "vpnId {} on dpn {}", flowEntity, subnetId, vpnId, dpn.getDpnId());
mdsalManager.installFlow(flowEntity);
} else {
LOG.info("addOrDelDefaultFibRouteToSNATForSubnet : Removing flow for subnetId {}," + "vpnId {} with dpn {}", subnetId, vpnId, dpn);
mdsalManager.removeFlow(flowEntity);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList in project netvirt by opendaylight.
the class RouterInterfaceVrfEntryHandler method installRouterFibEntries.
private Boolean installRouterFibEntries(VrfEntry vrfEntry, String rd, int addOrRemove, RouterInterface routerInterface) {
final VpnInstanceOpDataEntry vpnInstance = getFibUtil().getVpnInstance(rd);
Preconditions.checkNotNull(vpnInstance, "Vpn Instance not available " + rd);
Preconditions.checkNotNull(vpnInstance.getVpnId(), "Vpn Instance with rd " + vpnInstance.getVrfId() + " has null vpnId!");
synchronized (vpnInstance.getVpnInstanceName().intern()) {
final Collection<VpnToDpnList> vpnToDpnList;
if (vrfEntry.getParentVpnRd() != null && FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
VpnInstanceOpDataEntry parentVpnInstance = getFibUtil().getVpnInstance(vrfEntry.getParentVpnRd());
vpnToDpnList = parentVpnInstance != null ? parentVpnInstance.getVpnToDpnList() : vpnInstance.getVpnToDpnList();
} else {
vpnToDpnList = vpnInstance.getVpnToDpnList();
}
final Long vpnId = vpnInstance.getVpnId();
if (vpnToDpnList != null) {
String routerId = routerInterface.getUuid();
String macAddress = routerInterface.getMacAddress();
String ipValue = routerInterface.getIpAddress();
LOG.trace("createFibEntries - Router augmented vrfentry found for for router uuid:{}, ip:{}, mac:{}", routerId, ipValue, macAddress);
for (VpnToDpnList vpnDpn : vpnToDpnList) {
if (vpnDpn.getDpnState() == VpnToDpnList.DpnState.Active) {
installRouterFibEntry(vrfEntry, vpnDpn.getDpnId(), vpnId, ipValue, new MacAddress(macAddress), addOrRemove);
}
}
}
}
return true;
}
Aggregations