Search in sources :

Example 11 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 tepUpdateForBrNameTest.

@Test
public void tepUpdateForBrNameTest() throws Exception {
    // create Transport-zone in advance
    ItmUtils.syncWrite(LogicalDatastoreType.CONFIGURATION, tzonesPath, transportZones, dataBroker);
    String tepIp = ItmTestConstants.NB_TZ_TEP_IP;
    // prepare OVSDB 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, ItmTestConstants.TZ_NAME, 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);
    InstanceIdentifier<TransportZone> tzonePath = ItmTepAutoConfigTestUtil.getTzIid(ItmTestConstants.TZ_NAME);
    Assert.assertNotNull(tzonePath);
    // check TEP is added into TZ
    assertEqualBeans(ExpectedTransportZoneObjects.newTransportZone(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, tzonePath).checkedGet().get());
    IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
    InstanceIdentifier<Vteps> oldVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_DEF_BR_DPID, ITMConstants.DUMMY_PORT);
    Assert.assertNotNull(oldVTepPath);
    // add new bridge br2
    future = OvsdbTestUtil.addBridgeIntoNode(connInfo, ItmTestConstants.BR2_NAME, ItmTestConstants.BR2_DPID, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    // update OVSDB node with br-name=br2 in ExternalIds column
    String brName = ItmTestConstants.BR2_NAME;
    future = OvsdbTestUtil.updateNode(connInfo, ItmTestConstants.NB_TZ_TEP_IP, ItmTestConstants.TZ_NAME, brName, dataBroker);
    future.get();
    // wait for OvsdbNodeListener to perform config DS update through transaction
    Thread.sleep(1000);
    InstanceIdentifier<Vteps> newVTepPath = ItmTepAutoConfigTestUtil.getTepIid(subnetMaskObj, ItmTestConstants.TZ_NAME, ItmTestConstants.INT_BR2_DPID, ITMConstants.DUMMY_PORT);
    Assert.assertNotNull(newVTepPath);
    // check old TEP having default-bridge-DPID is deleted
    Assert.assertEquals(Optional.absent(), dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, oldVTepPath).get());
    // check TEP is updated with dpnId of br2 when br-name is updated to br2 from southbound
    Assert.assertEquals(ItmTestConstants.INT_BR2_DPID, dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, newVTepPath).checkedGet().get().getDpnId());
}
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 12 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 removeUnknownTzTepFromTepsNotHosted.

/**
 * Removes the TEP from the not-hosted transport zone in the TepsNotHosted list
 * from ITM Operational Datastore.
 *
 * @param tzName transport zone name in string
 * @param tepIpAddress TEP IP address in IpAddress object
 * @param dpnId bridge datapath ID in BigInteger
 * @param dataBroker data broker handle to perform operations on operational datastore
 * @param wrTx WriteTransaction object
 */
public static void removeUnknownTzTepFromTepsNotHosted(String tzName, IpAddress tepIpAddress, BigInteger dpnId, 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. Nothing to do for TEP removal.", tzName);
        return;
    } else {
        vtepList = tepsInNotHostedTransportZone.getUnknownVteps();
        if (vtepList == null || vtepList.isEmpty()) {
            // case: vtep list does not exist or it has no elements
            LOG.trace("Remove TEP from unhosted TZ ({}) when no vtep-list in the TZ. Nothing to do.", tzName);
        } else {
            // case: vtep list has elements
            boolean vtepFound = false;
            UnknownVteps foundVtep = null;
            for (UnknownVteps vtep : vtepList) {
                if (vtep.getDpnId().equals(dpnId)) {
                    vtepFound = true;
                    foundVtep = vtep;
                    break;
                }
            }
            if (vtepFound) {
                // vtep is found, update it with tep-ip
                LOG.trace("Remove TEP with IP ({}) from unhosted TZ ({}) inside not-hosted-transport-zones list.", tepIpAddress, tzName);
                if (vtepList.size() == 1) {
                    removeTzFromTepsNotHosted(tzName, wrTx);
                } else {
                    removeVtepFromTepsNotHosted(tzName, dpnId, wrTx);
                }
                vtepList.remove(foundVtep);
            }
        }
    }
}
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 13 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 TepCommandHelper method showState.

