Search in sources :

Example 26 with Transport

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.

the class ItmTepAutoConfigTest method tepUpdateForTzTest.

@Test
public void tepUpdateForTzTest() throws Exception {
    String tepIp = ItmTestConstants.DEF_TZ_TEP_IP;
    // create Network topology node with tep-ip set into ExternalIds list
    // OvsdbNodeListener would be automatically listen on Node to add TEP
    ConnectionInfo connInfo = OvsdbTestUtil.getConnectionInfo(ItmTestConstants.OVSDB_CONN_PORT, ItmTestConstants.LOCALHOST_IP);
    CheckedFuture<Void, TransactionCommitFailedException> future = OvsdbTestUtil.createNode(connInfo, tepIp, ITMConstants.DEFAULT_TRANSPORT_ZONE, dataBroker);
    future.get();
    // add bridge into node
    future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.DEF_BR_NAME, ItmTestConstants.DEF_BR_DPID, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    // iid for default-TZ
    InstanceIdentifier<TransportZone> defTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ITMConstants.DEFAULT_TRANSPORT_ZONE);
    Assert.assertNotNull(defTzonePath);
    // check TEP is added into default-TZ
    assertEqualBeans(ExpectedDefTransportZoneObjects.newDefTzWithTep(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, defTzonePath).checkedGet().get());
    IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
    InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ITMConstants.DEFAULT_TRANSPORT_ZONE, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
    Assert.assertNotNull(oldVTepPath);
    // create Transport-zone TZA
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
    // iid for TZA configured from NB
    InstanceIdentifier<TransportZone> tzaTzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
    Assert.assertNotNull(tzaTzonePath);
    // update OVSDB node with tzname=TZA in ExternalIds list
    String tzName = ItmTestConstants.TZ_NAME;
    OvsdbTestUtil.updateNode(connInfo, tepIp, tzName, null, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    // check old TEP which was in default-TZ is deleted
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
    // check TEP is updated and now it is added into TZA transport-zone when tzname is updated
    // to TZA from southbound
    assertEqualBeans(ExpectedTransportZoneObjects.updatedTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzaTzonePath).checkedGet().get());
}
Also used : IpPrefix(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix) TransactionCommitFailedException(org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException) Vteps(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps) ConnectionInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.ovsdb.node.attributes.ConnectionInfo) 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) Test(org.junit.Test)

Example 27 with Transport

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.

the class ItmTepInstanceRecoveryHandler method recoverTep.

private void recoverTep(String entityId) throws InterruptedException {
    List<DPNTEPsInfo> tepsToRecover = new ArrayList<>();
    DPNTEPsInfo dpnTepsToRecover = extractDPNTepsInfo(entityId);
    if (dpnTepsToRecover == null) {
        LOG.error("Please Enter appropriate arguments for Tep Recovery.");
        return;
    } else {
        tepsToRecover.add(dpnTepsToRecover);
        // Delete the transportZone and re create it
        // Get the transport zone from the transport zone name
        TransportZone oldTz = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (oldTz != null) {
            ItmTepRemoveWorker tepRemoveWorker = new ItmTepRemoveWorker(tepsToRecover, null, oldTz, dataBroker, imdsalApiManager, itmInternalTunnelDeleteWorker, dpntePsInfoCache);
            LOG.trace("Deleting transportzone {}", tzName);
            jobCoordinator.enqueueJob(tzName, tepRemoveWorker);
            ItmTepAddWorker tepAddWorker = new ItmTepAddWorker(tepsToRecover, null, dataBroker, imdsalApiManager, itmConfig, itmInternalTunnelAddWorker, itmExternalTunnelAddWorker, dpntePsInfoCache);
            LOG.trace("Re-creating transportzone {}", tzName);
            jobCoordinator.enqueueJob(tzName, tepAddWorker);
        }
    }
}
Also used : ItmTepRemoveWorker(org.opendaylight.genius.itm.confighelpers.ItmTepRemoveWorker) ArrayList(java.util.ArrayList) DPNTEPsInfo(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone) ItmTepAddWorker(org.opendaylight.genius.itm.confighelpers.ItmTepAddWorker)

Example 28 with Transport

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.

