Search in sources :

Example 1 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 addExternalTunnelEndpoint.

@Override
public Future<RpcResult<Void>> addExternalTunnelEndpoint(AddExternalTunnelEndpointInput input) {
    // TODO Auto-generated method stub
    // Ignore the Futures for now
    final SettableFuture<RpcResult<Void>> result = SettableFuture.create();
    Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
    externalTunnelAddWorker.buildTunnelsToExternalEndPoint(meshedDpnList, input.getDestinationIp(), input.getTunnelType());
    InstanceIdentifier<DcGatewayIp> extPath = InstanceIdentifier.builder(DcGatewayIpList.class).child(DcGatewayIp.class, new DcGatewayIpKey(input.getDestinationIp())).build();
    DcGatewayIp dcGatewayIp = new DcGatewayIpBuilder().setIpAddress(input.getDestinationIp()).setTunnnelType(input.getTunnelType()).build();
    WriteTransaction writeTransaction = dataBroker.newWriteOnlyTransaction();
    writeTransaction.put(LogicalDatastoreType.CONFIGURATION, extPath, dcGatewayIp, true);
    ListenableFuture<Void> futureCheck = writeTransaction.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 create DcGatewayIp {} in datastore for ip " + input.getDestinationIp() + "and " + "tunnel type " + input.getTunnelType();
            LOG.error("Unable to create DcGatewayIp in datastore for ip {} and tunnel type {}", input.getDestinationIp(), input.getTunnelType());
            result.set(RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, msg, error).build());
        }
    });
    return result;
}
Also used : DcGatewayIpBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.dc.gateway.ip.list.DcGatewayIpBuilder) 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 2 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 getDpnEndpointIps.

@Override
public Future<RpcResult<GetDpnEndpointIpsOutput>> getDpnEndpointIps(GetDpnEndpointIpsInput input) {
    BigInteger srcDpn = input.getSourceDpid();
    RpcResultBuilder<GetDpnEndpointIpsOutput> resultBld = RpcResultBuilder.failed();
    InstanceIdentifier<DPNTEPsInfo> tunnelInfoId = InstanceIdentifier.builder(DpnEndpoints.class).child(DPNTEPsInfo.class, new DPNTEPsInfoKey(srcDpn)).build();
    Optional<DPNTEPsInfo> tunnelInfo = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, tunnelInfoId, dataBroker);
    if (!tunnelInfo.isPresent()) {
        LOG.error("tunnelInfo is not present");
        return Futures.immediateFuture(resultBld.build());
    }
    List<TunnelEndPoints> tunnelEndPointList = tunnelInfo.get().getTunnelEndPoints();
    if (tunnelEndPointList == null || tunnelEndPointList.isEmpty()) {
        LOG.error("tunnelEndPointList is null or empty");
        return Futures.immediateFuture(resultBld.build());
    }
    List<IpAddress> nexthopIpList = new ArrayList<>();
    tunnelEndPointList.forEach(tunnelEndPoint -> nexthopIpList.add(tunnelEndPoint.getIpAddress()));
    GetDpnEndpointIpsOutputBuilder output = new GetDpnEndpointIpsOutputBuilder().setNexthopipList(nexthopIpList);
    resultBld = RpcResultBuilder.success();
    resultBld.withResult(output.build());
    return Futures.immediateFuture(resultBld.build());
}
Also used : ArrayList(java.util.ArrayList) GetDpnEndpointIpsOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutput) TunnelEndPoints(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints) GetDpnEndpointIpsOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetDpnEndpointIpsOutputBuilder) DPNTEPsInfoKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfoKey) 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 3 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 TransportZoneListener method remove.

