use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SalToOfIpv4MatchArbitraryBitMaskCase method process.
@Override
public Optional<List<MatchEntry>> process(@Nonnull Ipv4MatchArbitraryBitMask source, VersionConvertorData data, ConvertorExecutor convertorExecutor) {
List<MatchEntry> result = new ArrayList<>();
if (source.getIpv4SourceAddressNoMask() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Src.class);
Ipv4SrcBuilder ipv4SrcBuilder = new Ipv4SrcBuilder();
ipv4SrcBuilder.setIpv4Address(source.getIpv4SourceAddressNoMask());
DottedQuad sourceArbitrarySubNetMask = source.getIpv4SourceArbitraryBitmask();
boolean hasMask = false;
if (sourceArbitrarySubNetMask != null) {
byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(sourceArbitrarySubNetMask);
if (maskByteArray != null) {
ipv4SrcBuilder.setMask(maskByteArray);
hasMask = true;
}
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4SrcCaseBuilder ipv4SrcCaseBuilder = new Ipv4SrcCaseBuilder();
ipv4SrcCaseBuilder.setIpv4Src(ipv4SrcBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4SrcCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
if (source.getIpv4DestinationAddressNoMask() != null) {
MatchEntryBuilder matchEntryBuilder = new MatchEntryBuilder();
matchEntryBuilder.setOxmClass(OpenflowBasicClass.class);
matchEntryBuilder.setOxmMatchField(Ipv4Dst.class);
Ipv4DstBuilder ipv4DstBuilder = new Ipv4DstBuilder();
ipv4DstBuilder.setIpv4Address(source.getIpv4DestinationAddressNoMask());
DottedQuad destArbitrarySubNetMask = source.getIpv4DestinationArbitraryBitmask();
boolean hasMask = false;
if (destArbitrarySubNetMask != null) {
byte[] maskByteArray = IpConversionUtil.convertArbitraryMaskToByteArray(destArbitrarySubNetMask);
if (maskByteArray != null) {
ipv4DstBuilder.setMask(maskByteArray);
hasMask = true;
}
}
matchEntryBuilder.setHasMask(hasMask);
Ipv4DstCaseBuilder ipv4DstCaseBuilder = new Ipv4DstCaseBuilder();
ipv4DstCaseBuilder.setIpv4Dst(ipv4DstBuilder.build());
matchEntryBuilder.setMatchEntryValue(ipv4DstCaseBuilder.build());
result.add(matchEntryBuilder.build());
}
return Optional.of(result);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class ForwardingRulesManagerImpl method checkNodeInOperationalDataStore.
@Override
public boolean checkNodeInOperationalDataStore(InstanceIdentifier<FlowCapableNode> ident) {
boolean result = false;
InstanceIdentifier<Node> nodeIid = ident.firstIdentifierOf(Node.class);
final ReadOnlyTransaction transaction = dataService.newReadOnlyTransaction();
CheckedFuture<com.google.common.base.Optional<Node>, ReadFailedException> future = transaction.read(LogicalDatastoreType.OPERATIONAL, nodeIid);
try {
com.google.common.base.Optional<Node> optionalDataObject = future.checkedGet();
if (optionalDataObject.isPresent()) {
result = true;
} else {
LOG.debug("{}: Failed to read {}", Thread.currentThread().getStackTrace()[1], nodeIid);
}
} catch (ReadFailedException e) {
LOG.warn("Failed to read {} ", nodeIid, e);
}
transaction.close();
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SyncPlanPushStrategyIncrementalImpl method addMissingGroups.
ListenableFuture<RpcResult<Void>> addMissingGroups(final NodeId nodeId, final InstanceIdentifier<FlowCapableNode> nodeIdent, final List<ItemSyncBox<Group>> groupsAddPlan, final SyncCrudCounters counters) {
if (groupsAddPlan.isEmpty()) {
LOG.trace("no groups configured for node: {} -> SKIPPING", nodeId.getValue());
return RpcResultBuilder.<Void>success().buildFuture();
}
ListenableFuture<RpcResult<Void>> chainedResult;
try {
if (!groupsAddPlan.isEmpty()) {
final CrudCounts groupCrudCounts = counters.getGroupCrudCounts();
groupCrudCounts.setAdded(ReconcileUtil.countTotalPushed(groupsAddPlan));
groupCrudCounts.setUpdated(ReconcileUtil.countTotalUpdated(groupsAddPlan));
if (LOG.isDebugEnabled()) {
LOG.debug("adding groups: planSteps={}, toAddTotal={}, toUpdateTotal={}", groupsAddPlan.size(), groupCrudCounts.getAdded(), groupCrudCounts.getUpdated());
}
chainedResult = flushAddGroupPortionAndBarrier(nodeIdent, groupsAddPlan.get(0));
for (final ItemSyncBox<Group> groupsPortion : Iterables.skip(groupsAddPlan, 1)) {
chainedResult = Futures.transformAsync(chainedResult, input -> {
final ListenableFuture<RpcResult<Void>> result;
if (input.isSuccessful()) {
result = flushAddGroupPortionAndBarrier(nodeIdent, groupsPortion);
} else {
// pass through original unsuccessful rpcResult
result = Futures.immediateFuture(input);
}
return result;
}, MoreExecutors.directExecutor());
}
} else {
chainedResult = RpcResultBuilder.<Void>success().buildFuture();
}
} catch (IllegalStateException e) {
chainedResult = RpcResultBuilder.<Void>failed().withError(RpcError.ErrorType.APPLICATION, "failed to add missing groups", e).buildFuture();
}
return chainedResult;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class SimplifiedOperationalListener method processNodeModification.
/**
* Update cache, register for device mastership when device connected and start reconciliation if device
* is registered and actual modification is consistent.Skip the event otherwise.
*/
@Override
protected Optional<ListenableFuture<Boolean>> processNodeModification(final DataTreeModification<Node> modification) {
Optional<ListenableFuture<Boolean>> result;
final NodeId nodeId = ModificationUtil.nodeId(modification);
final DataObjectModification<Node> nodeModification = modification.getRootNode();
if (isDelete(nodeModification) || isDeleteLogical(nodeModification)) {
operationalSnapshot.updateCache(nodeId, Optional.absent());
deviceMastershipManager.onDeviceDisconnected(nodeId);
result = skipModification(modification);
} else {
operationalSnapshot.updateCache(nodeId, Optional.fromNullable(ModificationUtil.flowCapableNodeAfter(modification)));
final boolean isAdd = isAdd(nodeModification) || isAddLogical(nodeModification);
if (isAdd) {
deviceMastershipManager.onDeviceConnected(nodeId);
}
// one step on startup
if (reconciliationRegistry.isRegistered(nodeId) && (isAdd || isConsistentForReconcile(modification))) {
result = reconciliation(modification);
} else {
result = skipModification(modification);
}
}
return result;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.types.rev181109.pcrep.message.pcrep.message.replies.Result in project openflowplugin by opendaylight.
the class DeviceContextImplTest method testProcessFlowRemovedMessage.
@Test
public void testProcessFlowRemovedMessage() throws Exception {
// prepare translation result
final FlowRemovedBuilder flowRemovedMdsalBld = new FlowRemovedBuilder().setTableId((short) 0).setPriority(42).setCookie(new FlowCookie(BigInteger.ONE)).setMatch(new MatchBuilder().build());
final NotificationPublishService mockedNotificationPublishService = mock(NotificationPublishService.class);
Mockito.when(messageTranslatorFlowRemoved.translate(any(Object.class), any(DeviceInfo.class), any(Object.class))).thenReturn(flowRemovedMdsalBld.build());
// insert flow+flowId into local registry
final FlowRegistryKey flowRegKey = FlowRegistryKeyFactory.create(deviceInfo.getVersion(), flowRemovedMdsalBld.build());
final FlowDescriptor flowDescriptor = FlowDescriptorFactory.create((short) 0, new FlowId("ut-ofp:f456"));
deviceContext.getDeviceFlowRegistry().storeDescriptor(flowRegKey, flowDescriptor);
// prepare empty input message
final FlowRemovedMessageBuilder flowRemovedBld = new FlowRemovedMessageBuilder();
// prepare path to flow to be removed
final KeyedInstanceIdentifier<Flow, FlowKey> flowToBeRemovedPath = nodeKeyIdent.augmentation(FlowCapableNode.class).child(Table.class, new TableKey((short) 0)).child(Flow.class, new FlowKey(new FlowId("ut-ofp:f456")));
deviceContext.setNotificationPublishService(mockedNotificationPublishService);
deviceContext.processFlowRemovedMessage(flowRemovedBld.build());
}
Aggregations