Search in sources :

Example 6 with PortModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.

the class PortModInputMessageFactoryTest method testPortModInput.

/**
 * Testing of {@link PortModInputMessageFactory} for correct translation from POJO.
 */
@Test
public void testPortModInput() throws Exception {
    PortModInputBuilder builder = new PortModInputBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setPortNo(new PortNumber(9L));
    builder.setHwAddress(new MacAddress("08:00:27:00:B0:EB"));
    builder.setConfig(new PortConfig(true, false, true, false));
    builder.setMask(new PortConfig(false, true, false, true));
    builder.setAdvertise(new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false));
    final PortModInput message = builder.build();
    ByteBuf out = UnpooledByteBufAllocator.DEFAULT.buffer();
    // simulate parent message
    out.writeInt(1);
    out.writeZero(2);
    out.writeShort(3);
    portModFactory.serialize(message, out);
    // read parent message
    out.readInt();
    out.skipBytes(2);
    out.readShort();
    BufferHelper.checkHeaderV13(out, MESSAGE_TYPE, MESSAGE_LENGTH);
    Assert.assertEquals("Wrong PortNo", message.getPortNo().getValue().longValue(), out.readUnsignedInt());
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_01);
    byte[] address = new byte[6];
    out.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddress().getValue(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue());
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_02);
    Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(out.readInt()));
    Assert.assertEquals("Wrong mask", message.getMask(), createPortConfig(out.readInt()));
    Assert.assertEquals("Wrong advertise", message.getAdvertise(), createPortFeatures(out.readInt()));
    out.skipBytes(PADDING_IN_PORT_MOD_MESSAGE_03);
}
Also used : PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) ByteBuf(io.netty.buffer.ByteBuf) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) Test(org.junit.Test)

Example 7 with PortModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.

the class OF10PortModInputMessageFactory method deserialize.

@Override
public PortModInput deserialize(final ByteBuf rawMessage) {
    PortModInputBuilder builder = new PortModInputBuilder();
    builder.setVersion((short) EncodeConstants.OF10_VERSION_ID);
    builder.setXid(rawMessage.readUnsignedInt());
    builder.setPortNo(new PortNumber((long) rawMessage.readUnsignedShort()));
    builder.setHwAddress(ByteBufUtils.readIetfMacAddress(rawMessage));
    builder.setConfigV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setMaskV10(createPortConfig(rawMessage.readUnsignedInt()));
    builder.setAdvertiseV10(createPortFeatures(rawMessage.readUnsignedInt()));
    return builder.build();
}
Also used : PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)

Example 8 with PortModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.

the class PortModInputMessageFactoryTest method test.

@Test
public void test() throws Exception {
    ByteBuf bb = BufferHelper.buildBuffer("00 00 00 09 00 00 00 00 08 00 27 00 " + "b0 eb 00 00 00 00 00 24 00 00 00 41 00 00 01 10 00 00 00 00");
    PortModInput deserializedMessage = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(deserializedMessage);
    // Test Message
    Assert.assertEquals("Wrong port", new PortNumber(9L), deserializedMessage.getPortNo());
    Assert.assertEquals("Wrong hwAddr", new MacAddress("08:00:27:00:b0:eb"), deserializedMessage.getHwAddress());
    Assert.assertEquals("Wrong config", new PortConfig(true, false, true, false), deserializedMessage.getConfig());
    Assert.assertEquals("Wrong mask", new PortConfig(false, true, false, true), deserializedMessage.getMask());
    Assert.assertEquals("Wrong advertise", new PortFeatures(true, false, false, false, false, false, false, true, false, false, false, false, false, false, false, false), deserializedMessage.getAdvertise());
}
Also used : PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) ByteBuf(io.netty.buffer.ByteBuf) PortNumber(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig) Test(org.junit.Test)

Example 9 with PortModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.

the class SalPortServiceImpl method buildRequest.

@Override
protected OfHeader buildRequest(final Xid xid, final UpdatePortInput input) throws ServiceException {
    final Optional<PortModInput> ofPortModInput = convertorExecutor.convert(getPortFromInput(input), data);
    final PortModInputBuilder mdInput = new PortModInputBuilder(ofPortModInput.orElse(PortConvertor.defaultResult(getVersion()))).setXid(xid.getValue());
    return mdInput.build();
}
Also used : PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder)

Example 10 with PortModInput

use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput in project openflowplugin by opendaylight.

the class PortConvertorTest method testtoPortModInputwithAllParameters.

/**
 * test of {@link PortConvertor#convert(Port, VersionConvertorData)} }.
 */
@Test
public void testtoPortModInputwithAllParameters() {
    PortBuilder portBld = new PortBuilder();
    portBld.setAdvertisedFeatures(features);
    portBld.setConfiguration(config);
    portBld.setPortNumber(new PortNumberUni(42L));
    portBld.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
    VersionConvertorData data = new VersionConvertorData(OFConstants.OFP_VERSION_1_3);
    final ConvertorManager convertorManager = ConvertorManagerFactory.createDefaultManager();
    Optional<PortModInput> portOutOptional = convertorManager.convert(portBld.build(), data);
    final PortModInput portOut = portOutOptional.orElse(PortConvertor.defaultResult(OFConstants.OFP_VERSION_1_3));
    PortConfigV10 portConfV10 = new PortConfigV10(false, false, false, false, true, true, false);
    PortModInputBuilder portModInputBld = new PortModInputBuilder();
    portModInputBld.setConfig(config31);
    portModInputBld.setMask(configMask31);
    portModInputBld.setPortNo(new org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber(42L));
    portModInputBld.setHwAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
    portModInputBld.setAdvertise(portf31);
    portModInputBld.setConfigV10(portConfV10);
    portModInputBld.setMaskV10(portConfMaskV10);
    portModInputBld.setAdvertiseV10(new PortFeaturesV10(null, null, null, null, null, null, null, true, null, null, null, null));
    portModInputBld.setVersion((short) EncodeConstants.OF13_VERSION_ID);
    Assert.assertEquals(portModInputBld.build(), portOut);
}
Also used : PortConfigV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10) PortFeaturesV10(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10) PortModInput(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) VersionConvertorData(org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData) PortBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder) PortModInputBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder) Test(org.junit.Test)

Aggregations

PortNumber (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortNumber)7 PortModInput (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInput)7 PortModInputBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortModInputBuilder)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 Test (org.junit.Test)5 ByteBuf (io.netty.buffer.ByteBuf)4 PortConfigV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfigV10)4 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)3 PortFeaturesV10 (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeaturesV10)3 PortBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.port.mod.port.PortBuilder)2 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)2 ConversionException (org.opendaylight.openflowplugin.extension.api.exception.ConversionException)1 VersionConvertorData (org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData)1 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)1 BundlePortModCaseBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.BundlePortModCaseBuilder)1 PortModCaseDataBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.bundle.add.message.grouping.bundle.inner.message.bundle.port.mod._case.PortModCaseDataBuilder)1