Search in sources :

Example 6 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project openflowplugin by opendaylight.

the class HandshakeManagerImpl method sendHelloMessage.

/**
 * send hello reply without versionBitmap.
 *
 * @param helloVersion initial hello version for openflow connection negotiation
 * @param helloXid     transaction id
 */
private ListenableFuture<Void> sendHelloMessage(Short helloVersion, final Long helloXid) throws Exception {
    HelloInput helloInput = MessageFactory.createHelloInput(helloVersion, helloXid, versionOrder);
    final SettableFuture<Void> resultFtr = SettableFuture.create();
    LOG.debug("sending hello message: version{}, xid={}, version bitmap={}", helloVersion, helloXid, MessageFactory.digVersions(helloInput.getElements()));
    Future<RpcResult<Void>> helloResult = connectionAdapter.hello(helloInput);
    ListenableFuture<RpcResult<Void>> rpcResultListenableFuture = JdkFutureAdapters.listenInPoolThread(helloResult);
    Futures.addCallback(rpcResultListenableFuture, new FutureCallback<RpcResult<Void>>() {

        @Override
        public void onSuccess(@Nonnull RpcResult<Void> result) {
            if (result.isSuccessful()) {
                LOG.debug("hello successfully sent, xid={}, addr={}", helloXid, connectionAdapter.getRemoteAddress());
                resultFtr.set(null);
            } else {
                for (RpcError error : result.getErrors()) {
                    LOG.debug("hello sending failed [{}]: i:{} s:{} m:{}, addr:{}", helloXid, error.getInfo(), error.getSeverity(), error.getMessage(), connectionAdapter.getRemoteAddress());
                    if (error.getCause() != null) {
                        LOG.trace("DETAIL of sending hello failure", error.getCause());
                    }
                }
                resultFtr.cancel(false);
                handshakeListener.onHandshakeFailure();
            }
        }

        @Override
        public void onFailure(Throwable throwable) {
            LOG.warn("sending of hello failed seriously [{}, addr:{}]: {}", helloXid, connectionAdapter.getRemoteAddress(), throwable.getMessage());
            LOG.trace("DETAIL of sending of hello failure:", throwable);
            resultFtr.cancel(false);
            handshakeListener.onHandshakeFailure();
        }
    }, MoreExecutors.directExecutor());
    LOG.trace("sending hello message [{}] - result hooked ..", helloXid);
    return resultFtr;
}
Also used : HelloInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.HelloInput) RpcResult(org.opendaylight.yangtools.yang.common.RpcResult) RpcError(org.opendaylight.yangtools.yang.common.RpcError)

Example 7 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project openflowplugin by opendaylight.

the class SimplifiedOperationalListener method reconciliation.

/**
 * If node is present in config DS diff between wanted configuration (in config DS) and actual device
 * configuration (coming from operational) should be calculated and sent to device.
 * @param modification from DS
 * @return optional syncup future
 */
private Optional<ListenableFuture<Boolean>> reconciliation(final DataTreeModification<Node> modification) {
    final NodeId nodeId = ModificationUtil.nodeId(modification);
    final Optional<FlowCapableNode> nodeConfiguration = configDao.loadByNodeId(nodeId);
    if (nodeConfiguration.isPresent()) {
        LOG.debug("Reconciliation {}: {}", dsType(), nodeId.getValue());
        final InstanceIdentifier<FlowCapableNode> nodePath = InstanceIdentifier.create(Nodes.class).child(Node.class, new NodeKey(ModificationUtil.nodeId(modification))).augmentation(FlowCapableNode.class);
        final FlowCapableNode fcOperationalNode = ModificationUtil.flowCapableNodeAfter(modification);
        final SyncupEntry syncupEntry = new SyncupEntry(nodeConfiguration.get(), LogicalDatastoreType.CONFIGURATION, fcOperationalNode, dsType());
        return Optional.of(reactor.syncup(nodePath, syncupEntry));
    } else {
        LOG.debug("Config not present for reconciliation: {}", nodeId.getValue());
        reconciliationRegistry.unregisterIfRegistered(nodeId);
        return skipModification(modification);
    }
}
Also used : FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) SyncupEntry(org.opendaylight.openflowplugin.applications.frsync.util.SyncupEntry) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)

