Search in sources :

Example 1 with YFlowValidationHubCarrier

use of org.openkilda.wfm.topology.flowhs.service.yflow.YFlowValidationHubCarrier in project open-kilda by telstra.

the class DumpYFlowResourcesAction method perform.

@Override
protected void perform(State from, State to, Event event, YFlowValidationContext context, YFlowValidationFsm stateMachine) {
    String yFlowId = stateMachine.getYFlowId();
    YFlow yFlow = yFlowRepository.findById(yFlowId).orElseThrow(() -> new FlowProcessingException(ErrorType.NOT_FOUND, format("Y-flow %s not found", yFlowId)));
    log.debug("Start validating y-flow {} resources", yFlowId);
    List<SwitchId> switchIds = Stream.of(yFlow.getSharedEndpoint().getSwitchId(), yFlow.getYPoint(), yFlow.getProtectedPathYPoint()).filter(Objects::nonNull).collect(Collectors.toList());
    int switchCount = switchIds.size();
    stateMachine.setAwaitingRules(switchCount);
    stateMachine.setAwaitingMeters(switchCount);
    log.debug("Send commands to get rules & meters on {} switches", switchCount);
    YFlowValidationHubCarrier carrier = stateMachine.getCarrier();
    switchIds.forEach(switchId -> {
        carrier.sendSpeakerRequest(yFlowId, new DumpRulesForFlowHsRequest(switchId));
        carrier.sendSpeakerRequest(yFlowId, new DumpMetersForFlowHsRequest(switchId));
    });
}
Also used : YFlow(org.openkilda.model.YFlow) DumpMetersForFlowHsRequest(org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest) FlowProcessingException(org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException) DumpRulesForFlowHsRequest(org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest) YFlowValidationHubCarrier(org.openkilda.wfm.topology.flowhs.service.yflow.YFlowValidationHubCarrier) SwitchId(org.openkilda.model.SwitchId)

Aggregations

DumpMetersForFlowHsRequest (org.openkilda.messaging.command.switches.DumpMetersForFlowHsRequest)1 DumpRulesForFlowHsRequest (org.openkilda.messaging.command.switches.DumpRulesForFlowHsRequest)1 SwitchId (org.openkilda.model.SwitchId)1 YFlow (org.openkilda.model.YFlow)1 FlowProcessingException (org.openkilda.wfm.topology.flowhs.exception.FlowProcessingException)1 YFlowValidationHubCarrier (org.openkilda.wfm.topology.flowhs.service.yflow.YFlowValidationHubCarrier)1