use of org.openkilda.messaging.command.flow.RuleType in project open-kilda by telstra.
the class SwitchManager method deleteRulesByCriteria.
@Override
public List<Long> deleteRulesByCriteria(DatapathId dpid, boolean multiTable, RuleType ruleType, DeleteRulesCriteria... criteria) throws SwitchOperationException {
List<OFFlowStatsEntry> flowStatsBefore = dumpFlowTable(dpid);
IOFSwitch sw = lookupSwitch(dpid);
OFFactory ofFactory = sw.getOFFactory();
for (DeleteRulesCriteria criteriaEntry : criteria) {
OFFlowDelete dropFlowDelete = buildFlowDeleteByCriteria(ofFactory, criteriaEntry, multiTable, ruleType);
logger.info("Rules by criteria {} are to be removed from switch {}.", criteria, dpid);
pushFlow(sw, "--DeleteFlow--", dropFlowDelete);
}
// Wait for OFFlowDelete to be processed.
sendBarrierRequest(sw);
List<OFFlowStatsEntry> flowStatsAfter = dumpFlowTable(dpid);
Set<Long> cookiesAfter = flowStatsAfter.stream().map(entry -> entry.getCookie().getValue()).collect(Collectors.toSet());
return flowStatsBefore.stream().map(entry -> entry.getCookie().getValue()).filter(cookie -> !cookiesAfter.contains(cookie)).peek(cookie -> logger.info("Rule with cookie {} has been removed from switch {}.", cookie, dpid)).collect(toList());
}
Aggregations