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