use of org.openkilda.messaging.info.rule.FlowMatchField in project open-kilda by telstra.
the class CommandBuilderImpl method buildRemoveFlowWithoutMeterFromFlowEntry.
@VisibleForTesting
RemoveFlow buildRemoveFlowWithoutMeterFromFlowEntry(SwitchId switchId, FlowEntry entry) {
Optional<FlowMatchField> entryMatch = Optional.ofNullable(entry.getMatch());
Integer inPort = entryMatch.map(FlowMatchField::getInPort).map(Integer::valueOf).orElse(null);
FlowEncapsulationType encapsulationType = FlowEncapsulationType.TRANSIT_VLAN;
Integer encapsulationId = null;
Integer vlan = entryMatch.map(FlowMatchField::getVlanVid).map(Integer::valueOf).orElse(null);
if (vlan != null) {
encapsulationId = vlan;
} else {
Integer tunnelId = entryMatch.map(FlowMatchField::getTunnelId).map(Integer::decode).orElse(null);
if (tunnelId != null) {
encapsulationId = tunnelId;
encapsulationType = FlowEncapsulationType.VXLAN;
}
}
Optional<FlowApplyActions> actions = Optional.ofNullable(entry.getInstructions()).map(FlowInstructions::getApplyActions);
Integer outPort = actions.map(FlowApplyActions::getFlowOutput).filter(NumberUtils::isNumber).map(Integer::valueOf).orElse(null);
SwitchId ingressSwitchId = entryMatch.map(FlowMatchField::getEthSrc).map(SwitchId::new).orElse(null);
Long metadataValue = entryMatch.map(FlowMatchField::getMetadataValue).map(Long::decode).orElse(null);
Long metadataMask = entryMatch.map(FlowMatchField::getMetadataMask).map(Long::decode).orElse(null);
DeleteRulesCriteria criteria = new DeleteRulesCriteria(entry.getCookie(), inPort, encapsulationId, 0, outPort, encapsulationType, ingressSwitchId, metadataValue, metadataMask);
return RemoveFlow.builder().transactionId(transactionIdGenerator.generate()).flowId("SWMANAGER_BATCH_REMOVE").cookie(entry.getCookie()).switchId(switchId).criteria(criteria).build();
}
Aggregations