Search in sources :

Example 6 with PortState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState in project openflowplugin by opendaylight.

the class NodeConnectorInventoryEventTranslator method isPortDown.

private static boolean isPortDown(final FlowCapableNodeConnector flowCapableNodeConnector) {
    PortState portState = flowCapableNodeConnector.getState();
    PortConfig portConfig = flowCapableNodeConnector.getConfiguration();
    return portState != null && portState.isLinkDown() || portConfig != null && portConfig.isPORTDOWN();
}
Also used : PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState) PortConfig(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig)

Example 7 with PortState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState in project openflowplugin by opendaylight.

the class PortStatusMessageFactoryTest method test.

/**
 * Testing {@link PortStatusMessageFactory} for correct translation into POJO.
 */
@Test
public void test() {
    ByteBuf bb = BufferHelper.buildBuffer(// reason
    "01 " + // padding
    "00 00 00 00 00 00 00 " + // port no
    "00 01 02 03 " + // padding in ofp_port1
    "00 00 00 00 " + // mac address
    "08 00 27 00 B0 EB " + // padding in ofp_port2
    "00 00 " + // port name, String "s1-eth1"
    "73 31 2d 65 74 68 31 00 00 00 00 00 00 00 00 00 " + // port config
    "00 00 00 41 " + // port state
    "00 00 00 05 " + // current features
    "00 00 00 81 " + // advertised features
    "00 00 00 A1 " + // supported features
    "00 00 00 B1 " + // peer features
    "00 00 00 81 " + // curr speed
    "00 00 00 81 " + // max speed
    "00 00 00 80");
    PortStatusMessage builtByFactory = BufferHelper.deserialize(statusFactory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong reason", 0x01, builtByFactory.getReason().getIntValue());
    Assert.assertEquals("Wrong portNumber", 66051L, builtByFactory.getPortNo().longValue());
    Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), builtByFactory.getHwAddr());
    Assert.assertEquals("Wrong name", "s1-eth1", builtByFactory.getName());
    Assert.assertEquals("Wrong portConfig", new PortConfig(false, true, false, true), builtByFactory.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(false, true, true), builtByFactory.getState());
    Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getCurrentFeatures());
    Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, true, true, false, false, true, false, false, false, false, false, false), builtByFactory.getAdvertisedFeatures());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, true, true, true, false, true, false, false, false, false, false, false), builtByFactory.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), builtByFactory.getPeerFeatures());
    Assert.assertEquals("Wrong currSpeed", 129L, builtByFactory.getCurrSpeed().longValue());
    Assert.assertEquals("Wrong maxSpeed", 128L, builtByFactory.getMaxSpeed().longValue());
}
Also used : PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) ByteBuf(io.netty.buffer.ByteBuf) 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 8 with PortState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState in project openflowplugin by opendaylight.

the class MultipartReplyPortDescTest method testMultipartReplyPortDesc.

/**
 * Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
 */