Example 8 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.

the class ElanUtils method syncUpdateGroup.

public void syncUpdateGroup(Uint64 dpnId, Group newGroup, long delayTime, TypedWriteTransaction<Datastore.Configuration> confTx) {
    Node nodeDpn = buildDpnNode(dpnId);
    long groupIdInfo = newGroup.getGroupId().getValue().longValue();
    GroupKey groupKey = new GroupKey(new GroupId(groupIdInfo));
    InstanceIdentifier<Group> groupInstanceId = InstanceIdentifier.builder(Nodes.class).child(Node.class, nodeDpn.key()).augmentation(FlowCapableNode.class).child(Group.class, groupKey).build();
    LOG.trace("Performing merge operation for remote BC group for node {} with group {}", nodeDpn, newGroup);
    Optional<Group> existingGroupOpt = ElanUtils.read(broker, LogicalDatastoreType.CONFIGURATION, groupInstanceId);
    if (!existingGroupOpt.isPresent()) {
        LOG.debug("Group {} doesn't exist. Performing syncInstall", groupIdInfo);
        mdsalManager.addGroup(confTx, dpnId, newGroup);
        return;
    }
    Buckets existingGroup = existingGroupOpt.get().getBuckets();
    if (existingGroup == null) {
        LOG.debug("Bucket doesn't exist for group {}. Performing syncInstall", groupIdInfo);
        mdsalManager.addGroup(confTx, dpnId, newGroup);
        return;
    }
    if (newGroup.getBuckets() == null) {
        LOG.debug("Buckets are not sent for group {}. Skipping merge operation", groupIdInfo);
        return;
    }
    List<Bucket> newBuckets = new ArrayList<>(newGroup.getBuckets().nonnullBucket().values());
    List<Bucket> existingBuckets = new ArrayList<>(existingGroup.nonnullBucket().values());
    LOG.debug("New Buckets {} and Existing Buckets {}", newBuckets, existingBuckets);
    List<Bucket> combinedBuckets = new ArrayList<>(existingBuckets);
    Map<String, Bucket> ncBucketMap = new HashMap<>();
    Map<String, Bucket> reg6ActionBucketMap = new HashMap<>();
    // Add all buckets in the new group to a map with node connector/reg6 value as key
    newBuckets.forEach(bucket -> {
        List<Action> actionList = new ArrayList<>(bucket.getAction().values());
        if (actionList != null && !actionList.isEmpty()) {
            actionList.forEach(action -> {
                if (action.getAction() instanceof OutputActionCase) {
                    OutputActionCase outputAction = (OutputActionCase) action.getAction();
                    String nc = outputAction.getOutputAction().getOutputNodeConnector().getValue();
                    ncBucketMap.put(nc, bucket);
                }
                if (action.getAction() instanceof NxActionRegLoadNodesNodeTableFlowApplyActionsCase) {
                    NxActionRegLoadNodesNodeTableFlowApplyActionsCase regLoad = (NxActionRegLoadNodesNodeTableFlowApplyActionsCase) action.getAction();
                    String regValue = regLoad.getNxRegLoad().getValue().toString();
                    reg6ActionBucketMap.put(regValue, bucket);
                }
            });
        }
    });
    // Replace existing bucket if action has same node connector/reg6 value as stored in map
    // First, remove buckets with same nc id/reg6 value as in hashmap from combinedBuckets
    // Next, add all the buckets in hashmap to combined buckets
    existingBuckets.forEach(existingBucket -> {
        List<Action> actionList = new ArrayList<>(existingBucket.getAction().values());
        if (actionList != null && !actionList.isEmpty()) {
            actionList.forEach(action -> {
                if (action.getAction() instanceof OutputActionCase) {
                    OutputActionCase outputAction = (OutputActionCase) action.getAction();
                    String nc = outputAction.getOutputAction().getOutputNodeConnector().getValue();
                    Bucket storedBucket = ncBucketMap.get(nc);
                    if (storedBucket != null) {
                        combinedBuckets.remove(existingBucket);
                    }
                }
                if (action.getAction() instanceof NxActionRegLoadNodesNodeGroupBucketsBucketActionsCase) {
                    NxActionRegLoadNodesNodeGroupBucketsBucketActionsCase regLoad = (NxActionRegLoadNodesNodeGroupBucketsBucketActionsCase) action.getAction();
                    String regValue = regLoad.getNxRegLoad().getValue().toString();
                    Bucket storedBucket = reg6ActionBucketMap.get(regValue);
                    if (storedBucket != null) {
                        combinedBuckets.remove(existingBucket);
                    }
                }
            });
        }
    });
    AtomicLong bucketIdValue = new AtomicLong(-1);
    // Change the bucket id of existing buckets
    List<Bucket> bucketsToBeAdded = new ArrayList<>();
    bucketsToBeAdded.addAll(combinedBuckets.stream().map(bucket -> {
        BucketId bucketId = new BucketId(bucketIdValue.incrementAndGet());
        return new BucketBuilder(bucket).withKey(new BucketKey(bucketId)).setBucketId(bucketId).build();
    }).collect(Collectors.toList()));
    // Change the bucket id of remaining to be added to the combined buckets
    bucketsToBeAdded.addAll(ncBucketMap.values().stream().map(bucket -> {
        BucketId bucketId = new BucketId(bucketIdValue.incrementAndGet());
        return new BucketBuilder(bucket).withKey(new BucketKey(bucketId)).setBucketId(bucketId).build();
    }).collect(Collectors.toList()));
    bucketsToBeAdded.addAll(reg6ActionBucketMap.values().stream().map(bucket -> {
        BucketId bucketId = new BucketId(bucketIdValue.incrementAndGet());
        return new BucketBuilder(bucket).withKey(new BucketKey(bucketId)).setBucketId(bucketId).build();
    }).collect(Collectors.toList()));
    Group group = MDSALUtil.buildGroup(newGroup.getGroupId().getValue().longValue(), newGroup.getGroupName(), GroupTypes.GroupAll, MDSALUtil.buildBucketLists(bucketsToBeAdded));
    mdsalManager.addGroup(confTx, dpnId, group);
    LOG.trace("Installed remote BC group for node {} with group {}", nodeDpn.key().getId().getValue(), group);
}
Also used : Group(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.Group) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) HashMap(java.util.HashMap) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NxActionRegLoadNodesNodeTableFlowApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.table.flow.instructions.instruction.instruction.apply.actions._case.apply.actions.action.action.NxActionRegLoadNodesNodeTableFlowApplyActionsCase) BucketKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketKey) GroupKey(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.groups.GroupKey) ArrayList(java.util.ArrayList) BucketId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.BucketId) Buckets(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.Buckets) GroupId(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupId) BucketBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.BucketBuilder) AtomicLong(java.util.concurrent.atomic.AtomicLong) Bucket(org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.buckets.Bucket) OutputActionCase(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.action.OutputActionCase) NxActionRegLoadNodesNodeGroupBucketsBucketActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nodes.node.group.buckets.bucket.action.action.NxActionRegLoadNodesNodeGroupBucketsBucketActionsCase)

