ios-xe renderer now creates configuration per endpoint pair
[groupbasedpolicy.git] / renderers / ios-xe / src / main / java / org / opendaylight / groupbasedpolicy / renderer / ios_xe_provider / impl / manager / PolicyConfigurationContext.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8
9 package org.opendaylight.groupbasedpolicy.renderer.ios_xe_provider.impl.manager;
10
11 import java.util.ArrayList;
12 import java.util.List;
13 import com.google.common.util.concurrent.CheckedFuture;
14 import com.google.common.util.concurrent.Futures;
15 import com.google.common.util.concurrent.ListenableFuture;
16 import org.opendaylight.controller.md.sal.common.api.data.TransactionCommitFailedException;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.has.unconfigured.rule.groups.unconfigured.rule.group.UnconfiguredResolvedRule;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.Status;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.configuration.renderer.endpoints.RendererEndpoint;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.renderer.rev151103.renderers.renderer.renderer.policy.status.unconfigured.endpoints.UnconfiguredRendererEndpoint;
21
22 /**
23  * Purpose: placeholder for
24  * <ul>
25  * <li>{@link PolicyManagerImpl.PolicyMapLocation}</li>
26  * <li>{@link Status} parts</li>
27  * </ul>
28  */
29 public class PolicyConfigurationContext {
30
31     private final List<UnconfiguredRendererEndpoint> unconfiguredRendererEPBag;
32     private final List<CheckedFuture<Boolean, TransactionCommitFailedException>> cumulativeResult;
33     private PolicyManagerImpl.PolicyMapLocation policyMapLocation;
34     private RendererEndpoint currentRendererEP;
35     private UnconfiguredResolvedRule currentUnconfiguredRule;
36
37     public PolicyConfigurationContext() {
38         unconfiguredRendererEPBag = new ArrayList<>();
39         cumulativeResult = new ArrayList<>();
40     }
41
42     /**
43      * Set transaction result to result pool
44      *
45      * @param result current result
46      */
47     public void setFutureResult(final CheckedFuture<Boolean, TransactionCommitFailedException> result) {
48         cumulativeResult.add(result);
49     }
50
51     /**
52      * append given endpoint to collection of not configurable policies
53      *
54      * @param endpoint not configurable endpoint
55      */
56     public void appendUnconfiguredRendererEP(UnconfiguredRendererEndpoint endpoint) {
57         unconfiguredRendererEPBag.add(endpoint);
58     }
59
60     /**
61      * @return policy-map location
62      */
63     public PolicyManagerImpl.PolicyMapLocation getPolicyMapLocation() {
64         return policyMapLocation;
65     }
66
67     /**
68      * @param policyMapLocation for actual policy-map/interface location
69      */
70     public void setPolicyMapLocation(final PolicyManagerImpl.PolicyMapLocation policyMapLocation) {
71         this.policyMapLocation = policyMapLocation;
72     }
73
74     /**
75      * @return endpoint currently being configured
76      */
77     public RendererEndpoint getCurrentRendererEP() {
78         return currentRendererEP;
79     }
80
81     /**
82      * @param currentRendererEP endpoint currently being configured
83      */
84     public void setCurrentRendererEP(final RendererEndpoint currentRendererEP) {
85         this.currentRendererEP = currentRendererEP;
86     }
87
88     /**
89      * @return list of not configurable policies
90      */
91     List<UnconfiguredRendererEndpoint> getUnconfiguredRendererEPBag() {
92         return unconfiguredRendererEPBag;
93     }
94
95     /**
96      * @return all unconfigured rules
97      */
98     public UnconfiguredResolvedRule getCurrentUnconfiguredRule() {
99         return currentUnconfiguredRule;
100     }
101
102     /**
103      * Add unconfigured rule to list
104      *
105      * @param unconfiguredResolvedRule unconfigured rule
106      */
107     public void setCurrentUnconfiguredRule(final UnconfiguredResolvedRule unconfiguredResolvedRule) {
108         this.currentUnconfiguredRule = unconfiguredResolvedRule;
109     }
110
111     /**
112      * @return get all transaction results as a list
113      */
114     ListenableFuture<List<Boolean>> getCumulativeResult() {
115         return Futures.allAsList(cumulativeResult);
116     }
117 }