use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmTepInstanceRecoveryHandler method recoverTep.
private void recoverTep(String entityId) throws InterruptedException {
List<DPNTEPsInfo> tepsToRecover = new ArrayList<>();
DPNTEPsInfo dpnTepsToRecover = extractDPNTepsInfo(entityId);
if (dpnTepsToRecover == null) {
LOG.error("Please Enter appropriate arguments for Tep Recovery.");
return;
} else {
tepsToRecover.add(dpnTepsToRecover);
// Delete the transportZone and re create it
// Get the transport zone from the transport zone name
TransportZone oldTz = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (oldTz != null) {
ItmTepRemoveWorker tepRemoveWorker = new ItmTepRemoveWorker(tepsToRecover, null, oldTz, dataBroker, imdsalApiManager, itmInternalTunnelDeleteWorker, dpntePsInfoCache);
LOG.trace("Deleting transportzone {}", tzName);
jobCoordinator.enqueueJob(tzName, tepRemoveWorker);
ItmTepAddWorker tepAddWorker = new ItmTepAddWorker(tepsToRecover, null, dataBroker, imdsalApiManager, itmConfig, itmInternalTunnelAddWorker, itmExternalTunnelAddWorker, dpntePsInfoCache);
LOG.trace("Re-creating transportzone {}", tzName);
jobCoordinator.enqueueJob(tzName, tepAddWorker);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.
private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
String[] params = entityId.split(":");
if (params.length < 2) {
LOG.error("Not enough arguments..Exiting...");
return null;
} else if (params.length > 2) {
LOG.info("Ignoring extra parameter and proceeding...");
}
// ToDo:- Need to add more validations
this.tzName = params[0];
String ipAddress = params[1];
transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
if (transportZone == null) {
LOG.error("Transportzone name {} is not valid.", tzName);
return null;
}
for (Subnets sub : transportZone.getSubnets()) {
if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
}
for (Vteps vtep : sub.getVteps()) {
if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
// OfTunnels is false byDefault
TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
List<TunnelEndPoints> teps = new ArrayList<>();
teps.add(tunnelEndPoints);
return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
}
}
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmManagerRpcService method getInternalOrExternalInterfaceName.
@Override
public Future<RpcResult<GetInternalOrExternalInterfaceNameOutput>> getInternalOrExternalInterfaceName(GetInternalOrExternalInterfaceNameInput input) {
RpcResultBuilder<GetInternalOrExternalInterfaceNameOutput> resultBld = RpcResultBuilder.failed();
BigInteger srcDpn = input.getSourceDpid();
IpAddress dstIp = input.getDestinationIp();
InstanceIdentifier<ExternalTunnel> path1 = InstanceIdentifier.create(ExternalTunnelList.class).child(ExternalTunnel.class, new ExternalTunnelKey(String.valueOf(dstIp.getValue()), srcDpn.toString(), input.getTunnelType()));
Optional<ExternalTunnel> optExtTunnel = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path1, dataBroker);
if (optExtTunnel != null && optExtTunnel.isPresent()) {
ExternalTunnel extTunnel = optExtTunnel.get();
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(extTunnel.getTunnelInterfaceName());
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
// Look for external tunnels if not look for internal tunnel
for (DPNTEPsInfo teps : meshedDpnList) {
TunnelEndPoints firstEndPt = teps.getTunnelEndPoints().get(0);
if (dstIp.equals(firstEndPt.getIpAddress())) {
Optional<InternalTunnel> optTunnel = Optional.absent();
if (ItmUtils.isTunnelAggregationUsed(input.getTunnelType())) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), TunnelTypeLogicalGroup.class, dataBroker);
LOG.debug("MULTIPLE_VxLAN_TUNNELS: getInternalOrExternalInterfaceName {}", optTunnel);
}
if (!optTunnel.isPresent()) {
optTunnel = ItmUtils.getInternalTunnelFromDS(srcDpn, teps.getDPNID(), input.getTunnelType(), dataBroker);
}
if (optTunnel.isPresent()) {
InternalTunnel tunnel = optTunnel.get();
List<String> tunnelInterfaces = tunnel.getTunnelInterfaceNames();
if (tunnelInterfaces != null && !tunnelInterfaces.isEmpty()) {
GetInternalOrExternalInterfaceNameOutputBuilder output = new GetInternalOrExternalInterfaceNameOutputBuilder().setInterfaceName(tunnelInterfaces.get(0));
resultBld = RpcResultBuilder.success();
resultBld.withResult(output.build());
} else {
LOG.error("No tunnel interface found between source DPN {} ans destination IP {}", srcDpn, dstIp);
}
break;
} else {
LOG.error("Tunnel not found for source DPN {} ans destination IP {}", srcDpn, dstIp);
}
}
}
}
return Futures.immediateFuture(resultBld.build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmManagerRpcService method removeExternalTunnelEndpoint.
@Override
public Future<RpcResult<Void>> removeExternalTunnelEndpoint(RemoveExternalTunnelEndpointInput input) {
// Ignore the Futures for now
final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, meshedDpnList, input.getDestinationIp(), input.getTunnelType());
InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class).child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
WriteTransaction transaction = dataBroker.newWriteOnlyTransaction();
transaction.delete(LogicalDatastoreType.CONFIGURATION, extPath);
ListenableFuture<Void> futureCheck = transaction.submit();
Futures.addCallback(futureCheck, new FutureCallback<Void>() {
@Override
public void onSuccess(Void voidInstance) {
result.set(RpcResultBuilder.<Void>success().build());
}
@Override
public void onFailure(Throwable error) {
String msg = "Unable to delete DcGatewayIp " + input.getDestinationIp() + " in datastore and tunnel type " + input.getTunnelType();
LOG.error("Unable to delete DcGatewayIp {} in datastore and tunnel type {}", input.getDestinationIp(), input.getTunnelType());
result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
}
});
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo in project genius by opendaylight.
the class ItmTepRemoveWorker method call.
@Override
public List<ListenableFuture<Void>> call() {
List<ListenableFuture<Void>> futures = new ArrayList<>();
this.meshedDpnList = dpnTEPsInfoCache.getAllPresent();
futures.addAll(itmInternalTunnelDeleteWorker.deleteTunnels(mdsalManager, delDpnList, meshedDpnList));
LOG.debug("Invoking Internal Tunnel delete method with DpnList to be deleted {} ; Meshed DpnList {} ", delDpnList, meshedDpnList);
// IF EXTERNAL TUNNELS NEEDS TO BE DELETED, DO IT HERE, IT COULD BE TO DC GATEWAY OR TOR SWITCH
List<DcGatewayIp> dcGatewayIpList = ItmUtils.getDcGatewayIpList(dataBroker);
if (dcGatewayIpList != null && !dcGatewayIpList.isEmpty()) {
List<DPNTEPsInfo> dpnDeleteList = new ArrayList<>();
for (DPNTEPsInfo dpnTEPInfo : delDpnList) {
List<TunnelEndPoints> tunnelEndPointsList = dpnTEPInfo.getTunnelEndPoints();
if (tunnelEndPointsList.size() == 1) {
dpnDeleteList.add(dpnTEPInfo);
} else {
LOG.error("DPNTEPInfo not available in data store for dpnId {}. Unable to delete external tunnel " + "for dpn ", dpnTEPInfo.getDPNID());
}
}
for (DcGatewayIp dcGatewayIp : dcGatewayIpList) {
futures.addAll(ItmExternalTunnelDeleteWorker.deleteTunnels(dataBroker, dpnDeleteList, meshedDpnList, dcGatewayIp.getIpAddress(), dcGatewayIp.getTunnnelType()));
}
}
futures.addAll(ItmExternalTunnelDeleteWorker.deleteHwVtepsTunnels(dataBroker, delDpnList, cfgdHwVteps, this.originalTZone));
return futures;
}
Aggregations