@Test
public void testMultipartReplyPortDesc() {
    ByteBuf bb = BufferHelper.buildBuffer(// 
    "00 0D 00 00 00 00 00 00 " + // first port desc
    "00 01 02 03 00 00 00 00 " + // portNo, padding
    "08 00 27 00 B0 EB 00 00 " + // mac address, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
    "00 00 00 65 " + // port config
    "00 00 00 07 " + // port state
    "00 00 00 81 " + // current features
    "00 00 FF FF " + // advertised features
    "00 00 C1 89 " + // supported features
    "00 00 C5 8D " + // peer features
    "00 00 00 81 " + // curr speed
    "00 00 00 80 " + // second port desc
    "00 00 00 01 00 00 00 00 " + // portNo, padding
    "08 00 27 00 B0 EB 00 00 " + // mac address, padding
    "4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 " + // name
    "00 00 00 00 " + // port config
    "00 00 00 00 " + // port state
    "00 00 00 00 " + // current features
    "00 00 00 00 " + // advertised features
    "00 00 00 00 " + // supported features
    "00 00 00 00 " + // peer features
    "00 00 00 05 " + // curr speed
    "00 00 00 06");
    MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
    BufferHelper.checkHeaderV13(builtByFactory);
    Assert.assertEquals("Wrong type", 13, builtByFactory.getType().getIntValue());
    Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
    MultipartReplyPortDescCase messageCase = (MultipartReplyPortDescCase) builtByFactory.getMultipartReplyBody();
    MultipartReplyPortDesc message = messageCase.getMultipartReplyPortDesc();
    Assert.assertEquals("Wrong port desc size", 2, message.getPorts().size());
    Ports port = message.getPorts().get(0);
    Assert.assertEquals("Wrong portNo", 66051L, port.getPortNo().longValue());
    Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
    Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
    Assert.assertEquals("Wrong portConfig", new PortConfig(true, true, true, true), port.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(true, true, true), port.getState());
    Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, false), port.getCurrentFeatures());
    Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true), port.getAdvertisedFeatures());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(true, true, false, false, false, true, false, false, false, true, false, false, false, false, true, true), port.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(true, true, true, false, false, true, false, false, false, true, false, false, false, true, true, true), port.getPeerFeatures());
    Assert.assertEquals("Wrong currSpeed", 129L, port.getCurrSpeed().longValue());
    Assert.assertEquals("Wrong maxSpeed", 128L, port.getMaxSpeed().longValue());
    port = message.getPorts().get(1);
    Assert.assertEquals("Wrong portNo", 1L, port.getPortNo().longValue());
    Assert.assertEquals("Wrong macAddress", new MacAddress("08:00:27:00:b0:eb"), port.getHwAddr());
    Assert.assertEquals("Wrong portName", "Opendaylight", port.getName());
    Assert.assertEquals("Wrong portConfig", new PortConfig(false, false, false, false), port.getConfig());
    Assert.assertEquals("Wrong portState", new PortState(false, false, false), port.getState());
    Assert.assertEquals("Wrong currentFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getCurrentFeatures());
    Assert.assertEquals("Wrong advertisedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getAdvertisedFeatures());
    Assert.assertEquals("Wrong supportedFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getSupportedFeatures());
    Assert.assertEquals("Wrong peerFeatures", new PortFeatures(false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false), port.getPeerFeatures());
    Assert.assertEquals("Wrong currSpeed", 5L, port.getCurrSpeed().longValue());
    Assert.assertEquals("Wrong maxSpeed", 6L, port.getMaxSpeed().longValue());
}
Also used : MultipartReplyPortDescCase(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.MultipartReplyPortDescCase) MultipartReplyMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.MultipartReplyMessage) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MultipartReplyPortDesc(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.MultipartReplyPortDesc) ByteBuf(io.netty.buffer.ByteBuf) 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 PortState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState in project openflowplugin by opendaylight.

the class PortStatusMessageFactoryTest method testSerialize.

@Test
public void testSerialize() throws Exception {
    PortStatusMessageBuilder builder = new PortStatusMessageBuilder();
    BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
    builder.setReason(PortReason.forValue(1));
    builder.setPortNo(1L);
    builder.setHwAddr(new MacAddress("94:de:80:a6:61:40"));
    builder.setName("Port name");
    builder.setConfig(new PortConfig(true, false, true, false));
    builder.setState(new PortState(true, false, true));
    builder.setCurrentFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setAdvertisedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setSupportedFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setPeerFeatures(new PortFeatures(true, false, true, false, true, false, true, false, true, false, true, false, true, false, true, false));
    builder.setCurrSpeed(1234L);
    builder.setMaxSpeed(1234L);
    PortStatusMessage message = builder.build();
    ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
    factory.serialize(message, serializedBuffer);
    BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 80);
    Assert.assertEquals("Wrong reason", message.getReason().getIntValue(), serializedBuffer.readUnsignedByte());
    serializedBuffer.skipBytes(PADDING);
    Assert.assertEquals("Wrong PortNo", message.getPortNo().intValue(), serializedBuffer.readUnsignedInt());
    serializedBuffer.skipBytes(PORT_PADDING_1);
    byte[] address = new byte[6];
    serializedBuffer.readBytes(address);
    Assert.assertEquals("Wrong MacAddress", message.getHwAddr().getValue().toLowerCase(), new MacAddress(ByteBufUtils.macAddressToString(address)).getValue().toLowerCase());
    serializedBuffer.skipBytes(PORT_PADDING_2);
    byte[] name = new byte[16];
    serializedBuffer.readBytes(name);
    Assert.assertEquals("Wrong name", message.getName(), new String(name).trim());
    Assert.assertEquals("Wrong config", message.getConfig(), createPortConfig(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong state", message.getState(), createPortState(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong current", message.getCurrentFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong advertised", message.getAdvertisedFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong supported", message.getSupportedFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong peer", message.getPeerFeatures(), createPortFeatures(serializedBuffer.readInt()));
    Assert.assertEquals("Wrong Current speed", message.getCurrSpeed().longValue(), serializedBuffer.readInt());
    Assert.assertEquals("Wrong Max speed", message.getMaxSpeed().longValue(), serializedBuffer.readInt());
}
Also used : PortStatusMessageBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortFeatures(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures) PortStatusMessage(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage) 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 10 with PortState

use of org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState in project openflowplugin by opendaylight.

the class PortConvertorTest method testtoPortDescwithAllParameters.

/**
 * test of {@link PortConvertor#toPortDesc(FlowCapablePort , short)}.
 */
@Test
public void testtoPortDescwithAllParameters() {
    State state = new StateBuilder().setBlocked(false).setLinkDown(false).setLive(false).build();
    FlowCapableNodeConnectorBuilder flowCapableNodeConnectorBuilder = new FlowCapableNodeConnectorBuilder();
    flowCapableNodeConnectorBuilder.setAdvertisedFeatures(features);
    flowCapableNodeConnectorBuilder.setConfiguration(config);
    flowCapableNodeConnectorBuilder.setCurrentFeature(features);
    flowCapableNodeConnectorBuilder.setCurrentSpeed(null);
    flowCapableNodeConnectorBuilder.setHardwareAddress(new MacAddress(DEFAULT_MAC_ADDRESS));
    flowCapableNodeConnectorBuilder.setMaximumSpeed(null);
    flowCapableNodeConnectorBuilder.setName("foo");
    flowCapableNodeConnectorBuilder.setPeerFeatures(features);
    flowCapableNodeConnectorBuilder.setPortNumber(new PortNumberUni(42L));
    flowCapableNodeConnectorBuilder.setState(state);
    flowCapableNodeConnectorBuilder.setSupported(features);
    final Ports portsOut = PortConvertor.toPortDesc(flowCapableNodeConnectorBuilder.build(), EncodeConstants.OF13_VERSION_ID);
    PortsBuilder portsB = new PortsBuilder();
    portsB.setAdvertisedFeatures(portf31);
    portsB.setConfig(config31);
    portsB.setCurrentFeatures(portf31);
    portsB.setCurrSpeed(null);
    portsB.setHwAddr(new MacAddress(DEFAULT_MAC_ADDRESS));
    portsB.setMaxSpeed(null);
    portsB.setName("foo");
    portsB.setPeerFeatures(portf31);
    portsB.setPortNo(42L);
    portsB.setState(new PortState(false, false, false));
    portsB.setSupportedFeatures(portf31);
    Assert.assertEquals(portsB.build(), portsOut);
}
Also used : FlowCapableNodeConnectorBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) State(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State) PortState(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState) PortNumberUni(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni) StateBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder) Ports(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports) MacAddress(org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress) PortsBuilder(org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder) Test(org.junit.Test)

Aggregations

PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortState)8 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortConfig)7 MacAddress (org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.MacAddress)6 PortFeatures (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.PortFeatures)6 Test (org.junit.Test)5 ByteBuf (io.netty.buffer.ByteBuf)4 PortStatusMessage (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessage)3 Ports (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.Ports)3 PortsBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.port.desc._case.multipart.reply.port.desc.PortsBuilder)3 StateBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.StateBuilder)2 PortStatusMessageBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.PortStatusMessageBuilder)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 ArrayList (java.util.ArrayList)1 FlowCapableNodeConnectorBuilder (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNodeConnectorBuilder)1 PortConfig (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortConfig)1 PortNumberUni (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortNumberUni)1 PortState (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.PortState)1 State (org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.port.rev130925.flow.capable.port.State)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