use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action in project openflowplugin by opendaylight.
the class SalToOfSetVlanPcpActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final SetVlanPcpActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
SetVlanPcpAction setvlanpcpaction = source.getSetVlanPcpAction();
SetFieldCaseBuilder setFieldCaseBuilder = new SetFieldCaseBuilder();
SetFieldActionBuilder setFieldBuilder = new SetFieldActionBuilder();
List<MatchEntry> matchEntriesList = new ArrayList<>();
matchEntriesList.add(MatchConvertorUtil.toOfVlanPcp(setvlanpcpaction.getVlanPcp()));
setFieldBuilder.setMatchEntry(matchEntriesList);
setFieldCaseBuilder.setSetFieldAction(setFieldBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(setFieldCaseBuilder.build()).build());
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action in project openflowplugin by opendaylight.
the class SalToOfVendorCodecCase method process.
@SuppressWarnings("unchecked")
@Nonnull
@Override
public Optional<Action> process(@Nonnull final org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
final short version = data.getVersion();
final TypeVersionKey<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action> key = new TypeVersionKey<>((Class<? extends org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>) source.getImplementedInterface(), version);
ExtensionConverterProvider extensionConverterProvider = OFSessionUtil.getExtensionConvertorProvider();
if (extensionConverterProvider == null) {
return Optional.empty();
}
final ConvertorActionToOFJava<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action, Action> convertor = extensionConverterProvider.getConverter(key);
LOG.trace("OFP Extension action, key:{}, converter:{}", key, convertor);
return convertor != null ? Optional.of(convertor.convert(source)) : Optional.empty();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action in project openflowplugin by opendaylight.
the class FlowStatsResponseConvertor method wrapOF10ActionsToInstruction.
/**
* Method wraps openflow 1.0 actions list to Apply Action Instructions.
*
* @param actionsList list of action
* @param ipProtocol ip protocol
* @return OF10 actions as an instructions
*/
private Instructions wrapOF10ActionsToInstruction(List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.action.rev150203.actions.grouping.Action> actionsList, final short version, final Short ipProtocol) {
ActionResponseConvertorData actionResponseConvertorData = new ActionResponseConvertorData(version);
actionResponseConvertorData.setActionPath(ActionPath.FLOWS_STATISTICS_UPDATE_WRITE_ACTIONS);
actionResponseConvertorData.setIpProtocol(ipProtocol);
ApplyActionsCaseBuilder applyActionsCaseBuilder = new ApplyActionsCaseBuilder();
ApplyActionsBuilder applyActionsBuilder = new ApplyActionsBuilder();
final Optional<List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.Action>> actions = getConvertorExecutor().convert(actionsList, actionResponseConvertorData);
applyActionsBuilder.setAction(FlowConvertorUtil.wrapActionList(actions.orElse(Collections.emptyList())));
applyActionsCaseBuilder.setApplyActions(applyActionsBuilder.build());
InstructionBuilder instBuilder = new InstructionBuilder();
instBuilder.setInstruction(applyActionsCaseBuilder.build());
instBuilder.setKey(new InstructionKey(0));
instBuilder.setOrder(0);
List<Instruction> salInstructionList = new ArrayList<>();
salInstructionList.add(instBuilder.build());
InstructionsBuilder instructionsBuilder = new InstructionsBuilder();
instructionsBuilder.setInstruction(salInstructionList);
return instructionsBuilder.build();
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action in project openflowplugin by opendaylight.
the class GroupConvertorTest method testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure.
/**
* test of {@link GroupConvertor#convert(Group, VersionDatapathIdConvertorData)} }.
*/
@Test
public void testGroupModConvertorBucketwithNOWieghtValuesForGroupTypeFastFailure() {
int actionOrder = 0;
final AddGroupInputBuilder addGroupBuilder = new AddGroupInputBuilder();
addGroupBuilder.setGroupId(new GroupId(10L));
addGroupBuilder.setGroupType(GroupTypes.GroupFf);
final List<Bucket> bucketList = new ArrayList<>();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList = new ArrayList<>();
final List<org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.action.list.Action> actionsList1 = new ArrayList<>();
// Action1: 005
actionsList.add(assembleActionBuilder("005", actionOrder++).build());
// Action2: 006
actionsList.add(assembleActionBuilder("006", actionOrder++).build());
// .. and mr.Bond is not coming today
final BucketsBuilder bucketsB = new BucketsBuilder();
final BucketBuilder bucketB = new BucketBuilder();
bucketB.setAction(actionsList);
final Bucket bucket = bucketB.build();
// List of bucket
bucketList.add(bucket);
final BucketBuilder bucketB1 = new BucketBuilder();
// Action1
actionsList1.add(assembleCopyTtlInBuilder(actionOrder++).build());
// Action2:
actionsList1.add(assembleSetMplsTtlActionBuilder(actionOrder++).build());
bucketB1.setAction(actionsList1);
// second bucket
final Bucket bucket1 = bucketB1.build();
bucketList.add(bucket1);
// List of bucket added to the Buckets
bucketsB.setBucket(bucketList);
final Buckets buckets = bucketsB.build();
addGroupBuilder.setBuckets(buckets);
VersionDatapathIdConvertorData data = new VersionDatapathIdConvertorData((short) 0X4);
data.setDatapathId(BigInteger.valueOf(1));
final GroupModInputBuilder outAddGroupInput = convert(addGroupBuilder.build(), data);
assertEquals(GroupModCommand.OFPGCADD, outAddGroupInput.getCommand());
assertEquals(GroupType.OFPGTFF, outAddGroupInput.getType());
assertEquals(10L, outAddGroupInput.getGroupId().getValue().longValue());
final List<Action> outActionList = outAddGroupInput.getBucketsList().get(0).getAction();
for (int outItem = 0; outItem < outActionList.size(); outItem++) {
final Action action = outActionList.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
assertEquals((Long) 5L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
}
final List<Action> outActionList1 = outAddGroupInput.getBucketsList().get(1).getAction();
for (int outItem = 0; outItem < outActionList1.size(); outItem++) {
final Action action = outActionList1.get(outItem);
if (action.getActionChoice() instanceof GroupActionCase) {
assertEquals((Long) 6L, ((GroupActionCase) action.getActionChoice()).getGroupAction().getGroupId());
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.action.types.rev131112.Action in project openflowplugin by opendaylight.
the class SalToOfPopMplsActionCase method process.
@Nonnull
@Override
public Optional<Action> process(@Nonnull final PopMplsActionCase source, final ActionConvertorData data, ConvertorExecutor convertorExecutor) {
PopMplsCaseBuilder popMplsCaseBuilder = new PopMplsCaseBuilder();
PopMplsActionBuilder popMplsBuilder = new PopMplsActionBuilder();
popMplsBuilder.setEthertype(new EtherType(new EtherType(source.getPopMplsAction().getEthernetType())));
popMplsCaseBuilder.setPopMplsAction(popMplsBuilder.build());
return Optional.of(new ActionBuilder().setActionChoice(popMplsCaseBuilder.build()).build());
}
Aggregations