Search in sources :

Example 1 with VirtualFlowRuleProviderService

use of org.onosproject.incubator.net.virtual.provider.VirtualFlowRuleProviderService in project onos by opennetworkinglab.

the class DefaultVirtualFlowRuleProvider method executeBatch.

@Override
public void executeBatch(NetworkId networkId, FlowRuleBatchOperation batch) {
    checkNotNull(batch);
    for (FlowRuleBatchEntry fop : batch.getOperations()) {
        FlowRuleOperations.Builder builder = FlowRuleOperations.builder();
        switch(fop.operator()) {
            case ADD:
                devirtualize(networkId, fop.target()).forEach(builder::add);
                break;
            case REMOVE:
                devirtualize(networkId, fop.target()).forEach(builder::remove);
                break;
            case MODIFY:
                devirtualize(networkId, fop.target()).forEach(builder::modify);
                break;
            default:
                break;
        }
        flowRuleService.apply(builder.build(new FlowRuleOperationsContext() {

            @Override
            public void onSuccess(FlowRuleOperations ops) {
                CompletedBatchOperation status = new CompletedBatchOperation(true, Sets.newConcurrentHashSet(), batch.deviceId());
                VirtualFlowRuleProviderService providerService = (VirtualFlowRuleProviderService) providerRegistryService.getProviderService(networkId, VirtualFlowRuleProvider.class);
                providerService.batchOperationCompleted(batch.id(), status);
            }

            @Override
            public void onError(FlowRuleOperations ops) {
                Set<FlowRule> failures = ImmutableSet.copyOf(Lists.transform(batch.getOperations(), BatchOperationEntry::target));
                CompletedBatchOperation status = new CompletedBatchOperation(false, failures, batch.deviceId());
                VirtualFlowRuleProviderService providerService = (VirtualFlowRuleProviderService) providerRegistryService.getProviderService(networkId, VirtualFlowRuleProvider.class);
                providerService.batchOperationCompleted(batch.id(), status);
            }
        }));
    }
}
Also used : FlowRuleOperations(org.onosproject.net.flow.FlowRuleOperations) VirtualFlowRuleProvider(org.onosproject.incubator.net.virtual.provider.VirtualFlowRuleProvider) FlowRuleBatchEntry(org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) FlowRule(org.onosproject.net.flow.FlowRule) VirtualFlowRuleProviderService(org.onosproject.incubator.net.virtual.provider.VirtualFlowRuleProviderService) CompletedBatchOperation(org.onosproject.net.flow.CompletedBatchOperation) FlowRuleOperationsContext(org.onosproject.net.flow.FlowRuleOperationsContext)

Aggregations

VirtualFlowRuleProvider (org.onosproject.incubator.net.virtual.provider.VirtualFlowRuleProvider)1 VirtualFlowRuleProviderService (org.onosproject.incubator.net.virtual.provider.VirtualFlowRuleProviderService)1 CompletedBatchOperation (org.onosproject.net.flow.CompletedBatchOperation)1 DefaultFlowRule (org.onosproject.net.flow.DefaultFlowRule)1 FlowRule (org.onosproject.net.flow.FlowRule)1 FlowRuleOperations (org.onosproject.net.flow.FlowRuleOperations)1 FlowRuleOperationsContext (org.onosproject.net.flow.FlowRuleOperationsContext)1 FlowRuleBatchEntry (org.onosproject.net.flow.oldbatch.FlowRuleBatchEntry)1