Search in sources :

Example 86 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result in project openflowplugin by opendaylight.

the class GroupDescriptionService method transformToNotification.

@Override
public GroupDescStatsUpdated transformToNotification(List<MultipartReply> result, TransactionId emulatedTxId) {
    GroupDescStatsUpdatedBuilder notification = new GroupDescStatsUpdatedBuilder();
    notification.setId(getDeviceInfo().getNodeId());
    notification.setMoreReplies(Boolean.FALSE);
    notification.setTransactionId(emulatedTxId);
    notification.setGroupDescStats(new ArrayList<>());
    final VersionConvertorData data = new VersionConvertorData(getVersion());
    for (MultipartReply mpReply : result) {
        MultipartReplyGroupDescCase caseBody = (MultipartReplyGroupDescCase) mpReply.getMultipartReplyBody();
        MultipartReplyGroupDesc replyBody = caseBody.getMultipartReplyGroupDesc();
        final Optional<List<GroupDescStats>> groupDescStatsList = convertorExecutor.convert(replyBody.getGroupDesc(), data);
        groupDescStatsList.ifPresent(groupDescStats -> notification.getGroupDescStats().addAll(groupDescStats));
    }
    return notification.build();
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MultipartReplyGroupDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyGroupDescCase) MultipartReply(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReply) MultipartReplyGroupDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.desc._case.MultipartReplyGroupDesc) GroupDescStatsUpdatedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GroupDescStatsUpdatedBuilder) ArrayList(java.util.ArrayList) List(java.util.List)

Example 87 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result in project openflowplugin by opendaylight.

the class ActionResponseConvertor method convert.

