Search in sources :

Example 1 with VtepsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.

the class VtepConfigSchemaListener method deleteVteps.

/**
 * Delete vteps.
 *
 * @param schema
 *            the schema
 * @param lstDpnIdsToBeDeleted
 *            the dpn ids list to be deleted
 */
private void deleteVteps(VtepConfigSchema schema, List<BigInteger> lstDpnIdsToBeDeleted) {
    TepCommandHelper tepCommandHelper = new TepCommandHelper(this.dataBroker, itmConfig);
    List<IpAddress> freeIps = new ArrayList<>();
    String subnetCidr = ItmUtils.getSubnetCidrAsString(schema.getSubnet());
    String gatewayIp = handleGatewayIp(schema.getGatewayIp());
    for (BigInteger dpnId : lstDpnIdsToBeDeleted) {
        VtepsKey vtepkey = new VtepsKey(dpnId, schema.getPortName());
        InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(schema.getTransportZoneName())).child(Subnets.class, new SubnetsKey(schema.getSubnet())).child(Vteps.class, vtepkey).build();
        Vteps vtep;
        Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
        if (vtepOptional.isPresent()) {
            vtep = vtepOptional.get();
        } else {
            LOG.warn("VTEP doesn't exist for DPN [{}] and port [{}].", dpnId, schema.getPortName());
            continue;
        }
        IpAddress ipAddress = vtep.getIpAddress();
        try {
            tepCommandHelper.deleteVtep(dpnId, vtep.getPortname(), schema.getVlanId(), String.valueOf(ipAddress.getValue()), subnetCidr, gatewayIp, schema.getTransportZoneName(), null);
        } catch (TepException e) {
            LOG.error("delete Vtep Failed", e);
        }
        freeIps.add(ipAddress);
    }
    LOG.debug("Delete OnCommit in NewlyAddedDpns");
    tepCommandHelper.deleteOnCommit();
    deAllocateIpAddresses(freeIps, subnetCidr);
}
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) ArrayList(java.util.ArrayList) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) TepCommandHelper(org.opendaylight.genius.itm.cli.TepCommandHelper) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) 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) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 2 with VtepsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.

the class TepCommandHelper method deleteVtep.

@SuppressWarnings("checkstyle:IllegalCatch")
public void deleteVtep(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
    final VtepsKey vtepkey = new VtepsKey(dpnId);
    IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    Vteps vtepCli;
    InstanceIdentifier<Vteps> vpath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(transportZone)).child(Vteps.class, vtepkey).build();
    // check if present in tzones and delete from cache
    boolean existsInCache = isInCache(dpnId, ipAddress, transportZone);
    if (!existsInCache) {
        Optional<Vteps> vtepOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, vpath, dataBroker);
        if (vtepOptional.isPresent()) {
            vtepCli = vtepOptional.get();
            if (Objects.equals(vtepCli.getIpAddress(), ipAddressObj)) {
                vtepDelCommitList.add(vtepCli);
            }
        } else {
            handleError("Vtep Doesnt exist");
        }
    }
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) TransportZones(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Example 3 with VtepsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.

the class TepCommandHelper method createLocalCache.

@SuppressWarnings("checkstyle:IllegalCatch")
public void createLocalCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
    CHECK.incrementAndGet();
    IpAddress ipAddressObj;
    final VtepsKey vtepkey = new VtepsKey(dpnId);
    ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    if (checkTepPerTzPerDpn(transportZone, dpnId)) {
        handleError("Only one end point per transport Zone per Dpn is allowed");
        return;
    }
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
    if (transportZonesHashMap.containsKey(transportZone)) {
        List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
        if (!vtepListTemp.contains(vtepCli)) {
            vtepListTemp.add(vtepCli);
        }
    } else {
        List<Vteps> vtepListTemp = new ArrayList<>();
        vtepListTemp.add(vtepCli);
        transportZonesHashMap.put(transportZone, vtepListTemp);
    }
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) ArrayList(java.util.ArrayList) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)

Example 4 with VtepsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.

the class TepCommandHelper method isInCache.

// deletes from ADD-cache if it exists.
public boolean isInCache(Uint64 dpnId, String ipAddress, String transportZone) throws TepException {
    boolean exists = false;
    final VtepsKey vtepkey = new VtepsKey(dpnId);
    IpAddress ipAddressObj = IpAddressBuilder.getDefaultInstance(ipAddress);
    Vteps vtepCli = new VtepsBuilder().setDpnId(dpnId).setIpAddress(ipAddressObj).withKey(vtepkey).build();
    if (transportZonesHashMap.containsKey(transportZone)) {
        List<Vteps> vtepListTemp = transportZonesHashMap.get(transportZone);
        if (vtepListTemp.contains(vtepCli)) {
            // return true if tzones has vtep
            exists = true;
            vtepListTemp.remove(vtepCli);
            if (vtepListTemp.size() == 0) {
                transportZonesHashMap.remove(transportZone);
            }
        } else {
            handleError("Vtep has not been configured");
        }
    }
    return exists;
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress) VtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)

Example 5 with VtepsKey

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey in project genius by opendaylight.

the class ItmUtils method getDpIdFromTransportzone.

public static List<Uint64> getDpIdFromTransportzone(DataBroker dataBroker, String tzone) {
    List<Uint64> listOfDpId = new ArrayList<>();
    InstanceIdentifier<TransportZone> path = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzone)).build();
    Optional<TransportZone> transportZoneOptional = ItmUtils.read(LogicalDatastoreType.CONFIGURATION, path, dataBroker);
    if (transportZoneOptional.isPresent()) {
        TransportZone transportZone = transportZoneOptional.get();
        if (transportZone.getVteps() != null && !transportZone.getVteps().isEmpty()) {
            @Nullable Map<VtepsKey, Vteps> vtepsList = transportZone.getVteps();
            if (vtepsList != null && !vtepsList.isEmpty()) {
                for (Vteps vtep : vtepsList.values()) {
                    listOfDpId.add(vtep.getDpnId());
                }
            }
        }
    }
    return listOfDpId;
}
Also used : VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey) ArrayList(java.util.ArrayList) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps) 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) Nullable(org.eclipse.jdt.annotation.Nullable) Uint64(org.opendaylight.yangtools.yang.common.Uint64) TepsInNotHostedTransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey) TransportZoneKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)

Aggregations

TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)18 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsKey)17 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Vteps)15 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)12 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)11 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)11 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)11 ArrayList (java.util.ArrayList)9 VtepsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.VtepsBuilder)9 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)8 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)8 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)8 VtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey)8 TransportZoneBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder)7 SubnetsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey)7 List (java.util.List)6 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)6 DeviceVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.DeviceVtepsKey)6 Uint64 (org.opendaylight.yangtools.yang.common.Uint64)6 Nullable (org.eclipse.jdt.annotation.Nullable)5