use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultipartRequestInputMessageFactory method setTableFeatures.
private MultipartRequestTableFeaturesCase setTableFeatures(ByteBuf input) {
MultipartRequestTableFeaturesCaseBuilder caseBuilder = new MultipartRequestTableFeaturesCaseBuilder();
MultipartRequestTableFeaturesBuilder tableFeaturesBuilder = new MultipartRequestTableFeaturesBuilder();
List<TableFeatures> features = new ArrayList<>();
while (input.readableBytes() > 0) {
TableFeaturesBuilder featuresBuilder = new TableFeaturesBuilder();
final int length = input.readUnsignedShort();
featuresBuilder.setTableId(input.readUnsignedByte());
input.skipBytes(PADDING_IN_MULTIPART_REQUEST_TABLE_FEATURES);
featuresBuilder.setName(ByteBufUtils.decodeNullTerminatedString(input, MAX_TABLE_NAME_LENGTH));
byte[] metadataMatch = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataMatch);
featuresBuilder.setMetadataMatch(new BigInteger(1, metadataMatch));
byte[] metadataWrite = new byte[EncodeConstants.SIZE_OF_LONG_IN_BYTES];
input.readBytes(metadataWrite);
featuresBuilder.setMetadataWrite(new BigInteger(1, metadataWrite));
featuresBuilder.setConfig(createTableConfig(input.readUnsignedInt()));
featuresBuilder.setMaxEntries(input.readUnsignedInt());
featuresBuilder.setTableFeatureProperties(createTableFeaturesProperties(input, length - MULTIPART_REQUEST_TABLE_FEATURES_STRUCTURE_LENGTH));
features.add(featuresBuilder.build());
}
tableFeaturesBuilder.setTableFeatures(features);
caseBuilder.setMultipartRequestTableFeatures(tableFeaturesBuilder.build());
return caseBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class MultiLayerTableMultipartService method handleAndReply.
@Override
public Future<RpcResult<UpdateTableOutput>> handleAndReply(UpdateTableInput input) {
final ListenableFuture<RpcResult<List<MultipartReply>>> multipartFuture = handleServiceCall(input);
final SettableFuture<RpcResult<UpdateTableOutput>> finalFuture = SettableFuture.create();
class CallBackImpl implements FutureCallback<RpcResult<List<MultipartReply>>> {
@Override
@SuppressWarnings("checkstyle:IllegalCatch")
public void onSuccess(@Nonnull final RpcResult<List<MultipartReply>> result) {
if (result.isSuccessful()) {
final List<MultipartReply> multipartReplies = result.getResult();
if (multipartReplies.isEmpty()) {
LOG.debug("Multipart reply to table features request shouldn't be empty list.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withError(ErrorType.RPC, "Multipart reply list is empty.").build());
} else {
final Long xid = multipartReplies.get(0).getXid();
LOG.debug("OnSuccess, rpc result successful," + " multipart response for rpc update-table with xid {} obtained.", xid);
final UpdateTableOutputBuilder updateTableOutputBuilder = new UpdateTableOutputBuilder();
updateTableOutputBuilder.setTransactionId(new TransactionId(BigInteger.valueOf(xid)));
finalFuture.set(RpcResultBuilder.success(updateTableOutputBuilder.build()).build());
try {
storeStatistics(convertToSalTableFeatures(multipartReplies));
} catch (Exception e) {
LOG.warn("Not able to write to operational datastore: {}", e.getMessage());
}
}
} else {
LOG.debug("OnSuccess, rpc result unsuccessful," + " multipart response for rpc update-table was unsuccessful.");
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withRpcErrors(result.getErrors()).build());
}
}
@Override
public void onFailure(final Throwable throwable) {
LOG.error("Failure multipart response for table features request. Exception: {}", throwable);
finalFuture.set(RpcResultBuilder.<UpdateTableOutput>failed().withError(ErrorType.RPC, "Future error", throwable).build());
}
}
Futures.addCallback(multipartFuture, new CallBackImpl(), MoreExecutors.directExecutor());
return finalFuture;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features in project openflowplugin by opendaylight.
the class PortMessageDeserializerTest method deserialize.
@Test
public void deserialize() throws Exception {
buffer.writeByte(TYPE);
buffer.writeShort(EncodeConstants.EMPTY_LENGTH);
buffer.writeInt(XID);
buffer.writeInt(PORT);
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_1);
buffer.writeBytes(IetfYangUtil.INSTANCE.bytesFor(ADDRESS));
final int config = ByteBufUtils.fillBitMaskFromMap(ImmutableMap.<Integer, Boolean>builder().put(0, IS_PORTDOWN).put(2, IS_NORECV).put(5, IS_NOFWD).put(6, IS_NOPACKETIN).build());
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_2);
// config
buffer.writeInt(config);
// config mask
buffer.writeInt(config);
buffer.writeInt(ByteBufUtils.fillBitMask(0, IS_10MBHD, IS_10MBFD, IS_100MBHD, IS_100MBFD, IS_1GBHD, IS_1GBFD, IS_10GBFD, IS_40GBFD, IS_100GBFD, IS_1TBFD, IS_OTHER, IS_COPPER, IS_FIBER, IS_AUTOENG, IS_PAUSE, IS_PAUSE_ASYM));
buffer.writeZero(PADDING_IN_PORT_MOD_MESSAGE_3);
final PortMessage message = (PortMessage) getFactory().deserialize(buffer, EncodeConstants.OF13_VERSION_ID);
assertEquals(XID, message.getXid().intValue());
assertEquals(PORT, message.getPortNumber().getUint32().intValue());
assertEquals(ADDRESS.getValue(), message.getHardwareAddress().getValue());
// Config
assertEquals(IS_PORTDOWN, message.getConfiguration().isPORTDOWN());
assertEquals(IS_NORECV, message.getConfiguration().isNORECV());
assertEquals(IS_NOFWD, message.getConfiguration().isNOFWD());
assertEquals(IS_NOPACKETIN, message.getConfiguration().isNOPACKETIN());
// Features
assertEquals(IS_10MBHD, message.getAdvertisedFeatures().isTenMbHd());
assertEquals(IS_10MBFD, message.getAdvertisedFeatures().isTenMbHd());
assertEquals(IS_100MBHD, message.getAdvertisedFeatures().isHundredMbHd());
assertEquals(IS_100MBFD, message.getAdvertisedFeatures().isHundredMbFd());
assertEquals(IS_1GBHD, message.getAdvertisedFeatures().isOneGbHd());
assertEquals(IS_1GBFD, message.getAdvertisedFeatures().isOneGbFd());
assertEquals(IS_10GBFD, message.getAdvertisedFeatures().isTenGbFd());
assertEquals(IS_40GBFD, message.getAdvertisedFeatures().isFortyGbFd());
assertEquals(IS_100GBFD, message.getAdvertisedFeatures().isHundredGbFd());
assertEquals(IS_1TBFD, message.getAdvertisedFeatures().isOneTbFd());
assertEquals(IS_OTHER, message.getAdvertisedFeatures().isOther());
assertEquals(IS_COPPER, message.getAdvertisedFeatures().isCopper());
assertEquals(IS_FIBER, message.getAdvertisedFeatures().isFiber());
assertEquals(IS_AUTOENG, message.getAdvertisedFeatures().isAutoeng());
assertEquals(IS_PAUSE, message.getAdvertisedFeatures().isPause());
assertEquals(IS_PAUSE_ASYM, message.getAdvertisedFeatures().isPauseAsym());
assertEquals(buffer.readableBytes(), 0);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features 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);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.Features 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);
}
Aggregations