Search in sources :

Example 1 with MirrorConfigData

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;
}
Also used : VXLAN_SRC_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_SRC_IPV4_ADDRESS) FlowPath(org.openkilda.model.FlowPath) SwitchFeature(org.openkilda.model.SwitchFeature) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Action(org.openkilda.rulemanager.action.Action) SpecialPortType(org.openkilda.rulemanager.ProtoConstants.PortNumber.SpecialPortType) KILDA_OVS_PUSH_POP_MATCH_VXLAN(org.openkilda.model.SwitchFeature.KILDA_OVS_PUSH_POP_MATCH_VXLAN) OfMetadata(org.openkilda.rulemanager.OfMetadata) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) VXLAN_DST_IPV4_ADDRESS(org.openkilda.rulemanager.Constants.VXLAN_DST_IPV4_ADDRESS) Flow(org.openkilda.model.Flow) FlowEndpoint.makeVlanStack(org.openkilda.model.FlowEndpoint.makeVlanStack) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) ActionType(org.openkilda.rulemanager.action.ActionType) FlowSideAdapter(org.openkilda.adapter.FlowSideAdapter) WatchGroup(org.openkilda.rulemanager.group.WatchGroup) FlowEndpoint(org.openkilda.model.FlowEndpoint) Iterator(java.util.Iterator) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) WatchPort(org.openkilda.rulemanager.group.WatchPort) Set(java.util.Set) SpeakerData(org.openkilda.rulemanager.SpeakerData) NOVIFLOW_PUSH_POP_VXLAN(org.openkilda.model.SwitchFeature.NOVIFLOW_PUSH_POP_VXLAN) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) Bucket(org.openkilda.rulemanager.group.Bucket) MacAddress(org.openkilda.model.MacAddress) List(java.util.List) FlowEndpoint.isVlanIdSet(org.openkilda.model.FlowEndpoint.isVlanIdSet) SwitchId(org.openkilda.model.SwitchId) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) Optional(java.util.Optional) Field(org.openkilda.rulemanager.Field) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) ArrayList(java.util.ArrayList) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) HashSet(java.util.HashSet) Sets.newHashSet(com.google.common.collect.Sets.newHashSet)

Example 2 with MirrorConfigData

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;
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) ArrayList(java.util.ArrayList)

Example 3 with MirrorConfigData

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();
}
Also used : MirrorConfig(org.openkilda.model.MirrorConfig) CompletableFuture(java.util.concurrent.CompletableFuture) OfFlowStatsMapper(org.openkilda.floodlight.converter.OfFlowStatsMapper) SwitchIncorrectMirrorGroupException(org.openkilda.floodlight.error.SwitchIncorrectMirrorGroupException) HashSet(java.util.HashSet) OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) CompletableFutureAdapter(org.openkilda.floodlight.utils.CompletableFutureAdapter) OFGroupDescStatsRequest(org.projectfloodlight.openflow.protocol.OFGroupDescStatsRequest) OFFactory(org.projectfloodlight.openflow.protocol.OFFactory) OFGroupDescStatsEntry(org.projectfloodlight.openflow.protocol.OFGroupDescStatsEntry) GroupBucket(org.openkilda.messaging.info.rule.GroupBucket) FlowTransitData(org.openkilda.floodlight.model.FlowTransitData) MessageContext(org.openkilda.messaging.MessageContext) Set(java.util.Set) GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) UnsupportedSwitchOperationException(org.openkilda.floodlight.error.UnsupportedSwitchOperationException) OFGroupDescStatsReply(org.projectfloodlight.openflow.protocol.OFGroupDescStatsReply) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) SwitchId(org.openkilda.model.SwitchId) SpeakerCommandProcessor(org.openkilda.floodlight.command.SpeakerCommandProcessor) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) MatchField(org.projectfloodlight.openflow.protocol.match.MatchField) SwitchMissingGroupException(org.openkilda.floodlight.error.SwitchMissingGroupException) DatapathId(org.projectfloodlight.openflow.types.DatapathId) GroupId(org.openkilda.model.GroupId) GroupEntry(org.openkilda.messaging.info.rule.GroupEntry) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) GroupBucket(org.openkilda.messaging.info.rule.GroupBucket) GroupId(org.openkilda.model.GroupId) HashSet(java.util.HashSet)

