use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class VpnServiceElanDpnInterfacesListener method update.
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
LOG.info("received Dpninterfaces update event for dpn {}", update.getDpId());
BigInteger dpnId = update.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = VpnUtil.getElanInstanceByName(dataBroker, elanInstanceName);
String vpnName = VpnUtil.getVpnNameFromElanIntanceName(dataBroker, elanInstanceName);
if (vpnName == null) {
return;
}
String primaryRd = VpnUtil.getPrimaryRd(dataBroker, vpnName);
if (elanInstance != null && !elanInstance.isExternal() && VpnUtil.isVlan(elanInstance)) {
jobCoordinator.enqueueJob(elanInstance.getElanInstanceName(), () -> {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(writeConfigTxn -> {
List<String> addedInterfaces = getUpdatedInterfaceList(update.getInterfaces(), original.getInterfaces());
for (String addedInterface : addedInterfaces) {
if (interfaceManager.isExternalInterface(addedInterface)) {
InstanceIdentifier<VpnToDpnList> id = VpnUtil.getVpnToDpnListIdentifier(primaryRd, dpnId);
Optional<VpnToDpnList> dpnInVpn = VpnUtil.read(dataBroker, LogicalDatastoreType.OPERATIONAL, id);
if (!dpnInVpn.isPresent() || (dpnInVpn.get().getVpnInterfaces() != null && dpnInVpn.get().getVpnInterfaces().size() != 1)) {
return;
}
if (!VpnUtil.shouldPopulateFibForVlan(dataBroker, vpnName, elanInstanceName, dpnId, interfaceManager)) {
return;
}
long vpnId = VpnUtil.getVpnId(dataBroker, vpnName);
fibManager.populateFibOnNewDpn(dpnId, vpnId, primaryRd, null);
break;
}
}
List<String> deletedInterfaces = getUpdatedInterfaceList(original.getInterfaces(), update.getInterfaces());
if (!deletedInterfaces.isEmpty()) {
String routerPortUuid = VpnUtil.getRouterPordIdFromElanInstance(dataBroker, elanInstanceName);
if (update.getInterfaces().size() == 2 && update.getInterfaces().contains(routerPortUuid)) {
VpnUtil.removeRouterPortFromElanForVlanInDpn(vpnName, dpnId, dataBroker);
}
}
}));
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method add.
@Override
protected void add(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces dpnInterfaces) {
LOG.debug("received Dpninterfaces add event for dpn {}", dpnInterfaces.getDpId());
BigInteger dpnId = dpnInterfaces.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
// on br-int patch port for this DPN
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
LOG.debug("creating vlan member intf for elan {}, dpn {}", elanInstance.getPhysicalNetworkName(), dpnId);
elanService.createExternalElanNetwork(elanInstance, dpnId);
return Collections.emptyList();
});
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanDpnInterfacesListener method update.
@Override
protected void update(InstanceIdentifier<DpnInterfaces> identifier, DpnInterfaces original, DpnInterfaces update) {
LOG.debug("received Dpninterfaces update event for dpn {}", update.getDpId());
BigInteger dpnId = update.getDpId();
String elanInstanceName = identifier.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orNull();
if (elanInstance != null && !elanInstance.isExternal() && ElanUtils.isVlan(elanInstance)) {
List<String> interfaces = update.getInterfaces();
// trigger deletion for vlan provider intf on the DPN for the vlan provider network
if (interfaces.size() == 1 && interfaceManager.isExternalInterface(interfaces.get(0))) {
LOG.debug("deleting vlan prv intf for elan {}, dpn {}", elanInstanceName, dpnId);
jobCoordinator.enqueueJob(dpnId.toString(), () -> {
elanService.deleteExternalElanNetwork(elanInstance, dpnId);
return Collections.emptyList();
});
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanDpnToTransportZoneListener method remove.
@Override
protected void remove(InstanceIdentifier<DpnInterfaces> key, DpnInterfaces dataObjectModification) {
LOG.debug("Elan dpn {} delete detected, deleting transport zones", dataObjectModification.getDpId());
BigInteger dpId = dataObjectModification.getDpId();
String elanInstanceName = key.firstKeyOf(ElanDpnInterfacesList.class).getElanInstanceName();
if (!ElanUtils.isVxlanNetworkOrVxlanSegment(elanInstanceCache.get(elanInstanceName).orNull())) {
LOG.debug("ElanInstance {} is not vxlan network, nothing to do", elanInstanceName);
return;
}
LOG.debug("Deleting tz for elanInstance {} dpId {}", elanInstanceName, dpId);
transportZoneNotificationUtil.deleteTransportZone(elanInstanceName, dpId);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.elan.instances.ElanInstance in project netvirt by opendaylight.
the class ElanInterfaceManager method removeEntriesForElanInterface.
List<ListenableFuture<Void>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String interfaceName, boolean isLastElanInterface) {
String elanName = elanInfo.getElanInstanceName();
List<ListenableFuture<Void>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(flowTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(interfaceTx -> {
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
Optional<ElanInterfaceMac> existingElanInterfaceMac = interfaceTx.read(LogicalDatastoreType.OPERATIONAL, elanInterfaceId).checkedGet();
LOG.debug("Removing the Interface:{} from elan:{}", interfaceName, elanName);
if (interfaceInfo != null) {
if (existingElanInterfaceMac.isPresent()) {
List<MacEntry> existingMacEntries = existingElanInterfaceMac.get().getMacEntry();
if (existingMacEntries != null) {
List<PhysAddress> macAddresses = new ArrayList<>();
for (MacEntry macEntry : existingMacEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
LOG.debug("removing the mac-entry:{} present on elanInterface:{}", macAddress.getValue(), interfaceName);
Optional<MacEntry> macEntryOptional = elanUtils.getMacEntryForElanInstance(interfaceTx, elanName, macAddress);
if (!isLastElanInterface && macEntryOptional.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
elanUtils.deleteMacFlows(elanInfo, interfaceInfo, macEntry, flowTx);
macAddresses.add(macAddress);
}
// to this ELAN
if (isVxlanNetworkOrVxlanSegment(elanInfo) && !macAddresses.isEmpty()) {
elanL2GatewayUtils.removeMacsFromElanExternalDevices(elanInfo, macAddresses);
}
}
}
removeDefaultTermFlow(interfaceInfo.getDpId(), interfaceInfo.getInterfaceTag());
removeFilterEqualsTable(elanInfo, interfaceInfo, flowTx);
} else if (existingElanInterfaceMac.isPresent()) {
// Interface does not exist in ConfigDS, so lets remove everything
// about that interface related to Elan
List<MacEntry> macEntries = existingElanInterfaceMac.get().getMacEntry();
if (macEntries != null) {
for (MacEntry macEntry : macEntries) {
PhysAddress macAddress = macEntry.getMacAddress();
if (elanUtils.getMacEntryForElanInstance(elanName, macAddress).isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
}
}
}
if (existingElanInterfaceMac.isPresent()) {
interfaceTx.delete(LogicalDatastoreType.OPERATIONAL, elanInterfaceId);
}
unbindService(interfaceName, interfaceTx);
deleteElanInterfaceFromConfigDS(interfaceName, interfaceTx);
}));
}));
return futures;
}
Aggregations