Search in sources :

Example 31 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepRemoveConfigHelper method removeVtepFromTepsNotHosted.

/**
 * Removes the TEP from unknown vtep list under the transport zone in the TepsNotHosted list
 * from ITM operational Datastore by delete operation with write transaction.
 *
 * @param tzName transport zone name in string
 * @param dpnId bridge datapath ID in BigInteger
 * @param wrTx WriteTransaction object
 */
private static void removeVtepFromTepsNotHosted(String tzName, BigInteger dpnId, WriteTransaction wrTx) {
    UnknownVtepsKey unknownVtepkey = new UnknownVtepsKey(dpnId);
    InstanceIdentifier<UnknownVteps> vtepPath = InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class, new TepsInNotHostedTransportZoneKey(tzName)).child(UnknownVteps.class, unknownVtepkey).build();
    LOG.trace("Removing TEP from unhosted (TZ: {}, DPID: {}) inside ITM Oper DS.", tzName, dpnId);
    // remove vtep
    wrTx.delete(LogicalDatastoreType.OPERATIONAL, vtepPath);
}
Also used : TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) NotHostedTransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.NotHostedTransportZones)

Example 32 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class ItmUtils method validateForAddVtepConfigSchema.

public static VtepConfigSchema validateForAddVtepConfigSchema(VtepConfigSchema schema, List<VtepConfigSchema> existingSchemas) {
    VtepConfigSchema validSchema = validateVtepConfigSchema(schema);
    for (VtepConfigSchema existingSchema : emptyIfNull(existingSchemas)) {
        if (!StringUtils.equalsIgnoreCase(schema.getSchemaName(), existingSchema.getSchemaName()) && schema.getSubnet().equals(existingSchema.getSubnet())) {
            String subnetCidr = getSubnetCidrAsString(schema.getSubnet());
            Preconditions.checkArgument(false, "VTEP schema with subnet [" + subnetCidr + "] already exists. Multiple VTEP schemas with same subnet is not allowed.");
        }
    }
    if (isNotEmpty(getDpnIdList(validSchema.getDpnIds()))) {
        String tzone = validSchema.getTransportZoneName();
        List<BigInteger> lstDpns = getConflictingDpnsAlreadyConfiguredWithTz(validSchema.getSchemaName(), tzone, getDpnIdList(validSchema.getDpnIds()), existingSchemas);
        if (!lstDpns.isEmpty()) {
            Preconditions.checkArgument(false, "DPN's " + lstDpns + " already configured for transport zone " + tzone + ". Only one end point per transport Zone per Dpn is allowed.");
        }
        if (schema.getTunnelType().equals(TunnelTypeGre.class)) {
            validateForSingleGreTep(validSchema.getSchemaName(), getDpnIdList(validSchema.getDpnIds()), existingSchemas);
        }
    }
    return validSchema;
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) BigInteger(java.math.BigInteger)

Example 33 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepAddConfigHelper method addTepReceivedFromOvsdb.

/**
 * Adds the TEP into ITM configuration/operational Datastore in one of the following cases.
 * 1) default transport zone
 * 2) Configured transport zone
 * 3) Unhosted transport zone
 *
 * @param tepIp TEP-IP address in string
 * @param strDpnId bridge datapath ID in string
 * @param tzName transport zone name in string
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param dataBroker data broker handle to perform operations on config/operational datastore
 * @param wrTx WriteTransaction object
 */
