Search in sources :

Example 46 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class FlowConvertorTest method test.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void test() {
    RemoveFlowInputBuilder flowBuilder = new RemoveFlowInputBuilder();
    flowBuilder.setBarrier(false);
    flowBuilder.setCookie(new FlowCookie(new BigInteger("4")));
    flowBuilder.setCookieMask(new FlowCookie(new BigInteger("5")));
    flowBuilder.setTableId((short) 6);
    flowBuilder.setStrict(true);
    flowBuilder.setIdleTimeout(50);
    flowBuilder.setHardTimeout(500);
    flowBuilder.setPriority(40);
    flowBuilder.setBufferId(18L);
    flowBuilder.setOutPort(new BigInteger("65535"));
    flowBuilder.setOutGroup(5000L);
    flowBuilder.setFlags(null);
    flowBuilder.setMatch(null);
    RemoveFlowInput flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 4, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong cookie", 4, flowMod.get(0).getCookie().intValue());
    Assert.assertEquals("Wrong cookie mask", 5, flowMod.get(0).getCookieMask().intValue());
    Assert.assertEquals("Wrong table id", 6, flowMod.get(0).getTableId().getValue().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCDELETESTRICT, flowMod.get(0).getCommand());
    Assert.assertEquals("Wrong idle timeout", 50, flowMod.get(0).getIdleTimeout().intValue());
    Assert.assertEquals("Wrong hard timeout", 500, flowMod.get(0).getHardTimeout().intValue());
    Assert.assertEquals("Wrong priority", 40, flowMod.get(0).getPriority().intValue());
    Assert.assertEquals("Wrong buffer id", 18, flowMod.get(0).getBufferId().intValue());
    Assert.assertEquals("Wrong out port", 65535, flowMod.get(0).getOutPort().getValue().intValue());
    Assert.assertEquals("Wrong out group", 5000, flowMod.get(0).getOutGroup().intValue());
    Assert.assertEquals("Wrong flags", new FlowModFlags(false, false, false, false, false), flowMod.get(0).getFlags());
    Assert.assertEquals("Wrong match", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.OxmMatchType", flowMod.get(0).getMatch().getType().getName());
    Assert.assertEquals("Wrong match entries size", 0, flowMod.get(0).getMatch().getMatchEntry().size());
}
Also used : FlowCookie(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.FlowCookie) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) FlowModFlags(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.FlowModFlags) RemoveFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInput) RemoveFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.RemoveFlowInputBuilder) BigInteger(java.math.BigInteger) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) Test(org.junit.Test)

Example 47 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class FlowConvertorTest method testInstructionsTranslation.

/**
 * Tests {@link FlowConvertor#convert(Flow, VersionDatapathIdConvertorData)} }.
 */
