Search in sources :

Example 6 with TepsInNotHostedTransportZone

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone 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

TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)6 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)4 Test (org.junit.Test)2 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)2 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 TepsInNotHostedTransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneBuilder)1 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)1 UnknownVtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder)1 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)1 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)1