the class ItmTepInstanceRecoveryHandler method extractDPNTepsInfo.

private DPNTEPsInfo extractDPNTepsInfo(String entityId) {
    String[] params = entityId.split(":");
    if (params.length < 2) {
        LOG.error("Not enough arguments..Exiting...");
        return null;
    } else if (params.length > 2) {
        LOG.info("Ignoring extra parameter and proceeding...");
    }
    // ToDo:- Need to add more validations
    this.tzName = params[0];
    String ipAddress = params[1];
    transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
    if (transportZone == null) {
        LOG.error("Transportzone name {} is not valid.", tzName);
        return null;
    }
    for (Subnets sub : transportZone.getSubnets()) {
        if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
            LOG.error("Transport Zone {} subnet {} has no vteps", transportZone.getZoneName(), sub.getPrefix());
        }
        for (Vteps vtep : sub.getVteps()) {
            if (ipAddress.equals(String.valueOf(vtep.getIpAddress().getValue()))) {
                List<TzMembership> zones = ItmUtils.createTransportZoneMembership(tzName);
                LOG.trace("Transportzone {} found match for tep {} to be recovered", transportZone.getZoneName(), ipAddress);
                // OfTunnels is false byDefault
                TunnelEndPoints tunnelEndPoints = ItmUtils.createTunnelEndPoints(vtep.getDpnId(), IpAddressBuilder.getDefaultInstance(ipAddress), vtep.getPortname(), false, sub.getVlanId(), sub.getPrefix(), sub.getGatewayIp(), zones, transportZone.getTunnelType(), itmConfig.getDefaultTunnelTos());
                List<TunnelEndPoints> teps = new ArrayList<>();
                teps.add(tunnelEndPoints);
                return ItmUtils.createDPNTepInfo(vtep.getDpnId(), teps);
            }
        }
    }
    return null;
}
Also used : 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) 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)

Example 29 with Transport

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.

the class ItmManagerRpcService method getTunnelEndPointByDpnIdFromTranPortZone.

private Map<BigInteger, ComputesBuilder> getTunnelEndPointByDpnIdFromTranPortZone(Collection<BigInteger> dpnIds) throws ReadFailedException {
    TransportZones transportZones = singleTransactionDataBroker.syncRead(LogicalDatastoreType.CONFIGURATION, InstanceIdentifier.builder(TransportZones.class).build());
    if (transportZones.getTransportZone() == null || transportZones.getTransportZone().isEmpty()) {
        throw new IllegalStateException("Failed to find transport zones in config datastore");
    }
    Map<BigInteger, ComputesBuilder> result = new HashMap<>();
    for (TransportZone transportZone : transportZones.getTransportZone()) {
        if (transportZone.getSubnets() == null || transportZone.getSubnets().isEmpty()) {
            LOG.debug("Transport Zone {} has no subnets", transportZone.getZoneName());
            continue;
        }
        for (Subnets sub : transportZone.getSubnets()) {
            if (sub.getVteps() == null || sub.getVteps().isEmpty()) {
                LOG.debug("Transport Zone {} subnet {} has no vteps configured", transportZone.getZoneName(), sub.getPrefix());
                continue;
            }
            for (Vteps vtep : sub.getVteps()) {
                if (dpnIds.contains(vtep.getDpnId())) {
                    result.putIfAbsent(vtep.getDpnId(), new ComputesBuilder().setZoneName(transportZone.getZoneName()).setPrefix(sub.getPrefix()).setDpnId(vtep.getDpnId()).setPortName(vtep.getPortname()).setNodeId(getNodeId(vtep.getDpnId())).setTepIp(Collections.singletonList(vtep.getIpAddress())));
                }
            }
        }
    }
    for (BigInteger dpnId : dpnIds) {
        if (!result.containsKey(dpnId)) {
            throw new IllegalStateException("Failed to find dpn id " + dpnId + " in transport zone");
        }
    }
    return result;
}
Also used : Subnets(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets) HashMap(java.util.HashMap) ComputesBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.get.dpn.info.output.ComputesBuilder) 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) BigInteger(java.math.BigInteger) 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 30 with Transport

use of org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.rev151009.bgp.neighbor.group.Transport in project genius by opendaylight.