@Override
public List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convert(List<Action> source, ActionResponseConvertorData data) {
    final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> result = new ArrayList<>();
    final OpenflowVersion ofVersion = OpenflowVersion.get(data.getVersion());
    // Iterate over Openflow actions, run them through tokenizer and then add them to list of converted actions
    if (source != null) {
        for (final Action action : source) {
            final Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> convertedAction = PROCESSOR.process(action.getActionChoice(), data, getConvertorExecutor());
            if (convertedAction.isPresent()) {
                result.add(convertedAction.get());
            } else {
                /**
                 * TODO: EXTENSION PROPOSAL (action, OFJava to MD-SAL)
                 * - we might also need a way on how to identify exact type of augmentation to be
                 *   used as match can be bound to multiple models
                 */
                org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action processedAction = ActionExtensionHelper.processAlienAction(action, ofVersion, data.getActionPath());
                if (processedAction != null) {
                    result.add(processedAction);
                }
            }
        }
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) ArrayList(java.util.ArrayList)

Example 88 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result in project openflowplugin by opendaylight.

the class MultipartReplyTableFeaturesDeserializerTest method writeValues.

private void writeValues(ByteBuf buffer, int propertyType) {
    buffer.clear();
    final int replyIndex = buffer.readerIndex();
    buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
    buffer.writeByte(TABLE_ID);
    buffer.writeZero(PADDING_IN_MULTIPART_REPLY_TABLE_FEATURES);
    buffer.writeZero(MAX_TABLE_NAME_LENGTH);
    buffer.writeLong(METADATA_MATCH);
    buffer.writeLong(METADATA_WRITE);
    buffer.writeInt(TABLE_CONFIG);
    buffer.writeInt(MAX_ENTRIES);
    final int propIndex = buffer.writerIndex();
    buffer.writeShort(propertyType);
    final int propLengthIndex = buffer.writerIndex();
    buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
    TableFeaturesPropType propType = TableFeaturesPropType.forValue(propertyType);
    switch(propType) {
        case OFPTFPTINSTRUCTIONS:
        case OFPTFPTINSTRUCTIONSMISS:
            int instructionStartIndex = buffer.writerIndex();
            buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
            int instructionLengthIndex = buffer.writerIndex();
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            buffer.setShort(instructionLengthIndex, buffer.writerIndex() - instructionStartIndex);
            break;
        case OFPTFPTNEXTTABLES:
        case OFPTFPTNEXTTABLESMISS:
            buffer.writeByte(1);
            buffer.writeByte(2);
            break;
        case OFPTFPTWRITEACTIONS:
        case OFPTFPTWRITEACTIONSMISS:
            buffer.writeShort(InstructionConstants.WRITE_ACTIONS_TYPE);
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYACTIONS:
        case OFPTFPTAPPLYACTIONSMISS:
            buffer.writeShort(InstructionConstants.APPLY_ACTIONS_TYPE);
            buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTMATCH:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_OP << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWILDCARDS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_SHA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWRITESETFIELD:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_SPA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTWRITESETFIELDMISS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_THA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYSETFIELD:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ARP_TPA << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        case OFPTFPTAPPLYSETFIELDMISS:
            buffer.writeShort(OxmMatchConstants.OPENFLOW_BASIC_CLASS);
            buffer.writeByte(OxmMatchConstants.ETH_TYPE << 1);
            buffer.writeByte(EncodeConstants.EMPTY_LENGTH);
            break;
        default:
            break;
    }
    int propLength = buffer.writerIndex() - propIndex;
    buffer.setShort(propLengthIndex, buffer.writerIndex() - propIndex);
    int paddingRemainder = propLength % EncodeConstants.PADDING;
    int result = 0;
    if (paddingRemainder != 0) {
        result = EncodeConstants.PADDING - paddingRemainder;
    }
    buffer.writeZero(result);
    buffer.setShort(replyIndex, buffer.writerIndex() - replyIndex);
}
Also used : TableFeaturesPropType(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.TableFeaturesPropType)

Example 89 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result in project netvirt by opendaylight.

the class BaseVrfEntryHandler method addTunnelInterfaceActions.

protected void addTunnelInterfaceActions(AdjacencyResult adjacencyResult, Uint32 vpnId, VrfEntry vrfEntry, List<ActionInfo> actionInfos, String rd) {
    Class<? extends TunnelTypeBase> tunnelType = VpnExtraRouteHelper.getTunnelType(nextHopManager.getItmManager(), 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<Uint32> optionalLabel = FibUtil.getLabelForNextHop(vrfEntry, nextHopIp);
    if (!optionalLabel.isPresent()) {
        LOG.warn("NextHopIp {} not found in vrfEntry {}", nextHopIp, vrfEntry);
        return;
    }
    Uint32 label = optionalLabel.get();
    Uint64 tunnelId = null;
    Prefixes prefixInfo = null;
    // revisit
    if (tunnelType.equals(TunnelTypeVxlan.class)) {
        if (FibHelper.isControllerManagedNonSelfImportedRoute(RouteOrigin.value(vrfEntry.getOrigin()))) {
            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());
            }
        } else {
            // Imported Route. Get Prefix Info from parent RD
            VpnInstanceOpDataEntry parentVpn = fibUtil.getVpnInstance(vrfEntry.getParentVpnRd());
            prefixInfo = fibUtil.getPrefixToInterface(parentVpn.getVpnId(), 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().toJava() != 0) {
                tunnelId = Uint64.valueOf(vrfEntry.getL3vni().longValue());
            }
        } else {
            if (FibUtil.isVxlanNetwork(prefixInfo.getNetworkType())) {
                tunnelId = Uint64.valueOf(prefixInfo.getSegmentationId().longValue());
            } else {
                LOG.warn("Network is not of type VXLAN for prefix {}." + "Going with default Lport Tag.", prefixInfo.toString());
                tunnelId = Uint64.valueOf(label.longValue());
            }
        }
    } else {
        tunnelId = Uint64.valueOf(label.longValue());
    }
    LOG.debug("adding set tunnel id action for label {}", label);
    actionInfos.add(new ActionSetFieldTunnelId(tunnelId));
    addRewriteDstMacAction(vpnId, vrfEntry, prefixInfo, actionInfos);
}
Also used : VpnInstanceOpDataEntry(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.VpnInstanceOpDataEntry) Prefixes(org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.prefix.to._interface.vpn.ids.Prefixes) ActionSetFieldTunnelId(org.opendaylight.genius.mdsalutil.actions.ActionSetFieldTunnelId) Uint32(org.opendaylight.yangtools.yang.common.Uint32) Uint64(org.opendaylight.yangtools.yang.common.Uint64)

