Search in sources :

Example 6 with LinkPropsDto

use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.

the class LinkServiceTest method shouldGetPropsList.

@Test
public void shouldGetPropsList() {
    final String correlationId = "non-empty-link-props";
    org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId("00:00:00:00:00:00:00:01"), 1), new NetworkEndpoint(new SwitchId("00:00:00:00:00:00:00:02"), 2), Collections.singletonMap("cost", "2"));
    LinkPropsData linkPropsData = new LinkPropsData(linkProps);
    messageExchanger.mockChunkedResponse(correlationId, Collections.singletonList(linkPropsData));
    RequestCorrelationId.create(correlationId);
    List<LinkPropsDto> result = linkService.getLinkProps(null, 0, null, 0).join();
    assertFalse("List of link props shouldn't be empty", result.isEmpty());
    LinkPropsDto dto = result.get(0);
    assertThat(dto.getSrcSwitch(), is(linkPropsData.getLinkProps().getSource().getDatapath().toString()));
    assertThat(dto.getSrcPort(), is(linkPropsData.getLinkProps().getSource().getPortNumber()));
    assertThat(dto.getDstSwitch(), is(linkPropsData.getLinkProps().getDest().getDatapath().toString()));
    assertThat(dto.getDstPort(), is(linkPropsData.getLinkProps().getDest().getPortNumber()));
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) LinkPropsData(org.openkilda.messaging.nbtopology.response.LinkPropsData) SwitchId(org.openkilda.model.SwitchId) Test(org.junit.Test)

Example 7 with LinkPropsDto

use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.

the class LinkPropertiesSteps method createLinkPropertiesRequest.

@When("^create link properties request for ISL '(.*)'$")
public void createLinkPropertiesRequest(String islAlias) {
    linkPropsRequest = new LinkPropsDto();
    Isl theIsl = topologyUnderTest.getAliasedObject(islAlias);
    linkPropsRequest.setSrcSwitch(theIsl.getSrcSwitch().getDpId().toString());
    linkPropsRequest.setSrcPort(theIsl.getSrcPort());
    linkPropsRequest.setDstSwitch(theIsl.getDstSwitch().getDpId().toString());
    linkPropsRequest.setDstPort(theIsl.getDstPort());
}
Also used : Isl(org.openkilda.testing.model.topology.TopologyDefinition.Isl) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) When(cucumber.api.java.en.When)

Example 8 with LinkPropsDto

use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.

the class LinkPropertiesSteps method verifyResponseLinkProperties.

@Then("^response link properties from request has property '(.*)' with value '(.*)'$")
public void verifyResponseLinkProperties(String key, String value) {
    LinkPropsDto props = getLinkPropsResponse.stream().filter(p -> p.equals(linkPropsRequest)).findFirst().orElseThrow(() -> new IllegalStateException(format("Link properties %s not found.", linkPropsRequest)));
    assertThat(value, equalTo(String.valueOf(props.getProperty(key))));
}
Also used : LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) Then(cucumber.api.java.en.Then)

Example 9 with LinkPropsDto

use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.

the class LinkServiceImpl method delLinkProps.

@Override
public CompletableFuture<BatchResults> delLinkProps(List<LinkPropsDto> linkPropsList) {
    List<CompletableFuture<List<InfoData>>> pendingRequest = new ArrayList<>(linkPropsList.size());
    for (LinkPropsDto requestItem : linkPropsList) {
        LinkPropsDrop request = new LinkPropsDrop(linkPropsMapper.toLinkPropsMask(requestItem));
        String requestId = idFactory.produceChained(RequestCorrelationId.getId());
        CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), requestId);
        pendingRequest.add(messagingChannel.sendAndGetChunked(nbworkerTopic, message));
    }
    return collectChunkedResponses(pendingRequest, LinkPropsResponse.class).thenApply(responses -> getLinkPropsResult(responses, new ArrayList<>()));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) InfoData(org.openkilda.messaging.info.InfoData) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) ArrayList(java.util.ArrayList) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) LinkPropsDrop(org.openkilda.messaging.nbtopology.request.LinkPropsDrop) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Example 10 with LinkPropsDto

use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.

the class LinkPropsMapper method toLinkMaxBandwidth.

/**
 * Converts {@link LinkPropsDto} to {@link LinkMaxBandwidthDto}.
 */
default LinkMaxBandwidthDto toLinkMaxBandwidth(LinkPropsDto input) {
    NetworkEndpoint source = input.getSource();
    NetworkEndpoint dest = input.getDest();
    Long maxBandwidth = Long.valueOf(input.getProps().get(LinkProps.MAX_BANDWIDTH_PROP_NAME));
    return new LinkMaxBandwidthDto(source.getDatapath().toString(), source.getPortNumber(), dest.getDatapath().toString(), dest.getPortNumber(), maxBandwidth);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkMaxBandwidthDto(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto)

Aggregations

LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)9 Test (org.junit.Test)4 NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)4 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)4 SwitchId (org.openkilda.model.SwitchId)3 ArrayList (java.util.ArrayList)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 CommandMessage (org.openkilda.messaging.command.CommandMessage)2 LinkPropsDrop (org.openkilda.messaging.nbtopology.request.LinkPropsDrop)2 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)2 BatchResults (org.openkilda.northbound.dto.BatchResults)2 Then (cucumber.api.java.en.Then)1 When (cucumber.api.java.en.When)1 HashMap (java.util.HashMap)1 InfoData (org.openkilda.messaging.info.InfoData)1 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)1 LinkPropsMask (org.openkilda.messaging.model.LinkPropsMask)1 NetworkEndpointMask (org.openkilda.messaging.model.NetworkEndpointMask)1 LinkPropsRequest (org.openkilda.messaging.nbtopology.request.LinkPropsRequest)1 LinkPropsData (org.openkilda.messaging.nbtopology.response.LinkPropsData)1