Search in sources :

Example 11 with DPNTEPsInfo

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);
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) ArrayList(java.util.ArrayList) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 12 with DPNTEPsInfo

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;
}
Also used : TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ArrayList(java.util.ArrayList) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)

Example 13 with DPNTEPsInfo

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());
}
Also used : GetInternalOrExternalInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutput) ExternalTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList) ExternalTunnelKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey) ExternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel) InternalTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnel.list.InternalTunnel) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) GetInternalOrExternalInterfaceNameOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetInternalOrExternalInterfaceNameOutputBuilder) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 14 with DPNTEPsInfo

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;
}
Also used : WriteTransaction(org.opendaylight.controller.md.sal.binding.api.WriteTransaction) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) DcGatewayIp(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp) DcGatewayIpKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIpKey) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 15 with DPNTEPsInfo

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;
}
Also used : TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) DcGatewayIp(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp) ArrayList(java.util.ArrayList) ListenableFuture(com.google.common.util.concurrent.ListenableFuture) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Aggregations

DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)18 ArrayList (java.util.ArrayList)11 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)11 BigInteger (java.math.BigInteger)7 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)5 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)5 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)5 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)4 TzMembership (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)4 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)4 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)3 ItmTepAddWorker (org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)3 ItmTepRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker)3 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)3 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)3 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)3 DcGatewayIp (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIp)3 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)3 List (java.util.List)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2