Example 90 with Result

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.odl.bgp.app.peer.benchmark.rev200120.output.Result in project netvirt by opendaylight.

the class ElanL2GatewayUtils method checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry.

/**
 * gets the macs addresses for elan interfaces.
 *
 * @param lstElanInterfaceNames
 *            the lst elan interface names
 * @return the list
 */
/*
    public List<PhysAddress> getElanDpnMacsFromInterfaces(Set<String> lstElanInterfaceNames) {
        List<PhysAddress> result = new ArrayList<>();
        for (String interfaceName : lstElanInterfaceNames) {
            ElanInterfaceMac elanInterfaceMac = ElanUtils.getElanInterfaceMacByInterfaceName(broker, interfaceName);
            if (elanInterfaceMac != null && elanInterfaceMac.getMacEntry() != null) {
                for (MacEntry macEntry : elanInterfaceMac.getMacEntry()) {
                    result.add(macEntry.getMacAddress());
                }
            }
        }
        return result;
    }*/
/**
 * Check if phy locator already exists in remote mcast entry.
 *
 * @param nodeId
 *            the node id
 * @param remoteMcastMac
 *            the remote mcast mac
 * @param expectedPhyLocatorIp
 *            the expected phy locator ip
 * @return true, if successful
 */
public static boolean checkIfPhyLocatorAlreadyExistsInRemoteMcastEntry(NodeId nodeId, RemoteMcastMacs remoteMcastMac, IpAddress expectedPhyLocatorIp) {
    if (remoteMcastMac != null) {
        HwvtepPhysicalLocatorAugmentation expectedPhyLocatorAug = HwvtepSouthboundUtils.createHwvtepPhysicalLocatorAugmentation(expectedPhyLocatorIp);
        HwvtepPhysicalLocatorRef expectedPhyLocRef = new HwvtepPhysicalLocatorRef(HwvtepSouthboundUtils.createPhysicalLocatorInstanceIdentifier(nodeId, expectedPhyLocatorAug));
        if (remoteMcastMac.getLocatorSet() != null) {
            for (LocatorSet locatorSet : remoteMcastMac.getLocatorSet()) {
                if (Objects.equals(locatorSet.getLocatorRef(), expectedPhyLocRef)) {
                    LOG.trace("matched phyLocRef: {}", expectedPhyLocRef);
                    return true;
                }
            }
        }
    }
    return false;
}
Also used : HwvtepPhysicalLocatorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorRef) LocatorSet(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.hwvtep.physical.locator.set.attributes.LocatorSet) HwvtepPhysicalLocatorAugmentation(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.hwvtep.rev150901.HwvtepPhysicalLocatorAugmentation)

Aggregations

Test (org.junit.Test)384 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)212 ArrayList (java.util.ArrayList)136 ExecutionException (java.util.concurrent.ExecutionException)134 ByteBuf (io.netty.buffer.ByteBuf)115 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev200120.path.attributes.AttributesBuilder)51 Collections (java.util.Collections)50 ObjectHeaderImpl (org.opendaylight.protocol.pcep.spi.ObjectHeaderImpl)47 List (java.util.List)39 RouteAttributeContainer (org.opendaylight.protocol.bgp.openconfig.routing.policy.spi.registry.RouteAttributeContainer)39 Statement (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.routing.policy.rev151009.routing.policy.top.routing.policy.policy.definitions.policy.definition.statements.Statement)39 Uuid (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid)33 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)31 BigInteger (java.math.BigInteger)28 AllocateIdInput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInput)28 AllocateIdInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdInputBuilder)28 AllocateIdOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.idmanager.rev160406.AllocateIdOutput)27 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)26 CommitInfo (org.opendaylight.mdsal.common.api.CommitInfo)25 IPV4UNICAST (org.opendaylight.yang.gen.v1.http.openconfig.net.yang.bgp.types.rev151009.IPV4UNICAST)25