Search in sources :

Example 36 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 addVtepInITMConfigDS.

/**
 * Adds the TEP into Vtep list in the subnet list in the transport zone list
 * from ITM configuration Datastore by merge operation with write transaction.
 *
 * @param subnetList subnets list object
 * @param subnetMaskObj subnet mask in IpPrefix object
 * @param updatedVtepList updated Vteps list object which will have new TEP for addition
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param tzName transport zone name in string
 * @param dpid bridge datapath ID in BigInteger
 * @param portName port name as a part of VtepsKey
 * @param ofTunnel boolean flag for TEP to enable/disable of-tunnel feature on it
 * @param wrTx WriteTransaction object
 */
public static void addVtepInITMConfigDS(List<Subnets> subnetList, IpPrefix subnetMaskObj, List<Vteps> updatedVtepList, IpAddress tepIpAddress, String tzName, BigInteger dpid, String portName, boolean ofTunnel, WriteTransaction wrTx) {
    // Create TZ node path
    InstanceIdentifier<TransportZone> tranzportZonePath = InstanceIdentifier.builder(TransportZones.class).child(TransportZone.class, new TransportZoneKey(tzName)).build();
    // when VTEP is moved from TepsNotHosted list to TZ configured from Northbound.
    if (dpid.compareTo(BigInteger.ZERO) > 0) {
        // create vtep
        VtepsKey vtepkey = new VtepsKey(dpid, portName);
        Vteps vtepObj = new VtepsBuilder().setDpnId(dpid).setIpAddress(tepIpAddress).setKey(vtepkey).setPortname(portName).setOptionOfTunnel(ofTunnel).build();
        // Add vtep obtained from bridge into list
        updatedVtepList.add(vtepObj);
        LOG.trace("Adding TEP (TZ: {} Subnet: {} TEP IP: {} DPID: {}, of-tunnel: {}) in ITM Config DS.", tzName, subnetMaskObj, tepIpAddress, dpid, ofTunnel);
    } else {
        // corresponding TZ is configured from northbound.
        for (Vteps vtep : updatedVtepList) {
            LOG.trace("Moving TEP (TEP IP: {} DPID: {}, of-tunnel: {})" + "from not-hosted-transport-zone {} into  ITM Config DS.", vtep.getIpAddress(), vtep.getDpnId(), ofTunnel, tzName);
        }
    }
    // Create subnet object
    SubnetsKey subKey = new SubnetsKey(subnetMaskObj);
    IpAddress gatewayIP = IpAddressBuilder.getDefaultInstance(ITMConstants.DUMMY_GATEWAY_IP);
    int vlanID = ITMConstants.DUMMY_VLANID;
    Subnets subnet = new SubnetsBuilder().setGatewayIp(gatewayIP).setKey(subKey).setPrefix(subnetMaskObj).setVlanId(vlanID).setVteps(updatedVtepList).build();
    // add subnet into subnet list
    subnetList.add(subnet);
    // create TZ node with updated subnet having new vtep
    TransportZone updatedTzone = new TransportZoneBuilder().setKey(new TransportZoneKey(tzName)).setSubnets(subnetList).setZoneName(tzName).build();
    // Update TZ in Config DS to add vtep in TZ
    wrTx.merge(LogicalDatastoreType.CONFIGURATION, tranzportZonePath, updatedTzone, true);
}
Also used : SubnetsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsKey) Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) VtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.VtepsKey) UnknownVtepsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey) SubnetsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.SubnetsBuilder) 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) TransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneBuilder) TepsInNotHostedTransportZoneBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneBuilder) 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.subnets.VtepsBuilder) UnknownVtepsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsBuilder) 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) 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)

Example 37 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 TransportZoneListener method update.