the class OvsdbTepRemoveConfigHelper method removeTepReceivedFromOvsdb.

/**
 * Removes the TEP from ITM configuration/operational Datastore in one of the following cases.
 * 1) default transport zone
 * 2) Configured transport zone
 * 3) Unhosted transport zone
 * Function checks for above three cases and calls other sub-function to remove the TEP
 *
 * @param tepIp TEP-IP address in string
 * @param strDpnId bridge datapath ID in string
 * @param tzName transport zone name in string
 * @param dataBroker data broker handle to perform operations on config/operational datastore
 * @param wrTx WriteTransaction object
 */
public static void removeTepReceivedFromOvsdb(String tepIp, String strDpnId, String tzName, DataBroker dataBroker, WriteTransaction wrTx) {
    BigInteger dpnId = BigInteger.valueOf(0);
    LOG.trace("Remove TEP: TEP-IP: {}, TZ name: {}, DPID: {}", tepIp, tzName, strDpnId);
    if (strDpnId != null && !strDpnId.isEmpty()) {
        dpnId = MDSALUtil.getDpnId(strDpnId);
    }
    // Get tep IP
    IpAddress tepIpAddress = IpAddressBuilder.getDefaultInstance(tepIp);
    TransportZone transportZone = null;
    // Case: TZ name is not given from OVS's other_config parameters.
    if (tzName == null) {
        tzName = ITMConstants.DEFAULT_TRANSPORT_ZONE;
        // add TEP into default-TZ
        transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (transportZone == null) {
            LOG.error("Error: default-transport-zone is not yet created.");
            return;
        }
        LOG.trace("Remove TEP from default-transport-zone.");
    } else {
        // Case: Add TEP into corresponding TZ created from Northbound.
        transportZone = ItmUtils.getTransportZoneFromConfigDS(tzName, dataBroker);
        if (transportZone == null) {
            // Case: TZ is not configured from Northbound, then add TEP into
            // "teps-in-not-hosted-transport-zone"
            LOG.trace("Removing TEP from teps-in-not-hosted-transport-zone list.");
            removeUnknownTzTepFromTepsNotHosted(tzName, tepIpAddress, dpnId, dataBroker, wrTx);
            return;
        } else {
            LOG.trace("Remove TEP from transport-zone already configured by Northbound.");
        }
    }
    // Remove TEP from (default transport-zone) OR (transport-zone already configured by Northbound)
    // Get subnet list of corresponding TZ created from Northbound.
    List<Subnets> subnetList = transportZone.getSubnets();
    if (subnetList == null || subnetList.isEmpty()) {
        LOG.trace("No subnet list in transport-zone. Nothing to do.");
    } else {
        IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
        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
            LOG.trace("No vtep list in subnet list of transport-zone. Nothing to do.");
        } 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;
                    break;
                }
            }
            if (vtepFound) {
                // vtep is found, update it with tep-ip
                LOG.trace("Remove TEP from vtep list in subnet list of transport-zone.");
                dpnId = oldVtep.getDpnId();
                String portName = oldVtep.getPortname();
                removeVtepFromTZConfig(subnetMaskObj, tzName, dpnId, portName, wrTx);
            } else {
                LOG.trace("TEP is not found in the vtep list in subnet list of transport-zone. Nothing to do.");
            }
        }
    }
}
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) 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)

Aggregations

TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)16 Vteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.Vteps)14 ArrayList (java.util.ArrayList)11 TepsInNotHostedTransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZone)11 Subnets (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.Subnets)10 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)9 UnknownVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVteps)9 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)8 BigInteger (java.math.BigInteger)7 Test (org.junit.Test)7 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)5 TepsInNotHostedTransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.TepsInNotHostedTransportZoneKey)5 HashMap (java.util.HashMap)4 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)4 TransactionCommitFailedException (org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException)4 HwVtep (org.opendaylight.genius.itm.confighelpers.HwVtep)4 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)4 UnknownVtepsKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.not.hosted.transport.zones.tepsinnothostedtransportzone.UnknownVtepsKey)4 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)4 DeviceVteps (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.transport.zone.subnets.DeviceVteps)4