Search in sources :

Example 1 with FlowInfo

use of org.openkilda.model.FlowInfo in project open-kilda by telstra.

the class FlowConverter method toFlowInfo.

public static FlowInfo toFlowInfo(final Flow flow) {
    FlowInfo flowInfo = new FlowInfo();
    flowInfo.setFlowid(flow.getId());
    flowInfo.setMaximumBandwidth(flow.getMaximumBandwidth());
    flowInfo.setDescription(flow.getDescription());
    FlowEndpoint source = flow.getSource();
    if (source != null) {
        flowInfo.setSourceSwitch(source.getSwitchId());
        flowInfo.setSrcPort(source.getPortId());
        flowInfo.setSrcVlan(source.getVlanId());
    }
    FlowEndpoint destination = flow.getDestination();
    if (destination != null) {
        flowInfo.setTargetSwitch(destination.getSwitchId());
        flowInfo.setDstPort(destination.getPortId());
        flowInfo.setDstVlan(destination.getVlanId());
    }
    return flowInfo;
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) FlowEndpoint(org.openkilda.integration.model.FlowEndpoint)

Example 2 with FlowInfo

use of org.openkilda.model.FlowInfo in project open-kilda by telstra.

the class FlowControllerTest method testGetFlowById.

@Test
public void testGetFlowById() throws Exception {
    FlowInfo flowInfo = new FlowInfo();
    try {
        when(flowService.getFlowById(TestFlowMock.FLOW_ID, TestFlowMock.CONTROLLER_FLAG)).thenReturn(flowInfo);
        mockMvc.perform(get("/api/flows/{flowId}", TestFlowMock.FLOW_ID).contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk());
        assertTrue(true);
    } catch (Exception e) {
        assertTrue(false);
    }
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) Test(org.junit.Test)

Example 3 with FlowInfo

use of org.openkilda.model.FlowInfo in project open-kilda by telstra.

the class FlowConverter method toFlowInfo.

/**
 * To flow info.
 *
 * @param flow the flow
 * @param csNames the cs names
 * @return the flow info
 */
public FlowInfo toFlowInfo(final Flow flow, Map<String, String> csNames) {
    FlowInfo flowInfo = new FlowInfo();
    flowInfo.setFlowid(flow.getId());
    flowInfo.setMaximumBandwidth(flow.getMaximumBandwidth());
    flowInfo.setAllocateProtectedPath(flow.isAllocateProtectedPath());
    flowInfo.setDescription(flow.getDescription());
    flowInfo.setStatus(flow.getStatus().toUpperCase());
    flowInfo.setDiverseFlowid(flow.getDiverseFlowId());
    flowInfo.setIgnoreBandwidth(flow.isIgnoreBandwidth());
    flowInfo.setLastUpdated(flow.getLastUpdated());
    flowInfo.setCreated(flow.getCreated());
    flowInfo.setEncapsulationType(flow.getEncapsulationType());
    flowInfo.setPathComputationStrategy(flow.getPathComputationStrategy());
    flowInfo.setPinned(flow.isPinned());
    flowInfo.setPeriodicPings(flow.isPeriodicPings());
    flowInfo.setMaxLatency(Long.valueOf(flow.getMaxLatency()));
    flowInfo.setPriority(flow.getPriority());
    flowInfo.setTargetPathComputationStrategy(flow.getTargetPathComputationStrategy());
    flowInfo.setStatusInfo(flow.getStatusInfo());
    if (flow.getStatusDetails() != null) {
        flowInfo.setStatusDetails(flow.getStatusDetails());
    }
    if (flow.getDiverseWith() != null) {
        flowInfo.setDiverseWith(flow.getDiverseWith());
    }
    flowInfo.setControllerFlow(true);
    FlowEndpoint source = flow.getSource();
    if (source != null) {
        String switchName = switchIntegrationService.customSwitchName(csNames, source.getSwitchId());
        flowInfo.setSourceSwitchName(switchName);
        flowInfo.setSourceSwitch(source.getSwitchId());
        flowInfo.setSrcPort(source.getPortId());
        flowInfo.setSrcVlan(source.getVlanId());
        flowInfo.setSrcInnerVlan(source.getInnerVlanId());
        flowInfo.setSrcLldp(source.getDetectedDevice().isLldp());
        flowInfo.setSrcArp(source.getDetectedDevice().isArp());
    }
    FlowEndpoint destination = flow.getDestination();
    if (destination != null) {
        String switchName = switchIntegrationService.customSwitchName(csNames, destination.getSwitchId());
        flowInfo.setTargetSwitchName(switchName);
        flowInfo.setTargetSwitch(destination.getSwitchId());
        flowInfo.setDstPort(destination.getPortId());
        flowInfo.setDstVlan(destination.getVlanId());
        flowInfo.setDstInnerVlan(destination.getInnerVlanId());
        flowInfo.setDstLldp(destination.getDetectedDevice().isLldp());
        flowInfo.setDstArp(destination.getDetectedDevice().isArp());
    }
    return flowInfo;
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) FlowEndpoint(org.openkilda.integration.model.FlowEndpoint)

Example 4 with FlowInfo

use of org.openkilda.model.FlowInfo in project open-kilda by telstra.

the class FlowConverter method toFlowV2Info.

/**
 * To flow V2 info.
 *
 * @param flow V2 the flow
 * @param csNames the cs names
 * @return the flow info
 */