Example 4 with MirrorConfigData

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;
}
Also used : ModifyDefaultMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyDefaultMeterForSwitchManagerRequest) MirrorConfig(org.openkilda.model.MirrorConfig) NoArgGenerator(com.fasterxml.uuid.NoArgGenerator) EncapsulationResources(org.openkilda.wfm.share.flow.resources.EncapsulationResources) InstallServer42Flow(org.openkilda.messaging.command.flow.InstallServer42Flow) DeleteRulesCriteria(org.openkilda.messaging.command.switches.DeleteRulesCriteria) FlowPath(org.openkilda.model.FlowPath) BaseFlow(org.openkilda.messaging.command.flow.BaseFlow) FlowResourcesConfig(org.openkilda.wfm.share.flow.resources.FlowResourcesConfig) SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE) NumberUtils(org.apache.commons.lang.math.NumberUtils) LogicalPortInfoEntry(org.openkilda.messaging.info.switches.LogicalPortInfoEntry) ReinstallDefaultFlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallDefaultFlowForSwitchManagerRequest) Flow(org.openkilda.model.Flow) MirrorGroup(org.openkilda.model.MirrorGroup) Map(java.util.Map) FlowRepository(org.openkilda.persistence.repositories.FlowRepository) ModifyFlowMeterForSwitchManagerRequest(org.openkilda.messaging.command.flow.ModifyFlowMeterForSwitchManagerRequest) RemoveFlow(org.openkilda.messaging.command.flow.RemoveFlow) DeleteLogicalPortRequest(org.openkilda.messaging.command.grpc.DeleteLogicalPortRequest) SwitchProperties(org.openkilda.model.SwitchProperties) IpSocketAddress(org.openkilda.model.IpSocketAddress) FlowPathRepository(org.openkilda.persistence.repositories.FlowPathRepository) NonNull(lombok.NonNull) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) Set(java.util.Set) CookieType(org.openkilda.model.cookie.CookieBase.CookieType) InstallServer42FlowBuilder(org.openkilda.messaging.command.flow.InstallServer42Flow.InstallServer42FlowBuilder) Collectors(java.util.stream.Collectors) String.format(java.lang.String.format) ReinstallServer42FlowForSwitchManagerRequest(org.openkilda.messaging.command.flow.ReinstallServer42FlowForSwitchManagerRequest) MeterInfoEntry(org.openkilda.messaging.info.switches.MeterInfoEntry) SwitchPropertiesRepository(org.openkilda.persistence.repositories.SwitchPropertiesRepository) Slf4j(lombok.extern.slf4j.Slf4j) List(java.util.List) Stream(java.util.stream.Stream) FlowInstructions(org.openkilda.messaging.info.rule.FlowInstructions) Optional(java.util.Optional) FlowCommandFactory(org.openkilda.wfm.share.flow.service.FlowCommandFactory) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) PathSegment(org.openkilda.model.PathSegment) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SwitchNotFoundException(org.openkilda.wfm.topology.switchmanager.error.SwitchNotFoundException) BaseInstallFlow(org.openkilda.messaging.command.flow.BaseInstallFlow) CreateLogicalPortRequest(org.openkilda.messaging.command.grpc.CreateLogicalPortRequest) Cookie(org.openkilda.model.cookie.Cookie) LogicalPortMapper(org.openkilda.wfm.topology.switchmanager.mappers.LogicalPortMapper) FlowSegmentCookie(org.openkilda.model.cookie.FlowSegmentCookie) PersistenceManager(org.openkilda.persistence.PersistenceManager) CommandBuilder(org.openkilda.wfm.topology.switchmanager.service.CommandBuilder) PathId(org.openkilda.model.PathId) SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_FLOW_RTT_OUTPUT_VLAN_COOKIE) SharedSegmentType(org.openkilda.model.cookie.FlowSharedSegmentCookie.SharedSegmentType) FlowEncapsulationType(org.openkilda.model.FlowEncapsulationType) Switch(org.openkilda.model.Switch) GroupInstallContext(org.openkilda.wfm.topology.switchmanager.model.GroupInstallContext) SERVER_42_ISL_RTT_OUTPUT_COOKIE(org.openkilda.model.cookie.Cookie.SERVER_42_ISL_RTT_OUTPUT_COOKIE) FlowEntry(org.openkilda.messaging.info.rule.FlowEntry) PortColourCookie(org.openkilda.model.cookie.PortColourCookie) FlowSharedSegmentCookie(org.openkilda.model.cookie.FlowSharedSegmentCookie) FlowApplyActions(org.openkilda.messaging.info.rule.FlowApplyActions) MirrorGroupRepository(org.openkilda.persistence.repositories.MirrorGroupRepository) InstallSharedFlow(org.openkilda.messaging.command.flow.InstallSharedFlow) SwitchId(org.openkilda.model.SwitchId) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) FlowResourcesManager(org.openkilda.wfm.share.flow.resources.FlowResourcesManager) Generators(com.fasterxml.uuid.Generators) VisibleForTesting(com.google.common.annotations.VisibleForTesting) FlowMatchField(org.openkilda.messaging.info.rule.FlowMatchField) GroupId(org.openkilda.model.GroupId) Collections(java.util.Collections) MirrorConfig(org.openkilda.model.MirrorConfig) MirrorConfigData(org.openkilda.model.MirrorConfig.MirrorConfigData) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints)

Aggregations

MirrorConfigData (org.openkilda.model.MirrorConfig.MirrorConfigData)4 ArrayList (java.util.ArrayList)3 List (java.util.List)3 Set (java.util.Set)3 SwitchId (org.openkilda.model.SwitchId)3 String.format (java.lang.String.format)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Collectors (java.util.stream.Collectors)2 GroupId (org.openkilda.model.GroupId)2 MirrorConfig (org.openkilda.model.MirrorConfig)2 OFBucket (org.projectfloodlight.openflow.protocol.OFBucket)2 Generators (com.fasterxml.uuid.Generators)1 NoArgGenerator (com.fasterxml.uuid.NoArgGenerator)1 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 Collections (java.util.Collections)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 Map (java.util.Map)1