Search in sources :

Example 6 with GroupId

use of org.openkilda.model.GroupId in project open-kilda by telstra.

the class OfInstructionsConverterTest method buildActions.

private static List<Action> buildActions() {
    List<Action> actions = new ArrayList<>();
    actions.add(new GroupAction(new GroupId(3)));
    actions.add(new PortOutAction(new PortNumber(SpecialPortType.CONTROLLER)));
    actions.add(new PopVlanAction());
    actions.add(new PushVlanAction());
    actions.add(new PopVxlanAction(ActionType.POP_VXLAN_NOVIFLOW));
    actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
    actions.add(PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_NOVIFLOW).srcMacAddress(buildMacAddress("00:00:00:00:00:0b")).dstMacAddress(buildMacAddress("00:00:00:00:00:16")).srcIpv4Address(buildIPv4Address("0.0.0.33")).dstIpv4Address(buildIPv4Address("0.0.0.44")).udpSrc(55).vni(66).build());
    actions.add(PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_OVS).srcMacAddress(buildMacAddress("00:00:00:00:00:6f")).dstMacAddress(buildMacAddress("00:00:00:00:00:de")).srcIpv4Address(buildIPv4Address("0.0.1.77")).dstIpv4Address(buildIPv4Address("0.0.1.188")).udpSrc(555).vni(666).build());
    actions.add(SetFieldAction.builder().field(Field.UDP_DST).value(7).build());
    actions.add(CopyFieldAction.builder().numberOfBits(1).srcOffset(2).dstOffset(3).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build());
    actions.add(SwapFieldAction.builder().type(ActionType.NOVI_SWAP_FIELD).numberOfBits(11).srcOffset(22).dstOffset(33).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build());
    actions.add(SwapFieldAction.builder().type(ActionType.KILDA_SWAP_FIELD).numberOfBits(111).srcOffset(222).dstOffset(333).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build());
    return actions;
}
Also used : GroupAction(org.openkilda.rulemanager.action.GroupAction) 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) SwapFieldAction(org.openkilda.rulemanager.action.SwapFieldAction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) GroupAction(org.openkilda.rulemanager.action.GroupAction) CopyFieldAction(org.openkilda.rulemanager.action.noviflow.CopyFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) SetFieldAction(org.openkilda.rulemanager.action.SetFieldAction) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) PushVlanAction(org.openkilda.rulemanager.action.PushVlanAction) PopVxlanAction(org.openkilda.rulemanager.action.PopVxlanAction) ArrayList(java.util.ArrayList) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) GroupId(org.openkilda.model.GroupId) PopVlanAction(org.openkilda.rulemanager.action.PopVlanAction)

Example 7 with GroupId

use of org.openkilda.model.GroupId in project open-kilda by telstra.

the class OfGroupConverterTest method testConvertDeleteGroupCommand.

@Test
public void testConvertDeleteGroupCommand() {
    List<Bucket> buckets = new ArrayList<>();
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(2, null)))).build());
    buckets.add(Bucket.builder().watchPort(WatchPort.ANY).watchGroup(WatchGroup.ALL).writeActions(Sets.newHashSet(new PortOutAction(new PortNumber(1, null)))).build());
    GroupSpeakerData groupSpeakerData = GroupSpeakerData.builder().groupId(new GroupId(GROUP_ID)).type(GroupType.ALL).buckets(buckets).build();
    OFFactoryVer13 factory = new OFFactoryVer13();
    OFGroupDelete ofGroupDelete = OfGroupConverter.INSTANCE.convertDeleteGroupCommand(groupSpeakerData, factory);
    assertEquals(OFGroup.of(GROUP_ID), ofGroupDelete.getGroup());
    assertEquals(OFGroupType.ALL, ofGroupDelete.getGroupType());
}
Also used : OFBucket(org.projectfloodlight.openflow.protocol.OFBucket) Bucket(org.openkilda.rulemanager.group.Bucket) PortOutAction(org.openkilda.rulemanager.action.PortOutAction) OFFactoryVer13(org.projectfloodlight.openflow.protocol.ver13.OFFactoryVer13) ArrayList(java.util.ArrayList) GroupSpeakerData(org.openkilda.rulemanager.GroupSpeakerData) PortNumber(org.openkilda.rulemanager.ProtoConstants.PortNumber) OFGroupDelete(org.projectfloodlight.openflow.protocol.OFGroupDelete) GroupId(org.openkilda.model.GroupId) Test(org.junit.Test)

Example 8 with GroupId

use of org.openkilda.model.GroupId in project open-kilda by telstra.

the class SwitchOperationsServiceTest method shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties.

