use of org.openkilda.rulemanager.action.MeterAction in project open-kilda by telstra.
the class BroadCastDiscoveryRuleGeneratorTest method shouldBuildCorrectRuleWithMeterAndGroupForOf15.
@Test
public void shouldBuildCorrectRuleWithMeterAndGroupForOf15() {
sw = buildSwitch("OF_15", Sets.newHashSet(METERS, GROUP_PACKET_OUT_CONTROLLER, MATCH_UDP_PORT, PKTPS_FLAG));
List<SpeakerData> commands = generator.generateCommands(sw);
assertEquals(3, commands.size());
commands.forEach(c -> assertEquals(sw.getSwitchId(), c.getSwitchId()));
commands.forEach(c -> assertEquals(sw.getOfVersion(), c.getOfVersion().toString()));
FlowSpeakerData flowCommandData = getCommand(FlowSpeakerData.class, commands);
MeterSpeakerData meterCommandData = getCommand(MeterSpeakerData.class, commands);
GroupSpeakerData groupCommandData = getCommand(GroupSpeakerData.class, commands);
assertEquals(2, flowCommandData.getDependsOn().size());
assertTrue(flowCommandData.getDependsOn().contains(meterCommandData.getUuid()));
assertTrue(flowCommandData.getDependsOn().contains(groupCommandData.getUuid()));
// Check flow command
checkFlowCommandBaseProperties(flowCommandData);
Set<FieldMatch> match = flowCommandData.getMatch();
assertEquals(4, match.size());
checkEthDstMatch(match);
checkUpdDstMatch(match);
// Check flow command has correct instructions for OF 1.5
Instructions instructions = flowCommandData.getInstructions();
assertEquals(2, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof MeterAction);
MeterAction meterAction = (MeterAction) first;
assertEquals(meterCommandData.getMeterId(), meterAction.getMeterId());
checkGroupAction(instructions.getApplyActions().get(1), groupCommandData.getGroupId());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
// Check meter command
checkMeterCommand(meterCommandData);
// Check group command
checkGroupCommand(groupCommandData);
}
use of org.openkilda.rulemanager.action.MeterAction in project open-kilda by telstra.
the class LldpPostIngressVxlanRuleGeneratorTest method checkInstructionsOf15.
@Override
protected void checkInstructionsOf15(Instructions instructions, MeterId meterId) {
assertEquals(3, instructions.getApplyActions().size());
Action first = instructions.getApplyActions().get(0);
assertTrue(first instanceof PopVxlanAction);
PopVxlanAction popVxlanAction = (PopVxlanAction) first;
assertEquals(ActionType.POP_VXLAN_NOVIFLOW, popVxlanAction.getType());
Action second = instructions.getApplyActions().get(1);
assertTrue(second instanceof PortOutAction);
PortOutAction portOutAction = (PortOutAction) second;
assertEquals(SpecialPortType.CONTROLLER, portOutAction.getPortNumber().getPortType());
Action third = instructions.getApplyActions().get(2);
assertTrue(third instanceof MeterAction);
MeterAction meterAction = (MeterAction) third;
assertEquals(meterId, meterAction.getMeterId());
assertNull(instructions.getWriteActions());
assertNull(instructions.getGoToMeter());
assertNull(instructions.getGoToTable());
}
use of org.openkilda.rulemanager.action.MeterAction in project open-kilda by telstra.
the class RuleManagerHelperTest method buildAllActions.
private List<Action> buildAllActions() {
List<Action> actions = new ArrayList<>();
actions.add(new GroupAction(GROUP_ID_1));
actions.add(new MeterAction(METER_ID_1));
actions.add(new PopVlanAction());
actions.add(new PopVxlanAction(ActionType.POP_VXLAN_OVS));
actions.add(new PortOutAction(PORT_NUMBER));
actions.add(new PushVlanAction());
actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(VLAN_ID).build());
actions.add(CopyFieldAction.builder().srcOffset(0).dstOffset(0).numberOfBits(NUMBER_OF_BITS).oxmSrcHeader(OpenFlowOxms.NOVIFLOW_TX_TIMESTAMP).oxmDstHeader(OpenFlowOxms.NOVIFLOW_PACKET_OFFSET).build());
actions.add(PushVxlanAction.builder().type(ActionType.PUSH_VXLAN_NOVIFLOW).vni(VNI).srcMacAddress(SRC_MAC_ADDRESS).dstMacAddress(DST_MAC_ADDRESS).srcIpv4Address(SRC_IPV4_ADDRESS).dstIpv4Address(DST_IPV4_ADDRESS).udpSrc(UDP_SRC).build());
return actions;
}
use of org.openkilda.rulemanager.action.MeterAction in project open-kilda by telstra.
the class FlowEntryConverter method addAction.
private void addAction(FlowApplyActionsBuilder builder, Action action) {
switch(action.getType()) {
case GROUP:
GroupAction groupAction = (GroupAction) action;
builder.group(String.valueOf(groupAction.getGroupId().getValue()));
return;
case PORT_OUT:
PortOutAction portOutAction = (PortOutAction) action;
builder.flowOutput(portOutAction.getPortNumber().toString());
return;
case POP_VLAN:
builder.popVlan("");
return;
case PUSH_VLAN:
builder.pushVlan("");
return;
case POP_VXLAN_NOVIFLOW:
case POP_VXLAN_OVS:
// todo handle pop vxlan
return;
case PUSH_VXLAN_NOVIFLOW:
case PUSH_VXLAN_OVS:
PushVxlanAction pushVxlanAction = (PushVxlanAction) action;
builder.pushVxlan(String.valueOf(pushVxlanAction.getVni()));
return;
case METER:
MeterAction meterAction = (MeterAction) action;
builder.meter(String.valueOf(meterAction.getMeterId().getValue()));
return;
case NOVI_COPY_FIELD:
CopyFieldAction copyFieldAction = (CopyFieldAction) action;
builder.copyFieldAction(FlowCopyFieldAction.builder().bits(String.valueOf(copyFieldAction.getNumberOfBits())).srcOffset(String.valueOf(copyFieldAction.getSrcOffset())).dstOffset(String.valueOf(copyFieldAction.getDstOffset())).srcOxm(copyFieldAction.getOxmSrcHeader().toString()).dstOxm(copyFieldAction.getOxmDstHeader().toString()).build());
return;
case NOVI_SWAP_FIELD:
case KILDA_SWAP_FIELD:
SwapFieldAction swapFieldAction = (SwapFieldAction) action;
builder.swapFieldAction(FlowSwapFieldAction.builder().bits(String.valueOf(swapFieldAction.getNumberOfBits())).srcOffset(String.valueOf(swapFieldAction.getSrcOffset())).dstOffset(String.valueOf(swapFieldAction.getDstOffset())).srcOxm(swapFieldAction.getOxmSrcHeader().toString()).dstOxm(swapFieldAction.getOxmDstHeader().toString()).build());
return;
case SET_FIELD:
SetFieldAction setFieldAction = (SetFieldAction) action;
builder.setFieldAction(FlowSetFieldAction.builder().fieldName(setFieldAction.getField().toString()).fieldValue(String.valueOf(setFieldAction.getValue())).build());
return;
default:
throw new IllegalStateException(format("Unknown action type %s", action.getType()));
}
}
Aggregations