@Test
public void testInstructionsTranslation() {
    InstructionBuilder instructionBuilder = new InstructionBuilder();
    GoToTableCaseBuilder goToCaseBuilder = new GoToTableCaseBuilder();
    GoToTableBuilder goToBuilder = new GoToTableBuilder();
    goToBuilder.setTableId((short) 1);
    goToCaseBuilder.setGoToTable(goToBuilder.build());
    instructionBuilder.setInstruction(goToCaseBuilder.build());
    instructionBuilder.setOrder(0);
    List<Instruction> instructions = new ArrayList<>();
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    WriteMetadataCaseBuilder metaCaseBuilder = new WriteMetadataCaseBuilder();
    WriteMetadataBuilder metaBuilder = new WriteMetadataBuilder();
    metaBuilder.setMetadata(new BigInteger("2"));
    metaBuilder.setMetadataMask(new BigInteger("3"));
    metaCaseBuilder.setWriteMetadata(metaBuilder.build());
    instructionBuilder.setInstruction(metaCaseBuilder.build());
    instructionBuilder.setOrder(1);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    WriteActionsCaseBuilder writeCaseBuilder = new WriteActionsCaseBuilder();
    WriteActionsBuilder writeBuilder = new WriteActionsBuilder();
    List<Action> actions = new ArrayList<>();
    writeBuilder.setAction(actions);
    writeCaseBuilder.setWriteActions(writeBuilder.build());
    instructionBuilder.setInstruction(writeCaseBuilder.build());
    instructionBuilder.setOrder(2);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    ApplyActionsCaseBuilder applyCaseBuilder = new ApplyActionsCaseBuilder();
    ApplyActionsBuilder applyBuilder = new ApplyActionsBuilder();
    actions = new ArrayList<>();
    applyBuilder.setAction(actions);
    applyCaseBuilder.setApplyActions(applyBuilder.build());
    instructionBuilder.setInstruction(applyCaseBuilder.build());
    instructionBuilder.setOrder(3);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    ClearActionsCaseBuilder clearCaseBuilder = new ClearActionsCaseBuilder();
    ClearActionsBuilder clearBuilder = new ClearActionsBuilder();
    actions = new ArrayList<>();
    clearBuilder.setAction(actions);
    clearCaseBuilder.setClearActions(clearBuilder.build());
    instructionBuilder.setInstruction(clearCaseBuilder.build());
    instructionBuilder.setOrder(4);
    instructions.add(instructionBuilder.build());
    instructionBuilder = new InstructionBuilder();
    MeterCaseBuilder meterCaseBuilder = new MeterCaseBuilder();
    MeterBuilder meterBuilder = new MeterBuilder();
    meterBuilder.setMeterId(new MeterId(5L));
    meterCaseBuilder.setMeter(meterBuilder.build());
    instructionBuilder.setInstruction(meterCaseBuilder.build());
    instructionBuilder.setOrder(5);
    instructions.add(instructionBuilder.build());
    InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
    instructionsBuilder.setInstruction(instructions);
    AddFlowInputBuilder flowBuilder = new AddFlowInputBuilder();
    flowBuilder.setInstructions(instructionsBuilder.build());
    AddFlowInput flow = flowBuilder.build();
    VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_0);
    data.setDatapathId(new BigInteger("42"));
    List<FlowModInputBuilder> flowMod = convert(flow, data);
    Assert.assertEquals("Wrong version", 1, flowMod.get(0).getVersion().intValue());
    Assert.assertEquals("Wrong command", FlowModCommand.OFPFCADD, flowMod.get(0).getCommand());
    Assert.assertEquals("Wrong instructions size", 6, flowMod.get(0).getInstruction().size());
    org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instructions.grouping.Instruction instruction = flowMod.get(0).getInstruction().get(0);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    GotoTableCase gotoTableCase = (GotoTableCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong table id", 1, gotoTableCase.getGotoTable().getTableId().intValue());
    instruction = flowMod.get(0).getInstruction().get(1);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    WriteMetadataCase writeMetadataCase = (WriteMetadataCase) instruction.getInstructionChoice();
    Assert.assertArrayEquals("Wrong metadata", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, writeMetadataCase.getWriteMetadata().getMetadata());
    Assert.assertArrayEquals("Wrong metadata mask", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, writeMetadataCase.getWriteMetadata().getMetadataMask());
    instruction = flowMod.get(0).getInstruction().get(2);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    WriteActionsCase writeActionsCase = (WriteActionsCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong actions size", 0, writeActionsCase.getWriteActions().getAction().size());
    instruction = flowMod.get(0).getInstruction().get(3);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    ApplyActionsCase applyActionsCase = (ApplyActionsCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong actions size", 0, applyActionsCase.getApplyActions().getAction().size());
    instruction = flowMod.get(0).getInstruction().get(4);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.ClearActionsCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    instruction = flowMod.get(0).getInstruction().get(5);
    Assert.assertEquals("Wrong type", "org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common" + ".instruction.rev130731.instruction.grouping.instruction.choice.MeterCase", instruction.getInstructionChoice().getImplementedInterface().getName());
    MeterCase meterCase = (MeterCase) instruction.getInstructionChoice();
    Assert.assertEquals("Wrong meter id", 5, meterCase.getMeter().getMeterId().intValue());
}
Also used : MeterBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.meter._case.MeterBuilder) InstructionBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.InstructionBuilder) Action(org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action) VersionDatapathIdConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData) WriteMetadataCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteMetadataCaseBuilder) WriteMetadataCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteMetadataCase) MeterCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.MeterCase) ArrayList(java.util.ArrayList) AddFlowInput(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInput) WriteActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.WriteActionsCase) Instruction(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.list.Instruction) WriteMetadataBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.metadata._case.WriteMetadataBuilder) MeterId(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId) InstructionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.InstructionsBuilder) ApplyActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ApplyActionsCaseBuilder) AddFlowInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.service.rev130819.AddFlowInputBuilder) ClearActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.ClearActionsCaseBuilder) ApplyActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.apply.actions._case.ApplyActionsBuilder) GoToTableBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.go.to.table._case.GoToTableBuilder) MeterCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.MeterCaseBuilder) GotoTableCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.GotoTableCase) WriteActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.write.actions._case.WriteActionsBuilder) WriteActionsCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.WriteActionsCaseBuilder) ClearActionsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.clear.actions._case.ClearActionsBuilder) GoToTableCaseBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.instruction.instruction.GoToTableCaseBuilder) FlowModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.FlowModInputBuilder) BigInteger(java.math.BigInteger) ApplyActionsCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.instruction.rev130731.instruction.grouping.instruction.choice.ApplyActionsCase) Test(org.junit.Test)

Example 48 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MeterConfigStatsResponseConvertorTest method testToSALMeterConfigList.

@Test
public /**
 * Test of basic mapping functionality of {@link MeterConfigStatsResponseConvertor#convert(java.util.List)} }
 */
