use of org.openkilda.messaging.info.rule.GroupBucket in project open-kilda by telstra.
the class OfFlowStatsMapperTest method testFlowGroupEntry.
@Test
public void testFlowGroupEntry() {
OFGroupDescStatsEntry entry = buildFlowGroupEntry();
GroupEntry result = OfFlowStatsMapper.INSTANCE.toFlowGroupEntry(entry);
assertEquals(entry.getGroup().getGroupNumber(), result.getGroupId());
assertEquals(entry.getGroupType().toString(), result.getGroupType());
assertEquals(entry.getBuckets().size(), result.getBuckets().size());
GroupBucket firstBucket = result.getBuckets().get(0);
assertEquals("12", firstBucket.getApplyActions().getFlowOutput());
GroupBucket secondBucket = result.getBuckets().get(1);
assertEquals(EthType.VLAN_FRAME.toString(), secondBucket.getApplyActions().getPushVlan());
assertEquals("vlan_vid", secondBucket.getApplyActions().getSetFieldActions().get(0).getFieldName());
assertEquals("12", secondBucket.getApplyActions().getSetFieldActions().get(0).getFieldValue());
assertEquals("1", secondBucket.getApplyActions().getFlowOutput());
}
use of org.openkilda.messaging.info.rule.GroupBucket in project open-kilda by telstra.
the class FlowValidationTestBase method getSwitchGroupEntries.
protected List<SwitchGroupEntries> getSwitchGroupEntries() {
List<SwitchGroupEntries> switchGroupEntries = new ArrayList<>();
switchGroupEntries.add(SwitchGroupEntries.builder().switchId(TEST_SWITCH_ID_A).groupEntries(Lists.newArrayList(GroupEntry.builder().groupId(FLOW_GROUP_ID_A).buckets(Lists.newArrayList(new GroupBucket(0, FlowApplyActions.builder().flowOutput(String.valueOf(FLOW_GROUP_ID_A_OUT_PORT)).setFieldActions(Collections.singletonList(getFlowSetFieldAction(FLOW_GROUP_ID_A_OUT_VLAN))).build()), new GroupBucket(0, FlowApplyActions.builder().flowOutput(String.valueOf(FLOW_A_SEGMENT_B_DST_PORT_PROTECTED)).build()))).build())).build());
switchGroupEntries.add(SwitchGroupEntries.builder().switchId(TEST_SWITCH_ID_C).groupEntries(Collections.emptyList()).build());
return switchGroupEntries;
}
use of org.openkilda.messaging.info.rule.GroupBucket in project open-kilda by telstra.
the class GroupVerifyCommand method fromStatsEntry.
private MirrorConfig fromStatsEntry(OFGroupDescStatsEntry entry) {
GroupEntry groupEntry = OfFlowStatsMapper.INSTANCE.toFlowGroupEntry(entry);
GroupId groupId = new GroupId(groupEntry.getGroupId());
if (groupEntry.getBuckets().size() < 2) {
return null;
}
GroupBucket flowBucket = groupEntry.getBuckets().get(0);
int flowPort = Integer.parseInt(flowBucket.getApplyActions().getFlowOutput());
Set<MirrorConfigData> mirrorConfigDataSet = new HashSet<>();
for (int i = 1; i < groupEntry.getBuckets().size(); ++i) {
GroupBucket mirrorBucket = groupEntry.getBuckets().get(i);
int mirrorPort = Integer.parseInt(mirrorBucket.getApplyActions().getFlowOutput());
int mirrorVlan = mirrorBucket.getApplyActions().getSetFieldActions().stream().filter(action -> (MatchField.VLAN_VID.getName().equals(action.getFieldName()))).map(action -> Integer.valueOf(action.getFieldValue())).findFirst().orElse(0);
mirrorConfigDataSet.add(new MirrorConfigData(mirrorPort, mirrorVlan));
}
return MirrorConfig.builder().groupId(groupId).flowPort(flowPort).mirrorConfigDataSet(mirrorConfigDataSet).build();
}
use of org.openkilda.messaging.info.rule.GroupBucket in project open-kilda by telstra.
the class SimpleSwitchRuleConverter method mapGroupBuckets.
private List<SimpleGroupBucket> mapGroupBuckets(List<GroupBucket> buckets) {
List<SimpleGroupBucket> simpleGroupBuckets = new ArrayList<>();
for (GroupBucket bucket : buckets) {
FlowApplyActions actions = bucket.getApplyActions();
if (actions == null || !NumberUtils.isParsable(actions.getFlowOutput())) {
continue;
}
int bucketPort = NumberUtils.toInt(actions.getFlowOutput());
int bucketVlan = 0;
if (actions.getSetFieldActions() != null && actions.getSetFieldActions().size() == 1) {
FlowSetFieldAction setFieldAction = actions.getSetFieldActions().get(0);
if (VLAN_VID.equals(setFieldAction.getFieldName())) {
bucketVlan = NumberUtils.toInt(setFieldAction.getFieldValue());
}
}
int bucketVni = 0;
if (actions.getPushVxlan() != null) {
bucketVni = NumberUtils.toInt(actions.getPushVxlan());
}
simpleGroupBuckets.add(new SimpleGroupBucket(bucketPort, bucketVlan, bucketVni));
}
simpleGroupBuckets.sort(this::compareSimpleGroupBucket);
return simpleGroupBuckets;
}
Aggregations