@Override
public void update(@Nonnull TransportZone originalTransportZone, @Nonnull TransportZone updatedTransportZone) {
    LOG.debug("Received Transport Zone Update Event: Old - {}, Updated - {}", originalTransportZone, updatedTransportZone);
    List<DPNTEPsInfo> oldDpnTepsList = createDPNTepInfo(originalTransportZone);
    List<DPNTEPsInfo> newDpnTepsList = createDPNTepInfo(updatedTransportZone);
    List<DPNTEPsInfo> oldDpnTepsListcopy = new ArrayList<>();
    oldDpnTepsListcopy.addAll(oldDpnTepsList);
    LOG.trace("oldcopy0 {}", oldDpnTepsListcopy);
    List<DPNTEPsInfo> newDpnTepsListcopy = new ArrayList<>();
    newDpnTepsListcopy.addAll(newDpnTepsList);
    LOG.trace("newcopy0 {}", newDpnTepsListcopy);
    oldDpnTepsList.removeAll(newDpnTepsListcopy);
    newDpnTepsList.removeAll(oldDpnTepsListcopy);
    LOG.trace("oldDpnTepsList {}", oldDpnTepsList);
    LOG.trace("newDpnTepsList {}", newDpnTepsList);
    LOG.trace("oldcopy {}", oldDpnTepsListcopy);
    LOG.trace("newcopy {}", newDpnTepsListcopy);
    LOG.trace("oldcopy Size {}", oldDpnTepsList.size());
    LOG.trace("newcopy Size {}", newDpnTepsList.size());
    if (!newDpnTepsList.isEmpty()) {
        LOG.trace("Adding TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(newDpnTepsList, Collections.emptyList(), dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
    }
    if (!oldDpnTepsList.isEmpty()) {
        LOG.trace("Removing TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(oldDpnTepsList, Collections.emptyList(), originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
    }
    List<HwVtep> oldHwList = createhWVteps(originalTransportZone);
    List<HwVtep> newHwList = createhWVteps(updatedTransportZone);
    List<HwVtep> oldHwListcopy = new ArrayList<>();
    oldHwListcopy.addAll(oldHwList);
    LOG.trace("oldHwListcopy0 {}", oldHwListcopy);
    List<HwVtep> newHwListcopy = new ArrayList<>();
    newHwListcopy.addAll(newHwList);
    LOG.trace("newHwListcopy0 {}", newHwListcopy);
    oldHwList.removeAll(newHwListcopy);
    newHwList.removeAll(oldHwListcopy);
    LOG.trace("oldHwList {}", oldHwList);
    LOG.trace("newHwList {}", newHwList);
    LOG.trace("oldHwListcopy {}", oldHwListcopy);
    LOG.trace("newHwListcopy {}", newHwListcopy);
    if (!newHwList.isEmpty()) {
        LOG.trace("Adding HW TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepAddWorker(Collections.emptyList(), newHwList, dataBroker, mdsalManager, itmConfig, itmInternalTunnelAddWorker, externalTunnelAddWorker, dpnTEPsInfoCache));
    }
    if (!oldHwList.isEmpty()) {
        LOG.trace("Removing HW TEPs ");
        jobCoordinator.enqueueJob(updatedTransportZone.getZoneName(), new ItmTepRemoveWorker(Collections.emptyList(), oldHwList, originalTransportZone, dataBroker, mdsalManager, itmInternalTunnelDeleteWorker, dpnTEPsInfoCache));
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) ArrayList(java.util.ArrayList) HwVtep(org.opendaylight.genius.itm.confighelpers.HwVtep) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 38 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 VtepConfigSchemaListener method add.

@Override
public void add(@Nonnull VtepConfigSchema vtepConfigSchema) {
    // Construct the transport zones from the provided schemas and push it to config DS
    LOG.trace("Add VtepConfigSchema: {}", vtepConfigSchema);
    VtepConfigSchema validatedSchema = ItmUtils.validateForAddVtepConfigSchema(vtepConfigSchema, getAllVtepConfigSchemas());
    VtepIpPool vtepIpPool = processAvailableIps(validatedSchema);
    addVteps(validatedSchema, vtepIpPool);
}
Also used : VtepConfigSchema(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.config.schemas.VtepConfigSchema) VtepIpPool(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.config.rev160406.vtep.ip.pools.VtepIpPool)

Example 39 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 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 40 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 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)

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