Search in sources :

Example 36 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class BaseVrfEntryHandler method addTunnelInterfaceActions.

protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, long vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
    Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getInterfaceManager(), adjacencyResult.getInterfaceName());
    if (tunnelType == null) {
        LOG.debug("Tunnel type not found for vrfEntry {}", vrfEntry);
        return;
    }
    // TODO - For now have added routePath into adjacencyResult so that we know for which
    // routePath this result is built for. If this is not possible construct a map which does
    // the same.
    String nextHopIp = adjacencyResult.getNextHopIp();
    java.util.Optional<Long> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
    if (!optionalLabel.isPresent()) {
        LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
        return;
    }
    long label = optionalLabel.get();
    BigInteger tunnelId = null;
    Prefixes prefixInfo = null;
    // revisit
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        prefixInfo = fibUtil.getPrefixToInterface(vpnId, vrfEntry.getDestPrefix());
        // For extra route, the prefixInfo is fetched from the primary adjacency
        if (prefixInfo == null) {
            prefixInfo = fibUtil.getPrefixToInterface(vpnId, adjacencyResult.getPrefix());
        }
        // Internet VPN VNI will be used as tun_id for NAT use-cases
        if (Prefixes.PrefixCue.Nat.equals(prefixInfo.getPrefixCue())) {
            if (vrfEntry.getL3vni() != null && vrfEntry.getL3vni() != 0) {
                tunnelId = BigInteger.valueOf(vrfEntry.getL3vni());
            }
        } else {
            if (fibUtil.enforceVxlanDatapathSemanticsforInternalRouterVpn(prefixInfo.getSubnetId(), vpnId, rd)) {
                java.util.Optional<Long> optionalVni = fibUtil.getVniForVxlanNetwork(prefixInfo.getSubnetId());
                if (!optionalVni.isPresent()) {
                    LOG.error("VNI not found for nexthop {} vrfEntry {} with subnetId {}", nextHopIp, vrfEntry, prefixInfo.getSubnetId());
                    return;
                }
                tunnelId = BigInteger.valueOf(optionalVni.get());
            } else {
                tunnelId = BigInteger.valueOf(label);
            }
        }
    } else {
        tunnelId = BigInteger.valueOf(label);
    }
    LOG.debug("adding set tunnel id action for label {}", label);
    actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
    addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
Also used : BigInteger(java.math.BigInteger) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId)

Example 37 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class VpnUtil method lockSubnet.

public static void lockSubnet(LockManagerService lockManager, String subnetId) {
    TryLockInput input = new TryLockInputBuilder().setLockName(subnetId).setTime(3000L).setTimeUnit(TimeUnits.Milliseconds).build();
    Future<RpcResult<Void>> result = lockManager.tryLock(input);
    try {
        if (result != null && result.get().isSuccessful()) {
            LOG.debug("lockSubnet: Acquired lock for {}", subnetId);
        } else {
            LOG.error("Unable to get lock for subnet {}", subnetId);
            throw new RuntimeException("Unable to get lock for subnet " + subnetId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Unable to get lock for subnet {}", subnetId, e);
        throw new RuntimeException("Unable to get lock for subnet " + subnetId, e);
    }
}
Also used : TryLockInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) TryLockInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.lockmanager.rev160413.TryLockInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Example 38 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class VpnUtil method getDpnsOnVpn.

@Nonnull
public static List<BigInteger> getDpnsOnVpn(DataBroker dataBroker, String vpnInstanceName) {
    List<BigInteger> result = new ArrayList<>();
    String rd = getVpnRd(dataBroker, vpnInstanceName);
    if (rd == null) {
        LOG.debug("getDpnsOnVpn: Could not find Route-Distinguisher for VpnName={}", vpnInstanceName);
        return result;
    }
    VpnInstanceOpDataEntry vpnInstanceOpData = getVpnInstanceOpData(dataBroker, rd);
    if (vpnInstanceOpData == null) {
        LOG.debug("getDpnsOnVpn: Could not find OpState for VpnName={}", vpnInstanceName);
        return result;
    }
    List<VpnToDpnList> vpnToDpnList = vpnInstanceOpData.getVpnToDpnList();
    if (vpnToDpnList == null) {
        LOG.debug("getDpnsOnVpn: Could not find DPN footprint for VpnName={}", vpnInstanceName);
        return result;
    }
    for (VpnToDpnList vpnToDpn : vpnToDpnList) {
        result.add(vpnToDpn.getDpnId());
    }
    return result;
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) ArrayList(java.util.ArrayList) VpnToDpnList(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList) BigInteger(java.math.BigInteger) Nonnull(javax.annotation.Nonnull)

Example 39 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class DhcpPktHandler method getEgressAction.

private List<Action> getEgressAction(String interfaceName, BigInteger tunnelId) {
    List<Action> actions = null;
    try {
        GetEgressActionsForInterfaceInputBuilder egressAction = new GetEgressActionsForInterfaceInputBuilder().setIntfName(interfaceName);
        if (tunnelId != null) {
            egressAction.setTunnelKey(tunnelId.longValue());
        }
        Future<RpcResult<GetEgressActionsForInterfaceOutput>> result = interfaceManagerRpc.getEgressActionsForInterface(egressAction.build());
        RpcResult<GetEgressActionsForInterfaceOutput> rpcResult = result.get();
        if (!rpcResult.isSuccessful()) {
            LOG.warn("RPC Call to Get egress actions for interface {} returned with Errors {}", interfaceName, rpcResult.getErrors());
        } else {
            actions = rpcResult.getResult().getAction();
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.warn("Exception when egress actions for interface {}", interfaceName, e);
    }
    return actions;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetEgressActionsForInterfaceInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceInputBuilder) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) GetEgressActionsForInterfaceOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rpcs.rev160406.GetEgressActionsForInterfaceOutput) ExecutionException(java.util.concurrent.ExecutionException)

Example 40 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev131005.pcrep.message.pcrep.message.replies.Result in project netvirt by opendaylight.

the class DhcpAllocationPoolManager method createIdAllocationPool.

protected void createIdAllocationPool(String networkId, AllocationPool pool) {
    String poolName = getPoolKeyIdByAllocationPool(networkId, pool);
    long low = DhcpServiceUtils.convertIpToLong(pool.getAllocateFrom());
    long high = DhcpServiceUtils.convertIpToLong(pool.getAllocateTo());
    CreateIdPoolInput createPool = new CreateIdPoolInputBuilder().setPoolName(poolName).setLow(low).setHigh(high).build();
    try {
        Future<RpcResult<Void>> result = idManager.createIdPool(createPool);
        if (result != null && result.get().isSuccessful()) {
            LOG.info("DHCP Allocation Pool Service : Created IdPool name {}", poolName);
        } else {
            LOG.error("DHCP Allocation Pool Service : Unable to create IdPool name {}", poolName);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Failed to create Pool for DHCP Allocation Pool Service", e);
    }
}
Also used : RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) CreateIdPoolInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInput) ExecutionException(java.util.concurrent.ExecutionException) CreateIdPoolInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.CreateIdPoolInputBuilder)

Aggregations

Test (org.junit.Test)348 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)174 ByteBuf (io.netty.buffer.ByteBuf)97 ArrayList (java.util.ArrayList)94 ExecutionException (java.util.concurrent.ExecutionException)92 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)46 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)40 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)33 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)33 List (java.util.List)31 BigInteger (java.math.BigInteger)29 Collections (java.util.Collections)26 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)24 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)24 Nonnull (javax.annotation.Nonnull)23 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)23 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)23 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)22 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)22 RpcError (org.opendaylight.yangtools.yang.common.RpcError)22