@Override
public void remove(@Nonnull TransportZone transportZone) {
    LOG.debug("Received Transport Zone Remove Event: {}", transportZone);
    boolean allowTunnelDeletion;
    // due to change in def-tz-tunnel-type, then allow def-tz tunnels deletion
    if (transportZone.getZoneName().equalsIgnoreCase(ITMConstants.DEFAULT_TRANSPORT_ZONE)) {
        // Get TunnelTypeBase object for tunnel-type configured in config file
        Class<? extends TunnelTypeBase> tunType = ItmUtils.getTunnelType(itmConfig.getDefTzTunnelType());
        if (!itmConfig.isDefTzEnabled() || !transportZone.getTunnelType().equals(tunType)) {
            allowTunnelDeletion = true;
        } else {
            // this is case when def-tz removal request is from Northbound.
            allowTunnelDeletion = false;
            LOG.error("Deletion of {} is an incorrect usage", ITMConstants.DEFAULT_TRANSPORT_ZONE);
        }
    } else {
        allowTunnelDeletion = true;
    }
    if (allowTunnelDeletion) {
        // TODO : DPList code can be refactor with new specific class
        // which implement TransportZoneValidator
        List<DPNTEPsInfo> opDpnList = createDPNTepInfo(transportZone);
        List<HwVtep> hwVtepList = createhWVteps(transportZone);
        LOG.trace("Delete: Invoking deleteTunnels in ItmManager with DpnList {}", opDpnList);
        if (!opDpnList.isEmpty() || !hwVtepList.isEmpty()) {
            LOG.trace("Delete: Invoking ItmManager with hwVtep List {} ", hwVtepList);
            jobCoordinator.enqueueJob(transportZone.getZoneName(), new ItmTepRemoveWorker(opDpnList, hwVtepList, transportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 4 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 TransportZoneListener method createDPNTepInfo.

private List<DPNTEPsInfo> createDPNTepInfo(TransportZone transportZone) {
    Map<BigInteger, List<TunnelEndPoints>> mapDPNToTunnelEndpt = new ConcurrentHashMap<>();
    List<DPNTEPsInfo> dpnTepInfo = new ArrayList<>();
    List<TzMembership> zones = ItmUtils.createTransportZoneMembership(transportZone.getZoneName());
    Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
    LOG.trace("Transport Zone_name: {}", transportZone.getZoneName());
    List<Subnets> subnetsList = transportZone.getSubnets();
    if (subnetsList != null) {
        for (Subnets subnet : subnetsList) {
            IpPrefix ipPrefix = subnet.getPrefix();
            IpAddress gatewayIP = subnet.getGatewayIp();
            int vlanID = subnet.getVlanId();
            LOG.trace("IpPrefix: {}, gatewayIP: {}, vlanID: {} ", ipPrefix, gatewayIP, vlanID);
            List<Vteps> vtepsList = subnet.getVteps();
            if (vtepsList != null && !vtepsList.isEmpty()) {
                for (Vteps vteps : vtepsList) {
                    BigInteger dpnID = vteps.getDpnId();
                    String port = vteps.getPortname();
                    IpAddress ipAddress = vteps.getIpAddress();
                    boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOptionOfTunnel());
                    String tos = vteps.getOptionTunnelTos();
                    if (tos == null) {
                        tos = itmConfig.getDefaultTunnelTos();
                    }
                    LOG.trace("DpnID: {}, port: {}, ipAddress: {}", dpnID, port, ipAddress);
                    TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
                    List<TunnelEndPoints> tunnelEndPointsList = mapDPNToTunnelEndpt.get(dpnID);
                    if (tunnelEndPointsList != null) {
                        LOG.trace("Existing DPN info list in the Map: {} ", dpnID);
                        tunnelEndPointsList.add(tunnelEndPoints);
                    } else {
                        LOG.trace("Adding new DPN info list to the Map: {} ", dpnID);
                        tunnelEndPointsList = new ArrayList<>();
                        tunnelEndPointsList.add(tunnelEndPoints);
                        mapDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
                    }
                }
            }
        }
    }
    if (!mapDPNToTunnelEndpt.isEmpty()) {
        LOG.trace("List of dpns in the Map: {} ", mapDPNToTunnelEndpt.keySet());
        for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapDPNToTunnelEndpt.entrySet()) {
            DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
            dpnTepInfo.add(newDpnTepsInfo);
        }
    }
    return dpnTepInfo;
}
Also used : 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) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) 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) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) BigInteger(java.math.BigInteger) List(java.util.List) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)

Example 5 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 ItmUtils method getDpnTepListFromDpnId.

public static List<DPNTEPsInfo> getDpnTepListFromDpnId(DPNTEPsInfoCache dpnTEPsInfoCache, List<BigInteger> dpnIds) {
    Collection<DPNTEPsInfo> meshedDpnList = dpnTEPsInfoCache.getAllPresent();
    List<DPNTEPsInfo> cfgDpnList = new ArrayList<>();
    for (BigInteger dpnId : dpnIds) {
        for (DPNTEPsInfo teps : meshedDpnList) {
            if (dpnId.equals(teps.getDPNID())) {
                cfgDpnList.add(teps);
            }
        }
    }
    return cfgDpnList;
}
Also used : ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) 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