use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class SnatExternalRoutersListener method update.
@Override
public void update(InstanceIdentifier<Routers> identifier, Routers original, Routers update) {
if (natMode != NatMode.Conntrack) {
return;
}
String routerName = original.getRouterName();
Uint32 routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("update : external router event - Invalid routerId for routerName {}", routerName);
return;
}
LOG.info("update :called for router {} with originalSNATStatus {} and updatedSNATStatus {}", routerName, original.isEnableSnat(), update.isEnableSnat());
if (!upgradeState.isUpgradeInProgress()) {
centralizedSwitchScheduler.updateCentralizedSwitch(original, update);
}
if (!Objects.equals(original.getSubnetIds(), update.getSubnetIds()) || !Objects.equals(original.getExternalIps(), update.getExternalIps())) {
LoggingFutures.addErrorLogging(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, confTx -> natServiceManager.notify(confTx, update, original, null, null, SnatServiceManager.Action.SNAT_ROUTER_UPDATE)), LOG, "error handling external router update");
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanInterfaceManager method removeElanInterface.
@SuppressWarnings("checkstyle:ForbidCertainMethod")
public List<ListenableFuture<?>> removeElanInterface(ElanInstance elanInfo, String interfaceName, InterfaceInfo interfaceInfo) {
String elanName = elanInfo.getElanInstanceName();
EVENT_LOGGER.debug("ELAN-InterfaceState, REMOVE {} Instance {}", interfaceName, elanName);
Uint32 elanTag = elanInfo.getElanTag();
// We use two transaction so we don't suffer on multiple shards (interfaces and flows)
List<ListenableFuture<?>> futures = new ArrayList<>();
RemoveElanInterfaceHolder holder = new RemoveElanInterfaceHolder();
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(OPERATIONAL, interfaceTx -> {
Elan elanState = removeElanStateForInterface(elanInfo, interfaceName, interfaceTx);
if (elanState == null) {
return;
}
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, flowTx -> {
List<String> elanInterfaces = elanState.getElanInterfaces();
if (elanInterfaces == null || elanInterfaces.isEmpty()) {
holder.isLastElanInterface = true;
}
if (interfaceInfo != null) {
holder.dpId = interfaceInfo.getDpId();
DpnInterfaces dpnInterfaces = removeElanDpnInterfaceFromOperationalDataStore(elanName, holder.dpId, interfaceName, elanTag, interfaceTx);
/*
* If there are not elan ports, remove the unknown dmac, terminating
* service table flows, remote/local bc group
*/
if (dpnInterfaces == null || dpnInterfaces.getInterfaces() == null || dpnInterfaces.getInterfaces().isEmpty()) {
// No more Elan Interfaces in this DPN
EVENT_LOGGER.debug("ELAN-Flows, REMOVE {} Instance {}", interfaceName, elanName);
LOG.debug("deleting the elan: {} present on dpId: {}", elanInfo.getElanInstanceName(), holder.dpId);
if (!elanUtils.isOpenstackVniSemanticsEnforced()) {
removeDefaultTermFlow(holder.dpId, elanInfo.getElanTag().toJava());
}
removeUnknownDmacFlow(holder.dpId, elanInfo, flowTx, elanInfo.getElanTag().toJava());
removeEtreeUnknownDmacFlow(holder.dpId, elanInfo, flowTx);
removeElanBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeLocalBroadcastGroup(elanInfo, interfaceInfo, flowTx);
removeEtreeBroadcastGrups(elanInfo, interfaceInfo, flowTx);
if (isVxlanNetworkOrVxlanSegment(elanInfo)) {
if (elanUtils.isOpenstackVniSemanticsEnforced()) {
elanUtils.removeTerminatingServiceAction(holder.dpId, ElanUtils.getVxlanSegmentationId(elanInfo).intValue());
}
unsetExternalTunnelTable(holder.dpId, elanInfo, flowTx);
}
} else {
setupLocalBroadcastGroups(elanInfo, dpnInterfaces, interfaceInfo, flowTx);
}
}
}));
}));
futures.forEach(ElanUtils::waitForTransactionToComplete);
InterfaceRemoveWorkerOnElanInterface removeInterfaceWorker = new InterfaceRemoveWorkerOnElanInterface(interfaceName, elanInfo, interfaceInfo, this, holder.isLastElanInterface);
jobCoordinator.enqueueJob(ElanUtils.getElanInterfaceJobKey(interfaceName), removeInterfaceWorker, ElanConstants.JOB_MAX_RETRIES);
return futures;
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanInstanceManager method update.
@Override
public void update(InstanceIdentifier<ElanInstance> identifier, ElanInstance original, ElanInstance update) {
EVENT_LOGGER.debug("ELAN-Instance, UPDATE {}", original.getElanInstanceName());
Uint32 existingElanTag = original.getElanTag();
String elanName = update.getElanInstanceName();
if (existingElanTag == null || !existingElanTag.equals(update.getElanTag())) {
if (update.getElanTag() == null || update.getElanTag().longValue() == 0L) {
// update the elan-Instance with new properties
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, operTx -> LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> ElanUtils.updateOperationalDataStore(idManager, update, new ArrayList<>(), confTx, operTx)), LOG, "Error updating ELAN tag in ELAN instance for config " + "transaction")), LOG, "Error updating ELAN tag in ELAN instance for operational transaction");
} else {
jobCoordinator.enqueueJob(elanName, () -> elanInterfaceManager.handleunprocessedElanInterfaces(update), ElanConstants.JOB_MAX_RETRIES);
}
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanServiceProvider method addExternalTunnelArpResponderFlow.
@Override
public void addExternalTunnelArpResponderFlow(ArpResponderInput arpResponderInput, String elanInstanceName) {
Uint64 dpnId = Uint64.valueOf(arpResponderInput.getDpId());
String ipAddress = arpResponderInput.getSpa();
String macAddress = arpResponderInput.getSha();
LOG.trace("Installing the ExternalTunnel ARP responder flow on DPN {} for ElanInstance {} with MAC {} & IP {}", dpnId, elanInstanceName, macAddress, ipAddress);
ElanInstance elanInstance = elanInstanceCache.get(elanInstanceName).orElse(null);
if (elanInstance == null) {
LOG.warn("Null elan instance {}", elanInstanceName);
return;
}
int lportTag = arpResponderInput.getLportTag();
String flowId = ArpResponderUtil.getFlowId(lportTag, ipAddress);
Map<org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey, org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction> arpResponderInputInstructionsMap = new HashMap<>();
int instructionKey = 0;
for (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction instructionObj : arpResponderInput.getInstructions()) {
arpResponderInputInstructionsMap.put(new org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionKey(++instructionKey), instructionObj);
}
Flow flowEntity = MDSALUtil.buildFlowNew(NwConstants.ARP_RESPONDER_TABLE, flowId, NwConstants.DEFAULT_ARP_FLOW_PRIORITY, flowId, 0, 0, ArpResponderUtil.generateCookie(lportTag, ipAddress), ArpResponderUtil.getMatchCriteria(lportTag, elanInstance, ipAddress), arpResponderInputInstructionsMap);
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> mdsalManager.addFlow(tx, dpnId, flowEntity)), LOG, "Error adding flow {}", flowEntity);
LOG.trace("Installed the ExternalTunnel ARP Responder flow for ElanInstance {}", elanInstanceName);
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanEvpnFlowUtils method evpnRemoveFlowThatSendsThePacketOnAnExternalTunnel.
private List<ListenableFuture<?>> evpnRemoveFlowThatSendsThePacketOnAnExternalTunnel(long elanTag, Uint64 dpId, String nexthopIp, String macToRemove) {
String flowId = ElanEvpnFlowUtils.evpnGetKnownDynamicmacFlowRef(NwConstants.ELAN_DMAC_TABLE, dpId, nexthopIp, macToRemove, elanTag, false);
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)));
}
Aggregations