Example 9 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.

the class ElanItmUtils method getExternalTunnelItmEgressAction.

/**
 * Builds the list of actions to be taken when sending the packet over an
 * external VxLan tunnel interface, such as stamping the VNI on the VxLAN
 * header, setting the vlanId if it proceeds and output the packet over the
 * right port.
 *
 * @param srcDpnId
 *            Dpn where the tunnelInterface is located
 * @param torNode
 *            NodeId of the ExternalDevice where the packet must be sent to.
 * @param vni
 *            Vni to be stamped on the VxLAN Header.
 * @return the external itm egress action
 */
public List<Action> getExternalTunnelItmEgressAction(Uint64 srcDpnId, NodeId torNode, long vni) {
    List<Action> result = Collections.emptyList();
    GetExternalTunnelInterfaceNameInput input = new GetExternalTunnelInterfaceNameInputBuilder().setDestinationNode(torNode.getValue()).setSourceNode(srcDpnId.toString()).setTunnelType(TunnelTypeVxlan.class).build();
    Future<RpcResult<GetExternalTunnelInterfaceNameOutput>> output = itmRpcService.getExternalTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetExternalTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.debug("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, vni, false);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetExternalTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetExternalTunnelInterfaceNameInput) 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 10 with Sent

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.openconfig.extensions.rev180329.network.instance.protocol.bgp.neighbor_state.augmentation.messages.Sent in project netvirt by opendaylight.

the class ElanItmUtils method getInternalTunnelItmEgressAction.

/**
 * Builds the list of actions to be taken when sending the packet over an internal VxLAN tunnel interface, such
 * as setting the serviceTag/segmentationID on the VNI field of the VxLAN header, setting the vlanId if it proceeds
 * and output the packet over the right port.
 *
 * @param sourceDpnId
 *            Dpn where the tunnelInterface is located
 * @param destinationDpnId
 *            Dpn where the packet must be sent to. It is used here in order
 *            to select the right tunnel interface.
 * @param tunnelKey
 *            Tunnel key to be sent on the VxLAN header.
 * @return the internal itm egress action
 */
public List<Action> getInternalTunnelItmEgressAction(Uint64 sourceDpnId, Uint64 destinationDpnId, long tunnelKey) {
    List<Action> result = Collections.emptyList();
    LOG.trace("In getInternalItmEgressAction Action source {}, destination {}, serviceTag/Vni {}", sourceDpnId, destinationDpnId, tunnelKey);
    Class<? extends TunnelTypeBase> tunType = TunnelTypeVxlan.class;
    GetTunnelInterfaceNameInput input = new GetTunnelInterfaceNameInputBuilder().setDestinationDpid(destinationDpnId).setSourceDpid(sourceDpnId).setTunnelType(tunType).build();
    Future<RpcResult<GetTunnelInterfaceNameOutput>> output = itmRpcService.getTunnelInterfaceName(input);
    try {
        if (output.get().isSuccessful()) {
            GetTunnelInterfaceNameOutput tunnelInterfaceNameOutput = output.get().getResult();
            String tunnelIfaceName = tunnelInterfaceNameOutput.getInterfaceName();
            LOG.info("Received tunnelInterfaceName from getTunnelInterfaceName RPC {}", tunnelIfaceName);
            result = buildTunnelItmEgressActions(tunnelIfaceName, tunnelKey, true);
        } else {
            LOG.trace("Tunnel interface doesn't exist between srcDpId {} dstDpId {}", sourceDpnId, destinationDpnId);
        }
    } catch (InterruptedException | ExecutionException e) {
        LOG.error("Error in RPC call getTunnelInterfaceName", e);
    }
    return result;
}
Also used : Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) GetTunnelInterfaceNameInput(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInput) 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) GetTunnelInterfaceNameInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rpcs.rev160406.GetTunnelInterfaceNameInputBuilder) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

ArrayList (java.util.ArrayList)14 ExecutionException (java.util.concurrent.ExecutionException)13 Action (org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action)11 RpcResult (org.opendaylight.yangtools.yang.common.RpcResult)9 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)5 InstructionWriteMetadata (org.opendaylight.genius.mdsalutil.instructions.InstructionWriteMetadata)4 TunnelTypeVxlan (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.interfacemanager.rev160406.TunnelTypeVxlan)4 GotMapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.GotMapReply)4 MapReply (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.MapReply)4 MappingRecord (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.mapping.record.container.MappingRecord)4 UnknownHostException (java.net.UnknownHostException)3 Objects.requireNonNull (java.util.Objects.requireNonNull)3 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)3 VpnToDpnList (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnList)3 VpnToDpnListBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.VpnToDpnListBuilder)3 VpnInterfaces (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfaces)3 VpnInterfacesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.netvirt.l3vpn.rev130911.vpn.instance.op.data.vpn.instance.op.data.entry.vpn.to.dpn.list.VpnInterfacesBuilder)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 BigInteger (java.math.BigInteger)2 InetSocketAddress (java.net.InetSocketAddress)2