Search in sources :

Example 6 with TzMembership

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.tunnel.end.points.TzMembership 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

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