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;
}
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);
}
}
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);
}
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;
}
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;
}
Aggregations