Search in sources :

Example 1 with PatchEndpoint

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

the class FlowOperationsService method addChangedFields.

private FlowRequest addChangedFields(FlowRequest flowRequest, FlowPatch flowPatch) {
    boolean trackSrcLldp = flowRequest.getSource().isTrackLldpConnectedDevices();
    boolean trackSrcArp = flowRequest.getSource().isTrackArpConnectedDevices();
    PatchEndpoint source = flowPatch.getSource();
    if (source != null) {
        SwitchId switchId = Optional.ofNullable(source.getSwitchId()).orElse(flowRequest.getSource().getSwitchId());
        int port = Optional.ofNullable(source.getPortNumber()).orElse(flowRequest.getSource().getPortNumber());
        int vlan = Optional.ofNullable(source.getVlanId()).orElse(flowRequest.getSource().getOuterVlanId());
        int innerVlan = Optional.ofNullable(source.getInnerVlanId()).orElse(flowRequest.getSource().getInnerVlanId());
        trackSrcLldp = Optional.ofNullable(source.getTrackLldpConnectedDevices()).orElse(flowRequest.getSource().isTrackLldpConnectedDevices());
        trackSrcArp = Optional.ofNullable(source.getTrackArpConnectedDevices()).orElse(flowRequest.getSource().isTrackArpConnectedDevices());
        flowRequest.setSource(new FlowEndpoint(switchId, port, vlan, innerVlan));
    }
    boolean trackDstLldp = flowRequest.getDestination().isTrackLldpConnectedDevices();
    boolean trackDstArp = flowRequest.getDestination().isTrackArpConnectedDevices();
    PatchEndpoint destination = flowPatch.getDestination();
    if (destination != null) {
        SwitchId switchId = Optional.ofNullable(destination.getSwitchId()).orElse(flowRequest.getDestination().getSwitchId());
        int port = Optional.ofNullable(destination.getPortNumber()).orElse(flowRequest.getDestination().getPortNumber());
        int vlan = Optional.ofNullable(destination.getVlanId()).orElse(flowRequest.getDestination().getOuterVlanId());
        int innerVlan = Optional.ofNullable(destination.getInnerVlanId()).orElse(flowRequest.getDestination().getInnerVlanId());
        trackDstLldp = Optional.ofNullable(destination.getTrackLldpConnectedDevices()).orElse(flowRequest.getDestination().isTrackLldpConnectedDevices());
        trackDstArp = Optional.ofNullable(destination.getTrackArpConnectedDevices()).orElse(flowRequest.getDestination().isTrackArpConnectedDevices());
        flowRequest.setDestination(new FlowEndpoint(switchId, port, vlan, innerVlan));
    }
    flowRequest.setDetectConnectedDevices(new DetectConnectedDevicesDto(trackSrcLldp, trackSrcArp, trackDstLldp, trackDstArp));
    Optional.ofNullable(flowPatch.getBandwidth()).ifPresent(flowRequest::setBandwidth);
    Optional.ofNullable(flowPatch.getIgnoreBandwidth()).ifPresent(flowRequest::setIgnoreBandwidth);
    Optional.ofNullable(flowPatch.getAllocateProtectedPath()).ifPresent(flowRequest::setAllocateProtectedPath);
    Optional.ofNullable(flowPatch.getEncapsulationType()).map(FlowMapper.INSTANCE::map).ifPresent(flowRequest::setEncapsulationType);
    Optional.ofNullable(flowPatch.getPathComputationStrategy()).map(PathComputationStrategy::toString).ifPresent(flowRequest::setPathComputationStrategy);
    Optional.ofNullable(flowPatch.getDiverseFlowId()).ifPresent(flowRequest::setDiverseFlowId);
    return flowRequest;
}
Also used : RequestedFlowMapper(org.openkilda.wfm.share.mappers.RequestedFlowMapper) FlowMapper(org.openkilda.wfm.share.mappers.FlowMapper) FlowEndpoint(org.openkilda.model.FlowEndpoint) PatchEndpoint(org.openkilda.messaging.model.PatchEndpoint) DetectConnectedDevicesDto(org.openkilda.messaging.model.DetectConnectedDevicesDto) SwitchId(org.openkilda.model.SwitchId) FlowMirrorPoint(org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint) IslEndpoint(org.openkilda.model.IslEndpoint) PatchEndpoint(org.openkilda.messaging.model.PatchEndpoint) FlowEndpoint(org.openkilda.model.FlowEndpoint)

Aggregations

DetectConnectedDevicesDto (org.openkilda.messaging.model.DetectConnectedDevicesDto)1 PatchEndpoint (org.openkilda.messaging.model.PatchEndpoint)1 FlowMirrorPoint (org.openkilda.messaging.nbtopology.response.FlowMirrorPointsDumpResponse.FlowMirrorPoint)1 FlowEndpoint (org.openkilda.model.FlowEndpoint)1 IslEndpoint (org.openkilda.model.IslEndpoint)1 SwitchId (org.openkilda.model.SwitchId)1 FlowMapper (org.openkilda.wfm.share.mappers.FlowMapper)1 RequestedFlowMapper (org.openkilda.wfm.share.mappers.RequestedFlowMapper)1