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;
}
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);
}
}
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;
}
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;
}
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;
}
Aggregations