Search in sources :

Example 6 with LinkPropsResponse

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

the class LinkServiceTest method updateMaxBandwidth.

@Test
public void updateMaxBandwidth() {
    final String correlationId = "update-max-bw-corrId";
    Long maxBandwidth = 1000L;
    SwitchId srcSwitch = new SwitchId("ff:fe:00:00:00:00:00:01");
    Integer srcPort = 8;
    SwitchId dstSwitch = new SwitchId("ff:fe:00:00:00:00:00:02");
    Integer dstPort = 9;
    LinkMaxBandwidthRequest inputRequest = new LinkMaxBandwidthRequest();
    inputRequest.setMaxBandwidth(maxBandwidth);
    HashMap<String, String> requestProps = new HashMap<>();
    requestProps.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, String.valueOf(maxBandwidth));
    org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), requestProps);
    LinkPropsRequest request = new LinkPropsPut(linkProps);
    LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
    messageExchanger.mockResponse(correlationId, payload);
    RequestCorrelationId.create(correlationId);
    LinkMaxBandwidthDto result = linkService.updateLinkBandwidth(srcSwitch, srcPort, dstSwitch, dstPort, inputRequest).join();
    assertEquals(srcSwitch.toString(), result.getSrcSwitch());
    assertEquals(dstSwitch.toString(), result.getDstSwitch());
    assertEquals(srcPort, result.getSrcPort());
    assertEquals(dstPort, result.getDstPort());
    assertEquals(maxBandwidth, result.getMaxBandwidth());
}
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) LinkMaxBandwidthRequest(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthRequest) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) LinkMaxBandwidthDto(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto) Test(org.junit.Test)

Example 7 with LinkPropsResponse

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

the class LinkServiceImpl method updateLinkBandwidth.

/**
 * {@inheritDoc}
 */
@Override
public CompletableFuture<LinkMaxBandwidthDto> updateLinkBandwidth(SwitchId srcSwitch, Integer srcPort, SwitchId dstSwitch, Integer dstPort, LinkMaxBandwidthRequest input) {
    if (input.getMaxBandwidth() == null || input.getMaxBandwidth() < 0) {
        throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of max_bandwidth", "Maximum bandwidth must not be null");
    }
    if (srcPort < 0) {
        throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of source port", "Port number can't be negative");
    }
    if (dstPort < 0) {
        throw new MessageException(ErrorType.PARAMETERS_INVALID, "Invalid value of destination port", "Port number can't be negative");
    }
    org.openkilda.messaging.model.LinkPropsDto linkProps = org.openkilda.messaging.model.LinkPropsDto.builder().source(new NetworkEndpoint(srcSwitch, srcPort)).dest(new NetworkEndpoint(dstSwitch, dstPort)).props(ImmutableMap.of(LinkProps.MAX_BANDWIDTH_PROP_NAME, input.getMaxBandwidth().toString())).build();
    LinkPropsPut request = new LinkPropsPut(linkProps);
    String correlationId = RequestCorrelationId.getId();
    CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGet(nbworkerTopic, message).thenApply(response -> linkPropsMapper.toLinkMaxBandwidth(((LinkPropsResponse) response).getLinkProps()));
}
Also used : LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) MessageException(org.openkilda.messaging.error.MessageException) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) CommandMessage(org.openkilda.messaging.command.CommandMessage)

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