Search in sources :

Example 96 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.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());
}
Also used : FlowKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowKey) Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) FlowRemovedBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.FlowRemovedBuilder) TableKey(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableKey) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) DeviceInfo(org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo) FlowRemovedMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowRemovedMessageBuilder) MatchBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.MatchBuilder) NotificationPublishService(org.opendaylight.controller.md.sal.binding.api.NotificationPublishService) Test(org.junit.Test)

Example 97 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.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);
}
Also used : Table(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.Table) InOrder(org.mockito.InOrder) FlowRegistryKey(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowRegistryKey) FlowDescriptor(org.opendaylight.openflowplugin.api.openflow.registry.flow.FlowDescriptor) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Flow(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow) FlowId(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowId) FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) Test(org.junit.Test)

Example 98 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.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());
}
Also used : FlowBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.FlowBuilder) FlowCapableNode(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode) FlowCapableNodeBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeBuilder) TableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.TableBuilder) Test(org.junit.Test)

Example 99 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.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;
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) OpenflowVersion(org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion) Nullable(javax.annotation.Nullable)

Example 100 with Path

use of org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.topology.pcep.rev171025.pcep.client.attributes.path.computation.client.reported.lsp.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);
}
Also used : NxActionOutputReg(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.output.reg.grouping.NxActionOutputReg) NxActionOutputReg(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.ofj.nx.action.output.reg.grouping.NxActionOutputReg) ActionOutputReg(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowjava.nx.action.rev140421.action.container.action.choice.ActionOutputReg) SrcBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.nx.output.reg.SrcBuilder) NxOutputRegBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.nicira.action.rev140714.nx.action.output.reg.grouping.NxOutputRegBuilder)

Aggregations

Test (org.junit.Test)45 ArrayList (java.util.ArrayList)42 WriteTransaction (org.opendaylight.controller.md.sal.binding.api.WriteTransaction)22 TransportZone (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZone)19 InstanceIdentifier (org.opendaylight.yangtools.yang.binding.InstanceIdentifier)19 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)18 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)17 ExecutionException (java.util.concurrent.ExecutionException)16 AttributesBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.AttributesBuilder)16 ByteBuf (io.netty.buffer.ByteBuf)15 ReadFailedException (org.opendaylight.controller.md.sal.common.api.data.ReadFailedException)15 TransportZones (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.TransportZones)15 Update (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.Update)15 List (java.util.List)14 DataBroker (org.opendaylight.controller.md.sal.binding.api.DataBroker)14 AsPathBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.bgp.message.rev171207.path.attributes.attributes.AsPathBuilder)14 Logger (org.slf4j.Logger)14 LoggerFactory (org.slf4j.LoggerFactory)14 TransportZoneKey (org.opendaylight.yang.gen.v1.urn.opendaylight.genius.itm.rev160406.transport.zones.TransportZoneKey)13 BigInteger (java.math.BigInteger)12