Search in sources :

Example 16 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project genius by opendaylight.

the class RemoveExternalEndpoint method doExecute.

@SuppressWarnings({ "checkstyle:IllegalCatch", "checkstyle:RegexpSinglelineJava" })
@Override
protected Object doExecute() {
    try {
        LOG.debug("RemoveExternalEndpoint: destinationIP {} with tunnelType {}", destinationIp, tunnelType);
        Class<? extends TunnelTypeBase> tunType;
        if (tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_VXLAN)) {
            tunType = TunnelTypeVxlan.class;
        } else if (tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_GRE)) {
            tunType = TunnelTypeGre.class;
        } else if (tunnelType.equalsIgnoreCase(ITMConstants.TUNNEL_TYPE_MPLSoGRE)) {
            tunType = TunnelTypeMplsOverGre.class;
        } else {
            System.out.println("Invalid tunnel-type " + tunnelType);
            return null;
        }
        if (!itmProvider.validateIP(destinationIp)) {
            System.out.println("Invalid IpAddress " + destinationIp);
            return null;
        }
        IpAddress dcgwIPAddr = IpAddressBuilder.getDefaultInstance(destinationIp);
        itmProvider.remExternalEndpoint(tunType, dcgwIPAddr);
    } catch (IllegalArgumentException e) {
        System.out.println(e.getMessage());
    } catch (Exception e) {
        System.out.println(e.getMessage());
        LOG.error("Exception occurred during execution of command \"tep:configure-tunnelType\": ", e);
    }
    return null;
}
Also used : TunnelTypeGre(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre) IpAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)

Example 17 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase 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 18 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project netvirt by opendaylight.

the class ElanItmUtils method getExternalTunnelInterfaceName.

/**
 * Gets the external tunnel interface name.
 *
 * @param sourceNode
 *            the source node
 * @param dstNode
 *            the dst node
 * @return the external tunnel interface name
 */
public String getExternalTunnelInterfaceName(String sourceNode, String dstNode) {
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    String tunnelInterfaceName = null;
    try {
        Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(new GetExternalTunnelInterfaceNameInputBuilder().setSourceNode(sourceNode).setDestinationNode(dstNode).setTunnelType(tunType).build());
        RpcResult<GetExternalTunnelInterfaceNameOutput> rpcResult = output.get();
        if (rpcResult.isSuccessful()) {
            tunnelInterfaceName = rpcResult.getResult().getInterfaceName();
            LOG.debug("Tunnel interface name: {} for sourceNode: {} and dstNode: {}", tunnelInterfaceName, sourceNode, dstNode);
        } else {
            LOG.warn("RPC call to ITM.GetExternalTunnelInterfaceName failed with error: {}", rpcResult.getErrors());
        }
    } catch (NullPointerException | InterruptedException | ExecutionException e) {
        LOG.error("Failed to get external tunnel interface name for sourceNode: {} and dstNode: {}", sourceNode, dstNode, e);
    }
    return tunnelInterfaceName;
}
Also used : GetExternalTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameOutput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ExecutionException(java.util.concurrent.ExecutionException) GetExternalTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInputBuilder)

Example 19 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project netvirt by opendaylight.

the class AbstractSnatService method getTunnelInterfaceName.

protected String getTunnelInterfaceName(BigInteger srcDpId, BigInteger dstDpId) {
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    RpcResult<GetTunnelInterfaceNameOutput> rpcResult;
    try {
        Future<RpcResult<GetTunnelInterfaceNameOutput>> result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder().setSourceDpid(srcDpId).setDestinationDpid(dstDpId).setTunnelType(tunType).build());
        rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            tunType = TunnelTypeGre.class;
            result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder().setSourceDpid(srcDpId).setDestinationDpid(dstDpId).setTunnelType(tunType).build());
            rpcResult = result.get();
            if (!rpcResult.isSuccessful()) {
                LOG.warn("getTunnelInterfaceName : RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
            } else {
                return rpcResult.getResult().getInterfaceName();
            }
            LOG.warn("getTunnelInterfaceName : RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
        } else {
            return rpcResult.getResult().getInterfaceName();
        }
    } catch (InterruptedException | ExecutionException | NullPointerException e) {
        LOG.error("getTunnelInterfaceName : Exception when getting tunnel interface Id for tunnel " + "between {} and {}", srcDpId, dstDpId);
    }
    return null;
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ExecutionException(java.util.concurrent.ExecutionException) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder)

Example 20 with TunnelTypeBase

use of org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeBase in project netvirt by opendaylight.

the class NaptSwitchHA method getTunnelInterfaceName.

protected String getTunnelInterfaceName(BigInteger srcDpId, BigInteger dstDpId) {
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    RpcResult<GetTunnelInterfaceNameOutput> rpcResult;
    try {
        Future<RpcResult<GetTunnelInterfaceNameOutput>> result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder().setSourceDpid(srcDpId).setDestinationDpid(dstDpId).setTunnelType(tunType).build());
        rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            tunType = TunnelTypeGre.class;
            result = itmManager.getTunnelInterfaceName(new GetTunnelInterfaceNameInputBuilder().setSourceDpid(srcDpId).setDestinationDpid(dstDpId).setTunnelType(tunType).build());
            rpcResult = result.get();
            if (!rpcResult.isSuccessful()) {
                LOG.warn("getTunnelInterfaceName : RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
            } else {
                return rpcResult.getResult().getInterfaceName();
            }
            LOG.warn("getTunnelInterfaceName : RPC Call to getTunnelInterfaceId returned with Errors {}", rpcResult.getErrors());
        } else {
            return rpcResult.getResult().getInterfaceName();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getTunnelInterfaceName :Exception when getting tunnel interface Id for tunnel between {} and {}", srcDpId, dstDpId, e);
    }
    LOG.error("getTunnelInterfaceName : Tunnel missing between dpn {}:{}", srcDpId, dstDpId);
    return null;
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetTunnelInterfaceNameOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput) TunnelTypeVxlan(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan) ExecutionException(java.util.concurrent.ExecutionException) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder)

Aggregations

IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)13 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)9 ExecutionException (java.util.concurrent.ExecutionException)8 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)8 ArrayList (java.util.ArrayList)7 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)7 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)6 BigInteger (java.math.BigInteger)5 DPNTEPsInfo (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.DPNTEPsInfo)5 ExternalTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnel)5 GetTunnelInterfaceNameInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder)5 GetTunnelInterfaceNameOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameOutput)5 IpPrefix (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpPrefix)4 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)4 TunnelTypeGre (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeGre)4 ExternalTunnelList (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.ExternalTunnelList)4 TunnelEndPoints (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.dpn.endpoints.dpn.teps.info.TunnelEndPoints)4 ExternalTunnelKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.op.rev160406.external.tunnel.list.ExternalTunnelKey)4 List (java.util.List)3 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)3