Search in sources :

Example 36 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel 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 37 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method populatePolicyRoutesToDpn.

private void populatePolicyRoutesToDpn(StateTunnelList tunnelState, int addOrRemove) {
    BigInteger srcDpId = getTepDpnId(tunnelState.getSrcInfo());
    BigInteger dstDpId = getTepDpnId(tunnelState.getDstInfo());
    String tunnelInterfaceName = tunnelState.getTunnelInterfaceName();
    if (BigInteger.ZERO.equals(srcDpId) || BigInteger.ZERO.equals(dstDpId)) {
        LOG.warn("No valid DPN found for logical tunnel {}", tunnelInterfaceName);
        return;
    }
    List<PolicyProfile> policyProfiles = policyServiceUtil.getAllPolicyProfiles();
    if (policyProfiles == null || policyProfiles.isEmpty()) {
        LOG.debug("No policy profiles found on addition of {}", tunnelInterfaceName);
        return;
    }
    policyProfiles.forEach(policyProfile -> {
        String policyClassifier = policyProfile.getPolicyClassifier();
        List<String> underlayNetworks = PolicyServiceUtil.getUnderlayNetworksFromPolicyRoutes(policyProfile.getPolicyRoute());
        underlayNetworks.forEach(underlayNetwork -> {
            if (policyServiceUtil.underlayNetworkContainsDpn(underlayNetwork, srcDpId) && policyServiceUtil.underlayNetworkContainsRemoteDpn(underlayNetwork, dstDpId)) {
                routeFlowProgrammer.programPolicyClassifierFlow(policyClassifier, srcDpId, dstDpId, addOrRemove, true);
            } else {
                LOG.trace("logical tunnel {} source DPN {} dest DPN {} not associated to policy classifier {}", tunnelInterfaceName, srcDpId, dstDpId, policyClassifier);
            }
        });
    });
}
Also used : PolicyProfile(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.policy.rev170207.policy.profiles.PolicyProfile) BigInteger(java.math.BigInteger)

Example 38 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method unbindService.

private void unbindService(String tunnelInterfaceName) {
    coordinator.enqueueJob(tunnelInterfaceName, () -> {
        LOG.info("Unbind egress policy service on tunnel {}", tunnelInterfaceName);
        BoundServices boundServices = getBoundServices(tunnelInterfaceName, Collections.emptyList());
        interfaceManager.unbindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
        return null;
    });
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices)

Example 39 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project netvirt by opendaylight.

the class TunnelStateChangeListener method bindService.

private void bindService(String tunnelInterfaceName) {
    coordinator.enqueueJob(tunnelInterfaceName, () -> {
        LOG.info("Bind egress policy service on tunnel {}", tunnelInterfaceName);
        List<Instruction> instructions = Collections.singletonList(MDSALUtil.buildAndGetGotoTableInstruction(NwConstants.EGRESS_POLICY_CLASSIFIER_TABLE, 0));
        BoundServices boundServices = getBoundServices(tunnelInterfaceName, instructions);
        interfaceManager.bindService(tunnelInterfaceName, ServiceModeEgress.class, boundServices);
        return null;
    });
}
Also used : BoundServices(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.servicebinding.rev160406.service.bindings.services.info.BoundServices) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction)

Example 40 with Tunnel

use of org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana._if.type.rev140508.Tunnel in project bgpcep by opendaylight.

the class PCCTunnelBuilder method createTunnels.

static Map<PlspId, PCCTunnel> createTunnels(final String address, final int lsps) {
    final Map<PlspId, PCCTunnel> tunnels = new HashMap<>();
    for (int i = 1; i <= lsps; i++) {
        final PCCTunnel tunnel = new PCCTunnel(MsgBuilderUtil.getDefaultPathName(address, i), PCC_DELEGATION, LspType.PCC_LSP, createPath(Lists.newArrayList(DEFAULT_ENDPOINT_HOP)));
        tunnels.put(new PlspId((long) i), tunnel);
    }
    return tunnels;
}
Also used : HashMap(java.util.HashMap) PlspId(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.PlspId)

Aggregations

BigInteger (java.math.BigInteger)45 ArrayList (java.util.ArrayList)43 IfTunnel (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnel)27 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)23 ExecutionException (java.util.concurrent.ExecutionException)19 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)17 Interface (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.Interface)17 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)17 ParentRefs (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.ParentRefs)16 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)15 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)14 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)12 List (java.util.List)12 InterfaceKey (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.interfaces.rev140508.interfaces.InterfaceKey)12 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)12 Test (org.junit.Test)8 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)8 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)7 IfTunnelBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.IfTunnelBuilder)7 TunnelIpv4MatchBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.model.match.types.rev131026.match.layer._3.match.TunnelIpv4MatchBuilder)7