public static void addTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, boolean ofTunnel, DataBroker dataBroker, WriteTransaction wrTx) {
    BigInteger dpnId = BigInteger.valueOf(0);
    if (strDpnId != null && !strDpnId.isEmpty()) {
        dpnId = MDSALUtil.getDpnId(strDpnId);
    }
    // Get tep IP
    IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
    TransportZone tzone = null;
    // Case: TZ name is not given with OVS TEP.
    if (tzName == null) {
        tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
        // add TEP into default-TZ
        tzone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (tzone == null) {
            LOG.error("Error: default-transport-zone is not yet created.");
            return;
        }
        LOG.trace("Add TEP into default-transport-zone.");
    } else {
        // Case: Add TEP into corresponding TZ created from Northbound.
        tzone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (tzone == null) {
            // Case: TZ is not configured from Northbound, then add TEP into "teps-in-not-hosted-transport-zone"
            LOG.trace("Adding TEP with unknown TZ into teps-in-not-hosted-transport-zone.");
            addUnknownTzTepIntoTepsNotHosted(tzName, tepIpAddress, dpnId, ofTunnel, dataBroker, wrTx);
            return;
        } else {
            LOG.trace("Add TEP into transport-zone already configured by Northbound.");
        }
    }
    // Get subnet list of corresponding TZ created from Northbound.
    List<Subnets> subnetList = tzone.getSubnets();
    String portName = ITMConstants.DUMMY_PORT;
    IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
    if (subnetList == null || subnetList.isEmpty()) {
        if (subnetList == null) {
            subnetList = new ArrayList<>();
        }
        List<Vteps> vtepList = new ArrayList<>();
        LOG.trace("Add TEP in transport-zone when no subnet-list.");
        addVtepInITMConfigDS(subnetList, subnetMaskObj, vtepList, tepIpAddress, tzName, dpnId, portName, ofTunnel, wrTx);
    } else {
        List<Vteps> vtepList = null;
        // subnet list already exists case; check for dummy-subnet
        for (Subnets subnet : subnetList) {
            if (subnet.getKey().getPrefix().equals(subnetMaskObj)) {
                LOG.trace("Subnet exists in the subnet list of transport-zone {}.", tzName);
                // get vtep list of existing subnet
                vtepList = subnet.getVteps();
                break;
            }
        }
        if (vtepList == null || vtepList.isEmpty()) {
            // case: vtep list does not exist or it has no elements
            if (vtepList == null) {
                vtepList = new ArrayList<>();
            }
            LOG.trace("Add TEP in transport-zone when no vtep-list for specific subnet.");
            addVtepInITMConfigDS(subnetList, subnetMaskObj, vtepList, tepIpAddress, tzName, dpnId, portName, ofTunnel, wrTx);
        } else {
            // case: vtep list has elements
            boolean vtepFound = false;
            Vteps oldVtep = null;
            for (Vteps vtep : vtepList) {
                if (vtep.getDpnId().equals(dpnId)) {
                    vtepFound = true;
                    oldVtep = vtep;
                    // get portName of existing vtep
                    portName = vtep.getPortname();
                    break;
                }
            }
            if (!vtepFound) {
                addVtepInITMConfigDS(subnetList, subnetMaskObj, vtepList, tepIpAddress, tzName, dpnId, portName, ofTunnel, wrTx);
            } else {
                // vtep is found, update it with tep-ip
                vtepList.remove(oldVtep);
                addVtepInITMConfigDS(subnetList, subnetMaskObj, vtepList, tepIpAddress, tzName, dpnId, portName, ofTunnel, wrTx);
            }
        }
    }
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) 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) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) ArrayList(java.util.ArrayList) BigInteger(java.math.BigInteger) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)

Example 34 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepAddConfigHelper method addUnknownTzTepIntoTepsNotHosted.

/**
 * Adds the TEP into Vtep list in the subnet list in the transport zone list
 * from ITM operational Datastore by merge operation with write transaction.
 *
 * @param tzName transport zone name in string
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param dpid bridge datapath ID in BigInteger
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param dataBroker data broker handle to perform operations on operational datastore
 * @param wrTx WriteTransaction object
 */
protected static void addUnknownTzTepIntoTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpid, boolean ofTunnel, DataBroker dataBroker, WriteTransaction wrTx) {
    List<UnknownVteps> vtepList = null;
    TepsInNotHostedTransportZone tepsInNotHostedTransportZone = ItmUtils.getUnknownTransportZoneFromITMOperDS(tzName, dataBroker);
    if (tepsInNotHostedTransportZone == null) {
        LOG.trace("Unhosted TransportZone ({}) does not exist in OperDS.", tzName);
        vtepList = new ArrayList<>();
        addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
    } else {
        vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
        if (vtepList == null || vtepList.isEmpty()) {
            // case: vtep list does not exist or it has no elements
            if (vtepList == null) {
                vtepList = new ArrayList<>();
            }
            LOG.trace("Add TEP into unhosted TZ ({}) when no vtep-list in the TZ.", tzName);
            addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
        } else {
            // case: vtep list has elements
            boolean vtepFound = false;
            UnknownVteps oldVtep = null;
            for (UnknownVteps vtep : vtepList) {
                if (vtep.getDpnId().equals(dpid)) {
                    vtepFound = true;
                    oldVtep = vtep;
                    break;
                }
            }
            if (!vtepFound) {
                addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
            } else {
                // vtep is found, update it with tep-ip
                vtepList.remove(oldVtep);
                addVtepIntoTepsNotHosted(vtepList, tepIpAddress, tzName, dpid, ofTunnel, wrTx);
            }
        }
    }
}
Also used : TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)

Example 35 with Transport

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev201015.netconf.callhome.server.allowed.devices.device.Transport in project genius by opendaylight.

the class OvsdbTepAddConfigHelper method addVtepIntoTepsNotHosted.

/**
 * Adds the TEP into Unknown Vtep list under the transport zone in the TepsNotHosted list
 * from ITM operational Datastore by merge operation with write transaction.
 *
 * @param updatedVtepList updated UnknownVteps list object which will have new TEP for addition
 *                        into TepsNotHosted
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param tzName transport zone name in string
 * @param dpid bridge datapath ID in BigInteger
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param wrTx WriteTransaction object
 */
protected static void addVtepIntoTepsNotHosted(List<UnknownVteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid, boolean ofTunnel, WriteTransaction wrTx) {
    // Create TZ node path
    InstanceIdentifier<TepsInNotHostedTransportZone> tepsInNotHostedTransportZoneIid = InstanceIdentifier.builder(NotHostedTransportZones.class).child(TepsInNotHostedTransportZone.class, new TepsInNotHostedTransportZoneKey(tzName)).build();
    // create vtep
    UnknownVtepsKey vtepkey = new UnknownVtepsKey(dpid);
    UnknownVteps vtepObj = new UnknownVtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).setKey(vtepkey).setOfTunnel(ofTunnel).build();
    // Add vtep obtained into unknown TZ tep list
    updatedVtepList.add(vtepObj);
    // create unknown TZ node with updated vtep list
    TepsInNotHostedTransportZone updatedTzone = new TepsInNotHostedTransportZoneBuilder().setKey(new TepsInNotHostedTransportZoneKey(tzName)).setZoneName(tzName).setUnknownVteps(updatedVtepList).build();
    LOG.trace("Adding TEP  (DPID: {}, TEP IP: {}, of-tunnel: {}) into unhosted TZ: {}" + "inside ITM Oper DS.", dpid, tepIpAddress, ofTunnel, tzName);
    // Update TZ in Oper DS.
    wrTx.merge(LogicalDatastoreType.OPERATIONAL, tepsInNotHostedTransportZoneIid, updatedTzone, true);
}
Also used : TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TepsInNotHostedTransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone) UnknownVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder) UnknownVteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) TepsInNotHostedTransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneBuilder)

Aggregations

ArrayList (java.util.ArrayList)24 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)24 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)24 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)21 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)20 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps)17 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)16 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)16 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)15 List (java.util.List)13 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey)13 DataBroker (org.opendaylight.mdsal.binding.api.DataBroker)12 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)12 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)12 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)11 Map (java.util.Map)11 Test (org.junit.Test)11 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)11 Optional (java.util.Optional)10 Inject (javax.inject.Inject)10