use of org.onosproject.drivers.odtn.impl.DeviceConnection in project onos by opennetworkinglab.
the class TapiFlowRuleProgrammable method removeFlowRules.
@Override
public Collection<FlowRule> removeFlowRules(Collection<FlowRule> rules) {
DeviceId deviceId = handler().data().deviceId();
RestSBController controller = checkNotNull(handler().get(RestSBController.class));
ImmutableList.Builder<FlowRule> removed = ImmutableList.builder();
rules.forEach(flowRule -> {
DeviceConnection conn = getConnectionCache().get(deviceId, flowRule.id());
if (conn == null || conn.getId() == null) {
log.warn("Can't find associate device connection for flow {} and device {}", flowRule.id(), deviceId);
return;
}
CompletableFuture<Integer> flowRemoval = CompletableFuture.supplyAsync(() -> controller.delete(deviceId, CONN_REQ_REMOVE_DATA_API + conn.getId(), null, MediaType.APPLICATION_JSON_TYPE));
flowRemoval.thenApply(result -> {
if (result == HttpStatus.SC_NO_CONTENT) {
getConnectionCache().remove(deviceId, flowRule);
removed.add(flowRule);
} else {
log.error("Can't remove flow {}, result {}", flowRule, result);
}
return result;
});
});
// TODO workaround for blocking call on ADVA OLS shoudl return removed
return rules;
}
Aggregations