use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildTransformActionsVxlanEncapsulationDoubleVlanTest.
@Test
public void buildTransformActionsVxlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<Action> transformActions = generator.buildTransformActions(INNER_VLAN_ID_1, FEATURES);
List<Action> expectedActions = newArrayList(new PopVlanAction(), buildPushVxlan());
assertEquals(expectedActions, transformActions);
}
use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVxlanEncapsulationSingleVlanTest.
@Test
public void buildCommandsVxlanEncapsulationSingleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, 0);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VXLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(buildPushVxlan(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_SINGLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.
the class MultiTableServer42IngressRuleGeneratorTest method buildCommandsVlanEncapsulationDoubleVlanTest.
@Test
public void buildCommandsVlanEncapsulationDoubleVlanTest() {
Flow flow = buildFlow(PATH, OUTER_VLAN_ID_1, INNER_VLAN_ID_1);
MultiTableServer42IngressRuleGenerator generator = buildGenerator(PATH, flow, VLAN_ENCAPSULATION);
List<SpeakerData> commands = generator.generateCommands(SWITCH_1);
assertEquals(3, commands.size());
FlowSpeakerData ingressCommand = (FlowSpeakerData) commands.get(0);
FlowSpeakerData preIngressCommand = (FlowSpeakerData) commands.get(1);
FlowSpeakerData inputCustomerCommand = (FlowSpeakerData) commands.get(2);
assertPreIngressCommand(preIngressCommand, newArrayList(new PopVlanAction()));
assertInputCommand(inputCustomerCommand);
RoutingMetadata ingressMetadata = RoutingMetadata.builder().inputPort(PORT_NUMBER_1).outerVlanId(OUTER_VLAN_ID_1).build(SWITCH_1.getFeatures());
Set<FieldMatch> expectedIngressMatch = Sets.newHashSet(FieldMatch.builder().field(Field.IN_PORT).value(SERVER_42_PORT_NUMBER).build(), FieldMatch.builder().field(Field.VLAN_VID).value(INNER_VLAN_ID_1).build(), FieldMatch.builder().field(Field.METADATA).value(ingressMetadata.getValue()).mask(ingressMetadata.getMask()).build());
List<Action> expectedIngressActions = newArrayList(SetFieldAction.builder().field(Field.ETH_SRC).value(SWITCH_ID_1.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.ETH_DST).value(SWITCH_ID_2.toMacAddressAsLong()).build(), SetFieldAction.builder().field(Field.VLAN_VID).value(TRANSIT_VLAN_ID).build(), new PortOutAction(new PortNumber(PORT_NUMBER_2)));
assertIngressCommand(ingressCommand, Priority.SERVER_42_INGRESS_DOUBLE_VLAN_FLOW_PRIORITY, expectedIngressMatch, expectedIngressActions);
}
use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.
the class SingleTableIngressYRuleGeneratorTest method buildTransformActionsOneSwitchSingleVlanInFullPortOutTest.
@Test
public void buildTransformActionsOneSwitchSingleVlanInFullPortOutTest() {
Flow flow = buildFlow(ONE_SWITCH_PATH, OUTER_VLAN_ID_1, 0);
SingleTableIngressYRuleGenerator generator = buildGenerator(ONE_SWITCH_PATH, flow, VLAN_ENCAPSULATION);
List<Action> transformActions = generator.buildTransformActions(OUTER_VLAN_ID_1, FEATURES);
List<Action> expectedActions = newArrayList(new PopVlanAction());
assertEquals(expectedActions, transformActions);
}
use of org.openkilda.rulemanager.action.PopVlanAction in project open-kilda by telstra.
the class Utils method makeVlanReplaceActions.
/**
* Create series of actions required to reTAG one set of vlan tags to another.
*/
public static List<Action> makeVlanReplaceActions(List<Integer> currentVlanStack, List<Integer> targetVlanStack) {
Iterator<Integer> currentIter = currentVlanStack.iterator();
Iterator<Integer> targetIter = targetVlanStack.iterator();
final List<Action> actions = new ArrayList<>();
while (currentIter.hasNext() && targetIter.hasNext()) {
Integer current = currentIter.next();
Integer target = targetIter.next();
if (current == null || target == null) {
throw new IllegalArgumentException("Null elements are not allowed inside currentVlanStack and targetVlanStack arguments");
}
if (!current.equals(target)) {
// remove all extra VLANs
while (currentIter.hasNext()) {
currentIter.next();
actions.add(new PopVlanAction());
}
// rewrite existing VLAN stack "head"
actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(target).build());
break;
}
}
// remove all extra VLANs (if previous loops ends with lack of target VLANs)
while (currentIter.hasNext()) {
currentIter.next();
actions.add(new PopVlanAction());
}
while (targetIter.hasNext()) {
actions.add(new PushVlanAction());
actions.add(SetFieldAction.builder().field(Field.VLAN_VID).value(targetIter.next()).build());
}
return actions;
}
Aggregations