Search in sources :

Example 1 with GetDpnInterfaceListInputBuilder

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

the class GeniusProvider method getInterfacesFromNode.

public List<Interfaces> getInterfacesFromNode(NodeId nodeId) {
    // getPortsOnBridge() only returns Tunnel ports, so instead using getDpnInterfaceList.
    GetDpnInterfaceListInputBuilder inputBuilder = new GetDpnInterfaceListInputBuilder();
    inputBuilder.setDpid(BigInteger.valueOf(Long.parseLong(nodeId.getValue().split(":")[1])));
    GetDpnInterfaceListInput input = inputBuilder.build();
    try {
        LOG.debug("getInterfacesFromNode: invoking rpc");
        RpcResult<GetDpnInterfaceListOutput> output = interfaceManagerRpcService.getDpnInterfaceList(input).get();
        if (!output.isSuccessful()) {
            LOG.error("getInterfacesFromNode({}) failed: {}", input, output);
            return Collections.emptyList();
        }
        LOG.debug("getInterfacesFromNode({}) succeeded: {}", input, output);
        return output.getResult().getInterfaces();
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("getInterfacesFromNode failed to retrieve target interface name: ", e);
    }
    return Collections.emptyList();
}
Also used : GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) GetDpnInterfaceListInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with GetDpnInterfaceListInputBuilder

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

the class InterfaceManagerConfigurationTest method testDpnToInterfaceList.

@Ignore
@Test
public void testDpnToInterfaceList() throws Exception {
    // Write into DpnToInterfaceList
    createDpnToInterface(DPN_ID_1, "23701c04-7e58-4c65-9425-78a80d49a218", L2vlan.class);
    // Test interface list fetching from dpnId
    GetDpnInterfaceListInput dpnInterfaceListInput = new GetDpnInterfaceListInputBuilder().setDpid(DPN_ID_1).build();
    Future<RpcResult<GetDpnInterfaceListOutput>> dpnInterfaceListOutput = odlInterfaceRpcService.getDpnInterfaceList(dpnInterfaceListInput);
    List<Interfaces> actualDpnInterfaceList = dpnInterfaceListOutput.get().getResult().getInterfaces();
    assertEqualBeans(ExpectedInterfaceListFromDpn.checkDpnToInterfaceList(), actualDpnInterfaceList.get(0));
}
Also used : Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetDpnInterfaceListInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 3 with GetDpnInterfaceListInputBuilder

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

the class TunnelInterfaceStateListener method handleTunnelEventForDPN.

// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void handleTunnelEventForDPN(StateTunnelList stateTunnelList, TunnelAction tunnelAction) {
    final BigInteger srcDpnId = new BigInteger(stateTunnelList.getSrcInfo().getTepDeviceId());
    final String srcTepIp = String.valueOf(stateTunnelList.getSrcInfo().getTepIp().getValue());
    String destTepIp = String.valueOf(stateTunnelList.getDstInfo().getTepIp().getValue());
    String rd;
    BigInteger remoteDpnId = null;
    boolean isTepDeletedOnDpn = false;
    LOG.info("handleTunnelEventForDPN: Handle tunnel event for srcDpn {} SrcTepIp {} DestTepIp {} ", srcDpnId, srcTepIp, destTepIp);
    int tunTypeVal = getTunnelType(stateTunnelList);
    LOG.trace("handleTunnelEventForDPN: tunTypeVal is {}", tunTypeVal);
    try {
        if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
            LOG.info("handleTunnelEventForDPN: Tunnel ADD event received for Dpn {} VTEP Ip {} destTepIp {}", srcDpnId, srcTepIp, destTepIp);
            if (isTunnelInLogicalGroup(stateTunnelList)) {
                return;
            }
        } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE) {
            LOG.info("handleTunnelEventForDPN: Tunnel DELETE event received for Dpn {} VTEP Ip {} DestTepIp {}", srcDpnId, srcTepIp, destTepIp);
            // When tunnel EP is deleted on a DPN , VPN gets two deletion event.
            // One for a DPN on which tunnel EP was deleted and another for other-end DPN.
            // Update the adj for the vpninterfaces for a DPN on which TEP is deleted.
            // Update the adj & VRF for the vpninterfaces for a DPN on which TEP is deleted.
            // Dont update the adj & VRF for vpninterfaces for a DPN on which TEP is not deleted.
            String endpointIpForDPN = null;
            try {
                endpointIpForDPN = InterfaceUtils.getEndpointIpAddressForDPN(dataBroker, srcDpnId);
            } catch (Exception e) {
                LOG.error("handleTunnelEventForDPN: Unable to resolve endpoint IP for srcDpn {}", srcDpnId);
                /* this dpn does not have the VTEP */
                endpointIpForDPN = null;
            }
            if (endpointIpForDPN == null) {
                LOG.info("handleTunnelEventForDPN: Tunnel TEP is deleted on Dpn {} VTEP Ip {} destTepIp {}", srcDpnId, srcTepIp, destTepIp);
                isTepDeletedOnDpn = true;
            }
        }
        // Get the list of VpnInterfaces from Intf Mgr for a SrcDPN on which TEP is added/deleted
        Future<RpcResult<GetDpnInterfaceListOutput>> result;
        List<Interfaces> srcDpninterfacelist = new ArrayList<>();
        List<Interfaces> destDpninterfacelist = new ArrayList<>();
        try {
            result = intfRpcService.getDpnInterfaceList(new GetDpnInterfaceListInputBuilder().setDpid(srcDpnId).build());
            RpcResult<GetDpnInterfaceListOutput> rpcResult = result.get();
            if (!rpcResult.isSuccessful()) {
                LOG.error("handleTunnelEventForDPN: RPC Call to GetDpnInterfaceList for srcDpnid {} srcTepIp {}" + " destTepIP {} returned with Errors {}", srcDpnId, srcTepIp, destTepIp, rpcResult.getErrors());
            } else {
                srcDpninterfacelist = rpcResult.getResult().getInterfaces();
            }
        } catch (Exception e) {
            LOG.error("handleTunnelEventForDPN: Exception when querying for GetDpnInterfaceList for srcDpnid {}" + " srcTepIp {} destTepIp {}", srcDpnId, srcTepIp, destTepIp, e);
        }
        // Get the list of VpnInterfaces from Intf Mgr for a destDPN only for internal tunnel.
        if (tunTypeVal == VpnConstants.ITMTunnelLocType.Internal.getValue()) {
            remoteDpnId = new BigInteger(stateTunnelList.getDstInfo().getTepDeviceId());
            try {
                result = intfRpcService.getDpnInterfaceList(new GetDpnInterfaceListInputBuilder().setDpid(remoteDpnId).build());
                RpcResult<GetDpnInterfaceListOutput> rpcResult = result.get();
                if (!rpcResult.isSuccessful()) {
                    LOG.error("handleTunnelEventForDPN: RPC Call to GetDpnInterfaceList for remoteDpnid {}" + " srcTepIP {} destTepIp {} returned with Errors {}", remoteDpnId, srcTepIp, destTepIp, rpcResult.getErrors());
                } else {
                    destDpninterfacelist = rpcResult.getResult().getInterfaces();
                }
            } catch (Exception e) {
                LOG.error("handleTunnelEventForDPN: Exception when querying for GetDpnInterfaceList" + " for remoteDpnid {} srcTepIp {} destTepIp {}", remoteDpnId, srcTepIp, destTepIp, e);
            }
        }
        /*
             * Iterate over the list of VpnInterface for a SrcDpn on which TEP is added or deleted and read the adj.
             * Update the adjacencies with the updated nexthop.
             */
        Iterator<Interfaces> interfacelistIter = srcDpninterfacelist.iterator();
        Interfaces interfaces = null;
        String intfName = null;
        List<Uuid> subnetList = new ArrayList<>();
        Map<Long, String> vpnIdRdMap = new HashMap<>();
        Set<String> listVpnName = new HashSet<>();
        while (interfacelistIter.hasNext()) {
            interfaces = interfacelistIter.next();
            if (!L2vlan.class.equals(interfaces.getInterfaceType())) {
                LOG.info("handleTunnelEventForDPN: Interface {} not of type L2Vlan", interfaces.getInterfaceName());
                return;
            }
            intfName = interfaces.getInterfaceName();
            VpnInterface vpnInterface = VpnUtil.getConfiguredVpnInterface(dataBroker, intfName);
            if (vpnInterface != null && !Boolean.TRUE.equals(vpnInterface.isScheduledForRemove())) {
                listVpnName.addAll(VpnHelper.getVpnInterfaceVpnInstanceNamesString(vpnInterface.getVpnInstanceNames()));
                handleTunnelEventForDPNVpn(stateTunnelList, vpnIdRdMap, tunnelAction, isTepDeletedOnDpn, subnetList, TunnelEventProcessingMethod.POPULATESUBNETS, vpnInterface);
            }
        }
        /*
             * Iterate over the list of VpnInterface for destDPN and get the prefix .
             * Create remote rule for each of those prefix on srcDPN.
             */
        interfacelistIter = destDpninterfacelist.iterator();
        while (interfacelistIter.hasNext()) {
            interfaces = interfacelistIter.next();
            if (!L2vlan.class.equals(interfaces.getInterfaceType())) {
                LOG.info("handleTunnelEventForDPN: Interface {} not of type L2Vlan", interfaces.getInterfaceName());
                return;
            }
            intfName = interfaces.getInterfaceName();
            VpnInterface vpnInterface = VpnUtil.getConfiguredVpnInterface(dataBroker, intfName);
            if (vpnInterface != null) {
                handleTunnelEventForDPNVpn(stateTunnelList, vpnIdRdMap, tunnelAction, isTepDeletedOnDpn, subnetList, TunnelEventProcessingMethod.MANAGEREMOTEROUTES, vpnInterface);
            }
        }
        // Iterate over the VpnId-to-Rd map.
        for (Map.Entry<Long, String> entry : vpnIdRdMap.entrySet()) {
            Long vpnId = entry.getKey();
            rd = entry.getValue();
            if (tunnelAction == TunnelAction.TUNNEL_EP_ADD && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
                fibManager.populateExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
            } else if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && tunTypeVal == VpnConstants.ITMTunnelLocType.External.getValue()) {
                fibManager.cleanUpExternalRoutesOnDpn(srcDpnId, vpnId, rd, srcTepIp, destTepIp);
            }
        }
        if (listVpnName.size() >= 1) {
            if (tunnelAction == TunnelAction.TUNNEL_EP_ADD) {
                for (Uuid subnetId : subnetList) {
                    // Populate the List of subnets
                    vpnSubnetRouteHandler.updateSubnetRouteOnTunnelUpEvent(subnetId, srcDpnId);
                }
            }
            if (tunnelAction == TunnelAction.TUNNEL_EP_DELETE && isTepDeletedOnDpn) {
                for (Uuid subnetId : subnetList) {
                    // Populate the List of subnets
                    vpnSubnetRouteHandler.updateSubnetRouteOnTunnelDownEvent(subnetId, srcDpnId);
                }
            }
        }
    } catch (RuntimeException e) {
        LOG.error("handleTunnelEventForDpn: Unable to handle the tunnel event for srcDpnId {} srcTepIp {}" + " remoteDpnId {} destTepIp {}", srcDpnId, srcTepIp, remoteDpnId, destTepIp, e);
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) GetDpnInterfaceListOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput) HashSet(java.util.HashSet) L2vlan(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) Interfaces(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces) GetDpnInterfaceListInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder) Uuid(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid) VpnInterface(org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface) BigInteger(java.math.BigInteger) Map(java.util.Map) HashMap(java.util.HashMap)

Aggregations

GetDpnInterfaceListInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInputBuilder)3 GetDpnInterfaceListInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListInput)2 GetDpnInterfaceListOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetDpnInterfaceListOutput)2 Interfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.get.dpn._interface.list.output.Interfaces)2 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)2 BigInteger (java.math.BigInteger)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 Ignore (org.junit.Ignore)1 Test (org.junit.Test)1 VpnInterface (org.opendaylight.yang.gen.v1.urn.huawei.params.xml.ns.yang.l3vpn.rev140815.vpn.interfaces.VpnInterface)1 L2vlan (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.L2vlan)1 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)1