use of org.openkilda.model.MirrorConfig.MirrorConfigData in project open-kilda by telstra.
the class Utils method buildMirrorBuckets.
/**
* Builds group buckets for flow mirror points (only for sink endpoints. Flow bucket must be build separately).
*/
public static List<Bucket> buildMirrorBuckets(FlowMirrorPoints flowMirrorPoints) {
List<Bucket> buckets = new ArrayList<>();
Set<MirrorConfigData> mirrorConfigDataSet = flowMirrorPoints.getMirrorPaths().stream().map(mirrorPath -> new MirrorConfigData(mirrorPath.getEgressPort(), mirrorPath.getEgressOuterVlan())).collect(Collectors.toSet());
for (MirrorConfigData mirrorConfig : mirrorConfigDataSet) {
Set<Action> actions = new HashSet<>(makeVlanReplaceActions(new ArrayList<>(), makeVlanStack(mirrorConfig.getMirrorVlan())));
actions.add(new PortOutAction(new PortNumber(mirrorConfig.getMirrorPort())));
buckets.add(Bucket.builder().writeActions(actions).watchGroup(WatchGroup.ANY).watchPort(WatchPort.ANY).build());
}
return buckets;
}
use of org.openkilda.model.MirrorConfig.MirrorConfigData in project open-kilda by telstra.
the class AbstractGroupInstall method buildGroupOfBuckets.
protected List<OFBucket> buildGroupOfBuckets(OFFactory ofFactory) {
List<OFAction> flowActions = buildFlowActions(ofFactory);
flowActions.add(ofFactory.actions().buildOutput().setPort(OFPort.of(mirrorConfig.getFlowPort())).build());
OFBucket flowBucket = ofFactory.buildBucket().setActions(flowActions).setWatchGroup(OFGroup.ANY).build();
List<OFBucket> buckets = Lists.newArrayList(flowBucket);
for (MirrorConfigData mirrorConfigData : mirrorConfig.getMirrorConfigDataSet()) {
List<OFAction> mirrorActions = new ArrayList<>();
int mirrorVlan = mirrorConfigData.getMirrorVlan();
if (mirrorVlan > 0) {
mirrorActions.addAll(OfAdapter.INSTANCE.makeVlanReplaceActions(ofFactory, Collections.emptyList(), Lists.newArrayList(mirrorVlan)));
}
mirrorActions.add(ofFactory.actions().buildOutput().setPort(OFPort.of(mirrorConfigData.getMirrorPort())).build());
buckets.add(ofFactory.buildBucket().setActions(mirrorActions).setWatchGroup(OFGroup.ANY).build());
}
return buckets;
}
use of org.openkilda.model.MirrorConfig.MirrorConfigData 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.model.MirrorConfig.MirrorConfigData in project open-kilda by telstra.
the class CommandBuilderImpl method makeMirrorConfig.
private MirrorConfig makeMirrorConfig(@NonNull FlowPath flowPath, @NonNull SwitchId mirrorSwitchId, int mirrorPort) {
MirrorConfig mirrorConfig = null;
FlowMirrorPoints flowMirrorPoints = flowPath.getFlowMirrorPointsSet().stream().filter(mirrorPoints -> mirrorSwitchId.equals(mirrorPoints.getMirrorSwitchId())).findFirst().orElse(null);
if (flowMirrorPoints != null) {
Set<MirrorConfigData> mirrorConfigDataSet = flowMirrorPoints.getMirrorPaths().stream().map(mirrorPath -> new MirrorConfigData(mirrorPath.getEgressPort(), mirrorPath.getEgressOuterVlan())).collect(Collectors.toSet());
if (!mirrorConfigDataSet.isEmpty()) {
mirrorConfig = MirrorConfig.builder().groupId(flowMirrorPoints.getMirrorGroupId()).flowPort(mirrorPort).mirrorConfigDataSet(mirrorConfigDataSet).build();
}
}
return mirrorConfig;
}
Aggregations