use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method createSubPortInterface.
private void createSubPortInterface(Trunk trunk, SubPorts subPort) {
if (!NetworkTypeVlan.class.equals(subPort.getSegmentationType())) {
LOG.warn("SegmentationType other than VLAN not supported for Trunk:SubPorts");
return;
}
String portName = subPort.getPortId().getValue();
String parentName = trunk.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(portName);
// Should we use parentName?
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
/*
* Build Port-to-Subport details first, irrespective of port being available or not.
*/
PortIdToSubportBuilder portIdToSubportBuilder = new PortIdToSubportBuilder();
Uuid subPortUuid = subPort.getPortId();
portIdToSubportBuilder.withKey(new PortIdToSubportKey(subPortUuid)).setPortId(subPortUuid).setTrunkPortId(trunk.getPortId()).setVlanId(subPort.getSegmentationId());
List<ListenableFuture<?>> futures = new ArrayList<>();
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.merge(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPortUuid), portIdToSubportBuilder.build());
LOG.trace("Creating PortIdSubportMapping for port{}", portName);
}));
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
if (iface == null) {
/*
* Trunk creation requires NeutronPort to be present, by this time interface
* should've been created. In controller restart use case Interface would already be present.
* Clustering consideration:
* This being same shard as NeutronPort, interface creation will be triggered on the same
* node as this one. Use of DSJC helps ensure the order.
*/
LOG.warn("Interface not present for Trunk SubPort: {}", subPort);
return futures;
}
InterfaceBuilder interfaceBuilder = new InterfaceBuilder();
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.TrunkMember).setVlanId(new VlanId(subPort.getSegmentationId().intValue())).build();
ParentRefs parentRefs = new ParentRefsBuilder().setParentInterface(parentName).build();
SplitHorizon splitHorizon = new SplitHorizonBuilder().setOverrideSplitHorizonProtection(true).build();
interfaceBuilder.setName(portName).setType(L2vlan.class).addAugmentation(ifL2vlan).addAugmentation(parentRefs).addAugmentation(splitHorizon);
Interface newIface = interfaceBuilder.build();
/*
* Interface is already created for parent NeutronPort. We're updating parent refs
* and VLAN Information
*/
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, txn -> txn.merge(interfaceIdentifier, newIface));
LoggingFutures.addErrorLogging(future, LOG, "createSubPortInterface: Failed for portName {}, parentName {}", portName, parentName);
futures.add(future);
return futures;
});
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class NeutronTrunkChangeListener method deleteSubPortInterface.
private void deleteSubPortInterface(SubPorts subPort) {
String portName = subPort.getPortId().getValue();
InstanceIdentifier<Interface> interfaceIdentifier = NeutronvpnUtils.buildVlanInterfaceIdentifier(subPort.getPortId().getValue());
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
Interface iface = ifMgr.getInterfaceInfoFromConfigDataStore(portName);
List<ListenableFuture<?>> futures = new ArrayList<>();
if (iface == null) {
LOG.warn("Interface not present for SubPort {}", subPort);
return futures;
}
/*
* We'll reset interface back to way it was? Can IFM handle parentRef delete?
*/
InterfaceBuilder interfaceBuilder = new InterfaceBuilder(iface);
// Reset augmentations
interfaceBuilder.removeAugmentation(IfL2vlan.class).removeAugmentation(ParentRefs.class).removeAugmentation(SplitHorizon.class);
IfL2vlan ifL2vlan = new IfL2vlanBuilder().setL2vlanMode(IfL2vlan.L2vlanMode.Trunk).build();
interfaceBuilder.addAugmentation(ifL2vlan);
Interface newIface = interfaceBuilder.build();
/*
* There is no means to do an update to remove elements from a node.
* Our solution is to get existing iface, remove parentRef and VlanId,
* and do a put to replace existing entry. This works out better as put
* has better performance than merge.
* Only drawback is any in-flight changes might be lost, but that is a corner case
* and this being subport delete path, don't expect any significant changes to
* corresponding Neutron Port. Deletion of NeutronPort should follow soon enough.
*/
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.put(interfaceIdentifier, newIface);
LOG.trace("Resetting trunk member interface {}", newIface);
}));
futures.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
tx.delete(NeutronvpnUtils.buildPortIdSubportMappingIdentifier(subPort.getPortId()));
LOG.trace("Deleting PortIdSubportMapping for portName {}", portName);
}));
return futures;
});
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class InterVpnLinkListener method remove.
@Override
public void remove(InstanceIdentifier<InterVpnLink> identifier, InterVpnLink del) {
LOG.debug("Reacting to InterVpnLink {} removal", del.getName());
// Remove learnt routes
// Remove entries in the LPortDispatcher table
// Remove the corresponding entries in InterVpnLinkState
// For each endpoint, remove all routes that have been learnt by intervpnLink
String vpn1Uuid = del.getFirstEndpoint().getVpnUuid().getValue();
String rd1 = vpnUtil.getVpnRd(vpn1Uuid);
LOG.debug("Removing leaked routes in VPN {} rd={}", vpn1Uuid, rd1);
vpnUtil.removeVrfEntriesByOrigin(rd1, RouteOrigin.INTERVPN);
List<VrfEntry> vrfEntriesSecondEndpoint = vpnUtil.findVrfEntriesByNexthop(rd1, del.getSecondEndpoint().getIpAddress().getValue());
String vpn2Uuid = del.getSecondEndpoint().getVpnUuid().getValue();
String rd2 = vpnUtil.getVpnRd(vpn2Uuid);
LOG.debug("Removing leaked routes in VPN {} rd={}", vpn2Uuid, rd2);
vpnUtil.removeVrfEntriesByOrigin(rd2, RouteOrigin.INTERVPN);
List<VrfEntry> vrfEntriesFirstEndpoint = vpnUtil.findVrfEntriesByNexthop(rd2, del.getFirstEndpoint().getIpAddress().getValue());
Optional<InterVpnLinkState> optIVpnLinkState = interVpnLinkUtil.getInterVpnLinkState(del.getName());
if (optIVpnLinkState.isPresent()) {
InterVpnLinkState interVpnLinkState = optIVpnLinkState.get();
boolean isVpnFirstEndPoint = true;
if (interVpnLinkState.getFirstEndpointState() != null) {
Long firstEndpointLportTag = interVpnLinkState.getFirstEndpointState().getLportTag().toJava();
removeVpnLinkEndpointFlows(del, vpn2Uuid, rd1, interVpnLinkState.getSecondEndpointState().getDpId(), firstEndpointLportTag.intValue(), del.getFirstEndpoint().getIpAddress().getValue(), vrfEntriesSecondEndpoint, isVpnFirstEndPoint);
} else {
LOG.info("Could not get first endpoint state attributes for InterVpnLink {}", del.getName());
}
isVpnFirstEndPoint = false;
if (interVpnLinkState.getSecondEndpointState() != null) {
Long secondEndpointLportTag = interVpnLinkState.getSecondEndpointState().getLportTag().toJava();
removeVpnLinkEndpointFlows(del, vpn1Uuid, rd2, interVpnLinkState.getFirstEndpointState().getDpId(), secondEndpointLportTag.intValue(), del.getSecondEndpoint().getIpAddress().getValue(), vrfEntriesFirstEndpoint, isVpnFirstEndPoint);
} else {
LOG.info("Could not get second endpoint state attributes for InterVpnLink {}", del.getName());
}
}
vpnUtil.removeVrfEntries(rd1, vrfEntriesSecondEndpoint);
vpnUtil.removeVrfEntries(rd2, vrfEntriesFirstEndpoint);
vpnUtil.withdrawRoutes(rd1, vrfEntriesSecondEndpoint);
vpnUtil.withdrawRoutes(rd2, vrfEntriesFirstEndpoint);
// Release idManager with LPortTag associated to endpoints
LOG.debug("Releasing InterVpnLink {} endpoints LportTags", del.getName());
InterVpnLinkKey key = del.key();
Uuid firstEndpointVpnUuid = del.getFirstEndpoint().getVpnUuid();
Uuid secondEndpointVpnUuid = del.getSecondEndpoint().getVpnUuid();
releaseVpnLinkLPortTag(key.getName() + firstEndpointVpnUuid.getValue());
releaseVpnLinkLPortTag(key.getName() + secondEndpointVpnUuid.getValue());
// Routes with nextHop pointing to an end-point of the inter-vpn-link are populated into FIB table.
// The action in that case is a nx_resubmit to LPortDispatcher table. This is done in FibManager.
// At this point. we need to check if is there any entry in FIB table pointing to LPortDispatcher table.
// Remove it in that case.
// Removing the InterVpnLinkState
InstanceIdentifier<InterVpnLinkState> interVpnLinkStateIid = InterVpnLinkUtil.getInterVpnLinkStateIid(del.getName());
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(interVpnLinkStateIid)), LOG, "Error deleting inter-VPN link state {}", interVpnLinkStateIid);
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class QosAlertManager method writeConfigDataStore.
private void writeConfigDataStore(boolean qosAlertEnabled, short dropPacketThreshold, int alertPollInterval) {
InstanceIdentifier<QosalertConfig> path = InstanceIdentifier.builder(QosalertConfig.class).build();
QosalertConfig qosAlertConfig = new QosalertConfigBuilder().setQosDropPacketThreshold(dropPacketThreshold).setQosAlertEnabled(qosAlertEnabled).setQosAlertPollInterval(alertPollInterval).build();
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.mergeParentStructurePut(path, qosAlertConfig)), LOG, "Error writing to the config data store");
}
use of org.opendaylight.mdsal.binding.util.Datastore.CONFIGURATION in project netvirt by opendaylight.
the class InterfaceStateChangeListener method add.
@Override
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
public void add(InstanceIdentifier<Interface> identifier, Interface intrf) {
try {
if (L2vlan.class.equals(intrf.getType())) {
LOG.info("VPN Interface add event - intfName {} from InterfaceStateChangeListener", intrf.getName());
jobCoordinator.enqueueJob("VPNINTERFACE-" + intrf.getName(), () -> {
List<ListenableFuture<?>> futures = new ArrayList<>(3);
futures.add(txRunner.callWithNewReadWriteTransactionAndSubmit(CONFIGURATION, writeInvTxn -> {
// map of prefix and vpn name used, as entry in prefix-to-interface datastore
// is prerequisite for refresh Fib to avoid race condition leading to missing remote next hop
// in bucket actions on bgp-vpn delete
Map<String, Set<String>> mapOfRdAndPrefixesForRefreshFib = new HashMap<>();
ListenableFuture<?> configFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, writeConfigTxn -> {
ListenableFuture<?> operFuture = txRunner.callWithNewWriteOnlyTransactionAndSubmit(OPERATIONAL, writeOperTxn -> {
final String interfaceName = intrf.getName();
LOG.info("Detected interface add event for interface {}", interfaceName);
final VpnInterface vpnIf = vpnUtil.getConfiguredVpnInterface(interfaceName);
if (vpnIf != null) {
for (VpnInstanceNames vpnInterfaceVpnInstance : vpnIf.nonnullVpnInstanceNames().values()) {
String vpnName = vpnInterfaceVpnInstance.getVpnName();
String primaryRd = vpnUtil.getPrimaryRd(vpnName);
if (!vpnInterfaceManager.isVpnInstanceReady(vpnName)) {
LOG.info("VPN Interface add event - intfName {} onto vpnName {} " + "running oper-driven, VpnInstance not ready, holding" + " on", vpnIf.getName(), vpnName);
} else if (vpnUtil.isVpnPendingDelete(primaryRd)) {
LOG.error("add: Ignoring addition of vpnInterface {}, as" + " vpnInstance {} with primaryRd {} is already marked for" + " deletion", interfaceName, vpnName, primaryRd);
} else {
Uint64 intfDpnId = Uint64.ZERO;
try {
intfDpnId = InterfaceUtils.getDpIdFromInterface(intrf);
} catch (Exception e) {
LOG.error("Unable to retrieve dpnId for interface {}. " + "Process vpn interface add failed", intrf.getName(), e);
return;
}
LOG.error("InterfaceStateChangeListener- Processing ifState" + " {} add event with dpnId {}", intrf.getName(), intfDpnId);
final Uint64 dpnId = intfDpnId;
final int ifIndex = intrf.getIfIndex();
LOG.info("VPN Interface add event - intfName {} onto vpnName {}" + " running oper-driven", vpnIf.getName(), vpnName);
Set<String> prefixes = new HashSet<>();
vpnInterfaceManager.processVpnInterfaceUp(dpnId, vpnIf, primaryRd, ifIndex, false, writeConfigTxn, writeOperTxn, writeInvTxn, intrf, vpnName, prefixes);
mapOfRdAndPrefixesForRefreshFib.put(primaryRd, prefixes);
}
}
}
});
futures.add(operFuture);
// Synchronous submit of operTxn
operFuture.get();
});
Futures.addCallback(configFuture, new VpnInterfaceCallBackHandler(mapOfRdAndPrefixesForRefreshFib), MoreExecutors.directExecutor());
futures.add(configFuture);
// TODO: Allow immediateFailedFuture from writeCfgTxn to cancel writeInvTxn as well.
Futures.addCallback(configFuture, new PostVpnInterfaceThreadWorker(intrf.getName(), true, "Operational"), MoreExecutors.directExecutor());
}));
return futures;
});
}
} catch (Exception e) {
LOG.error("Exception caught in Interface {} Operational State Up event", intrf.getName(), e);
}
}
Aggregations