use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanInterfaceManager method removeEntriesForElanInterface.
List<ListenableFuture<?>> removeEntriesForElanInterface(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String interfaceName, boolean isLastElanInterface) {
String elanName = elanInfo.getElanInstanceName();
EVENT_LOGGER.debug("ELAN-InterfaceEntries, REMOVE {} Instance {}", interfaceName, elanName);
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, interfaceTx -> {
InstanceIdentifier<ElanInterfaceMac> elanInterfaceId = ElanUtils.getElanInterfaceMacEntriesOperationalDataPath(interfaceName);
Optional<ElanInterfaceMac> existingElanInterfaceMac = interfaceTx.read(elanInterfaceId).get();
LOG.debug("Removing the Interface:{} from elan:{}", interfaceName, elanName);
if (interfaceInfo != null) {
if (existingElanInterfaceMac.isPresent()) {
Map<MacEntryKey, MacEntry> existingMacEntries = existingElanInterfaceMac.get().nonnullMacEntry();
if (existingMacEntries != null) {
List<PhysAddress> macAddresses = new ArrayList<>();
for (MacEntry macEntry : existingMacEntries.values()) {
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(ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
EVENT_LOGGER.debug("ELAN-MacFlows, REMOVE {} Instance {} Mac {}", interfaceName, 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
Map<MacEntryKey, MacEntry> macEntries = existingElanInterfaceMac.get().nonnullMacEntry();
if (macEntries != null) {
for (MacEntry macEntry : macEntries.values()) {
PhysAddress macAddress = macEntry.getMacAddress();
if (elanUtils.getMacEntryForElanInstance(elanName, macAddress).isPresent()) {
interfaceTx.delete(ElanUtils.getMacEntryOperationalDataPath(elanName, macAddress));
}
}
}
}
if (existingElanInterfaceMac.isPresent()) {
interfaceTx.delete(elanInterfaceId);
}
unbindService(interfaceName, flowTx);
deleteElanInterfaceFromConfigDS(interfaceName, flowTx);
}));
}));
return futures;
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanInterfaceManager method handleExternalTunnelStateEvent.
/**
* Handle external tunnel state event.
*
* @param externalTunnel
* the external tunnel
* @param intrf
* the interface
*/
void handleExternalTunnelStateEvent(ExternalTunnel externalTunnel, Interface intrf) {
if (!validateExternalTunnelStateEvent(externalTunnel, intrf)) {
return;
}
// dpId/externalNodeId will be available either in source or destination
// based on the tunnel end point
Uint64 dpId = null;
NodeId externalNodeId = null;
if (StringUtils.isNumeric(externalTunnel.getSourceDevice())) {
dpId = Uint64.valueOf(externalTunnel.getSourceDevice());
externalNodeId = new NodeId(externalTunnel.getDestinationDevice());
} else if (StringUtils.isNumeric(externalTunnel.getDestinationDevice())) {
dpId = Uint64.valueOf(externalTunnel.getDestinationDevice());
externalNodeId = new NodeId(externalTunnel.getSourceDevice());
}
if (dpId == null || externalNodeId == null) {
LOG.error("Dp ID / externalNodeId not found in external tunnel {}", externalTunnel);
return;
}
ElanDpnInterfaces dpnInterfaceLists = elanUtils.getElanDpnInterfacesList();
if (dpnInterfaceLists == null) {
return;
}
Map<ElanDpnInterfacesListKey, ElanDpnInterfacesList> elanDpnIf = dpnInterfaceLists.nonnullElanDpnInterfacesList();
for (ElanDpnInterfacesList elanDpns : elanDpnIf.values()) {
String elanName = elanDpns.getElanInstanceName();
ElanInstance elanInfo = elanInstanceCache.get(elanName).orElse(null);
DpnInterfaces dpnInterfaces = elanUtils.getElanInterfaceInfoByElanDpn(elanName, dpId);
if (elanInfo == null || dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
continue;
}
LOG.debug("Elan instance:{} is present in Dpn:{} ", elanName, dpId);
final Uint64 finalDpId = dpId;
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> elanL2GatewayMulticastUtils.setupElanBroadcastGroups(elanInfo, finalDpId, confTx)), LOG, "Error setting up ELAN BGs");
// install L2gwDevices local macs in dpn.
elanL2GatewayUtils.installL2gwDeviceMacsInDpn(dpId, externalNodeId, elanInfo, intrf.getName());
// Install dpn macs on external device
installDpnMacsInL2gwDevice(elanName, new HashSet<>(dpnInterfaces.getInterfaces()), dpId, externalNodeId);
}
LOG.info("Handled ExternalTunnelStateEvent for {}", externalTunnel);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanEvpnFlowUtils method evpnRemoveTheDropFlow.
private List<ListenableFuture<?>> evpnRemoveTheDropFlow(long elanTag, Uint64 dpId, String nexthopIp, String macToRemove) {
String flowId = ElanEvpnFlowUtils.evpnGetKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, nexthopIp, macToRemove, elanTag, true);
Flow flowToRemove = new FlowBuilder().setId(new FlowId(flowId)).setTableId(NwConstants.ELAN_DMAC_TABLE).build();
return Collections.singletonList(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, tx -> mdsalManager.removeFlow(tx, dpId, flowToRemove)));
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanNodeListener method add.
@Override
public void add(InstanceIdentifier<Node> identifier, Node add) {
NodeId nodeId = add.getId();
String[] node = nodeId.getValue().split(":");
if (node.length < 2) {
LOG.warn("Unexpected nodeId {}", nodeId.getValue());
return;
}
addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
Uint64 dpId = Uint64.valueOf(node[1]);
createTableMissEntry(tx, dpId);
createMulticastFlows(tx, dpId);
createArpDefaultFlowsForArpCheckTable(dpId);
}), LOG, "Error handling ELAN node addition for {}", add);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanNodeListener method createArpRequestMatchFlows.
private void createArpRequestMatchFlows(Uint64 dpId, TypedReadWriteTransaction<Configuration> tx) throws ExecutionException, InterruptedException {
long arpRequestGroupId = ArpResponderUtil.retrieveStandardArpResponderGroupId(idManagerService);
List<BucketInfo> buckets = ArpResponderUtil.getDefaultBucketInfos(NwConstants.ARP_RESPONDER_TABLE);
LOG.trace("Installing group flow on dpn {}", dpId);
GroupEntity groupEntity = MDSALUtil.buildGroupEntity(dpId, arpRequestGroupId, ArpResponderConstant.GROUP_FLOW_NAME.value(), GroupTypes.GroupAll, buckets);
mdsalManager.addGroup(tx, groupEntity);
InstanceIdentifier<Group> groupIid = ElanUtils.getGroupInstanceid(dpId, arpRequestGroupId);
if (tx.read(groupIid).get().isPresent()) {
LOG.info("group {} is present in the config hence adding the flow", arpRequestGroupId);
createArpRequestMatchFlowsForGroup(dpId, arpRequestGroupId, tx);
return;
}
eventCallbacks.onAddOrUpdate(LogicalDatastoreType.CONFIGURATION, ElanUtils.getGroupInstanceid(dpId, arpRequestGroupId), (unused, newGroupId) -> {
LOG.info("group {} added in the config", arpRequestGroupId);
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, innerConfTx -> createArpRequestMatchFlowsForGroup(dpId, arpRequestGroupId, innerConfTx)), LOG, "Error adding flow for the group {}", arpRequestGroupId);
return DataTreeEventCallbackRegistrar.NextAction.UNREGISTER;
}, Duration.ofSeconds(5), iid -> LOG.error("arpRequestGroupId {} not found in Config datastore", arpRequestGroupId));
}
Aggregations