import java.util.Optional;
import javax.annotation.CheckForNull;
import org.opendaylight.openflowplugin.api.OFConstants;
+import org.opendaylight.openflowplugin.impl.util.GroupUtil;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionConvertorData;
import org.opendaylight.openflowplugin.openflow.md.util.OpenflowPortsUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterKbps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterPktps;
import org.opendaylight.yang.gen.v1.urn.opendaylight.meter.types.rev130918.MeterStats;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.desc._case.MultipartReplyDesc;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.group.features._case.MultipartReplyGroupFeatures;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.protocol.rev130731.multipart.reply.multipart.reply.body.multipart.reply.meter.features._case.MultipartReplyMeterFeatures;
addGroupCapabilities(reply, gCapability);
groupFeature.setGroupCapabilitiesSupported(gCapability);
- final List<Long> supportActionByGroups = new ArrayList<>();
- for (final ActionType actionType : reply.getActionsBitmap()) {
- long supportActionBitmap = 0;
- supportActionBitmap |= actionType.isOFPATOUTPUT() ? (1 << 0) : 0;
- supportActionBitmap |= actionType.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
- supportActionBitmap |= actionType.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
- supportActionBitmap |= actionType.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
- supportActionBitmap |= actionType.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
- supportActionBitmap |= actionType.isOFPATPUSHVLAN() ? (1 << 17) : 0;
- supportActionBitmap |= actionType.isOFPATPOPVLAN() ? (1 << 18) : 0;
- supportActionBitmap |= actionType.isOFPATPUSHMPLS() ? (1 << 19) : 0;
- supportActionBitmap |= actionType.isOFPATPOPMPLS() ? (1 << 20) : 0;
- supportActionBitmap |= actionType.isOFPATSETQUEUE() ? (1 << 21) : 0;
- supportActionBitmap |= actionType.isOFPATGROUP() ? (1 << 22) : 0;
- supportActionBitmap |= actionType.isOFPATSETNWTTL() ? (1 << 23) : 0;
- supportActionBitmap |= actionType.isOFPATDECNWTTL() ? (1 << 24) : 0;
- supportActionBitmap |= actionType.isOFPATSETFIELD() ? (1 << 25) : 0;
- supportActionBitmap |= actionType.isOFPATPUSHPBB() ? (1 << 26) : 0;
- supportActionBitmap |= actionType.isOFPATPOPPBB() ? (1 << 27) : 0;
- supportActionByGroups.add(Long.valueOf(supportActionBitmap));
- }
- groupFeature.setActions(supportActionByGroups);
+ groupFeature.setActions(GroupUtil.extractGroupActionsSupportBitmap(reply.getActionsBitmap()));
return new NodeGroupFeaturesBuilder().setGroupFeatures(groupFeature.build()).build();
}
import java.util.List;
import java.util.Optional;
import org.opendaylight.openflowplugin.api.openflow.md.util.OpenflowVersion;
+import org.opendaylight.openflowplugin.impl.util.GroupUtil;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.ConvertorExecutor;
import org.opendaylight.openflowplugin.openflow.md.core.sal.convertor.data.VersionDatapathIdConvertorData;
import org.opendaylight.openflowplugin.openflow.md.util.InventoryDataServiceUtil;
message.setGroupCapabilitiesSupported(supportedCapabilities);
- message.setActions(getGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
+ message.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
listDataObject.add(message.build());
}
BigInteger bigIntXid = BigInteger.valueOf(xid);
return new TransactionId(bigIntXid);
}
-
- /*
- * Method returns the bitmap of actions supported by each group.
- *
- * @param actionsSupported
- * @return
- */
- static List<Long> getGroupActionsSupportBitmap(final List<org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType> actionsSupported) {
- List<Long> supportActionByGroups = new ArrayList<Long>();
- for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
- long supportActionBitmap = 0;
- supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1 << 0) : 0;
- supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
- supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
- supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
- supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
- supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
- supportActionByGroups.add(Long.valueOf(supportActionBitmap));
- }
- return supportActionByGroups;
- }
-
}
import org.opendaylight.openflowplugin.api.openflow.device.Xid;
import org.opendaylight.openflowplugin.impl.services.RequestInputUtils;
import org.opendaylight.openflowplugin.impl.statistics.services.compatibility.AbstractCompatibleStatService;
+import org.opendaylight.openflowplugin.impl.util.GroupUtil;
import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.transaction.rev150304.TransactionId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.statistics.rev131111.GetGroupFeaturesOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectLiveness;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.SelectWeight;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupCapabilities;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartType;
notification.setGroupTypesSupported(extractSupportedGroupTypes(replyBody.getTypes()));
notification.setMaxGroups(replyBody.getMaxGroups());
notification.setGroupCapabilitiesSupported(extractSupportedCapabilities(replyBody.getCapabilities()));
- notification.setActions(extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
+ notification.setActions(GroupUtil.extractGroupActionsSupportBitmap(replyBody.getActionsBitmap()));
return notification.build();
}
}
return supportedGroups;
}
-
- @VisibleForTesting
- static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
- List<Long> supportActionByGroups = new ArrayList<>();
- for (ActionType supportedActions : actionsSupported) {
- long supportActionBitmap = 0;
- supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1 << 0) : 0;
- supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
- supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
- supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
- supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
- supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
- supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
- supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
- supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
- supportActionByGroups.add(Long.valueOf(supportActionBitmap));
- }
- return supportActionByGroups;
- }
}
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
/**
* provides group util methods
};
}
+ /*
+ * Method returns the bitmap of actions supported by each group.
+ *
+ * @param actionsSupported
+ * @return
+ */
+ public static List<Long> extractGroupActionsSupportBitmap(final List<ActionType> actionsSupported) {
+ List<Long> supportActionByGroups = new ArrayList<>();
+ for (org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType supportedActions : actionsSupported) {
+ long supportActionBitmap = 0;
+ supportActionBitmap |= supportedActions.isOFPATOUTPUT() ? (1) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLOUT() ? (1 << 11) : 0;
+ supportActionBitmap |= supportedActions.isOFPATCOPYTTLIN() ? (1 << 12) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETMPLSTTL() ? (1 << 15) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECMPLSTTL() ? (1 << 16) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHVLAN() ? (1 << 17) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPVLAN() ? (1 << 18) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHMPLS() ? (1 << 19) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPMPLS() ? (1 << 20) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETQUEUE() ? (1 << 21) : 0;
+ supportActionBitmap |= supportedActions.isOFPATGROUP() ? (1 << 22) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETNWTTL() ? (1 << 23) : 0;
+ supportActionBitmap |= supportedActions.isOFPATDECNWTTL() ? (1 << 24) : 0;
+ supportActionBitmap |= supportedActions.isOFPATSETFIELD() ? (1 << 25) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPUSHPBB() ? (1 << 26) : 0;
+ supportActionBitmap |= supportedActions.isOFPATPOPPBB() ? (1 << 27) : 0;
+ supportActionByGroups.add(supportActionBitmap);
+ }
+ return supportActionByGroups;
+ }
+
/**
* Factory method: create {@link Function} which attaches barrier response to given {@link RpcResult}<T>
* and changes success flag if needed.
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.GroupTypes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.group.types.rev131018.group.desc.stats.reply.GroupDescStats;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Node;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupId;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.GroupType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.MultipartRequestFlags;
private static final Long DUMMY_REF_COUNT = 1234L;
private static final GroupTypes DUMMY_GROUPS_TYPE = GroupTypes.GroupAll;
private static final GroupType DUMMY_GROUP_TYPE = GroupType.OFPGTALL;
- private static final Long GROUP_ACTION_BITMAP = 0b00000000000000000000000000000000000001111111111111001100000000001L;
@Before
public void setUp() {
assertEquals(DUMMY_GROUPS_TYPE,groupDescStat.getGroupType() );
}
- @Test
- public void getGroupActionsSupportBitmap() {
- ActionType actionSupported = new ActionType(true,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
- final List<Long> groupActionsSupportBitmap = SinglePurposeMultipartReplyTranslator.getGroupActionsSupportBitmap(Lists.newArrayList(actionSupported));
- assertEquals(1, groupActionsSupportBitmap.size());
- final Long bitmap = groupActionsSupportBitmap.get(0);
- assertEquals(GROUP_ACTION_BITMAP, bitmap);
- }
-
private MultipartReplyBody prepareMultipartReplyGroupDesc() {
MultipartReplyGroupDescCaseBuilder multipartReplyGroupDescCaseBuilder = new MultipartReplyGroupDescCaseBuilder();
MultipartReplyGroupDescBuilder multipartReplyGroupDescBuilder = new MultipartReplyGroupDescBuilder();
package org.opendaylight.openflowplugin.impl.util;
+import static org.junit.Assert.assertEquals;
+
import com.google.common.base.Function;
import com.google.common.collect.Lists;
import java.util.Collections;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.Nodes;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.Node;
import org.opendaylight.yang.gen.v1.urn.opendaylight.inventory.rev130819.nodes.NodeKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.openflow.common.types.rev130731.ActionType;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.common.RpcError;
import org.opendaylight.yangtools.yang.common.RpcResult;
public static final NodeId DUMMY_NODE_ID = new NodeId("dummyNodeId");
private static final GroupId DUMMY_GROUP_ID = new GroupId(42L);
private static final GroupId DUMMY_GROUP_ID_2 = new GroupId(43L);
+ private static final Long GROUP_ACTION_BITMAP = 0b00000000000000000000000000000000000001111111111111001100000000001L;
@Test
public void testBuildGroupPath() throws Exception {
Assert.assertEquals(1, composite.getResult().getBatchFailedGroupsOutput().size());
}
+ @Test
+ public void testExtractGroupActionsSupportBitmap() {
+ ActionType actionSupported = new ActionType(true,true, true, true, true, true, true, true, true, true, true, true, true, true, true, true, true);
+ final List<Long> groupActionsSupportBitmap = GroupUtil.extractGroupActionsSupportBitmap(Lists.newArrayList(actionSupported));
+ assertEquals(1, groupActionsSupportBitmap.size());
+ final Long bitmap = groupActionsSupportBitmap.get(0);
+ assertEquals(GROUP_ACTION_BITMAP, bitmap);
+ }
+
private RpcResult<Void> createBarrierFailureOutcome() {
return RpcResultBuilder.<Void>failed()
.withError(RpcError.ErrorType.APPLICATION, "ut-barrier-error")