Search in sources :

Example 1 with ItmTepsNotHostedMoveWorker

use of org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedMoveWorker in project genius by opendaylight.

the class TransportZoneListener method createDPNTepInfoFromNotHosted.

private List<DPNTEPsInfo> createDPNTepInfoFromNotHosted(TransportZone tzNew) {
    Map<BigInteger, List<TunnelEndPoints>> mapNotHostedDPNToTunnelEndpt = new ConcurrentHashMap<>();
    List<DPNTEPsInfo> notHostedDpnTepInfo = new ArrayList<>();
    String newZoneName = tzNew.getZoneName();
    List<TzMembership> zones = ItmUtils.createTransportZoneMembership(newZoneName);
    Class<? extends TunnelTypeBase> tunnelType = tzNew.getTunnelType();
    TepsInNotHostedTransportZone tepsInNotHostedTransportZone = getNotHostedTransportZone(newZoneName).get();
    if (tepsInNotHostedTransportZone == null) {
        return notHostedDpnTepInfo;
    }
    List<UnknownVteps> unVtepsLst = tepsInNotHostedTransportZone.getUnknownVteps();
    List<Vteps> vtepsList = new ArrayList<>();
    if (unVtepsLst != null && !unVtepsLst.isEmpty()) {
        for (UnknownVteps vteps : unVtepsLst) {
            BigInteger dpnID = vteps.getDpnId();
            String port = ITMConstants.DUMMY_PORT;
            int vlanID = ITMConstants.DUMMY_VLANID;
            IpPrefix ipPrefix = IpPrefixBuilder.getDefaultInstance(ITMConstants.DUMMY_PREFIX);
            IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
            IpAddress ipAddress = vteps.getIpAddress();
            boolean useOfTunnel = ItmUtils.falseIfNull(vteps.isOfTunnel());
            String tos = vteps.getOptionTunnelTos();
            if (tos == null) {
                tos = itmConfig.getDefaultTunnelTos();
            }
            TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(dpnID, ipAddress, port, useOfTunnel, vlanID, ipPrefix, gatewayIP, zones, tunnelType, tos);
            List<TunnelEndPoints> tunnelEndPointsList = mapNotHostedDPNToTunnelEndpt.get(dpnID);
            if (tunnelEndPointsList != null) {
                tunnelEndPointsList.add(tunnelEndPoints);
            } else {
                tunnelEndPointsList = new ArrayList<>();
                tunnelEndPointsList.add(tunnelEndPoints);
                mapNotHostedDPNToTunnelEndpt.put(dpnID, tunnelEndPointsList);
            }
            Vteps newVtep = createVtepFromUnKnownVteps(dpnID, ipAddress, ITMConstants.DUMMY_PORT);
            vtepsList.add(newVtep);
            // Enqueue 'remove TEP from TepsNotHosted list' operation
            // into DataStoreJobCoordinator
            ItmTepsNotHostedRemoveWorker removeWorker = new ItmTepsNotHostedRemoveWorker(newZoneName, ipAddress, dpnID, dataBroker);
            jobCoordinator.enqueueJob(newZoneName, removeWorker);
        }
    }
    // Enqueue 'add TEP received from southbound OVSDB into ITM config DS' operation
    // into DataStoreJobCoordinator
    ItmTepsNotHostedMoveWorker moveWorker = new ItmTepsNotHostedMoveWorker(vtepsList, newZoneName, dataBroker);
    jobCoordinator.enqueueJob(newZoneName, moveWorker);
    if (mapNotHostedDPNToTunnelEndpt.size() > 0) {
        for (Entry<BigInteger, List<TunnelEndPoints>> entry : mapNotHostedDPNToTunnelEndpt.entrySet()) {
            DPNTEPsInfo newDpnTepsInfo = ItmUtils.createDPNTepInfo(entry.getKey(), entry.getValue());
            notHostedDpnTepInfo.add(newDpnTepsInfo);
        }
    }
    return notHostedDpnTepInfo;
}
Also used : ItmTepsNotHostedMoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedMoveWorker) ArrayList(java.util.ArrayList) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) 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) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) List(java.util.List) ArrayList(java.util.ArrayList) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepsNotHostedRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedRemoveWorker) TzMembership(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership) 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) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Aggregations

BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ItmTepsNotHostedMoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedMoveWorker)1 ItmTepsNotHostedRemoveWorker (org.opendaylight.genius.itm.confighelpers.ItmTepsNotHostedRemoveWorker)1 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)1 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)1 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)1 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)1 TzMembership (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership)1 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)1 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)1 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)1 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)1