use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path 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());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImplTest method testFill.
@Test
public void testFill() throws Exception {
final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
final Flow flow = new FlowBuilder().setTableId((short) 1).setPriority(10).setCookie(new FlowCookie(BigInteger.TEN)).setId(new FlowId("HELLO")).build();
final Table table = new TableBuilder().setFlow(Collections.singletonList(flow)).build();
final FlowCapableNode flowCapableNode = new FlowCapableNodeBuilder().setTable(Collections.singletonList(table)).build();
final Map<FlowRegistryKey, FlowDescriptor> allFlowDescriptors = fillRegistry(path, flowCapableNode);
key = FlowRegistryKeyFactory.create(OFConstants.OFP_VERSION_1_3, flow);
InOrder order = inOrder(dataBroker, readOnlyTransaction);
order.verify(dataBroker).newReadOnlyTransaction();
order.verify(readOnlyTransaction).read(LogicalDatastoreType.CONFIGURATION, path);
order.verify(dataBroker).newReadOnlyTransaction();
order.verify(readOnlyTransaction).read(LogicalDatastoreType.OPERATIONAL, path);
assertTrue(allFlowDescriptors.containsKey(key));
deviceFlowRegistry.addMark(key);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path in project openflowplugin by opendaylight.
the class DeviceFlowRegistryImplTest method testFailedFill.
@Test
public void testFailedFill() throws Exception {
final InstanceIdentifier<FlowCapableNode> path = nodeInstanceIdentifier.augmentation(FlowCapableNode.class);
fillRegistry(path, null);
fillRegistry(path, new FlowCapableNodeBuilder().setTable(null).build());
fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(null)).build());
fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(null).build())).build());
fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(null)).build())).build());
fillRegistry(path, new FlowCapableNodeBuilder().setTable(Collections.singletonList(new TableBuilder().setFlow(Collections.singletonList(new FlowBuilder().setId(null).build())).build())).build());
verify(dataBroker, times(12)).newReadOnlyTransaction();
verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.CONFIGURATION, path);
verify(readOnlyTransaction, times(6)).read(LogicalDatastoreType.OPERATIONAL, path);
Assert.assertEquals(1, deviceFlowRegistry.getAllFlowDescriptors().size());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path in project openflowplugin by opendaylight.
the class NodeConnectorRefToPortTranslator method toNodeConnectorRef.
/**
* Converts {@link PacketIn} to {@link NodeConnectorRef}.
* @param packetIn Packet input
* @param dataPathId Data path id
* @return packet input converted to node connector reference
*/
@Nullable
public static NodeConnectorRef toNodeConnectorRef(@Nonnull PacketIn packetIn, BigInteger dataPathId) {
Preconditions.checkNotNull(packetIn);
NodeConnectorRef ref = null;
Long port = getPortNoFromPacketIn(packetIn);
if (port != null) {
OpenflowVersion version = OpenflowVersion.get(packetIn.getVersion());
ref = InventoryDataServiceUtil.nodeConnectorRefFromDatapathIdPortno(dataPathId, port, version);
}
return ref;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.pcep.ietf.stateful.rev171025.pcrpt.message.pcrpt.message.reports.Path in project openflowplugin by opendaylight.
the class OutputRegConvertor method convert.
@Override
public org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action convert(final Action input, final ActionPath path) {
NxActionOutputReg action = ((ActionOutputReg) input.getActionChoice()).getNxActionOutputReg();
SrcBuilder srcBuilder = new SrcBuilder();
srcBuilder.setSrcChoice(RegMoveConvertor.resolveSrcValue(action.getSrc()));
srcBuilder.setOfsNbits(action.getNBits());
NxOutputRegBuilder builder = new NxOutputRegBuilder();
builder.setSrc(srcBuilder.build());
builder.setMaxLen(action.getMaxLen());
return resolveAction(builder.build(), path);
}
Aggregations