Search in sources :

Example 6 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class OF10DeviceInitializerTest method setUp.

@Before
public void setUp() throws Exception {
    final KeyedInstanceIdentifier<Node, NodeKey> nodeInstanceIdentifier = DeviceStateUtil.createNodeInstanceIdentifier(new NodeId("openflow:1"));
    deviceInitializer = new OF10DeviceInitializer();
    when(featuresReply.getCapabilitiesV10()).thenReturn(capabilitiesV10);
    when(featuresReply.getPhyPort()).thenReturn(Collections.singletonList(new PhyPortBuilder().setPortNo(42L).build()));
    when(connectionContext.getFeatures()).thenReturn(featuresReply);
    when(connectionContext.getOutboundQueueProvider()).thenReturn(outboundQueueProvider);
    when(deviceContext.getDeviceState()).thenReturn(deviceState);
    when(deviceInfo.getNodeInstanceIdentifier()).thenReturn(nodeInstanceIdentifier);
    when(deviceContext.getDeviceInfo()).thenReturn(deviceInfo);
    when(deviceContext.getMessageSpy()).thenReturn(messageSpy);
    when(translatorLibrary.lookupTranslator(any())).thenReturn(messageTranslator);
    when(deviceContext.oook()).thenReturn(translatorLibrary);
    when(requestContext.getXid()).thenReturn(new Xid(42L));
    when(requestContext.getFuture()).thenReturn(RpcResultBuilder.success().buildFuture());
    when(deviceContext.createRequestContext()).thenReturn(requestContext);
    when(deviceContext.getPrimaryConnectionContext()).thenReturn(connectionContext);
}
Also used : Xid(org.opendaylight.openflowplugin.api.openflow.device.Xid) PhyPortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPortBuilder) Node(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node) NodeId(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId) NodeKey(org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey) Before(org.junit.Before)

