Search in sources :

Example 6 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase 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 7 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase 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 8 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.

the class VtepConfigSchemaListener method addVteps.

/**
 * Adds the vteps.
 *
 * @param schema
 *            the schema
 * @param vtepIpPool
 *            the vtep ip pool
 */
private void addVteps(VtepConfigSchema schema, VtepIpPool vtepIpPool) {
    if (schema.getDpnIds() == null || schema.getDpnIds().isEmpty()) {
        LOG.debug("DPN list is empty, skipping addVteps for schema: {}", schema);
        return;
    }
    String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
    if (vtepIpPool == null) {
        LOG.error("VTEP config pool not found for subnetCidr {}. Failed to add VTEPs for schema {}", subnetCidr, schema);
        return;
    }
    TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
    // Check this later
    String tunType;
    Class<? extends TunnelTypeBase> tunnelType = schema.getTunnelType();
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        tunType = ITMConstants.TUNNEL_TYPE_VXLAN;
    } else {
        tunType = ITMConstants.TUNNEL_TYPE_GRE;
    }
    tepCommandHelper.configureTunnelType(schema.getTransportZoneName(), StringUtils.upperCase(tunType));
    List<IpAddress> availableIps = vtepIpPool.getAvailableIpaddress();
    List<IpAddress> newlyAllocatedIps = new ArrayList<>();
    List<BigInteger> skippedDpnIds = new ArrayList<>();
    String gatewayIp = handleGatewayIp(schema.getGatewayIp());
    for (BigInteger dpnId : ItmUtils.getDpnIdList(schema.getDpnIds())) {
        IpAddress ipAddress = getAnAvailableIP(availableIps);
        if (ipAddress == null) {
            skippedDpnIds.add(dpnId);
            continue;
        }
        try {
            tepCommandHelper.createLocalCache(dpnId, schema.getPortName(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
        } catch (TepException e) {
            LOG.error("create local cache Failed", e);
        }
        newlyAllocatedIps.add(ipAddress);
    }
    if (!skippedDpnIds.isEmpty()) {
        LOG.error("No available IP addresses in the VTEP config pool {}, skipping VTEP configurations for DPN's {}", subnetCidr, skippedDpnIds);
    }
    if (!newlyAllocatedIps.isEmpty()) {
        LOG.debug("Delete OnCommit and buildTeps in NewlyAddedDpns");
        tepCommandHelper.deleteOnCommit();
        tepCommandHelper.buildTeps();
        allocateIpAddresses(newlyAllocatedIps, vtepIpPool, subnetCidr);
    }
}
Also used : TepCommandHelper(org.opendaylight.genius.itm.cli.TepCommandHelper) ArrayList(java.util.ArrayList) TepException(org.opendaylight.genius.itm.cli.TepException) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 9 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.

the class ItmProvider method remExternalEndpoint.

@Override
public void remExternalEndpoint(Class<? extends TunnelTypeBase> tunnelType, IpAddress dcgwIP) {
    RemoveExternalTunnelEndpointInput removeExternalTunnelEndpointInput = new RemoveExternalTunnelEndpointInputBuilder().setTunnelType(tunnelType).setDestinationIp(dcgwIP).build();
    JdkFutures.addErrorLogging(itmRpcService.removeExternalTunnelEndpoint(removeExternalTunnelEndpointInput), LOG, "removeExternalTunnelEndpoint");
}
Also used : RemoveExternalTunnelEndpointInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelEndpointInput) RemoveExternalTunnelEndpointInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.RemoveExternalTunnelEndpointInputBuilder)

Example 10 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.

the class ItmUtils method buildHwTunnelInterface.

public static Interface buildHwTunnelInterface(String tunnelIfName, String desc, boolean enabled, String topoId, String nodeId, Class<? extends TunnelTypeBase> tunType, IpAddress srcIp, IpAddress destIp, IpAddress gwIp, Boolean monitorEnabled, Class<? extends TunnelMonitoringTypeBase> monitorProtocol, Integer monitorInterval) {
    InterfaceBuilder builder = new InterfaceBuilder().setKey(new InterfaceKey(tunnelIfName)).setName(tunnelIfName).setDescription(desc).setEnabled(enabled).setType(Tunnel.class);
    List<NodeIdentifier> nodeIds = new ArrayList<>();
    NodeIdentifier hwNode = new NodeIdentifierBuilder().setKey(new NodeIdentifierKey(topoId)).setTopologyId(topoId).setNodeId(nodeId).build();
    nodeIds.add(hwNode);
    ParentRefs parent = new ParentRefsBuilder().setNodeIdentifier(nodeIds).build();
    builder.addAugmentation(ParentRefs.class, parent);
    IfTunnel tunnel = new IfTunnelBuilder().setTunnelDestination(destIp).setTunnelGateway(gwIp).setTunnelSource(srcIp).setMonitorEnabled(monitorEnabled == null || monitorEnabled).setMonitorProtocol(monitorProtocol == null ? ITMConstants.DEFAULT_MONITOR_PROTOCOL : monitorProtocol).setMonitorInterval(DEFAULT_MONITORING_INTERVAL).setTunnelInterfaceType(tunType).setInternal(false).build();
    builder.addAugmentation(IfTunnel.class, tunnel);
    LOG.trace("iftunnel {} built from hwvtep {} ", tunnel, nodeId);
    return builder.build();
}
Also used : ParentRefs(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs) NodeIdentifier(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifier) ArrayList(java.util.ArrayList) NodeIdentifierBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierBuilder) IfTunnel(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel) InterfaceBuilder(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceBuilder) InterfaceKey(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey) IfTunnelBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder) NodeIdentifierKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.interfaces._interface.NodeIdentifierKey) ParentRefsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefsBuilder)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)13 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)9 ExecutionException (java.util.concurrent.ExecutionException)8 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)8 ArrayList (java.util.ArrayList)7 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)7 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)6 BigInteger (java.math.BigInteger)5 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)5 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)5 GetTunnelInterfaceNameInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder)5 GetTunnelInterfaceNameOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)4 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)4 TunnelTypeGre (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre)4 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)4 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)4 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)4 List (java.util.List)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3