use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature in project openflowplugin by opendaylight.
the class MultipartReplyMessageFactoryTest method testGroupFeaturesSerialize.
@Test
public void testGroupFeaturesSerialize() throws Exception {
MultipartReplyMessageBuilder builder = new MultipartReplyMessageBuilder();
BufferHelper.setupHeader(builder, EncodeConstants.OF13_VERSION_ID);
builder.setFlags(new MultipartRequestFlags(true));
builder.setType(MultipartType.forValue(8));
final MultipartReplyGroupFeaturesCaseBuilder featureCase = new MultipartReplyGroupFeaturesCaseBuilder();
MultipartReplyGroupFeaturesBuilder feature = new MultipartReplyGroupFeaturesBuilder();
feature.setTypes(new GroupTypes(true, false, true, false));
feature.setCapabilities(new GroupCapabilities(true, false, true, true));
List<Long> maxGroups = new ArrayList<>();
maxGroups.add(1L);
maxGroups.add(2L);
maxGroups.add(3L);
maxGroups.add(4L);
feature.setMaxGroups(maxGroups);
feature.setActionsBitmap(createActionType());
featureCase.setMultipartReplyGroupFeatures(feature.build());
builder.setMultipartReplyBody(featureCase.build());
MultipartReplyMessage message = builder.build();
ByteBuf serializedBuffer = UnpooledByteBufAllocator.DEFAULT.buffer();
factory.serialize(message, serializedBuffer);
BufferHelper.checkHeaderV13(serializedBuffer, MESSAGE_TYPE, 56);
Assert.assertEquals("Wrong type", MultipartType.OFPMPGROUPFEATURES.getIntValue(), serializedBuffer.readShort());
Assert.assertEquals("Wrong flags", message.getFlags(), createMultipartRequestFlags(serializedBuffer.readShort()));
serializedBuffer.skipBytes(PADDING);
MultipartReplyGroupFeaturesCase body = (MultipartReplyGroupFeaturesCase) message.getMultipartReplyBody();
MultipartReplyGroupFeatures messageOutput = body.getMultipartReplyGroupFeatures();
Assert.assertEquals("Wrong type", messageOutput.getTypes(), createGroupTypes(serializedBuffer.readInt()));
Assert.assertEquals("Wrong capabilities", messageOutput.getCapabilities(), createGroupCapabilities(serializedBuffer.readInt()));
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(0).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(1).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(2).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong max groups", messageOutput.getMaxGroups().get(3).intValue(), serializedBuffer.readInt());
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(0), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(1), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(2), createActionType(serializedBuffer.readInt()));
Assert.assertEquals("Wrong actions", messageOutput.getActionsBitmap().get(3), createActionType(serializedBuffer.readInt()));
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0C 00 00 00 00 00 00 " + // first table feature
"00 40 01 00 00 00 00 00 " + // length, tableId, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + //
"00 00 00 00 00 00 00 00 00 00 00 00 00 " + // name
"00 00 00 00 00 00 00 01 " + // metadata match
"00 00 00 00 00 00 00 02 " + // metadata write
"00 00 00 00 " + // config
"00 00 00 2A " + // second table feature
"00 40 02 00 00 00 00 00 " + // length, tableId, padding
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00" + // name
" 00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
"00 00 00 00 00 00 00 03 " + // metadata write
"00 00 00 00 00 00 00 04 " + // config
"00 00 00 03 " + // max entries
"00 00 00 2B");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 2, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
feature = message.getTableFeatures().get(1);
Assert.assertEquals("Wrong table id", 2, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 3 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 4 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", true, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 43, feature.getMaxEntries().intValue());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature in project netvirt by opendaylight.
the class NeutronvpnManager method updateVpnInstanceWithRDs.
public void updateVpnInstanceWithRDs(String vpnInstanceId, final List<String> rds) {
InstanceIdentifier<VpnInstance> vpnIdentifier = InstanceIdentifier.builder(VpnInstances.class).child(VpnInstance.class, new VpnInstanceKey(vpnInstanceId)).build();
try {
Optional<VpnInstance> vpnInstanceConfig = SingleTransactionDataBroker.syncReadOptional(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier);
if (!vpnInstanceConfig.isPresent()) {
LOG.debug("No VpnInstance present under config vpnInstance:{}", vpnInstanceId);
return;
}
VpnInstance vpnInstance = vpnInstanceConfig.get();
VpnInstanceBuilder updateVpnInstanceBuilder = new VpnInstanceBuilder(vpnInstance);
if (vpnInstance.getIpv4Family() != null) {
Ipv4FamilyBuilder ipv4FamilyBuilder = new Ipv4FamilyBuilder(vpnInstance.getIpv4Family());
updateVpnInstanceBuilder.setIpv4Family(ipv4FamilyBuilder.setRouteDistinguisher(rds).build());
}
if (vpnInstance.getIpv6Family() != null) {
Ipv6FamilyBuilder ipv6FamilyBuilder = new Ipv6FamilyBuilder(vpnInstance.getIpv6Family());
updateVpnInstanceBuilder.setIpv6Family(ipv6FamilyBuilder.setRouteDistinguisher(rds).build());
}
LOG.debug("Updating Config vpn-instance: {} with the list of RDs: {}", vpnInstanceId, rds);
SingleTransactionDataBroker.syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, vpnIdentifier, updateVpnInstanceBuilder.build());
} catch (ReadFailedException | TransactionCommitFailedException ex) {
LOG.warn("Error configuring feature ", ex);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature in project netvirt by opendaylight.
the class NeutronvpnManager method configureFeatures.
private void configureFeatures() {
InstanceIdentifier<Feature> iid = InstanceIdentifier.builder(Neutron.class).child(Features.class).child(Feature.class, new FeatureKey(OperationalPortStatus.class)).build();
Feature feature = new FeatureBuilder().setKey(new FeatureKey(OperationalPortStatus.class)).build();
try {
SingleTransactionDataBroker.syncWrite(dataBroker, LogicalDatastoreType.OPERATIONAL, iid, feature);
} catch (TransactionCommitFailedException e) {
LOG.warn("Error configuring feature {}", feature, e);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.extensions.rev160617.service.provider.features.attributes.features.Feature in project openflowplugin by opendaylight.
the class MultipartReplyTableFeaturesTest method testMultipartReplyTableFeatures2.
/**
* Testing {@link MultipartReplyMessageFactory} for correct translation into POJO.
*/
@Test
public void testMultipartReplyTableFeatures2() {
ByteBuf bb = BufferHelper.buildBuffer(//
"00 0C 00 00 00 00 00 00 " + // length, tableId, padding
"00 B0 01 00 00 00 00 00 " + //
"4F 70 65 6E 64 61 79 6C 69 67 68 74 00 00 00 00 00 00 00 " + // name
"00 00 00 00 00 00 00 00 00 00 00 00 00 " + // metadata match
"00 00 00 00 00 00 00 01 " + // metadata write
"00 00 00 00 00 00 00 02 " + // config
"00 00 00 00 " + // max entries
"00 00 00 2A " + //
"00 00 00 04 00 00 00 00 " + //
"00 01 00 04 00 00 00 00 " + //
"00 02 00 08 01 02 03 04 " + //
"00 03 00 07 05 06 07 00 " + //
"00 04 00 04 00 00 00 00 " + //
"00 05 00 04 00 00 00 00 " + //
"00 06 00 04 00 00 00 00 " + //
"00 07 00 04 00 00 00 00 " + //
"00 08 00 04 00 00 00 00 " + //
"00 0A 00 04 00 00 00 00 " + //
"00 0C 00 04 00 00 00 00 " + //
"00 0D 00 04 00 00 00 00 " + //
"00 0E 00 04 00 00 00 00 " + "00 0F 00 04 00 00 00 00");
MultipartReplyMessage builtByFactory = BufferHelper.deserialize(factory, bb);
BufferHelper.checkHeaderV13(builtByFactory);
Assert.assertEquals("Wrong type", 12, builtByFactory.getType().getIntValue());
Assert.assertEquals("Wrong flag", false, builtByFactory.getFlags().isOFPMPFREQMORE());
MultipartReplyTableFeaturesCase messageCase = (MultipartReplyTableFeaturesCase) builtByFactory.getMultipartReplyBody();
MultipartReplyTableFeatures message = messageCase.getMultipartReplyTableFeatures();
Assert.assertEquals("Wrong table features size", 1, message.getTableFeatures().size());
TableFeatures feature = message.getTableFeatures().get(0);
Assert.assertEquals("Wrong table id", 1, feature.getTableId().intValue());
Assert.assertEquals("Wrong name", "Opendaylight", feature.getName());
Assert.assertArrayEquals("Wrong metadata match", new byte[] { 0, 0, 0, 0, 0, 0, 0, 1 }, feature.getMetadataMatch());
Assert.assertArrayEquals("Wrong metadata write", new byte[] { 0, 0, 0, 0, 0, 0, 0, 2 }, feature.getMetadataWrite());
Assert.assertEquals("Wrong config", false, feature.getConfig().isOFPTCDEPRECATEDMASK());
Assert.assertEquals("Wrong max entries", 42, feature.getMaxEntries().intValue());
Assert.assertEquals("Wrong properties size", 14, feature.getTableFeatureProperties().size());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONS, feature.getTableFeatureProperties().get(0).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTINSTRUCTIONSMISS, feature.getTableFeatureProperties().get(1).getType());
TableFeatureProperties property = feature.getTableFeatureProperties().get(2);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLES, property.getType());
List<NextTableIds> tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 4, tableIds.size());
Assert.assertEquals("Wrong next table id", 1, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 2, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 3, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 4, tableIds.get(3).getTableId().intValue());
property = feature.getTableFeatureProperties().get(3);
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTNEXTTABLESMISS, property.getType());
tableIds = property.getAugmentation(NextTableRelatedTableFeatureProperty.class).getNextTableIds();
Assert.assertEquals("Wrong next table id size", 3, tableIds.size());
Assert.assertEquals("Wrong next table id", 5, tableIds.get(0).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 6, tableIds.get(1).getTableId().intValue());
Assert.assertEquals("Wrong next table id", 7, tableIds.get(2).getTableId().intValue());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONS, feature.getTableFeatureProperties().get(4).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITEACTIONSMISS, feature.getTableFeatureProperties().get(5).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONS, feature.getTableFeatureProperties().get(6).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYACTIONSMISS, feature.getTableFeatureProperties().get(7).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTMATCH, feature.getTableFeatureProperties().get(8).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWILDCARDS, feature.getTableFeatureProperties().get(9).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELD, feature.getTableFeatureProperties().get(10).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTWRITESETFIELDMISS, feature.getTableFeatureProperties().get(11).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELD, feature.getTableFeatureProperties().get(12).getType());
Assert.assertEquals("Wrong property type", TableFeaturesPropType.OFPTFPTAPPLYSETFIELDMISS, feature.getTableFeatureProperties().get(13).getType());
}
Aggregations