use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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());
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber 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;
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.
the class Server42FlowRttOutputVxlanRuleGeneratorTest method testOutputRule.
private void testOutputRule(Switch sw, Action expectedPopVxlan, boolean copyField) {
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new Cookie(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_OUTPUT_VXLAN_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(expectedPopVxlan, new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_PORT).build());
if (copyField) {
expectedApplyActions.add(CopyFieldAction.builder().oxmSrcHeader(OpenFlowOxms.NOVIFLOW_TX_TIMESTAMP).oxmDstHeader(OpenFlowOxms.NOVIFLOW_UDP_PAYLOAD_OFFSET).srcOffset(0).dstOffset(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).numberOfBits(NOVIFLOW_TIMESTAMP_SIZE_IN_BITS).build());
}
expectedApplyActions.add(new PortOutAction(new PortNumber(Utils.SERVER_42_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.
the class Server42FlowRttVxlanTurningRuleGeneratorTest method testOutputRule.
private void testOutputRule(Switch sw, ActionType expectedSwapFieldType) {
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new Cookie(SERVER_42_FLOW_RTT_VXLAN_TURNING_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_FLOW_RTT_VXLAN_TURNING_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(sw.getSwitchId().toMacAddressAsLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT).build(), FieldMatch.builder().field(Field.UDP_DST).value(VXLAN_UDP_DST).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(SetFieldAction.builder().field(Field.UDP_SRC).value(SERVER_42_FLOW_RTT_REVERSE_UDP_VXLAN_PORT).build(), SwapFieldAction.builder().type(expectedSwapFieldType).numberOfBits(MAC_ADDRESS_SIZE_IN_BITS).srcOffset(0).dstOffset(0).oxmSrcHeader(OpenFlowOxms.ETH_SRC).oxmDstHeader(OpenFlowOxms.ETH_DST).build(), new PortOutAction(new PortNumber(SpecialPortType.IN_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
use of org.openkilda.rulemanager.ProtoConstants.PortNumber in project open-kilda by telstra.
the class Server42IslRttOutputRuleGeneratorTest method server42IslRttOutputRuleGeneratorTest.
@Test
public void server42IslRttOutputRuleGeneratorTest() {
Switch sw = buildSwitch("OF_13", Sets.newHashSet(NOVIFLOW_COPY_FIELD));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(1, commands.size());
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
assertEquals(sw.getSwitchId(), flowCommandData.getSwitchId());
assertEquals(sw.getOfVersion(), flowCommandData.getOfVersion().toString());
assertTrue(flowCommandData.getDependsOn().isEmpty());
assertEquals(new Cookie(SERVER_42_ISL_RTT_OUTPUT_COOKIE), flowCommandData.getCookie());
assertEquals(OfTable.INPUT, flowCommandData.getTable());
assertEquals(SERVER_42_ISL_RTT_OUTPUT_PRIORITY, flowCommandData.getPriority());
Set<FieldMatch> expectedMatch = Sets.newHashSet(FieldMatch.builder().field(Field.ETH_DST).value(MAC_ADDRESS.toLong()).build(), FieldMatch.builder().field(Field.ETH_TYPE).value(EthType.IPv4).build(), FieldMatch.builder().field(Field.IP_PROTO).value(IpProto.UDP).build(), FieldMatch.builder().field(Field.UDP_SRC).value(SERVER_42_ISL_RTT_REVERSE_UDP_PORT).build());
assertEquals(expectedMatch, flowCommandData.getMatch());
List<Action> expectedApplyActions = Lists.newArrayList(new PushVlanAction(), SetFieldAction.builder().field(Field.VLAN_VID).value(Utils.SERVER_42_VLAN).build(), SetFieldAction.builder().field(Field.ETH_SRC).value(sw.getSwitchId().toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(Utils.SERVER_42_MAC_ADDRESS.toLong()).build(), new PortOutAction(new PortNumber(Utils.SERVER_42_PORT)));
Instructions expectedInstructions = Instructions.builder().applyActions(expectedApplyActions).build();
assertEquals(expectedInstructions, flowCommandData.getInstructions());
}
Aggregations