public FlowInfo toFlowV2Info(final FlowV2 flow, Map<String, String> csNames) {
    FlowInfo flowInfo = new FlowInfo();
    flowInfo.setFlowid(flow.getId());
    flowInfo.setMaximumBandwidth(flow.getMaximumBandwidth());
    flowInfo.setAllocateProtectedPath(flow.isAllocateProtectedPath());
    flowInfo.setDescription(flow.getDescription());
    flowInfo.setStatus(flow.getStatus().toUpperCase());
    flowInfo.setDiverseFlowid(flow.getDiverseFlowId());
    flowInfo.setIgnoreBandwidth(flow.isIgnoreBandwidth());
    flowInfo.setLastUpdated(flow.getLastUpdated());
    flowInfo.setCreated(flow.getCreated());
    flowInfo.setEncapsulationType(flow.getEncapsulationType());
    flowInfo.setPathComputationStrategy(flow.getPathComputationStrategy());
    flowInfo.setPinned(flow.isPinned());
    flowInfo.setPeriodicPings(flow.isPeriodicPings());
    flowInfo.setMaxLatency(flow.getMaxLatency());
    flowInfo.setMaxLatencyTier2(flow.getMaxLatencyTier2());
    flowInfo.setPriority(flow.getPriority());
    flowInfo.setTargetPathComputationStrategy(flow.getTargetPathComputationStrategy());
    flowInfo.setStatusInfo(flow.getStatusInfo());
    if (flow.getStatusDetails() != null) {
        flowInfo.setStatusDetails(flow.getStatusDetails());
    }
    if (flow.getDiverseWith() != null) {
        flowInfo.setDiverseWith(flow.getDiverseWith());
    }
    flowInfo.setControllerFlow(true);
    FlowV2Endpoint source = flow.getSource();
    if (source != null) {
        String switchName = switchIntegrationService.customSwitchName(csNames, source.getSwitchId());
        flowInfo.setSourceSwitchName(switchName);
        flowInfo.setSourceSwitch(source.getSwitchId());
        flowInfo.setSrcPort(source.getPortId());
        flowInfo.setSrcVlan(source.getVlanId());
        flowInfo.setSrcInnerVlan(source.getInnerVlanId());
        flowInfo.setSrcLldp(source.getDetectedDevice().isLldp());
        flowInfo.setSrcArp(source.getDetectedDevice().isArp());
    }
    FlowV2Endpoint destination = flow.getDestination();
    if (destination != null) {
        String switchName = switchIntegrationService.customSwitchName(csNames, destination.getSwitchId());
        flowInfo.setTargetSwitchName(switchName);
        flowInfo.setTargetSwitch(destination.getSwitchId());
        flowInfo.setDstPort(destination.getPortId());
        flowInfo.setDstVlan(destination.getVlanId());
        flowInfo.setDstInnerVlan(destination.getInnerVlanId());
        flowInfo.setDstLldp(destination.getDetectedDevice().isLldp());
        flowInfo.setDstArp(destination.getDetectedDevice().isArp());
    }
    return flowInfo;
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) FlowV2Endpoint(org.openkilda.integration.model.FlowV2Endpoint)

Example 5 with FlowInfo

use of org.openkilda.model.FlowInfo in project open-kilda by telstra.

the class FlowController method getFlowById.

/**
 * Get flow by Id.
 *
 * @param flowId
 *            id of flow requested.
 * @return flowInfo
 * @throws AccessDeniedException the access denied exception
 */
@RequestMapping(value = "/{flowId}", method = RequestMethod.GET)
@ResponseStatus(HttpStatus.OK)
@Permissions(values = { IConstants.Permission.MENU_FLOWS })
@ResponseBody
public FlowInfo getFlowById(@PathVariable final String flowId, @RequestParam(name = "controller", required = false) boolean controller) throws AccessDeniedException {
    LOGGER.info("Get flow by id. Flow id: '" + flowId + "'");
    FlowInfo flowInfo = flowService.getFlowById(flowId, controller);
    return flowInfo;
}
Also used : FlowInfo(org.openkilda.model.FlowInfo) ResponseStatus(org.springframework.web.bind.annotation.ResponseStatus) Permissions(org.openkilda.auth.model.Permissions) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

FlowInfo (org.openkilda.model.FlowInfo)9 InventoryFlow (org.openkilda.integration.source.store.dto.InventoryFlow)3 AccessDeniedException (java.nio.file.AccessDeniedException)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 IntegrationException (org.openkilda.integration.exception.IntegrationException)2 InvalidResponseException (org.openkilda.integration.exception.InvalidResponseException)2 FlowEndpoint (org.openkilda.integration.model.FlowEndpoint)2 FlowBandwidth (org.openkilda.model.FlowBandwidth)2 FlowDiscrepancy (org.openkilda.model.FlowDiscrepancy)2 FlowState (org.openkilda.model.FlowState)2 RequestValidationException (org.usermanagement.exception.RequestValidationException)2 UserInfo (org.usermanagement.model.UserInfo)2 Permissions (org.openkilda.auth.model.Permissions)1 FlowV2 (org.openkilda.integration.model.FlowV2)1 FlowV2Endpoint (org.openkilda.integration.model.FlowV2Endpoint)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1 ResponseBody (org.springframework.web.bind.annotation.ResponseBody)1 ResponseStatus (org.springframework.web.bind.annotation.ResponseStatus)1