use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.
the class PersistenceDataAdapterTest method shouldProvideCorrectVxlanEncapsulation.
@Test
public void shouldProvideCorrectVxlanEncapsulation() {
PathId pathId = new PathId("path1");
Set<PathId> pathIds = Sets.newHashSet(pathId);
Vxlan vxlan = Vxlan.builder().flowId("flowId").pathId(pathId).vni(8).build();
when(vxlanRepository.findByPathId(pathId, null)).thenReturn(Collections.singletonList(vxlan));
adapter = PersistenceDataAdapter.builder().pathIds(pathIds).persistenceManager(persistenceManager).build();
FlowTransitEncapsulation actual = adapter.getTransitEncapsulation(pathId, null);
assertEquals(FlowEncapsulationType.VXLAN, actual.getType());
assertEquals(vxlan.getVni(), actual.getId().intValue());
adapter.getTransitEncapsulation(pathId, null);
verify(transitVlanRepository).findByPathId(pathId, null);
verify(vxlanRepository).findByPathId(pathId, null);
verifyNoMoreInteractions(transitVlanRepository);
verifyNoMoreInteractions(vxlanRepository);
}
use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.
the class IngressFlowSegmentInstallFlowModFactory method makeTransformActions.
@Override
protected List<OFAction> makeTransformActions(List<Integer> vlanStack, boolean groupIsPresent) {
List<OFAction> actions = new ArrayList<>();
FlowTransitEncapsulation encapsulation = command.getEncapsulation();
switch(encapsulation.getType()) {
case TRANSIT_VLAN:
actions.addAll(makeVlanEncapsulationTransformActions(vlanStack, groupIsPresent));
break;
case VXLAN:
actions.addAll(makeVxLanEncapsulationTransformActions(vlanStack, groupIsPresent));
break;
default:
throw new NotImplementedEncapsulationException(getClass(), encapsulation.getType(), command.getSwitchId(), command.getMetadata().getFlowId());
}
return actions;
}
use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.
the class SpeakerFlowSegmentRequestBuilder method makeRequests.
private List<FlowSegmentRequestFactory> makeRequests(CommandContext context, Flow flow, FlowPath path, FlowPath oppositePath, boolean doIngress, boolean doTransit, boolean doEgress, SpeakerRequestBuildContext speakerRequestBuildContext, MirrorContext mirrorContext) {
// TODO: this swap is weird, need to clean this up and not to rely on luck.
if (path == null) {
path = oppositePath;
oppositePath = null;
speakerRequestBuildContext = SpeakerRequestBuildContext.builder().forward(speakerRequestBuildContext.getReverse()).reverse(speakerRequestBuildContext.getForward()).build();
}
if (path == null) {
throw new IllegalArgumentException("At least one flow path must be not null");
}
boolean isDeleteOperation = speakerRequestBuildContext.isDeleteOperation();
FlowTransitEncapsulation encapsulation = null;
if (!flow.isOneSwitchFlow()) {
try {
encapsulation = getEncapsulation(flow.getEncapsulationType(), path.getPathId(), oppositePath != null ? oppositePath.getPathId() : null);
} catch (IllegalStateException e) {
if (!isDeleteOperation) {
throw e;
}
encapsulation = DELETE_ENCAPSULATION_STUB;
}
}
List<FlowSegmentRequestFactory> requests = new ArrayList<>(makePathRequests(flow, path, context, encapsulation, doIngress, doTransit, doEgress, createRulesContext(speakerRequestBuildContext.getForward()), mirrorContext));
if (oppositePath != null) {
if (!flow.isOneSwitchFlow()) {
try {
encapsulation = getEncapsulation(flow.getEncapsulationType(), oppositePath.getPathId(), path.getPathId());
} catch (IllegalStateException e) {
if (!isDeleteOperation) {
throw e;
}
encapsulation = DELETE_ENCAPSULATION_STUB;
}
}
requests.addAll(makePathRequests(flow, oppositePath, context, encapsulation, doIngress, doTransit, doEgress, createRulesContext(speakerRequestBuildContext.getReverse()), mirrorContext));
}
return requests;
}
use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.
the class IngressFlowSegmentInstallFlowModFactory method makeServer42IngressFlowTransformActions.
@Override
protected List<OFAction> makeServer42IngressFlowTransformActions(List<Integer> vlanStack) {
List<OFAction> actions = new ArrayList<>();
FlowTransitEncapsulation encapsulation = command.getEncapsulation();
switch(encapsulation.getType()) {
case TRANSIT_VLAN:
MacAddress ethSrc = MacAddress.of(sw.getId());
MacAddress ethDst = MacAddress.of(command.getEgressSwitchId().toLong());
actions.add(of.actions().setField(of.oxms().ethSrc(ethSrc)));
actions.add(of.actions().setField(of.oxms().ethDst(ethDst)));
if (!getCommand().getMetadata().isMultiTable()) {
actions.add(of.actions().setField(of.oxms().udpSrc(TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT))));
actions.add(of.actions().setField(of.oxms().udpDst(TransportPort.of(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT))));
if (switchFeatures.contains(NOVIFLOW_COPY_FIELD)) {
actions.add(buildServer42CopyFirstTimestamp(of));
}
}
actions.addAll(makeVlanEncapsulationTransformActions(vlanStack, false));
break;
case VXLAN:
if (!getCommand().getMetadata().isMultiTable() && switchFeatures.contains(NOVIFLOW_COPY_FIELD)) {
actions.add(buildServer42CopyFirstTimestamp(of));
}
actions.addAll(OfAdapter.INSTANCE.makeVlanReplaceActions(of, vlanStack, Collections.emptyList()));
actions.add(pushVxlanAction(SERVER_42_FLOW_RTT_FORWARD_UDP_PORT));
break;
default:
throw new NotImplementedEncapsulationException(getClass(), encapsulation.getType(), command.getSwitchId(), command.getMetadata().getFlowId());
}
return actions;
}
use of org.openkilda.model.FlowTransitEncapsulation in project open-kilda by telstra.
the class PingTest method serializeLoop.
@Test
public void serializeLoop() throws Exception {
Ping origin = new Ping(new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:01"), 8), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 10), new FlowTransitEncapsulation(2, FlowEncapsulationType.TRANSIT_VLAN), 3);
serializer.serialize(origin);
Ping decoded = (Ping) serializer.deserialize();
Assert.assertEquals(String.format("%s object have been mangled in serialisation/deserialization loop", origin.getClass().getName()), origin, decoded);
}
Aggregations