Search in sources :

Example 1 with OfVersion

use of org.openkilda.rulemanager.OfVersion in project open-kilda by telstra.

the class RuleManagerHelperTest method buildFullFlowSpeakerCommandData.

private FlowSpeakerData buildFullFlowSpeakerCommandData(MeterId goToMeterId, UUID dependsOnUuid) {
    Set<FieldMatch> match = Arrays.stream(Field.values()).map(f -> FieldMatch.builder().field(f).value(f.ordinal()).mask(f.ordinal() + 1L).build()).collect(Collectors.toSet());
    Set<OfFlowFlag> flags = Sets.newHashSet(OfFlowFlag.values());
    List<Action> applyActions = new ArrayList<>(buildAllActions());
    applyActions.addAll(buildAllActions());
    Instructions instructions = Instructions.builder().goToMeter(goToMeterId).goToTable(OfTable.INPUT).writeMetadata(new OfMetadata(15, 0xff)).writeActions(new HashSet<>(buildAllActions())).applyActions(applyActions).build();
    return FlowSpeakerData.builder().uuid(UUID.randomUUID()).cookie(new Cookie(123)).priority(PRIORITY).table(OfTable.INPUT).match(match).instructions(instructions).flags(flags).switchId(SWITCH_ID).ofVersion(OfVersion.OF_13).dependsOn(dependsOnUuid == null ? newArrayList() : newArrayList(dependsOnUuid)).build();
}
Also used : MeterAction(org.openkilda.rulemanager.action.MeterAction) Arrays(java.util.Arrays) MeterFlag(org.openkilda.rulemanager.MeterFlag) GroupType(org.openkilda.rulemanager.group.GroupType) OfMetadata(org.openkilda.rulemanager.OfMetadata) Sets.newHashSet(com.google.common.collect.Sets.newHashSet) RuleManagerHelper.sortCommandsByDependencies(org.openkilda.rulemanager.utils.RuleManagerHelper.sortCommandsByDependencies) WatchGroup(org.openkilda.rulemanager.group.WatchGroup) Instructions(org.openkilda.rulemanager.Instructions) Set(java.util.Set) SpeakerData(org.openkilda.rulemanager.SpeakerData) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) MacAddress(org.openkilda.model.MacAddress) OfFlowFlag(org.openkilda.rulemanager.OfFlowFlag) List(java.util.List) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) RuleManagerHelper.checkCircularDependencies(org.openkilda.rulemanager.utils.RuleManagerHelper.checkCircularDependencies) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) IPv4Address(org.openkilda.model.IPv4Address) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) Action(org.openkilda.rulemanager.action.Action) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) RuleManagerHelper.removeDuplicateCommands(org.openkilda.rulemanager.utils.RuleManagerHelper.removeDuplicateCommands) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) Cookie(org.openkilda.model.cookie.Cookie) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) ActionType(org.openkilda.rulemanager.action.ActionType) OpenFlowOxms(org.openkilda.rulemanager.action.noviflow.OpenFlowOxms) MeterSpeakerData(org.openkilda.rulemanager.MeterSpeakerData) OfVersion(org.openkilda.rulemanager.OfVersion) WatchPort(org.openkilda.rulemanager.group.WatchPort) Assert.assertTrue(org.junit.Assert.assertTrue) Test(org.junit.Test) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData) MeterId(org.openkilda.model.MeterId) Bucket(org.openkilda.rulemanager.group.Bucket) SwitchId(org.openkilda.model.SwitchId) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) OfTable(org.openkilda.rulemanager.OfTable) GroupId(org.openkilda.model.GroupId) Assert.assertEquals(org.junit.Assert.assertEquals) Field(org.openkilda.rulemanager.Field) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OfMetadata(org.openkilda.rulemanager.OfMetadata) Cookie(org.openkilda.model.cookie.Cookie) MeterAction(org.openkilda.rulemanager.action.MeterAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) Action(org.openkilda.rulemanager.action.Action) PushVxlanAction(org.openkilda.rulemanager.action.PushVxlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) OfFlowFlag(org.openkilda.rulemanager.OfFlowFlag) Lists.newArrayList(com.google.common.collect.Lists.newArrayList) ArrayList(java.util.ArrayList) Instructions(org.openkilda.rulemanager.Instructions)

Example 2 with OfVersion

use of org.openkilda.rulemanager.OfVersion in project open-kilda by telstra.

the class DropDiscoveryLoopRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    OfVersion ofVersion = OfVersion.of(sw.getOfVersion());
    if (ofVersion == OF_12) {
        return Collections.emptyList();
    }
    long ethDst = new SwitchId(config.getDiscoveryBcastPacketDst()).toLong();
    Set<FieldMatch> match = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(ethDst).build(), FieldMatch.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toLong()).build());
    return Collections.singletonList(FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(ofVersion).cookie(new Cookie(DROP_VERIFICATION_LOOP_RULE_COOKIE)).table(OfTable.INPUT).priority(DROP_DISCOVERY_LOOP_RULE_PRIORITY).match(match).instructions(Instructions.builder().build()).build());
}
Also used : Cookie(org.openkilda.model.cookie.Cookie) OfVersion(org.openkilda.rulemanager.OfVersion) FieldMatch(org.openkilda.rulemanager.match.FieldMatch) SwitchId(org.openkilda.model.SwitchId)

Example 3 with OfVersion

use of org.openkilda.rulemanager.OfVersion in project open-kilda by telstra.

the class TableDefaultRuleGenerator method generateCommands.

@Override
public List<SpeakerData> generateCommands(Switch sw) {
    OfVersion ofVersion = OfVersion.of(sw.getOfVersion());
    SpeakerData command = FlowSpeakerData.builder().switchId(sw.getSwitchId()).ofVersion(ofVersion).cookie(cookie).table(ofTable).priority(Priority.MINIMAL_POSITIVE_PRIORITY).instructions(Instructions.builder().build()).build();
    return Collections.singletonList(command);
}
Also used : OfVersion(org.openkilda.rulemanager.OfVersion) SpeakerData(org.openkilda.rulemanager.SpeakerData) FlowSpeakerData(org.openkilda.rulemanager.FlowSpeakerData)

Aggregations

OfVersion (org.openkilda.rulemanager.OfVersion)3 SwitchId (org.openkilda.model.SwitchId)2 Cookie (org.openkilda.model.cookie.Cookie)2 FlowSpeakerData (org.openkilda.rulemanager.FlowSpeakerData)2 SpeakerData (org.openkilda.rulemanager.SpeakerData)2 Lists.newArrayList (com.google.common.collect.Lists.newArrayList)1 Sets (com.google.common.collect.Sets)1 Sets.newHashSet (com.google.common.collect.Sets.newHashSet)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 UUID (java.util.UUID)1 Collectors (java.util.stream.Collectors)1 Assert.assertEquals (org.junit.Assert.assertEquals)1 Assert.assertTrue (org.junit.Assert.assertTrue)1 Test (org.junit.Test)1 GroupId (org.openkilda.model.GroupId)1 IPv4Address (org.openkilda.model.IPv4Address)1