Search in sources :

Example 1 with NetworkEndpoint

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());
}
Also used : UDP(net.floodlightcontroller.packet.UDP) IPacket(net.floodlightcontroller.packet.IPacket) Vxlan(org.openkilda.floodlight.shared.packet.Vxlan) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) IPv4(net.floodlightcontroller.packet.IPv4) FlowTransitEncapsulation(org.openkilda.model.FlowTransitEncapsulation) SwitchId(org.openkilda.model.SwitchId) InputService(org.openkilda.floodlight.service.of.InputService) PingWiredView(org.openkilda.floodlight.model.PingWiredView) Ping(org.openkilda.messaging.model.Ping) Ethernet(net.floodlightcontroller.packet.Ethernet) Test(org.junit.Test)

Example 2 with NetworkEndpoint

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());
}
Also used : LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) LinkPropsDto(org.openkilda.messaging.model.LinkPropsDto) SwitchRepository(org.openkilda.persistence.repositories.SwitchRepository) Test(org.junit.Test)

Example 3 with NetworkEndpoint

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()));
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) RerouteFlowsForIslRequest(org.openkilda.messaging.nbtopology.request.RerouteFlowsForIslRequest) MessageException(org.openkilda.messaging.error.MessageException) FlowsResponse(org.openkilda.messaging.info.flow.FlowsResponse) Collection(java.util.Collection) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 4 with NetworkEndpoint

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()));
}
Also used : UpdateLinkUnderMaintenanceRequest(org.openkilda.messaging.nbtopology.request.UpdateLinkUnderMaintenanceRequest) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) MessageException(org.openkilda.messaging.error.MessageException) SwitchId(org.openkilda.model.SwitchId) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 5 with NetworkEndpoint

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()));
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) MessageException(org.openkilda.messaging.error.MessageException) FlowResponse(org.openkilda.messaging.info.flow.FlowResponse) GetFlowsForIslRequest(org.openkilda.messaging.nbtopology.request.GetFlowsForIslRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)32 SwitchId (org.openkilda.model.SwitchId)16 Test (org.junit.Test)14 Ping (org.openkilda.messaging.model.Ping)7 CommandMessage (org.openkilda.messaging.command.CommandMessage)5 InfoMessage (org.openkilda.messaging.info.InfoMessage)5 LinkPropsDto (org.openkilda.messaging.model.LinkPropsDto)5 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)5 FlowTransitEncapsulation (org.openkilda.model.FlowTransitEncapsulation)5 ApiOperation (io.swagger.annotations.ApiOperation)4 HashMap (java.util.HashMap)4 MessageException (org.openkilda.messaging.error.MessageException)4 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)4 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)4 Ethernet (net.floodlightcontroller.packet.Ethernet)3 IPacket (net.floodlightcontroller.packet.IPacket)3 InputService (org.openkilda.floodlight.service.of.InputService)3 DatapathId (org.projectfloodlight.openflow.types.DatapathId)3 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)3 Date (java.util.Date)2