Example 7 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    GetFeaturesOutputBuilder builder = new GetFeaturesOutputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF10_VERSION_ID);
    builder.setDatapathId(BigInteger.valueOf(1L));
    builder.setBuffers(1L);
    builder.setTables((short) 1);
    builder.setCapabilitiesV10(new CapabilitiesV10(true, false, true, false, true, false, true, false));
    builder.setActionsV10(new ActionTypeV10(true, false, true, false, true, false, true, false, true, false, true, false, true));
    builder.setPhyPort(createPorts());
    GetFeaturesOutput message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV10(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong datapath id", message.getDatapathId().longValue(), serializedBuffer.readLong());
    Assert.assertEquals("Wrong n buffers", message.getBuffers().longValue(), serializedBuffer.readUnsignedInt());
    Assert.assertEquals("Wrong n tables", message.getTables().shortValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(3);
    Assert.assertEquals("Wrong capabilities", message.getCapabilitiesV10(), createCapabilities(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong actions", message.getActionsV10(), createActionsV10(serializedBuffer.readInt()));
    PhyPort port = message.getPhyPort().get(0);
    Assert.assertEquals("Wrong port No", port.getPortNo().intValue(), serializedBuffer.readShort());
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", port.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", port.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", port.getConfigV10(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", port.getStateV10(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", port.getCurrentFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", port.getAdvertisedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", port.getSupportedFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", port.getPeerFeaturesV10(), createPortFeatures(serializedBuffer.readInt()));
}
Also used : GetFeaturesOutputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutputBuilder) ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) ByteBuf(io.netty.buffer.ByteBuf) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 8 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method test.

/**
 * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 FF 00 00 0F FF " + "00 10 01 01 05 01 04 02 41 4C 4F 48 41 00 00 00 00 00 00 00 00 00 00 00 00 00 00 7F 00 00 02 00 " + "00 00 0F FF 00 00 00 00 00 00 03 0C 00 00 08 88");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong datapathId", 0x0001020304050607L, builtByFactory.getDatapathId().longValue());
    Assert.assertEquals("Wrong n-buffers", 0x00010203L, builtByFactory.getBuffers().longValue());
    Assert.assertEquals("Wrong n-tables", 0x01, builtByFactory.getTables().shortValue());
    Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(true, true, true, true, true, true, true, true), builtByFactory.getCapabilitiesV10());
    Assert.assertEquals("Wrong actions", new ActionTypeV10(true, true, true, true, true, true, true, true, true, true, true, true, false), builtByFactory.getActionsV10());
    PhyPort port = builtByFactory.getPhyPort().get(0);
    Assert.assertEquals("Wrong port - port-no", 16, port.getPortNo().intValue());
    Assert.assertEquals("Wrong port - hw-addr", new MacAddress("01:01:05:01:04:02"), port.getHwAddr());
    Assert.assertEquals("Wrong port - name", new String("ALOHA"), port.getName());
    Assert.assertEquals("Wrong port - config", new PortConfigV10(true, true, true, true, true, true, true), port.getConfigV10());
    Assert.assertEquals("Wrong port - state", new PortStateV10(false, false, false, false, true, false, true, false), port.getStateV10());
    Assert.assertEquals("Wrong port - curr", new PortFeaturesV10(true, true, true, true, true, true, true, true, true, true, true, true), port.getCurrentFeaturesV10());
    Assert.assertEquals("Wrong port - advertised", new PortFeaturesV10(false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeaturesV10());
    Assert.assertEquals("Wrong port - supported", new PortFeaturesV10(true, true, false, false, false, false, false, true, false, true, false, false), port.getSupportedFeaturesV10());
    Assert.assertEquals("Wrong port - peer", new PortFeaturesV10(true, false, false, false, false, false, false, false, true, false, false, true), port.getPeerFeaturesV10());
}
Also used : ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortStateV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortStateV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PhyPort(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort) ByteBuf(io.netty.buffer.ByteBuf) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) Test(org.junit.Test)

Example 9 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class OF10FeaturesReplyMessageFactoryTest method testWithNoPortsSet.

/**
 * Testing {@link OF10FeaturesReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testWithNoPortsSet() {
    ByteBuf bb = BufferHelper.buildBuffer("00 01 02 03 04 05 06 07 00 01 02 03 01 00 00 00 " + "00 00 00 00 00 00 00 00");
    GetFeaturesOutput builtByFactory = BufferHelper.deserialize(featuresFactory, bb);
    BufferHelper.checkHeaderV10(builtByFactory);
    Assert.assertEquals("Wrong capabilities", new CapabilitiesV10(false, false, false, false, false, false, false, false), builtByFactory.getCapabilitiesV10());
    Assert.assertEquals("Wrong actions", new ActionTypeV10(false, false, false, false, false, false, false, false, false, false, false, false, false), builtByFactory.getActionsV10());
    Assert.assertEquals("Wrong ports size", 0, builtByFactory.getPhyPort().size());
}
Also used : ActionTypeV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10) GetFeaturesOutput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput) ByteBuf(io.netty.buffer.ByteBuf) CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10) Test(org.junit.Test)

Example 10 with CapabilitiesV10

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10 in project openflowplugin by opendaylight.

the class SwitchFeaturesUtilTest method testSwFeaturesCapabilitiesMalformed.

/**
 * Test method for
 * {@link SwitchFeaturesUtil#buildSwitchFeatures} for malformed switch feature capabilities
 * - at least one feature is null
 * .
 */
// @Test TODO:do we need to check if capability is null?
public void testSwFeaturesCapabilitiesMalformed() {
    CapabilitiesV10 capabilities = new CapabilitiesV10(true, false, true, false, true, false, true, null);
    featuresOutputBuilder.setCapabilitiesV10(capabilities).setCapabilities(null).setVersion((short) 1);
    Assert.assertNull(swUtil.buildSwitchFeatures(featuresOutputBuilder.build()));
}
Also used : CapabilitiesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)

Aggregations

CapabilitiesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.CapabilitiesV10)9 Test (org.junit.Test)7 ByteBuf (io.netty.buffer.ByteBuf)3 ActionTypeV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionTypeV10)3 GetFeaturesOutput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.GetFeaturesOutput)3 Before (org.junit.Before)2 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)2 PhyPort (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.features.reply.PhyPort)2 HashedWheelTimer (io.netty.util.HashedWheelTimer)1 Nullable (javax.annotation.Nullable)1 TransactionChainListener (org.opendaylight.controller.md.sal.common.api.data.TransactionChainListener)1 ConnectionContext (org.opendaylight.openflowplugin.api.openflow.connection.ConnectionContext)1 DeviceInfo (org.opendaylight.openflowplugin.api.openflow.device.DeviceInfo)1 DeviceState (org.opendaylight.openflowplugin.api.openflow.device.DeviceState)1 Xid (org.opendaylight.openflowplugin.api.openflow.device.Xid)1 NodeId (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.NodeId)1 Node (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node)1 NodeKey (org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey)1 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)1 PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)1