Search in sources :

Example 56 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId 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)

Example 57 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TransportZoneListener method createhWVteps.

private List<HwVtep> createhWVteps(TransportZone transportZone) {
    List<HwVtep> hwVtepsList = new ArrayList<>();
    String zoneName = transportZone.getZoneName();
    Class<? extends TunnelTypeBase> tunnelType = transportZone.getTunnelType();
    LOG.trace("Transport Zone_name: {}", zoneName);
    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<DeviceVteps> deviceVtepsList = subnet.getDeviceVteps();
            if (deviceVtepsList != null) {
                for (DeviceVteps vteps : deviceVtepsList) {
                    String topologyId = vteps.getTopologyId();
                    String nodeId = vteps.getNodeId();
                    IpAddress ipAddress = vteps.getIpAddress();
                    LOG.trace("topo-id: {}, node-id: {}, ipAddress: {}", topologyId, nodeId, ipAddress);
                    HwVtep hwVtep = ItmUtils.createHwVtepObject(topologyId, nodeId, ipAddress, ipPrefix, gatewayIP, vlanID, tunnelType, transportZone);
                    LOG.trace("Adding new HwVtep {} info ", hwVtep.getHwIp());
                    hwVtepsList.add(hwVtep);
                }
            }
        }
    }
    LOG.trace("returning hwvteplist {}", hwVtepsList);
    return hwVtepsList;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) DeviceVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) ArrayList(java.util.ArrayList) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 58 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TepCommandHelper method showTeps.

@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showTeps(boolean monitorEnabled, int monitorInterval, CommandSession session) throws TepException {
    boolean flag = false;
    InstanceIdentifier<TransportZones> path = InstanceIdentifier.builder(TransportZones.class).build();
    Optional<TransportZones> transportZonesOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (transportZonesOptional.isPresent()) {
        TransportZones transportZones = transportZonesOptional.get();
        if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
            handleError("No teps configured", session);
            return;
        }
        List<String> result = new ArrayList<>();
        result.add(String.format("Tunnel Monitoring (for VXLAN tunnels): %s", monitorEnabled ? "On" : "Off"));
        result.add(String.format("Tunnel Monitoring Interval (for VXLAN tunnels): %d", monitorInterval));
        result.add(System.lineSeparator());
        result.add(String.format("%-16s  %-16s  %-16s  %-12s  %-12s %-12s %-16s %-12s", "TransportZone", "TunnelType", "SubnetMask", "GatewayIP", "VlanID", "DpnID", "IPAddress", "PortName"));
        result.add("---------------------------------------------------------------------------------------------" + "---------------------------------");
        for (TransportZone tz : transportZones.getTransportZone()) {
            if (tz.getSubnets() == null || tz.getSubnets().isEmpty()) {
                LOG.error("Transport Zone {} has no subnets", tz.getZoneName());
                continue;
            }
            for (Subnets sub : tz.getSubnets()) {
                if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
                    LOG.error("Transport Zone {} subnet {} has no vteps", tz.getZoneName(), sub.getPrefix());
                    continue;
                }
                for (Vteps vtep : sub.getVteps()) {
                    flag = true;
                    String strTunnelType;
                    if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
                        strTunnelType = ITMConstants.TUNNEL_TYPE_GRE;
                    } else {
                        strTunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
                    }
                    result.add(String.format("%-16s  %-16s  %-16s  %-12s  %-12s %-12s %-16s %-12s", tz.getZoneName(), strTunnelType, new String(sub.getPrefix().getValue()), new String(sub.getGatewayIp().getValue()), sub.getVlanId().toString(), vtep.getDpnId().toString(), new String(vtep.getIpAddress().getValue()), vtep.getPortname()));
                }
            }
        }
        if (session != null) {
            if (flag) {
                for (String print : result) {
                    System.out.println(print);
                }
            } else {
                System.out.println("No teps to display");
            }
        }
    } else if (session != null) {
        System.out.println("No teps configured");
    }
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) ArrayList(java.util.ArrayList) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 59 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TepCommandHelper method createLocalCache.

