use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class VpnUtil method getGWMacAddressFromInterface.
static Optional<String> getGWMacAddressFromInterface(MacEntry macEntry, IpAddress gatewayIp, DataBroker dataBroker) {
Optional<String> gatewayMac = Optional.absent();
long vpnId = getVpnId(dataBroker, macEntry.getVpnName());
InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds> vpnIdsInstanceIdentifier = VpnUtil.getVpnIdToVpnInstanceIdentifier(vpnId);
Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds> vpnIdsOptional = VpnUtil.read(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdsInstanceIdentifier);
if (!vpnIdsOptional.isPresent()) {
LOG.error("getGWMacAddressFromInterface: VPN {} not configured", vpnId);
return gatewayMac;
}
VpnPortipToPort vpnTargetIpToPort = VpnUtil.getNeutronPortFromVpnPortFixedIp(dataBroker, macEntry.getVpnName(), gatewayIp.getIpv4Address().getValue());
if (vpnTargetIpToPort != null && vpnTargetIpToPort.isSubnetIp()) {
gatewayMac = Optional.of(vpnTargetIpToPort.getMacAddress());
} else {
org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.id.to.vpn.instance.VpnIds vpnIds = vpnIdsOptional.get();
if (vpnIds.isExternalVpn()) {
gatewayMac = InterfaceUtils.getMacAddressForInterface(dataBroker, macEntry.getInterfaceName());
}
}
return gatewayMac;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry 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;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanInterfaceManager method removeInterfaceStaticMacEntries.
protected void removeInterfaceStaticMacEntries(String elanInstanceName, String interfaceName, PhysAddress physAddress) {
InterfaceInfo interfaceInfo = interfaceManager.getInterfaceInfo(interfaceName);
InstanceIdentifier<MacEntry> macId = getMacEntryOperationalDataPath(elanInstanceName, physAddress);
Optional<MacEntry> existingMacEntry = ElanUtils.read(broker, LogicalDatastoreType.OPERATIONAL, macId);
if (!existingMacEntry.isPresent()) {
return;
}
MacEntry macEntry = new MacEntryBuilder().setMacAddress(physAddress).setInterface(interfaceName).setKey(new MacEntryKey(physAddress)).build();
elanForwardingEntriesHandler.deleteElanInterfaceForwardingEntries(elanInstanceCache.get(elanInstanceName).orNull(), interfaceInfo, macEntry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanMacEntryListener method remove.
@Override
protected void remove(InstanceIdentifier<MacEntry> instanceIdentifier, MacEntry macEntry) {
LOG.info("ElanMacEntryListener : remove macEntry {} ", instanceIdentifier);
String elanName = instanceIdentifier.firstKeyOf(MacTable.class).getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (EvpnUtils.getEvpnNameFromElan(elanInfo) == null) {
LOG.trace("ElanMacEntryListener : Remove evpnName is null for elan {} ", elanInfo);
return;
}
evpnUtils.withdrawPrefix(elanInfo, macEntry);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.elan.rev150602.forwarding.entries.MacEntry in project netvirt by opendaylight.
the class ElanMacEntryListener method add.
@Override
protected void add(InstanceIdentifier<MacEntry> instanceIdentifier, MacEntry macEntry) {
LOG.info("ElanMacEntryListener : ADD macEntry {} ", instanceIdentifier);
String elanName = instanceIdentifier.firstKeyOf(MacTable.class).getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orNull();
if (EvpnUtils.getEvpnNameFromElan(elanInfo) == null) {
LOG.trace("ElanMacEntryListener : Add evpnName is null for elan {} ", elanInfo);
return;
}
evpnUtils.advertisePrefix(elanInfo, macEntry);
}
Aggregations