void testToSALMeterConfigList() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<List<MeterConfigStats>> meterConfigsOptional = convertorManager.convert(createMeterConfigList(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    List<MeterConfigStats> meterConfigs = meterConfigsOptional.orElse(Collections.emptyList());
    assertEquals(PRESET_COUNT, meterConfigs.size());
    int cnt = 0;
    for (MeterConfigStats meterConfigStats : meterConfigs) {
        assertEquals(new Long(cnt), meterConfigStats.getMeterId().getValue());
        assertTrue(meterConfigStats.getFlags().isMeterBurst());
        assertFalse(meterConfigStats.getFlags().isMeterKbps());
        assertTrue(meterConfigStats.getFlags().isMeterPktps());
        assertFalse(meterConfigStats.getFlags().isMeterStats());
        cnt++;
    }
}
Also used : VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) ArrayList(java.util.ArrayList) List(java.util.List) MeterConfigStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.config.stats.reply.MeterConfigStats) Test(org.junit.Test)

Example 49 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class MeterStatsResponseConvertorTest method testToSALMeterStatsList.

@Test
public /**
 * Test of basic mapping functionality of {@link MeterStatsResponseConvertor#convert(java.util.List)}
 */
void testToSALMeterStatsList() {
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<List<MeterStats>> meterStatsListOptional = convertorManager.convert(createMeterStatsLit(), new VersionConvertorData(OFConstants.OFP_VERSION_1_3));
    List<MeterStats> meterStatsList = meterStatsListOptional.orElse(Collections.emptyList());
    assertEquals(PRESET_COUNT, meterStatsList.size());
    int cnt = 0;
    for (MeterStats meterStats : meterStatsList) {
        assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getKey().getMeterId());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
        assertEquals(new Long(1000 * cnt), meterStats.getDuration().getNanosecond().getValue());
        assertEquals(new Long(10 * cnt), meterStats.getDuration().getSecond().getValue());
        assertEquals(new Long(cnt), meterStats.getFlowCount().getValue());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getByteInCount().getValue());
        assertEquals(PRESET_COUNT, meterStats.getMeterBandStats().getBandStat().size());
        int bandStatCount = 0;
        for (BandStat bandStat : meterStats.getMeterBandStats().getBandStat()) {
            assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getByteBandCount().getValue());
            assertEquals(BigInteger.valueOf(bandStatCount), bandStat.getPacketBandCount().getValue());
            bandStatCount++;
        }
        assertEquals(new MeterStatsKey(new org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterId((long) cnt)).getMeterId(), meterStats.getMeterId());
        assertEquals(BigInteger.valueOf(cnt), meterStats.getPacketInCount().getValue());
        cnt++;
    }
}
Also used : MeterStatsKey(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStatsKey) BandStat(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.meter.band.stats.BandStat) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) MeterStats(org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.meter.statistics.reply.MeterStats) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Example 50 with Link

use of org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Link in project openflowplugin by opendaylight.

the class PacketUtils method createNodeConnRef.

/**
 * Returns the port wrapped into {@link NodeConnectorRef}.
 */
public static NodeConnectorRef createNodeConnRef(final InstanceIdentifier<Node> nodeInstId, final NodeKey nodeKey, final String port) {
    StringBuilder builder = new StringBuilder(nodeKey.getId().getValue()).append(':').append(port);
    NodeConnectorKey connKey = new NodeConnectorKey(new NodeConnectorId(builder.toString()));
    InstanceIdentifier<NodeConnector> portPath = nodeInstId.child(NodeConnector.class, connKey);
    return new NodeConnectorRef(portPath);
}
Also used : NodeConnectorRef(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorRef) NodeConnector(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnector) NodeConnectorId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeConnectorId) NodeConnectorKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.node.NodeConnectorKey)

Aggregations

Test (org.junit.Test)454 ByteBuf (io.netty.buffer.ByteBuf)138 ArrayList (java.util.ArrayList)71 BigInteger (java.math.BigInteger)58 Eid (org.opendaylight.yang.gen.v1.urn.opendaylight.lfm.lisp.proto.rev151105.eid.container.Eid)54 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)51 Ipv4Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv4Address)45 VersionDatapathIdConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData)38 Ipv6Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.Ipv6Address)37 IpAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress)35 MatchEntry (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.oxm.rev150225.match.entries.grouping.MatchEntry)35 InetAddress (java.net.InetAddress)33 SimpleAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.SimpleAddress)33 MappingData (org.opendaylight.lispflowmapping.lisp.type.MappingData)32 MultipartReplyMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage)28 Inet4Address (java.net.Inet4Address)27 Inet6Address (java.net.Inet6Address)27 NoAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.address.NoAddress)27 LispAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.LispAddress)26 Address (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.lisp.address.types.rev151105.lisp.address.Address)26