use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class PingServiceTest method testWrapUnwrapCycleVxlan.
@Test
public void testWrapUnwrapCycleVxlan() throws Exception {
Ping ping = new Ping(new NetworkEndpoint(new SwitchId(dpIdAlpha.getLong()), 8), new NetworkEndpoint(new SwitchId(dpIdBeta.getLong()), 9), new FlowTransitEncapsulation(2, FlowEncapsulationType.VXLAN), 3);
moduleContext.getServiceImpl(InputService.class).addTranslator(eq(OFType.PACKET_IN), anyObject(PingInputTranslator.class));
replayAll();
pingService.setup(moduleContext);
byte[] payload = new byte[] { 0x31, 0x32, 0x33, 0x34, 0x35 };
byte[] wrapped = pingService.wrapData(ping, payload).serialize();
IPacket ethernet = new Ethernet().deserialize(wrapped, 0, wrapped.length);
Assert.assertTrue(ethernet instanceof Ethernet);
IPacket ipv4 = ethernet.getPayload();
Assert.assertTrue(ipv4 instanceof IPv4);
IPacket udp = ipv4.getPayload();
Assert.assertTrue(udp instanceof UDP);
Assert.assertEquals(((UDP) udp).getSourcePort(), TransportPort.of(SwitchManager.STUB_VXLAN_UDP_SRC));
Assert.assertEquals(((UDP) udp).getDestinationPort(), TransportPort.of(SwitchManager.VXLAN_UDP_DST));
byte[] udpPayload = udp.getPayload().serialize();
Vxlan vxlan = (Vxlan) new Vxlan().deserialize(udpPayload, 0, udpPayload.length);
Assert.assertEquals((int) ping.getTransitEncapsulation().getId(), vxlan.getVni());
byte[] vxlanPayload = vxlan.getPayload().serialize();
IPacket decoded = new Ethernet().deserialize(vxlanPayload, 0, vxlanPayload.length);
Assert.assertTrue(decoded instanceof Ethernet);
PingWiredView parsed = pingService.unwrapData(dpIdBeta, (Ethernet) decoded);
Assert.assertNotNull(parsed);
Assert.assertArrayEquals(payload, parsed.getPayload());
Assert.assertTrue(parsed.getVlanStack().isEmpty());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkOperationsBoltTest method shouldCreateLinkProps.
@Test
public void shouldCreateLinkProps() {
SwitchRepository switchRepository = persistenceManager.getRepositoryFactory().createSwitchRepository();
switchRepository.add(Switch.builder().switchId(SWITCH_ID_1).build());
switchRepository.add(Switch.builder().switchId(SWITCH_ID_2).build());
LinkOperationsBolt bolt = new LinkOperationsBolt(persistenceManager);
bolt.prepare(null, topologyContext, null);
LinkPropsPut linkPropsPutRequest = new LinkPropsPut(new LinkPropsDto(new NetworkEndpoint(SWITCH_ID_1, 1), new NetworkEndpoint(SWITCH_ID_2, 1), Collections.emptyMap()));
LinkPropsResponse response = (LinkPropsResponse) bolt.processRequest(null, linkPropsPutRequest).get(0);
assertNotNull(response.getLinkProps());
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceImpl method rerouteFlowsForLink.
@Override
public CompletableFuture<List<String>> rerouteFlowsForLink(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
final String correlationId = RequestCorrelationId.getId();
logger.debug("Reroute all flows for a particular link request processing");
RerouteFlowsForIslRequest data = null;
try {
data = new RerouteFlowsForIslRequest(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), correlationId);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage());
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments when create \"reroute flows for link\" request");
}
CommandMessage message = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(FlowsResponse.class::cast).map(FlowsResponse::getFlowIds).flatMap(Collection::stream).collect(Collectors.toList()));
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceImpl method updateLinkUnderMaintenance.
@Override
public CompletableFuture<List<LinkDto>> updateLinkUnderMaintenance(LinkUnderMaintenanceDto link) {
final String correlationId = RequestCorrelationId.getId();
logger.debug("Update under maintenance link request processing");
UpdateLinkUnderMaintenanceRequest data = null;
try {
data = new UpdateLinkUnderMaintenanceRequest(new NetworkEndpoint(new SwitchId(link.getSrcSwitch()), link.getSrcPort()), new NetworkEndpoint(new SwitchId(link.getDstSwitch()), link.getDstPort()), link.isUnderMaintenance(), link.isEvacuate());
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage());
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments when create 'update ISL Under maintenance' request");
}
CommandMessage message = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(IslInfoData.class::cast).map(linkMapper::mapResponse).collect(Collectors.toList()));
}
use of org.openkilda.messaging.model.NetworkEndpoint in project open-kilda by telstra.
the class LinkServiceImpl method getFlowsForLink.
@Override
public CompletableFuture<List<FlowResponsePayload>> getFlowsForLink(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort) {
final String correlationId = RequestCorrelationId.getId();
logger.debug("Get all flows for a particular link request processing");
GetFlowsForIslRequest data = null;
try {
data = new GetFlowsForIslRequest(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), correlationId);
} catch (IllegalArgumentException e) {
logger.error("Can not parse arguments: {}", e.getMessage());
throw new MessageException(correlationId, System.currentTimeMillis(), ErrorType.DATA_INVALID, e.getMessage(), "Can not parse arguments when create \"get flows for link\" request");
}
CommandMessage message = new CommandMessage(data, System.currentTimeMillis(), correlationId, Destination.WFM);
return messagingChannel.sendAndGetChunked(nbworkerTopic, message).thenApply(response -> response.stream().map(FlowResponse.class::cast).map(FlowResponse::getPayload).map(flowMapper::toFlowResponseOutput).collect(Collectors.toList()));
}
Aggregations