use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class L2GatewayListener method removeL2Device.
private void removeL2Device(Devices l2Device, L2gateway input) {
final String l2DeviceName = l2Device.getDeviceName();
L2GatewayDevice l2GwDevice = l2GatewayCache.get(l2DeviceName);
if (l2GwDevice != null) {
// Also, do not delete device from cache if it's connected
if (L2GatewayUtils.isLastL2GatewayBeingDeleted(l2GwDevice)) {
if (l2GwDevice.isConnected()) {
/*
l2GwDevice.removeL2GatewayId(input.getUuid());
// Delete ITM tunnels
final String hwvtepId = l2GwDevice.getHwvtepNodeId();
final Set<IpAddress> tunnelIps = l2GwDevice.getTunnelIps();
jobCoordinator.enqueueJob(hwvtepId, () -> {
if (entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE,
HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
LOG.info("Deleting ITM Tunnels for {} connected to cluster node owner", l2DeviceName);
for (IpAddress tunnelIp : tunnelIps) {
L2GatewayUtils.deleteItmTunnels(itmRpcService, hwvtepId, l2DeviceName, tunnelIp);
}
} else {
LOG.info("ITM Tunnels are not deleted on the cluster node as this is not owner for {}",
l2DeviceName);
}
return null;
});
*/
} else {
l2GatewayCache.remove(l2DeviceName);
}
l2GwDevice.removeL2GatewayId(input.getUuid());
// Delete itm tunnels
elanClusterUtils.runOnlyInOwnerNode(l2GwDevice.getDeviceName(), "handling delete of l2gwdevice delete itm tunnels ", () -> {
if (l2GwDevice.getHwvtepNodeId() == null) {
return Collections.emptyList();
}
// Cleaning up the config DS
NodeId nodeId = new NodeId(l2GwDevice.getHwvtepNodeId());
LOG.info("L2GatewayListener deleting the config nodes {} {}", nodeId, l2DeviceName);
NodeId psNodeId = HwvtepSouthboundUtils.createManagedNodeId(nodeId, l2DeviceName);
InstanceIdentifier<Node> psNodeIid = HwvtepSouthboundUtils.createInstanceIdentifier(psNodeId);
InstanceIdentifier<Node> globalIid = HwvtepSouthboundUtils.createInstanceIdentifier(nodeId);
List<ListenableFuture<?>> result = new ArrayList<>();
result.add(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.info("Deleting the zero day config for l2gw delete {}", psNodeIid);
l2gwZeroDayConfigUtil.deleteZeroDayConfig(tx, globalIid, l2GwDevice);
}));
LOG.info("L2GatewayListener Deleting itm tunnels for {}", l2GwDevice.getDeviceName());
for (final IpAddress tunnelIpAddr : l2GwDevice.getTunnelIps()) {
L2GatewayUtils.deleteItmTunnels(itmRpcService, l2GwDevice.getHwvtepNodeId(), l2DeviceName, tunnelIpAddr);
// result.add(ElanL2GatewayUtils.deleteItmTunnels(tunnelIpAddr, dataBroker));
LOG.info("L2GatewayListener Deleting itm tunnel {}", tunnelIpAddr);
}
return result;
});
} else {
l2GwDevice.removeL2GatewayId(input.getUuid());
LOG.info("ITM tunnels are not deleted for {} as this device has other L2gateway associations", l2DeviceName);
}
} else {
LOG.error("L2GatewayListener Unable to find L2 Gateway details for {}", l2DeviceName);
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class ElanInterfaceRecoveryHandler method recoverService.
@Override
public void recoverService(String entityId) {
if (!entityOwnershipUtils.isEntityOwner(HwvtepSouthboundConstants.ELAN_ENTITY_TYPE, HwvtepSouthboundConstants.ELAN_ENTITY_NAME)) {
return;
}
LOG.info("recover elan interface {}", entityId);
// Fetch the elan interface from elan interface config DS first.
ElanInterface elanInterface = elanServiceProvider.getElanInterfaceByElanInterfaceName(entityId);
if (elanInterface != null) {
// Do a delete and recreate of the elan interface configuration.
InstanceIdentifier<ElanInterface> elanInterfaceId = ElanUtils.getElanInterfaceConfigurationDataPathId(entityId);
try {
LOG.trace("deleting elan interface {}", entityId);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.delete(elanInterfaceId)).get();
LOG.trace("recreating elan interface {}, {}", entityId, elanInterface);
txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(elanInterfaceId, elanInterface)).get();
} catch (InterruptedException | ExecutionException e) {
LOG.error("Service recovery failed for elan interface {}", entityId, e);
}
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class VrfEntryListener method cleanUpExternalRoutesOnDpn.
public void cleanUpExternalRoutesOnDpn(final Uint64 dpnId, final Uint32 vpnId, final String rd, final String localNextHopIp, final String remoteNextHopIp) {
LOG.trace("cleanUpExternalRoutesOnDpn : cleanup remote routes on dpn {} for vpn {}, rd {}, " + " localNexthopIp {} , remoteNexhtHopIp {}", dpnId, vpnId, rd, localNextHopIp, remoteNextHopIp);
InstanceIdentifier<VrfTables> id = buildVrfId(rd);
final VpnInstanceOpDataEntry vpnInstance = fibUtil.getVpnInstance(rd);
List<SubTransaction> txnObjects = new ArrayList<>();
final Optional<VrfTables> vrfTable;
try {
vrfTable = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, id);
} catch (ExecutionException | InterruptedException e) {
LOG.error("getVrfEntry: Exception while reading VrfTable for the rd {} vpnId {}", rd, vpnId, e);
return;
}
if (vrfTable.isPresent()) {
jobCoordinator.enqueueJob(FibUtil.getJobKeyForVpnIdDpnId(vpnId, dpnId), () -> {
final ReentrantLock lock = lockFor(vpnInstance);
lock.lock();
try {
return Collections.singletonList(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> vrfTable.get().nonnullVrfEntry().values().stream().filter(vrfEntry -> RouteOrigin.value(vrfEntry.getOrigin()) == RouteOrigin.BGP).forEach(bgpRouteVrfEntryHandler.getConsumerForDeletingRemoteFib(dpnId, vpnId, remoteNextHopIp, vrfTable, TransactionAdapter.toWriteTransaction(tx), txnObjects))));
} finally {
lock.unlock();
}
});
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class VrfEntryListener method installSubnetRouteInFib.
void installSubnetRouteInFib(final Uint64 dpnId, final long elanTag, final String rd, final Uint32 vpnId, final VrfEntry vrfEntry, TypedWriteTransaction<Configuration> tx) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, newTx -> installSubnetRouteInFib(dpnId, elanTag, rd, vpnId, vrfEntry, newTx)), LOG, "Error installing subnet route in FIB");
return;
}
int etherType;
try {
etherType = NWUtil.getEtherTypeFromIpPrefix(vrfEntry.getDestPrefix());
} catch (IllegalArgumentException ex) {
LOG.error("Unable to get etherType for IP Prefix {}", vrfEntry.getDestPrefix());
return;
}
final List<InstructionInfo> instructions = new ArrayList<>();
Uint64 subnetRouteMeta = Uint64.valueOf(BigInteger.valueOf(elanTag).shiftLeft(24).or(BigInteger.valueOf(vpnId.longValue()).shiftLeft(1)));
instructions.add(new InstructionWriteMetadata(subnetRouteMeta, MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
instructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
baseVrfEntryHandler.makeConnectedRoute(dpnId, vpnId, vrfEntry, rd, instructions, NwConstants.ADD_FLOW, TransactionAdapter.toWriteTransaction(tx), null);
if (vrfEntry.getRoutePaths() != null) {
for (RoutePaths routePath : vrfEntry.getRoutePaths().values()) {
if (RouteOrigin.value(vrfEntry.getOrigin()) != RouteOrigin.SELF_IMPORTED) {
List<ActionInfo> actionsInfos = new ArrayList<>();
// reinitialize instructions list for LFIB Table
final List<InstructionInfo> LFIBinstructions = new ArrayList<>();
actionsInfos.add(new ActionPopMpls(etherType));
LFIBinstructions.add(new InstructionApplyActions(actionsInfos));
LFIBinstructions.add(new InstructionWriteMetadata(subnetRouteMeta, MetaDataUtil.METADATA_MASK_SUBNET_ROUTE));
LFIBinstructions.add(new InstructionGotoTable(NwConstants.L3_SUBNET_ROUTE_TABLE));
makeLFibTableEntry(dpnId, routePath.getLabel(), LFIBinstructions, DEFAULT_FIB_FLOW_PRIORITY, NwConstants.ADD_FLOW, tx);
}
}
}
}
use of org.opendaylight.mdsal.binding.util.Datastore.Configuration in project netvirt by opendaylight.
the class VrfEntryListener method makeLFibTableEntry.
private void makeLFibTableEntry(Uint64 dpId, Uint32 label, @Nullable List<InstructionInfo> instructions, int priority, int addOrRemove, TypedWriteTransaction<Configuration> tx) {
if (tx == null) {
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, newTx -> makeLFibTableEntry(dpId, label, instructions, priority, addOrRemove, newTx)), LOG, "Error making LFIB table entry");
return;
}
List<MatchInfo> matches = new ArrayList<>();
matches.add(MatchEthernetType.MPLS_UNICAST);
matches.add(new MatchMplsLabel(label.longValue()));
// Install the flow entry in L3_LFIB_TABLE
String flowRef = FibUtil.getFlowRef(dpId, NwConstants.L3_LFIB_TABLE, label, priority);
FlowEntity flowEntity;
flowEntity = MDSALUtil.buildFlowEntity(dpId, NwConstants.L3_LFIB_TABLE, flowRef, priority, flowRef, 0, 0, NwConstants.COOKIE_VM_LFIB_TABLE, matches, instructions);
Flow flow = flowEntity.getFlowBuilder().build();
String flowId = flowEntity.getFlowId();
FlowKey flowKey = new FlowKey(new FlowId(flowId));
Node nodeDpn = FibUtil.buildDpnNode(dpId);
InstanceIdentifier<Flow> flowInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class).child(Table.class, new TableKey(flow.getTableId())).child(Flow.class, flowKey).build();
if (addOrRemove == NwConstants.ADD_FLOW) {
tx.mergeParentStructurePut(flowInstanceId, flow);
} else {
tx.delete(flowInstanceId);
}
LOG.debug("LFIB Entry for dpID {} : label : {} instructions {} : key {} {} successfully", dpId, label, instructions, flowKey, NwConstants.ADD_FLOW == addOrRemove ? "ADDED" : "REMOVED");
}
Aggregations