@Test(expected = IllegalSwitchPropertiesException.class)
public void shouldValidateFlowMirrorPointsWhenUpdatingSwitchLldpProperties() {
    Switch mirrorSwitch = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(mirrorSwitch);
    MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(TEST_SWITCH_ID).groupId(new GroupId(12L)).pathId(new PathId("test_path_id")).flowId(TEST_FLOW_ID_1).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).mirrorDirection(MirrorDirection.INGRESS).build();
    mirrorGroupRepository.add(mirrorGroup);
    FlowMirrorPoints flowMirrorPoints = FlowMirrorPoints.builder().mirrorGroup(mirrorGroup).mirrorSwitch(mirrorSwitch).build();
    flowMirrorPointsRepository.add(flowMirrorPoints);
    createSwitchProperties(mirrorSwitch, Collections.singleton(FlowEncapsulationType.TRANSIT_VLAN), true, false, false);
    SwitchPropertiesDto update = new SwitchPropertiesDto();
    update.setSupportedTransitEncapsulation(Collections.singleton(org.openkilda.messaging.payload.flow.FlowEncapsulationType.TRANSIT_VLAN));
    update.setMultiTable(true);
    update.setSwitchLldp(true);
    switchOperationsService.updateSwitchProperties(TEST_SWITCH_ID, update);
}
Also used : PathId(org.openkilda.model.PathId) SwitchPropertiesDto(org.openkilda.messaging.model.SwitchPropertiesDto) MirrorGroup(org.openkilda.model.MirrorGroup) Switch(org.openkilda.model.Switch) FlowMirrorPoints(org.openkilda.model.FlowMirrorPoints) GroupId(org.openkilda.model.GroupId) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 9 with GroupId

use of org.openkilda.model.GroupId in project open-kilda by telstra.

the class IngressInstallFlowModFactory method makeForwardMessageInstructions.

protected List<OFInstruction> makeForwardMessageInstructions(EffectiveIds effectiveIds, List<Integer> vlanStack) {
    List<OFAction> applyActions = new ArrayList<>();
    List<OFInstruction> instructions = new ArrayList<>();
    MeterId effectiveMeterId = effectiveIds.getMeterId();
    if (effectiveMeterId != null) {
        OfAdapter.INSTANCE.makeMeterCall(of, effectiveMeterId, applyActions, instructions);
    }
    GroupId effectiveGroupId = effectiveIds.getGroupId();
    boolean groupIsPresent = effectiveGroupId != null;
    applyActions.addAll(makeTransformActions(vlanStack, groupIsPresent));
    if (groupIsPresent) {
        applyActions.add(makeGroupAction(effectiveGroupId));
    } else {
        applyActions.add(makeOutputAction());
    }
    instructions.add(of.instructions().applyActions(applyActions));
    if (command.getMetadata().isMultiTable() && effectiveGroupId == null) {
        instructions.add(of.instructions().gotoTable(TableId.of(SwitchManager.POST_INGRESS_TABLE_ID)));
        instructions.addAll(makeMetadataInstructions());
    }
    return instructions;
}
Also used : OFInstruction(org.projectfloodlight.openflow.protocol.instruction.OFInstruction) OFAction(org.projectfloodlight.openflow.protocol.action.OFAction) ArrayList(java.util.ArrayList) MeterId(org.openkilda.model.MeterId) GroupId(org.openkilda.model.GroupId)

Example 10 with GroupId

use of org.openkilda.model.GroupId in project open-kilda by telstra.

the class FermaMirrorGroupRepositoryTest method createMirrorGroup.

private MirrorGroup createMirrorGroup(int groupId, PathId pathId) {
    MirrorGroup mirrorGroup = MirrorGroup.builder().switchId(theSwitch.getSwitchId()).groupId(new GroupId(groupId)).pathId(pathId).flowId(TEST_FLOW_ID).mirrorDirection(MirrorDirection.INGRESS).mirrorGroupType(MirrorGroupType.TRAFFIC_INTEGRITY).build();
    mirrorGroupRepository.add(mirrorGroup);
    return mirrorGroup;
}
Also used : MirrorGroup(org.openkilda.model.MirrorGroup) GroupId(org.openkilda.model.GroupId)

Aggregations

GroupId (org.openkilda.model.GroupId)20 MirrorGroup (org.openkilda.model.MirrorGroup)9 ArrayList (java.util.ArrayList)8 PathId (org.openkilda.model.PathId)8 SwitchId (org.openkilda.model.SwitchId)6 List (java.util.List)5 Test (org.junit.Test)5 FlowMirrorPoints (org.openkilda.model.FlowMirrorPoints)5 Switch (org.openkilda.model.Switch)5 PortNumber (org.openkilda.rulemanager.ProtoConstants.PortNumber)5 PortOutAction (org.openkilda.rulemanager.action.PortOutAction)5 OFBucket (org.projectfloodlight.openflow.protocol.OFBucket)5 Optional (java.util.Optional)4 Collectors (java.util.stream.Collectors)4 MirrorGroupRepository (org.openkilda.persistence.repositories.MirrorGroupRepository)4 Bucket (org.openkilda.rulemanager.group.Bucket)4 Set (java.util.Set)3 Generators (com.fasterxml.uuid.Generators)2 NoArgGenerator (com.fasterxml.uuid.NoArgGenerator)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2