@SuppressWarnings("checkstyle:RegexpSinglelineJava")
public void showState(Collection<StateTunnelList> tunnelLists, boolean tunnelMonitorEnabled, CommandSession session) throws TepException {
    if (tunnelLists == null || tunnelLists.isEmpty()) {
        handleError("No Internal Tunnels Exist", session);
        return;
    }
    if (!tunnelMonitorEnabled) {
        if (session != null) {
            session.getConsole().println("Tunnel Monitoring is Off");
        }
    }
    String displayFormat = "%-16s  %-16s  %-16s  %-16s  %-16s  %-10s  %-10s";
    System.out.println(String.format(displayFormat, "Tunnel Name", "Source-DPN", "Destination-DPN", "Source-IP", "Destination-IP", "Trunk-State", "Transport Type"));
    System.out.println("-----------------------------------------------------------------------------------------" + "--------------------------------------------");
    for (StateTunnelList tunnelInst : tunnelLists) {
        // Display only the internal tunnels
        if (tunnelInst.getDstInfo().getTepDeviceType().equals(TepTypeInternal.class)) {
            String tunnelInterfaceName = tunnelInst.getTunnelInterfaceName();
            LOG.trace("tunnelInterfaceName::: {}", tunnelInterfaceName);
            String tunnelState = ITMConstants.TUNNEL_STATE_UNKNOWN;
            if (tunnelInst.getOperState() == TunnelOperStatus.Up) {
                tunnelState = ITMConstants.TUNNEL_STATE_UP;
            } else if (tunnelInst.getOperState() == TunnelOperStatus.Down) {
                tunnelState = ITMConstants.TUNNEL_STATE_DOWN;
            }
            Class<? extends TunnelTypeBase> tunType = tunnelInst.getTransportType();
            String tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
            if (tunType.equals(TunnelTypeVxlan.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_VXLAN;
            } else if (tunType.equals(TunnelTypeGre.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_GRE;
            } else if (tunType.equals(TunnelTypeMplsOverGre.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_MPLSoGRE;
            } else if (tunType.equals(TunnelTypeLogicalGroup.class)) {
                tunnelType = ITMConstants.TUNNEL_TYPE_LOGICAL_GROUP_VXLAN;
            }
            System.out.println(String.format(displayFormat, tunnelInst.getTunnelInterfaceName(), tunnelInst.getSrcInfo().getTepDeviceId(), tunnelInst.getDstInfo().getTepDeviceId(), new String(tunnelInst.getSrcInfo().getTepIp().getValue()), new String(tunnelInst.getDstInfo().getTepIp().getValue()), tunnelState, tunnelType));
        }
    }
}
Also used : TunnelTypeLogicalGroup(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeLogicalGroup) TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList)

Example 14 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 TepCommandHelper method validateForDuplicates.

/**
 * Validate for duplicates.
 *
 * @param inputVtep
 *            the input vtep
 * @param transportZone
 *            the transport zone
 */
public void validateForDuplicates(Vteps inputVtep, String transportZone) {
    Map<String, TransportZone> allTransportZonesAsMap = getAllTransportZonesAsMap();
    boolean isConfiguredTepGreType = isGreTunnelType(transportZone, allTransportZonesAsMap);
    // Checking for duplicates in local cache
    for (Entry<String, Map<SubnetObject, List<Vteps>>> entry : transportZonesHashMap.entrySet()) {
        String tz = entry.getKey();
        boolean isGreType = isGreTunnelType(tz, allTransportZonesAsMap);
        Map<SubnetObject, List<Vteps>> subVtepMapTemp = entry.getValue();
        for (List<Vteps> vtepList : subVtepMapTemp.values()) {
            validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
        }
    }
    // Checking for duplicates in config DS
    for (TransportZone tz : allTransportZonesAsMap.values()) {
        boolean isGreType = false;
        if (tz.getTunnelType().equals(TunnelTypeGre.class)) {
            isGreType = true;
        }
        for (Subnets sub : ItmUtils.emptyIfNull(tz.getSubnets())) {
            List<Vteps> vtepList = sub.getVteps();
            validateForDuplicateAndSingleGreTep(inputVtep, isConfiguredTepGreType, isGreType, vtepList);
        }
    }
}
Also used : 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) StateTunnelList(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.tunnels_state.StateTunnelList) List(java.util.List) ArrayList(java.util.ArrayList) Map(java.util.Map) HashMap(java.util.HashMap) TransportZone(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)

Example 15 with Transport

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

the class MdsalLowLevelTestProvider method unsubscribeDtcl.

@Override
public Future<RpcResult<UnsubscribeDtclOutput>> unsubscribeDtcl() {
    LOG.debug("Received unsubscribe-dtcl");
    if (idIntsListener == null || dtclReg == null) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "Dtcl missing.", "No DataTreeChangeListener registered.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    try {
        idIntsListener.tryFinishProcessing().get(120, TimeUnit.SECONDS);
    } catch (InterruptedException | ExecutionException | TimeoutException e) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.RPC, "resource-denied-transport", "Unable to finish notification processing in 120 seconds.", "clustering-it", "clustering-it", e);
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    dtclReg.close();
    dtclReg = null;
    if (!idIntsListener.hasTriggered()) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "No notification received.", "id-ints listener has not received" + "any notifications.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
    final DOMDataReadOnlyTransaction rTx = domDataBroker.newReadOnlyTransaction();
    try {
        final Optional<NormalizedNode<?, ?>> readResult = rTx.read(CONTROLLER_CONFIG, WriteTransactionsHandler.ID_INT_YID).checkedGet();
        if (!readResult.isPresent()) {
            final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Final read empty.", "No data read from id-ints list.");
            return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
        }
        return Futures.immediateFuture(RpcResultBuilder.success(new UnsubscribeDtclOutputBuilder().setCopyMatches(idIntsListener.checkEqual(readResult.get()))).build());
    } catch (final ReadFailedException e) {
        final RpcError error = RpcResultBuilder.newError(ErrorType.APPLICATION, "Read failed.", "Final read from id-ints failed.");
        return Futures.immediateFuture(RpcResultBuilder.<UnsubscribeDtclOutput>failed().withRpcError(error).build());
    }
}
Also used : ReadFailedException(org.opendaylight.controller.md.sal.common.api.data.ReadFailedException) UnsubscribeDtclOutput(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutput) DOMDataReadOnlyTransaction(org.opendaylight.controller.md.sal.dom.api.DOMDataReadOnlyTransaction) RpcError(org.opendaylight.yangtools.yang.common.RpcError) ExecutionException(java.util.concurrent.ExecutionException) NormalizedNode(org.opendaylight.yangtools.yang.data.api.schema.NormalizedNode) UnsubscribeDtclOutputBuilder(org.opendaylight.yang.gen.v1.tag.opendaylight.org._2017.controller.yang.lowlevel.control.rev170215.UnsubscribeDtclOutputBuilder) TimeoutException(java.util.concurrent.TimeoutException)

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