Search in sources :

Example 1 with LinkPropsResponse

use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse 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 2 with LinkPropsResponse

use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.

the class LinkOperationsBolt method dropLinkProps.

private LinkPropsResponse dropLinkProps(LinkPropsDrop request) {
    LinkProps linkPropsToDrop = LinkProps.builder().srcSwitchId(request.getPropsMask().getSource().getDatapath()).srcPort(request.getPropsMask().getSource().getPortNumber()).dstSwitchId(request.getPropsMask().getDest().getDatapath()).dstPort(request.getPropsMask().getDest().getPortNumber()).build();
    LinkProps reverseLinkPropsToDrop = swapLinkProps(linkPropsToDrop);
    try {
        LinkProps result = deleteLinkProps(linkPropsToDrop, reverseLinkPropsToDrop);
        return new LinkPropsResponse(request, LinkPropsMapper.INSTANCE.map(result), null);
    } catch (Exception e) {
        log.error("Unhandled exception in drop linkprops operation.", e);
        return new LinkPropsResponse(request, null, e.getMessage());
    }
}
Also used : LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkProps(org.openkilda.model.LinkProps) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) MessageException(org.openkilda.messaging.error.MessageException) LinkPropsException(org.openkilda.wfm.error.LinkPropsException) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Example 3 with LinkPropsResponse

use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.

the class LinkOperationsBolt method putLinkProps.

private LinkPropsResponse putLinkProps(LinkPropsPut request) {
    try {
        LinkProps toSetForward = LinkPropsMapper.INSTANCE.map(request.getLinkProps());
        LinkProps toSetBackward = swapLinkProps(toSetForward);
        LinkProps result = createOrUpdateProps(toSetForward);
        createOrUpdateProps(toSetBackward);
        return new LinkPropsResponse(request, LinkPropsMapper.INSTANCE.map(result), null);
    } catch (LinkPropsException e) {
        throw new MessageException(ErrorType.DATA_INVALID, "Can't create/update link props", e.getMessage());
    } catch (Exception e) {
        log.error("Unhandled exception in create or update linkprops operation.", e);
        return new LinkPropsResponse(request, null, e.getMessage());
    }
}
Also used : LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsException(org.openkilda.wfm.error.LinkPropsException) MessageException(org.openkilda.messaging.error.MessageException) LinkProps(org.openkilda.model.LinkProps) IslNotFoundException(org.openkilda.wfm.error.IslNotFoundException) MessageException(org.openkilda.messaging.error.MessageException) LinkPropsException(org.openkilda.wfm.error.LinkPropsException) IllegalIslStateException(org.openkilda.wfm.error.IllegalIslStateException)

Example 4 with LinkPropsResponse

use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.

the class LinkServiceTest method dropLinkProps.

@Test
public void dropLinkProps() {
    final String correlationId = getClass().getCanonicalName();
    LinkPropsDto input = new LinkPropsDto("ff:fe:00:00:00:00:00:01", 8, "ff:fe:00:00:00:00:00:05", null, null);
    LinkPropsDrop request = new LinkPropsDrop(new LinkPropsMask(new NetworkEndpointMask(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpointMask(new SwitchId(input.getDstSwitch()), input.getDstPort())));
    org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId(input.getSrcSwitch()), input.getSrcPort()), new NetworkEndpoint(new SwitchId("ff:fe:00:00:00:00:00:02"), 9), new HashMap<>());
    LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
    String requestIdBatch = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
    messageExchanger.mockChunkedResponse(requestIdBatch, Collections.singletonList(payload));
    RequestCorrelationId.create(correlationId);
    BatchResults result = linkService.delLinkProps(Collections.singletonList(input)).join();
    assertThat(result.getFailures(), is(0));
    assertThat(result.getSuccesses(), is(1));
    assertTrue(result.getMessages().isEmpty());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) LinkPropsMask(org.openkilda.messaging.model.LinkPropsMask) BatchResults(org.openkilda.northbound.dto.BatchResults) LinkPropsDrop(org.openkilda.messaging.nbtopology.request.LinkPropsDrop) NetworkEndpointMask(org.openkilda.messaging.model.NetworkEndpointMask) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) Test(org.junit.Test)

Example 5 with LinkPropsResponse

use of org.openkilda.messaging.nbtopology.response.LinkPropsResponse in project open-kilda by telstra.

the class LinkServiceTest method putLinkProps.

@Test
public void putLinkProps() {
    final String correlationId = getClass().getCanonicalName();
    HashMap<String, String> requestProps = new HashMap<>();
    requestProps.put("test", "value");
    org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(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"), 9), requestProps);
    LinkPropsRequest request = new LinkPropsPut(linkProps);
    LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
    String subCorrelationId = idFactory.produceChained(String.valueOf(requestIdIndex++), correlationId);
    messageExchanger.mockResponse(subCorrelationId, payload);
    LinkPropsDto inputItem = new LinkPropsDto(linkProps.getSource().getDatapath().toString(), linkProps.getSource().getPortNumber(), linkProps.getDest().getDatapath().toString(), linkProps.getDest().getPortNumber(), requestProps);
    RequestCorrelationId.create(correlationId);
    BatchResults result = linkService.setLinkProps(Collections.singletonList(inputItem)).join();
    assertThat(result.getFailures(), is(0));
    assertThat(result.getSuccesses(), is(1));
    assertTrue(result.getMessages().isEmpty());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) HashMap(java.util.HashMap) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) BatchResults(org.openkilda.northbound.dto.BatchResults) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) Test(org.junit.Test)

Aggregations

LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)7 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)5 Test (org.junit.Test)4 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)4 MessageException (org.openkilda.messaging.error.MessageException)3 SwitchId (org.openkilda.model.SwitchId)3 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)3 HashMap (java.util.HashMap)2 LinkPropsRequest (org.openkilda.messaging.nbtopology.request.LinkPropsRequest)2 LinkProps (org.openkilda.model.LinkProps)2 BatchResults (org.openkilda.northbound.dto.BatchResults)2 IllegalIslStateException (org.openkilda.wfm.error.IllegalIslStateException)2 IslNotFoundException (org.openkilda.wfm.error.IslNotFoundException)2 LinkPropsException (org.openkilda.wfm.error.LinkPropsException)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 LinkPropsDto (org.openkilda.messaging.model.LinkPropsDto)1 LinkPropsMask (org.openkilda.messaging.model.LinkPropsMask)1 NetworkEndpointMask (org.openkilda.messaging.model.NetworkEndpointMask)1 LinkPropsDrop (org.openkilda.messaging.nbtopology.request.LinkPropsDrop)1 LinkMaxBandwidthDto (org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto)1