@SuppressWarnings("checkstyle:IllegalCatch")
public void createLocalCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask, String gatewayIp, String transportZone, CommandSession session) throws TepException {
    CHECK.incrementAndGet();
    IpAddress ipAddressObj = null;
    IpAddress gatewayIpObj = null;
    IpPrefix subnetMaskObj = null;
    final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
    try {
        ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
        gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
        if ((gatewayIp != null) && !gatewayIp.isEmpty() && !("null".equals(gatewayIp)) || ("0.0.0.0".equals(gatewayIp))) {
            gatewayIpObj = IpAddressBuilder.getDefaultInstance(gatewayIp);
        } else {
            LOG.debug("gateway is null");
            gatewayIp = null;
        }
    } catch (RuntimeException e) {
        handleError("Invalid IpAddress. Expected: 1.0.0.0 to 254.255.255.255", session);
        return;
    }
    try {
        subnetMaskObj = IpPrefixBuilder.getDefaultInstance(subnetMask);
    } catch (Exception e) {
        handleError("Invalid Subnet Mask. Expected: 0.0.0.0/0 to 255.255.255.255/32", session);
        return;
    }
    if (!validateIPs(ipAddress, subnetMask, gatewayIp)) {
        handleError("IpAddress and gateWayIp should belong to the subnet provided", session);
        return;
    }
    if (checkTepPerTzPerDpn(transportZone, dpnId)) {
        if (session != null) {
            session.getConsole().println("Only one end point per transport Zone per Dpn is allowed");
        }
        return;
    }
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).setKey(vtepkey).setPortname(portName).build();
    validateForDuplicates(vtepCli, transportZone);
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
    if (transportZonesHashMap.containsKey(transportZone)) {
        Map<SubnetObject, List<Vteps>> subVtepMapTemp = transportZonesHashMap.get(transportZone);
        if (subVtepMapTemp.containsKey(subObCli)) {
            // if Subnet exists
            List<Vteps> vtepListTemp = subVtepMapTemp.get(subObCli);
            if (vtepListTemp.contains(vtepCli)) {
            // do nothing
            } else {
                vtepListTemp.add(vtepCli);
            }
        } else {
            // subnet doesnt exist
            if (checkExistingSubnet(subVtepMapTemp, subObCli)) {
                if (session != null) {
                    session.getConsole().println("subnet with subnet mask " + subObCli.get_key() + "already exists");
                }
                return;
            }
            List<Vteps> vtepListTemp = new ArrayList<>();
            vtepListTemp.add(vtepCli);
            subVtepMapTemp.put(subObCli, vtepListTemp);
        }
    } else {
        List<Vteps> vtepListTemp = new ArrayList<>();
        vtepListTemp.add(vtepCli);
        Map<SubnetObject, List<Vteps>> subVtepMapTemp = new HashMap<>();
        subVtepMapTemp.put(subObCli, vtepListTemp);
        transportZonesHashMap.put(transportZone, subVtepMapTemp);
    }
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder) IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 60 with VlanId

use of org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanId in project genius by opendaylight.

the class TepCommandHelper method isInCache.

// deletes from ADD-cache if it exists.
public boolean isInCache(BigInteger dpnId, String portName, Integer vlanId, String ipAddress, String subnetMask, String gatewayIp, String transportZone, CommandSession session) {
    boolean exists = false;
    final VtepsKey vtepkey = new VtepsKey(dpnId, portName);
    IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    IpPrefix subnetMaskObj = IpPrefixBuilder.getDefaultInstance(subnetMask);
    IpAddress gatewayIpObj = IpAddressBuilder.getDefaultInstance("0.0.0.0");
    if (gatewayIp != null) {
        gatewayIpObj = IpAddressBuilder.getDefaultInstance(gatewayIp);
    } else {
        LOG.debug("gateway is null");
    }
    SubnetsKey subnetsKey = new SubnetsKey(subnetMaskObj);
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).setKey(vtepkey).setPortname(portName).build();
    SubnetObject subObCli = new SubnetObject(gatewayIpObj, subnetsKey, subnetMaskObj, vlanId);
    if (transportZonesHashMap.containsKey(transportZone)) {
        Map<SubnetObject, List<Vteps>> subVtepMapTemp = transportZonesHashMap.get(transportZone);
        if (subVtepMapTemp.containsKey(subObCli)) {
            // if Subnet exists
            List<Vteps> vtepListTemp = subVtepMapTemp.get(subObCli);
            if (vtepListTemp.contains(vtepCli)) {
                // return true if tzones has vtep
                exists = true;
                vtepListTemp.remove(vtepCli);
                if (vtepListTemp.size() == 0) {
                    subVtepMapTemp.remove(subObCli);
                    if (subVtepMapTemp.size() == 0) {
                        transportZonesHashMap.remove(transportZone);
                    }
                }
            } else if (session != null) {
                session.getConsole().println("Vtep " + "has not been configured");
            }
        }
    }
    return exists;
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsBuilder)

Aggregations

ArrayList (java.util.ArrayList)27 VlanId (org.opendaylight.yang.gen.v1.urn.opendaylight.l2.types.rev130827.VlanId)26 BigInteger (java.math.BigInteger)14 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)12 IfL2vlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfL2vlan)12 List (java.util.List)11 Test (org.junit.Test)11 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)10 MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder)10 VlanMatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.VlanMatchBuilder)10 VlanIdBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.vlan.match.fields.VlanIdBuilder)10 SetVlanIdActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.set.vlan.id.action._case.SetVlanIdActionBuilder)9 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)9 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 SetVlanIdActionCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.SetVlanIdActionCaseBuilder)6 ActionBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.ActionBuilder)6 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)6 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)6 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)6 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)6