use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf in project openflowplugin by opendaylight.
the class BundleAddMessageConverter method convert.
@Override
public BundleAddMessageOnf convert(BundleAddMessageSal experimenterMessageCase) throws ConversionException {
final OnfAddMessageGroupingDataBuilder dataBuilder = new OnfAddMessageGroupingDataBuilder();
dataBuilder.setBundleId(experimenterMessageCase.getSalAddMessageData().getBundleId());
dataBuilder.setFlags(experimenterMessageCase.getSalAddMessageData().getFlags());
dataBuilder.setBundleProperty(experimenterMessageCase.getSalAddMessageData().getBundleProperty());
final BundleInnerMessage innerMessage = experimenterMessageCase.getSalAddMessageData().getBundleInnerMessage();
final VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData(OFConstants.OFP_VERSION_1_3);
data.setDatapathId(digDatapathId(node));
if (innerMessage.getImplementedInterface().equals(BundleAddFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateFlowCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveFlowCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundleFlowCase(innerMessage, data));
} else if (innerMessage.getImplementedInterface().equals(BundleAddGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleUpdateGroupCase.class) || innerMessage.getImplementedInterface().equals(BundleRemoveGroupCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundleGroupCase(innerMessage, data));
} else if (innerMessage.getImplementedInterface().equals(BundleUpdatePortCase.class)) {
dataBuilder.setBundleInnerMessage(convertBundlePortCase(innerMessage, data));
} else {
throw new ConversionException("Unsupported inner message");
}
return new BundleAddMessageOnfBuilder().setOnfAddMessageGroupingData(dataBuilder.build()).build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf in project openflowplugin by opendaylight.
the class BundleAddMessageConverterTest method testConvert.
private void testConvert(final BundleInnerMessage message, Class clazz, final boolean withProperty) throws Exception {
final BundleAddMessageSal original = createMessage(withProperty, message);
final BundleAddMessageOnf converted = converter.convert(original);
Assert.assertEquals("Wrong BundleId", new BundleId(original.getSalAddMessageData().getBundleId().getValue()), converted.getOnfAddMessageGroupingData().getBundleId());
Assert.assertEquals("Wrong flags", new BundleFlags(original.getSalAddMessageData().getFlags().isAtomic(), original.getSalAddMessageData().getFlags().isOrdered()), converted.getOnfAddMessageGroupingData().getFlags());
Assert.assertEquals("Wrong inner message conversion", clazz, converted.getOnfAddMessageGroupingData().getBundleInnerMessage().getImplementedInterface());
if (withProperty) {
final BundlePropertyExperimenter originalProperty = (BundlePropertyExperimenter) original.getSalAddMessageData().getBundleProperty().get(0).getBundlePropertyEntry();
final BundlePropertyExperimenter convertedProperty = (BundlePropertyExperimenter) converted.getOnfAddMessageGroupingData().getBundleProperty().get(0).getBundlePropertyEntry();
Assert.assertEquals("Wrong property ExperimenterId", new ExperimenterId(originalProperty.getExperimenter()), convertedProperty.getExperimenter());
Assert.assertEquals("Wrong property experimenter type", originalProperty.getExpType(), convertedProperty.getExpType());
Assert.assertEquals("Wrong property data", originalProperty.getBundlePropertyExperimenterData(), convertedProperty.getBundlePropertyExperimenterData());
} else {
Assert.assertTrue("Properties not empty", converted.getOnfAddMessageGroupingData().getBundleProperty().isEmpty());
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.openflowplugin.extension.onf.rev170124.experimenter.input.experimenter.data.of.choice.BundleAddMessageOnf in project openflowplugin by opendaylight.
the class BundleAddMessageFactory method serialize.
@Override
public void serialize(BundleAddMessageOnf input, ByteBuf outBuffer) {
outBuffer.writeInt(input.getOnfAddMessageGroupingData().getBundleId().getValue().intValue());
outBuffer.writeZero(2);
writeBundleFlags(input.getOnfAddMessageGroupingData().getFlags(), outBuffer);
int msgStart = outBuffer.writerIndex();
final BundleInnerMessage message = input.getOnfAddMessageGroupingData().getBundleInnerMessage();
serializeInnerMessage(message, outBuffer);
int msgLength = outBuffer.writerIndex() - msgStart;
List<BundleProperty> bundleProperties = input.getOnfAddMessageGroupingData().getBundleProperty();
if (bundleProperties != null && !bundleProperties.isEmpty()) {
outBuffer.writeZero(paddingNeeded(msgLength));
writeBundleProperties(input.getOnfAddMessageGroupingData().getBundleProperty(), outBuffer);
}
}
Aggregations