Committed by
Gerrit Code Review
[ONOS-3835] Install load balanced classifier rules
Change-Id: I585a83021dbf2aff6a65dd43944a1f6979b33ead
Showing
16 changed files
with
761 additions
and
121 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
1 | package org.onosproject.sfc.installer; | 16 | package org.onosproject.sfc.installer; |
2 | 17 | ||
18 | +import org.onosproject.net.ConnectPoint; | ||
3 | import org.onosproject.net.NshServicePathId; | 19 | import org.onosproject.net.NshServicePathId; |
4 | -import org.onosproject.net.flowobjective.Objective.Operation; | 20 | +import org.onosproject.vtnrsc.FiveTuple; |
5 | -import org.onosproject.vtnrsc.FlowClassifier; | ||
6 | import org.onosproject.vtnrsc.PortChain; | 21 | import org.onosproject.vtnrsc.PortChain; |
7 | -import org.onosproject.vtnrsc.PortPair; | ||
8 | 22 | ||
9 | /** | 23 | /** |
10 | * Abstraction of an entity which installs flow classification rules in ovs. | 24 | * Abstraction of an entity which installs flow classification rules in ovs. |
... | @@ -12,29 +26,38 @@ import org.onosproject.vtnrsc.PortPair; | ... | @@ -12,29 +26,38 @@ import org.onosproject.vtnrsc.PortPair; |
12 | public interface FlowClassifierInstallerService { | 26 | public interface FlowClassifierInstallerService { |
13 | 27 | ||
14 | /** | 28 | /** |
15 | - * Install Flow-Classifier. | 29 | + * Install flow classifier. |
30 | + * | ||
31 | + * @param portChain port-chain | ||
32 | + * @param nshSpiId service path index identifier | ||
33 | + */ | ||
34 | + ConnectPoint installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId); | ||
35 | + | ||
36 | + /** | ||
37 | + * Uninstall flow classifier. | ||
16 | * | 38 | * |
17 | * @param portChain port-chain | 39 | * @param portChain port-chain |
18 | - * @param nshSpiId nsh spi-id | 40 | + * @param nshSpiId service path index identifier |
19 | */ | 41 | */ |
20 | - void installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId); | 42 | + ConnectPoint unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId); |
21 | 43 | ||
22 | /** | 44 | /** |
23 | - * Uninstall Flow-Classifier. | 45 | + * Install load balanced flow classifier. |
24 | * | 46 | * |
25 | * @param portChain port-chain | 47 | * @param portChain port-chain |
26 | - * @param nshSpiId nsh spi-id | 48 | + * @param fiveTuple five tuple packet information |
49 | + * @param nshSpiId service path index identifier | ||
27 | */ | 50 | */ |
28 | - void unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId); | 51 | + ConnectPoint installLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple, |
52 | + NshServicePathId nshSpiId); | ||
29 | 53 | ||
30 | /** | 54 | /** |
31 | - * Prepare forwarding object for flow classifier. | 55 | + * Uninstall load balanced flow classifier. |
32 | * | 56 | * |
33 | - * @param flowClassifier flow classifier | 57 | + * @param portChain port-chain |
34 | - * @param portPair port pair | 58 | + * @param fiveTuple five tuple packet information |
35 | - * @param nshSpiId nsh spi id | 59 | + * @param nshSpiId service path index identifier |
36 | - * @param type forwarding objective operation type | ||
37 | */ | 60 | */ |
38 | - void prepareFlowClassification(FlowClassifier flowClassifier, PortPair portPair, NshServicePathId nshSpiId, | 61 | + ConnectPoint unInstallLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple, |
39 | - Operation type); | 62 | + NshServicePathId nshSpiId); |
40 | } | 63 | } | ... | ... |
... | @@ -15,20 +15,29 @@ | ... | @@ -15,20 +15,29 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.sfc.installer.impl; | 16 | package org.onosproject.sfc.installer.impl; |
17 | 17 | ||
18 | -import org.apache.felix.scr.annotations.Component; | 18 | +import static com.google.common.base.Preconditions.checkNotNull; |
19 | -import org.apache.felix.scr.annotations.Reference; | 19 | +import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI; |
20 | -import org.apache.felix.scr.annotations.ReferenceCardinality; | 20 | +import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI; |
21 | -import org.apache.felix.scr.annotations.Service; | 21 | +import static org.slf4j.LoggerFactory.getLogger; |
22 | + | ||
23 | +import java.util.LinkedList; | ||
24 | +import java.util.List; | ||
25 | +import java.util.ListIterator; | ||
26 | + | ||
22 | import org.onlab.osgi.DefaultServiceDirectory; | 27 | import org.onlab.osgi.DefaultServiceDirectory; |
23 | import org.onlab.osgi.ServiceDirectory; | 28 | import org.onlab.osgi.ServiceDirectory; |
24 | import org.onlab.packet.Ethernet; | 29 | import org.onlab.packet.Ethernet; |
30 | +import org.onlab.packet.IPv4; | ||
31 | +import org.onlab.packet.IpPrefix; | ||
25 | import org.onlab.packet.MacAddress; | 32 | import org.onlab.packet.MacAddress; |
26 | import org.onlab.packet.TpPort; | 33 | import org.onlab.packet.TpPort; |
27 | import org.onlab.packet.VlanId; | 34 | import org.onlab.packet.VlanId; |
28 | import org.onosproject.core.ApplicationId; | 35 | import org.onosproject.core.ApplicationId; |
36 | +import org.onosproject.net.ConnectPoint; | ||
29 | import org.onosproject.net.DeviceId; | 37 | import org.onosproject.net.DeviceId; |
30 | import org.onosproject.net.Host; | 38 | import org.onosproject.net.Host; |
31 | import org.onosproject.net.HostId; | 39 | import org.onosproject.net.HostId; |
40 | +import org.onosproject.net.NshServiceIndex; | ||
32 | import org.onosproject.net.NshServicePathId; | 41 | import org.onosproject.net.NshServicePathId; |
33 | import org.onosproject.net.PortNumber; | 42 | import org.onosproject.net.PortNumber; |
34 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; | 43 | import org.onosproject.net.behaviour.ExtensionTreatmentResolver; |
... | @@ -46,9 +55,9 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; | ... | @@ -46,9 +55,9 @@ import org.onosproject.net.flowobjective.FlowObjectiveService; |
46 | import org.onosproject.net.flowobjective.ForwardingObjective; | 55 | import org.onosproject.net.flowobjective.ForwardingObjective; |
47 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; | 56 | import org.onosproject.net.flowobjective.ForwardingObjective.Flag; |
48 | import org.onosproject.net.flowobjective.Objective; | 57 | import org.onosproject.net.flowobjective.Objective; |
49 | -import org.onosproject.net.flowobjective.Objective.Operation; | ||
50 | import org.onosproject.net.host.HostService; | 58 | import org.onosproject.net.host.HostService; |
51 | import org.onosproject.sfc.installer.FlowClassifierInstallerService; | 59 | import org.onosproject.sfc.installer.FlowClassifierInstallerService; |
60 | +import org.onosproject.vtnrsc.FiveTuple; | ||
52 | import org.onosproject.vtnrsc.FlowClassifier; | 61 | import org.onosproject.vtnrsc.FlowClassifier; |
53 | import org.onosproject.vtnrsc.FlowClassifierId; | 62 | import org.onosproject.vtnrsc.FlowClassifierId; |
54 | import org.onosproject.vtnrsc.PortChain; | 63 | import org.onosproject.vtnrsc.PortChain; |
... | @@ -64,48 +73,20 @@ import org.onosproject.vtnrsc.service.VtnRscService; | ... | @@ -64,48 +73,20 @@ import org.onosproject.vtnrsc.service.VtnRscService; |
64 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; | 73 | import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
65 | import org.slf4j.Logger; | 74 | import org.slf4j.Logger; |
66 | 75 | ||
67 | -import java.util.LinkedList; | ||
68 | -import java.util.List; | ||
69 | -import java.util.ListIterator; | ||
70 | - | ||
71 | -import static com.google.common.base.Preconditions.checkNotNull; | ||
72 | -import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SI; | ||
73 | -import static org.onosproject.net.flow.instructions.ExtensionTreatmentType.ExtensionTreatmentTypes.NICIRA_SET_NSH_SPI; | ||
74 | -import static org.slf4j.LoggerFactory.getLogger; | ||
75 | - | ||
76 | /** | 76 | /** |
77 | * Provides flow classifier installer implementation. | 77 | * Provides flow classifier installer implementation. |
78 | */ | 78 | */ |
79 | -@Component(immediate = true) | ||
80 | -@Service | ||
81 | public class FlowClassifierInstallerImpl implements FlowClassifierInstallerService { | 79 | public class FlowClassifierInstallerImpl implements FlowClassifierInstallerService { |
82 | - | ||
83 | private final Logger log = getLogger(getClass()); | 80 | private final Logger log = getLogger(getClass()); |
84 | 81 | ||
85 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
86 | protected VirtualPortService virtualPortService; | 82 | protected VirtualPortService virtualPortService; |
87 | - | ||
88 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
89 | protected VtnRscService vtnRscService; | 83 | protected VtnRscService vtnRscService; |
90 | - | ||
91 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
92 | protected PortPairService portPairService; | 84 | protected PortPairService portPairService; |
93 | - | ||
94 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
95 | protected PortPairGroupService portPairGroupService; | 85 | protected PortPairGroupService portPairGroupService; |
96 | - | ||
97 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
98 | protected FlowClassifierService flowClassifierService; | 86 | protected FlowClassifierService flowClassifierService; |
99 | - | ||
100 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
101 | protected DriverService driverService; | 87 | protected DriverService driverService; |
102 | - | ||
103 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
104 | protected DeviceService deviceService; | 88 | protected DeviceService deviceService; |
105 | - | ||
106 | - @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
107 | protected HostService hostService; | 89 | protected HostService hostService; |
108 | - | ||
109 | protected FlowObjectiveService flowObjectiveService; | 90 | protected FlowObjectiveService flowObjectiveService; |
110 | protected ApplicationId appId; | 91 | protected ApplicationId appId; |
111 | 92 | ||
... | @@ -114,8 +95,8 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -114,8 +95,8 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
114 | private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow-Classifier-Id cannot be null"; | 95 | private static final String FLOW_CLASSIFIER_ID_NOT_NULL = "Flow-Classifier-Id cannot be null"; |
115 | private static final String PORT_CHAIN_NOT_NULL = "Port-Chain cannot be null"; | 96 | private static final String PORT_CHAIN_NOT_NULL = "Port-Chain cannot be null"; |
116 | private static final int NULL = 0; | 97 | private static final int NULL = 0; |
117 | - private static final int L3FWD_PRIORITY = 0xffff; | 98 | + private static final int FLOW_CLASSIFIER_PRIORITY = 0x7fff; |
118 | - private static final int NSH_SI_ID = 0xff; | 99 | + private static final short NSH_SI_ID = 0xff; |
119 | 100 | ||
120 | /** | 101 | /** |
121 | * Default constructor. | 102 | * Default constructor. |
... | @@ -126,40 +107,102 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -126,40 +107,102 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
126 | /** | 107 | /** |
127 | * Explicit constructor. | 108 | * Explicit constructor. |
128 | * | 109 | * |
129 | - * @param appId Application ID. | 110 | + * @param appId application id. |
130 | */ | 111 | */ |
131 | public FlowClassifierInstallerImpl(ApplicationId appId) { | 112 | public FlowClassifierInstallerImpl(ApplicationId appId) { |
132 | this.appId = checkNotNull(appId, "ApplicationId can not be null"); | 113 | this.appId = checkNotNull(appId, "ApplicationId can not be null"); |
133 | ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); | 114 | ServiceDirectory serviceDirectory = new DefaultServiceDirectory(); |
134 | this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class); | 115 | this.flowObjectiveService = serviceDirectory.get(FlowObjectiveService.class); |
116 | + this.driverService = serviceDirectory.get(DriverService.class); | ||
117 | + this.deviceService = serviceDirectory.get(DeviceService.class); | ||
118 | + this.hostService = serviceDirectory.get(HostService.class); | ||
119 | + this.virtualPortService = serviceDirectory.get(VirtualPortService.class); | ||
120 | + this.vtnRscService = serviceDirectory.get(VtnRscService.class); | ||
121 | + this.portPairService = serviceDirectory.get(PortPairService.class); | ||
122 | + this.portPairGroupService = serviceDirectory.get(PortPairGroupService.class); | ||
123 | + this.flowClassifierService = serviceDirectory.get(FlowClassifierService.class); | ||
135 | } | 124 | } |
136 | 125 | ||
137 | @Override | 126 | @Override |
138 | - public void installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) { | 127 | + public ConnectPoint installFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) { |
139 | checkNotNull(portChain, PORT_CHAIN_NOT_NULL); | 128 | checkNotNull(portChain, PORT_CHAIN_NOT_NULL); |
140 | - processFlowClassifier(portChain, nshSpiId, Objective.Operation.ADD); | 129 | + // Get the portPairGroup |
130 | + List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups(); | ||
131 | + ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator(); | ||
132 | + PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next(); | ||
133 | + PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId); | ||
134 | + List<PortPairId> llPortPairIdList = portPairGroup.portPairs(); | ||
135 | + | ||
136 | + // Get port pair | ||
137 | + ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator(); | ||
138 | + PortPairId portPairId = portPairListIterator.next(); | ||
139 | + PortPair portPair = portPairService.getPortPair(portPairId); | ||
140 | + | ||
141 | + return processFlowClassifier(portChain, portPair, nshSpiId, null, Objective.Operation.ADD); | ||
141 | } | 142 | } |
142 | 143 | ||
143 | @Override | 144 | @Override |
144 | - public void unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) { | 145 | + public ConnectPoint unInstallFlowClassifier(PortChain portChain, NshServicePathId nshSpiId) { |
145 | checkNotNull(portChain, PORT_CHAIN_NOT_NULL); | 146 | checkNotNull(portChain, PORT_CHAIN_NOT_NULL); |
146 | - processFlowClassifier(portChain, nshSpiId, Objective.Operation.REMOVE); | 147 | + // Get the portPairGroup |
147 | - } | ||
148 | - | ||
149 | - public void processFlowClassifier(PortChain portChain, NshServicePathId nshSpiId, Objective.Operation type) { | ||
150 | - | ||
151 | - // get the portPairGroup | ||
152 | List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups(); | 148 | List<PortPairGroupId> llPortPairGroupIdList = portChain.portPairGroups(); |
153 | ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator(); | 149 | ListIterator<PortPairGroupId> portPairGroupIdListIterator = llPortPairGroupIdList.listIterator(); |
154 | PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next(); | 150 | PortPairGroupId portPairGroupId = portPairGroupIdListIterator.next(); |
155 | PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId); | 151 | PortPairGroup portPairGroup = portPairGroupService.getPortPairGroup(portPairGroupId); |
156 | List<PortPairId> llPortPairIdList = portPairGroup.portPairs(); | 152 | List<PortPairId> llPortPairIdList = portPairGroup.portPairs(); |
157 | 153 | ||
158 | - // get port pair | 154 | + // Get port pair |
159 | ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator(); | 155 | ListIterator<PortPairId> portPairListIterator = llPortPairIdList.listIterator(); |
160 | PortPairId portPairId = portPairListIterator.next(); | 156 | PortPairId portPairId = portPairListIterator.next(); |
161 | PortPair portPair = portPairService.getPortPair(portPairId); | 157 | PortPair portPair = portPairService.getPortPair(portPairId); |
162 | 158 | ||
159 | + return processFlowClassifier(portChain, portPair, nshSpiId, null, Objective.Operation.REMOVE); | ||
160 | + } | ||
161 | + | ||
162 | + @Override | ||
163 | + public ConnectPoint installLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple, | ||
164 | + NshServicePathId nshSpiId) { | ||
165 | + checkNotNull(portChain, PORT_CHAIN_NOT_NULL); | ||
166 | + | ||
167 | + // Get the load balanced path | ||
168 | + List<PortPairId> portPairs = portChain.getLoadBalancePath(fiveTuple); | ||
169 | + | ||
170 | + // Get the first port pair | ||
171 | + ListIterator<PortPairId> portPairListIterator = portPairs.listIterator(); | ||
172 | + PortPairId portPairId = portPairListIterator.next(); | ||
173 | + PortPair portPair = portPairService.getPortPair(portPairId); | ||
174 | + | ||
175 | + return processFlowClassifier(portChain, portPair, nshSpiId, fiveTuple, Objective.Operation.ADD); | ||
176 | + } | ||
177 | + | ||
178 | + @Override | ||
179 | + public ConnectPoint unInstallLoadBalancedFlowClassifier(PortChain portChain, FiveTuple fiveTuple, | ||
180 | + NshServicePathId nshSpiId) { | ||
181 | + checkNotNull(portChain, PORT_CHAIN_NOT_NULL); | ||
182 | + // Get the load balanced path | ||
183 | + List<PortPairId> portPairs = portChain.getLoadBalancePath(fiveTuple); | ||
184 | + | ||
185 | + // Get the first port pair | ||
186 | + ListIterator<PortPairId> portPairListIterator = portPairs.listIterator(); | ||
187 | + PortPairId portPairId = portPairListIterator.next(); | ||
188 | + PortPair portPair = portPairService.getPortPair(portPairId); | ||
189 | + | ||
190 | + return processFlowClassifier(portChain, portPair, nshSpiId, fiveTuple, Objective.Operation.REMOVE); | ||
191 | + } | ||
192 | + | ||
193 | + public ConnectPoint processFlowClassifier(PortChain portChain, PortPair portPair, NshServicePathId nshSpiId, | ||
194 | + FiveTuple fiveTuple, Objective.Operation type) { | ||
195 | + | ||
196 | + DeviceId deviceIdfromPortPair = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.ingress())); | ||
197 | + MacAddress srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.ingress())).macAddress(); | ||
198 | + Host host = hostService.getHost(HostId.hostId(srcMacAddress)); | ||
199 | + PortNumber port = host.location().port(); | ||
200 | + | ||
201 | + DeviceId deviceId = deviceIdfromPortPair; | ||
202 | + | ||
203 | + // Vxlan tunnel port for NSH header(Vxlan + NSH). | ||
204 | + TpPort nshDstPort = TpPort.tpPort(6633); | ||
205 | + | ||
163 | FlowClassifierInstallerService flowclassifierinstallerService; | 206 | FlowClassifierInstallerService flowclassifierinstallerService; |
164 | // get flow classifiers | 207 | // get flow classifiers |
165 | List<FlowClassifierId> llFlowClassifierList = portChain.flowClassifiers(); | 208 | List<FlowClassifierId> llFlowClassifierList = portChain.flowClassifiers(); |
... | @@ -168,61 +211,76 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -168,61 +211,76 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
168 | while (flowClassifierListIterator.hasNext()) { | 211 | while (flowClassifierListIterator.hasNext()) { |
169 | FlowClassifierId flowclassifierId = flowClassifierListIterator.next(); | 212 | FlowClassifierId flowclassifierId = flowClassifierListIterator.next(); |
170 | FlowClassifier flowClassifier = flowClassifierService.getFlowClassifier(flowclassifierId); | 213 | FlowClassifier flowClassifier = flowClassifierService.getFlowClassifier(flowclassifierId); |
171 | - prepareFlowClassification(flowClassifier, portPair, nshSpiId, type); | ||
172 | - } | ||
173 | - } | ||
174 | - | ||
175 | - @Override | ||
176 | - public void prepareFlowClassification(FlowClassifier flowClassifier, PortPair portPair, NshServicePathId nshSpi, | ||
177 | - Operation type) { | ||
178 | - DeviceId deviceId = null; | ||
179 | - // device id if virtual ports are set in flow classifier. | ||
180 | - DeviceId deviceIdfromFc = null; | ||
181 | - // device id if port pair is used to fetch device id. | ||
182 | - DeviceId deviceIdfromPp = null; | ||
183 | - MacAddress srcMacAddress = null; | ||
184 | - // Vxlan tunnel port for NSH header(Vxlan + NSH). | ||
185 | - TpPort nshDstPort = TpPort.tpPort(6633); | ||
186 | 214 | ||
187 | if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) { | 215 | if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) { |
188 | - deviceIdfromFc = vtnRscService.getSfToSffMaping(flowClassifier.srcPort()); | 216 | + deviceId = vtnRscService.getSfToSffMaping(flowClassifier.srcPort()); |
189 | - deviceId = deviceIdfromFc; | ||
190 | - } else { | ||
191 | - deviceIdfromPp = vtnRscService.getSfToSffMaping(VirtualPortId.portId(portPair.ingress())); | ||
192 | - srcMacAddress = virtualPortService.getPort(VirtualPortId.portId(portPair.egress())).macAddress(); | ||
193 | - deviceId = deviceIdfromPp; | ||
194 | } | 217 | } |
195 | 218 | ||
196 | // Build Traffic selector. | 219 | // Build Traffic selector. |
197 | - TrafficSelector.Builder selector = packTrafficSelector(flowClassifier); | 220 | + TrafficSelector.Builder selector = packTrafficSelector(flowClassifier, fiveTuple); |
198 | - | 221 | + |
199 | - // Build traffic treatment. | 222 | + if (fiveTuple == null) { |
200 | - TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, srcMacAddress, nshDstPort, deviceIdfromFc, | 223 | + // Send the packet to controller |
201 | - deviceIdfromPp, nshSpi, flowClassifier); | 224 | + TrafficTreatment.Builder treatment = DefaultTrafficTreatment.builder(); |
202 | - | 225 | + treatment.setOutput(PortNumber.CONTROLLER); |
226 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type); | ||
227 | + } else if (deviceId.equals(deviceIdfromPortPair)) { | ||
228 | + // classifier and source device are in the same OVS. So directly send packet to first port pair | ||
229 | + TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, | ||
230 | + nshSpiId, flowClassifier, true); | ||
231 | + // Build forwarding objective and send to OVS. | ||
232 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type); | ||
233 | + } else { | ||
234 | + // classifier and source device are not in the same OVS. Send packet on vlan Tunnel | ||
235 | + TrafficTreatment.Builder treatment = packTrafficTreatment(deviceId, port, nshDstPort, | ||
236 | + nshSpiId, flowClassifier, false); | ||
203 | // Build forwarding objective and send to OVS. | 237 | // Build forwarding objective and send to OVS. |
204 | - sendServiceFunctionForwarder(selector, treatment, deviceId, type); | 238 | + sendServiceFunctionClassifier(selector, treatment, deviceId, type); |
239 | + | ||
240 | + // At the other device get the packet from vlan and send to first port pair | ||
241 | + TrafficSelector.Builder selectorDst = DefaultTrafficSelector.builder(); | ||
242 | + selectorDst.matchVlanId((VlanId.vlanId(Short.parseShort((vtnRscService | ||
243 | + .getL3vni(flowClassifier.tenantId()).toString()))))); | ||
244 | + TrafficTreatment.Builder treatmentDst = DefaultTrafficTreatment.builder(); | ||
245 | + Host hostDst = hostService.getHost(HostId.hostId(srcMacAddress)); | ||
246 | + treatmentDst.setOutput(hostDst.location().port()); | ||
247 | + sendServiceFunctionClassifier(selectorDst, treatmentDst, deviceIdfromPortPair, type); | ||
248 | + } | ||
249 | + } | ||
250 | + return host.location(); | ||
205 | } | 251 | } |
206 | 252 | ||
207 | /** | 253 | /** |
208 | * Pack Traffic selector. | 254 | * Pack Traffic selector. |
209 | * | 255 | * |
210 | * @param flowClassifier flow-classifier | 256 | * @param flowClassifier flow-classifier |
257 | + * @param fiveTuple five tuple info for the packet | ||
211 | * @return traffic selector | 258 | * @return traffic selector |
212 | */ | 259 | */ |
213 | - public TrafficSelector.Builder packTrafficSelector(FlowClassifier flowClassifier) { | 260 | + public TrafficSelector.Builder packTrafficSelector(FlowClassifier flowClassifier, FiveTuple fiveTuple) { |
261 | + | ||
214 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); | 262 | TrafficSelector.Builder selector = DefaultTrafficSelector.builder(); |
215 | 263 | ||
216 | if ((flowClassifier.srcIpPrefix() != null) && (flowClassifier.srcIpPrefix().prefixLength() != 0)) { | 264 | if ((flowClassifier.srcIpPrefix() != null) && (flowClassifier.srcIpPrefix().prefixLength() != 0)) { |
217 | selector.matchIPSrc(flowClassifier.srcIpPrefix()); | 265 | selector.matchIPSrc(flowClassifier.srcIpPrefix()); |
266 | + } else if (fiveTuple != null && fiveTuple.ipSrc() != null) { | ||
267 | + selector.matchIPSrc(IpPrefix.valueOf(fiveTuple.ipSrc(), 24)); | ||
218 | } | 268 | } |
219 | 269 | ||
220 | if ((flowClassifier.dstIpPrefix() != null) && (flowClassifier.dstIpPrefix().prefixLength() != 0)) { | 270 | if ((flowClassifier.dstIpPrefix() != null) && (flowClassifier.dstIpPrefix().prefixLength() != 0)) { |
221 | selector.matchIPDst(flowClassifier.dstIpPrefix()); | 271 | selector.matchIPDst(flowClassifier.dstIpPrefix()); |
272 | + } else if (fiveTuple != null && fiveTuple.ipDst() != null) { | ||
273 | + selector.matchIPDst(IpPrefix.valueOf(fiveTuple.ipDst(), 24)); | ||
222 | } | 274 | } |
223 | 275 | ||
224 | if ((flowClassifier.protocol() != null) && (!flowClassifier.protocol().isEmpty())) { | 276 | if ((flowClassifier.protocol() != null) && (!flowClassifier.protocol().isEmpty())) { |
225 | - selector.add(Criteria.matchIPProtocol(Short.parseShort(flowClassifier.protocol()))); | 277 | + if (flowClassifier.protocol().equalsIgnoreCase("TCP")) { |
278 | + selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_TCP)); | ||
279 | + } else if (flowClassifier.protocol().equalsIgnoreCase("UDP")) { | ||
280 | + selector.add(Criteria.matchIPProtocol(IPv4.PROTOCOL_UDP)); | ||
281 | + } | ||
282 | + } else if (fiveTuple != null && fiveTuple.protocol() != 0) { | ||
283 | + selector.add(Criteria.matchIPProtocol(fiveTuple.protocol())); | ||
226 | } | 284 | } |
227 | 285 | ||
228 | if (((flowClassifier.etherType() != null) && (!flowClassifier.etherType().isEmpty())) | 286 | if (((flowClassifier.etherType() != null) && (!flowClassifier.etherType().isEmpty())) |
... | @@ -234,6 +292,19 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -234,6 +292,19 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
234 | } | 292 | } |
235 | } | 293 | } |
236 | 294 | ||
295 | + if ((flowClassifier.srcPort() != null) && (!flowClassifier.srcPort().portId().isEmpty())) { | ||
296 | + VirtualPortId vPortId = VirtualPortId.portId(flowClassifier.srcPort().portId()); | ||
297 | + MacAddress macAddress = virtualPortService.getPort(vPortId).macAddress(); | ||
298 | + Host host = hostService.getHost(HostId.hostId(macAddress)); | ||
299 | + selector.matchInPort(host.location().port()); | ||
300 | + } | ||
301 | + | ||
302 | + // Take the port information from five tuple only when the protocol is TCP. | ||
303 | + if (fiveTuple != null && fiveTuple.protocol() == IPv4.PROTOCOL_TCP) { | ||
304 | + selector.matchTcpSrc(TpPort.tpPort((int) fiveTuple.portSrc().toLong())); | ||
305 | + selector.matchTcpDst(TpPort.tpPort((int) fiveTuple.portDst().toLong())); | ||
306 | + } else { | ||
307 | + // For udp packets take the port information from flow classifier | ||
237 | List<TpPort> srcPortRange = new LinkedList<>(); | 308 | List<TpPort> srcPortRange = new LinkedList<>(); |
238 | List<TpPort> dstPortRange = new LinkedList<>(); | 309 | List<TpPort> dstPortRange = new LinkedList<>(); |
239 | if ((flowClassifier.minSrcPortRange() != 0) && flowClassifier.maxSrcPortRange() != 0 | 310 | if ((flowClassifier.minSrcPortRange() != 0) && flowClassifier.maxSrcPortRange() != 0 |
... | @@ -253,6 +324,7 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -253,6 +324,7 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
253 | for (TpPort outPort : dstPortRange) { | 324 | for (TpPort outPort : dstPortRange) { |
254 | selector.matchUdpDst(outPort); | 325 | selector.matchUdpDst(outPort); |
255 | } | 326 | } |
327 | + } | ||
256 | return selector; | 328 | return selector; |
257 | } | 329 | } |
258 | 330 | ||
... | @@ -260,26 +332,23 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -260,26 +332,23 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
260 | * Pack traffic treatment. | 332 | * Pack traffic treatment. |
261 | * | 333 | * |
262 | * @param deviceId device id | 334 | * @param deviceId device id |
263 | - * @param srcMacAddress source mac-address | ||
264 | * @param nshDstPort vxlan tunnel port for nsh header | 335 | * @param nshDstPort vxlan tunnel port for nsh header |
265 | - * @param deviceIdfromFc device id if virtual ports are set in flow classifier. | ||
266 | - * @param deviceIdfromPp device id if port pair is used to fetch device id. | ||
267 | * @param nshSpi nsh spi | 336 | * @param nshSpi nsh spi |
268 | * @param flowClassifier flow-classifier | 337 | * @param flowClassifier flow-classifier |
269 | * @return traffic treatment | 338 | * @return traffic treatment |
270 | */ | 339 | */ |
271 | - public TrafficTreatment.Builder packTrafficTreatment(DeviceId deviceId, MacAddress srcMacAddress, | 340 | + public TrafficTreatment.Builder packTrafficTreatment(DeviceId deviceId, PortNumber port, |
272 | - TpPort nshDstPort, DeviceId deviceIdfromFc, DeviceId deviceIdfromPp, | 341 | + TpPort nshDstPort, NshServicePathId nshSpi, |
273 | - NshServicePathId nshSpi, FlowClassifier flowClassifier) { | 342 | + FlowClassifier flowClassifier, boolean isSameOvs) { |
343 | + | ||
274 | TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); | 344 | TrafficTreatment.Builder treatmentBuilder = DefaultTrafficTreatment.builder(); |
275 | 345 | ||
276 | - Host host = hostService.getHost(HostId.hostId(srcMacAddress)); | 346 | + if (isSameOvs) { |
277 | - PortNumber port = host.location().port(); | ||
278 | - if (deviceIdfromPp != null) { | ||
279 | treatmentBuilder.setOutput(port); | 347 | treatmentBuilder.setOutput(port); |
280 | - } else if (deviceIdfromFc != null) { | 348 | + } else { |
281 | - treatmentBuilder.setVlanId((VlanId.vlanId(Short.parseShort((vtnRscService.getL3vni(flowClassifier | 349 | + treatmentBuilder.setVlanId((VlanId.vlanId(Short.parseShort((vtnRscService |
282 | - .tenantId()).toString()))))); | 350 | + .getL3vni(flowClassifier.tenantId()).toString()))))); |
351 | + treatmentBuilder.setUdpDst(nshDstPort); | ||
283 | } | 352 | } |
284 | 353 | ||
285 | // Set NSH | 354 | // Set NSH |
... | @@ -290,7 +359,6 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -290,7 +359,6 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
290 | 359 | ||
291 | treatmentBuilder.extension(nspIdTreatment, deviceId); | 360 | treatmentBuilder.extension(nspIdTreatment, deviceId); |
292 | treatmentBuilder.extension(nsiIdTreatment, deviceId); | 361 | treatmentBuilder.extension(nsiIdTreatment, deviceId); |
293 | - treatmentBuilder.setUdpDst(nshDstPort); | ||
294 | 362 | ||
295 | try { | 363 | try { |
296 | nspIdTreatment.setPropertyValue("nshSpi", nshSpi); | 364 | nspIdTreatment.setPropertyValue("nshSpi", nshSpi); |
... | @@ -298,10 +366,11 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -298,10 +366,11 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
298 | log.error("Failed to get extension instruction to set Nsh Spi Id {}", deviceId); | 366 | log.error("Failed to get extension instruction to set Nsh Spi Id {}", deviceId); |
299 | } | 367 | } |
300 | try { | 368 | try { |
301 | - nsiIdTreatment.setPropertyValue("nshSi", NSH_SI_ID); | 369 | + nsiIdTreatment.setPropertyValue("nshSi", NshServiceIndex.of(NSH_SI_ID)); |
302 | } catch (Exception e) { | 370 | } catch (Exception e) { |
303 | log.error("Failed to get extension instruction to set Nsh Si Id {}", deviceId); | 371 | log.error("Failed to get extension instruction to set Nsh Si Id {}", deviceId); |
304 | } | 372 | } |
373 | + | ||
305 | return treatmentBuilder; | 374 | return treatmentBuilder; |
306 | } | 375 | } |
307 | 376 | ||
... | @@ -313,11 +382,13 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi | ... | @@ -313,11 +382,13 @@ public class FlowClassifierInstallerImpl implements FlowClassifierInstallerServi |
313 | * @param deviceId device id | 382 | * @param deviceId device id |
314 | * @param type operation type | 383 | * @param type operation type |
315 | */ | 384 | */ |
316 | - public void sendServiceFunctionForwarder(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, | 385 | + public void sendServiceFunctionClassifier(TrafficSelector.Builder selector, TrafficTreatment.Builder treatment, |
317 | DeviceId deviceId, Objective.Operation type) { | 386 | DeviceId deviceId, Objective.Operation type) { |
387 | + log.info("Sending flow to service function classifier. Selector {}, Treatment {}", | ||
388 | + selector.toString(), treatment.toString()); | ||
318 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) | 389 | ForwardingObjective.Builder objective = DefaultForwardingObjective.builder().withTreatment(treatment.build()) |
319 | .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) | 390 | .withSelector(selector.build()).fromApp(appId).makePermanent().withFlag(Flag.VERSATILE) |
320 | - .withPriority(L3FWD_PRIORITY); | 391 | + .withPriority(FLOW_CLASSIFIER_PRIORITY); |
321 | 392 | ||
322 | if (type.equals(Objective.Operation.ADD)) { | 393 | if (type.equals(Objective.Operation.ADD)) { |
323 | log.debug("flowClassifierRules-->ADD"); | 394 | log.debug("flowClassifierRules-->ADD"); | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sfc.installer.impl; | ||
17 | + | ||
18 | +import static org.easymock.EasyMock.createMock; | ||
19 | +import static org.easymock.EasyMock.expect; | ||
20 | +import static org.easymock.EasyMock.replay; | ||
21 | +import static org.hamcrest.Matchers.is; | ||
22 | +import static org.junit.Assert.assertThat; | ||
23 | + | ||
24 | +import java.util.LinkedList; | ||
25 | +import java.util.List; | ||
26 | +import java.util.Map; | ||
27 | +import java.util.Set; | ||
28 | + | ||
29 | +import org.junit.Test; | ||
30 | +import org.onlab.packet.IpAddress; | ||
31 | +import org.onlab.packet.IpPrefix; | ||
32 | +import org.onlab.packet.MacAddress; | ||
33 | +import org.onosproject.core.ApplicationId; | ||
34 | +import org.onosproject.core.DefaultApplicationId; | ||
35 | +import org.onosproject.net.ConnectPoint; | ||
36 | +import org.onosproject.net.DeviceId; | ||
37 | +import org.onosproject.net.HostLocation; | ||
38 | +import org.onosproject.net.NshServicePathId; | ||
39 | +import org.onosproject.net.device.DeviceService; | ||
40 | +import org.onosproject.net.device.DeviceServiceAdapter; | ||
41 | +import org.onosproject.net.driver.DriverHandler; | ||
42 | +import org.onosproject.net.driver.DriverService; | ||
43 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
44 | +import org.onosproject.net.host.HostService; | ||
45 | +import org.onosproject.net.host.HostServiceAdapter; | ||
46 | +import org.onosproject.sfc.util.FlowClassifierAdapter; | ||
47 | +import org.onosproject.sfc.util.FlowObjectiveAdapter; | ||
48 | +import org.onosproject.sfc.util.MockDriverHandler; | ||
49 | +import org.onosproject.sfc.util.PortPairAdapter; | ||
50 | +import org.onosproject.sfc.util.PortPairGroupAdapter; | ||
51 | +import org.onosproject.sfc.util.VirtualPortAdapter; | ||
52 | +import org.onosproject.sfc.util.VtnRscAdapter; | ||
53 | +import org.onosproject.vtnrsc.AllowedAddressPair; | ||
54 | +import org.onosproject.vtnrsc.BindingHostId; | ||
55 | +import org.onosproject.vtnrsc.DefaultFlowClassifier; | ||
56 | +import org.onosproject.vtnrsc.DefaultPortChain; | ||
57 | +import org.onosproject.vtnrsc.DefaultPortPair; | ||
58 | +import org.onosproject.vtnrsc.DefaultPortPairGroup; | ||
59 | +import org.onosproject.vtnrsc.DefaultVirtualPort; | ||
60 | +import org.onosproject.vtnrsc.FixedIp; | ||
61 | +import org.onosproject.vtnrsc.FlowClassifier; | ||
62 | +import org.onosproject.vtnrsc.FlowClassifierId; | ||
63 | +import org.onosproject.vtnrsc.PortChain; | ||
64 | +import org.onosproject.vtnrsc.PortChainId; | ||
65 | +import org.onosproject.vtnrsc.PortPair; | ||
66 | +import org.onosproject.vtnrsc.PortPairGroup; | ||
67 | +import org.onosproject.vtnrsc.PortPairGroupId; | ||
68 | +import org.onosproject.vtnrsc.PortPairId; | ||
69 | +import org.onosproject.vtnrsc.SecurityGroup; | ||
70 | +import org.onosproject.vtnrsc.SubnetId; | ||
71 | +import org.onosproject.vtnrsc.TenantId; | ||
72 | +import org.onosproject.vtnrsc.TenantNetworkId; | ||
73 | +import org.onosproject.vtnrsc.VirtualPort; | ||
74 | +import org.onosproject.vtnrsc.VirtualPortId; | ||
75 | +import org.onosproject.vtnrsc.flowclassifier.FlowClassifierService; | ||
76 | +import org.onosproject.vtnrsc.portpair.PortPairService; | ||
77 | +import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | ||
78 | +import org.onosproject.vtnrsc.service.VtnRscService; | ||
79 | +import org.onosproject.vtnrsc.virtualport.VirtualPortService; | ||
80 | + | ||
81 | +import com.google.common.collect.Lists; | ||
82 | +import com.google.common.collect.Maps; | ||
83 | +import com.google.common.collect.Sets; | ||
84 | + | ||
85 | +public class FlowClassifierInstallerImplTest { | ||
86 | + | ||
87 | + FlowObjectiveService flowObjectiveService = new FlowObjectiveAdapter(); | ||
88 | + DeviceService deviceService = new DeviceServiceAdapter(); | ||
89 | + HostService hostService = new HostServiceAdapter(); | ||
90 | + VirtualPortService virtualPortService = new VirtualPortAdapter(); | ||
91 | + VtnRscService vtnRscService = new VtnRscAdapter(); | ||
92 | + PortPairService portPairService = new PortPairAdapter(); | ||
93 | + PortPairGroupService portPairGroupService = new PortPairGroupAdapter(); | ||
94 | + FlowClassifierService flowClassifierService = new FlowClassifierAdapter(); | ||
95 | + | ||
96 | + final DriverService driverService = createMock(DriverService.class); | ||
97 | + | ||
98 | + final PortChainId portChainId = PortChainId.of("78888888-fc23-aeb6-f44b-56dc5e2fb3ae"); | ||
99 | + final TenantId tenantId = TenantId.tenantId("1"); | ||
100 | + final String name = "PortChain"; | ||
101 | + final String description = "PortChain"; | ||
102 | + final List<PortPairGroupId> portPairGroups = new LinkedList<PortPairGroupId>(); | ||
103 | + final List<FlowClassifierId> flowClassifiers = new LinkedList<FlowClassifierId>(); | ||
104 | + PortPairGroupId portPairGroupId1 = PortPairGroupId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); | ||
105 | + PortPairGroupId portPairGroupId2 = PortPairGroupId.of("73343531-fc23-aeb6-f44b-56dc5e2fb3af"); | ||
106 | + | ||
107 | + PortPairId portPairId1 = PortPairId.of("73333333-fc23-aeb6-f44b-56dc5e2fb3ae"); | ||
108 | + PortPairId portPairId2 = PortPairId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); | ||
109 | + | ||
110 | + FlowClassifierId flowClassifierId1 = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3ae"); | ||
111 | + FlowClassifierId flowClassifierId2 = FlowClassifierId.of("74444444-fc23-aeb6-f44b-56dc5e2fb3af"); | ||
112 | + | ||
113 | + final String ppName = "PortPair"; | ||
114 | + final String ppDescription = "PortPair"; | ||
115 | + final String ingress = "d3333333-24fc-4fae-af4b-321c5e2eb3d1"; | ||
116 | + final String egress = "a4444444-4a56-2a6e-cd3a-9dee4e2ec345"; | ||
117 | + | ||
118 | + | ||
119 | + final String ppgName = "PortPairGroup"; | ||
120 | + final String ppgDescription = "PortPairGroup"; | ||
121 | + final List<PortPairId> portPairList = new LinkedList<PortPairId>(); | ||
122 | + | ||
123 | + VirtualPortId id1 = VirtualPortId.portId(ingress); | ||
124 | + VirtualPortId id2 = VirtualPortId.portId("3414"); | ||
125 | + | ||
126 | + DeviceId deviceId = DeviceId.deviceId("of:000000000000001"); | ||
127 | + | ||
128 | + final DriverHandler driverHandler = new MockDriverHandler(); | ||
129 | + | ||
130 | + private PortPair createPortPair(PortPairId ppId) { | ||
131 | + DefaultPortPair.Builder portPairBuilder = new DefaultPortPair.Builder(); | ||
132 | + PortPair portPair = portPairBuilder.setId(ppId).setName(ppName).setTenantId(tenantId) | ||
133 | + .setDescription(ppDescription).setIngress(ingress).setEgress(egress).build(); | ||
134 | + return portPair; | ||
135 | + } | ||
136 | + | ||
137 | + private PortPairGroup createPortPairGroup(PortPairGroupId ppgId) { | ||
138 | + | ||
139 | + portPairList.clear(); | ||
140 | + // Create same two port-pair-group objects. | ||
141 | + portPairList.add(portPairId1); | ||
142 | + portPairList.add(portPairId2); | ||
143 | + | ||
144 | + DefaultPortPairGroup.Builder portPairGroupBuilder = new DefaultPortPairGroup.Builder(); | ||
145 | + PortPairGroup portPairGroup = portPairGroupBuilder.setId(ppgId).setTenantId(tenantId) | ||
146 | + .setName(ppgName).setDescription(ppgDescription).setPortPairs(portPairList).build(); | ||
147 | + | ||
148 | + return portPairGroup; | ||
149 | + | ||
150 | + } | ||
151 | + | ||
152 | + private PortChain createPortChain() { | ||
153 | + | ||
154 | + portPairGroups.clear(); | ||
155 | + flowClassifiers.clear(); | ||
156 | + // create list of Port Pair Groups. | ||
157 | + | ||
158 | + portPairGroups.add(portPairGroupId1); | ||
159 | + portPairGroups.add(portPairGroupId2); | ||
160 | + // create list of Flow classifiers. | ||
161 | + flowClassifiers.add(flowClassifierId1); | ||
162 | + flowClassifiers.add(flowClassifierId2); | ||
163 | + | ||
164 | + DefaultPortChain.Builder portChainBuilder = new DefaultPortChain.Builder(); | ||
165 | + final PortChain portChain = portChainBuilder.setId(portChainId).setTenantId(tenantId).setName(name) | ||
166 | + .setDescription(description).setPortPairGroups(portPairGroups).setFlowClassifiers(flowClassifiers) | ||
167 | + .build(); | ||
168 | + | ||
169 | + return portChain; | ||
170 | + } | ||
171 | + | ||
172 | + private FlowClassifier createFlowClassifier(FlowClassifierId id) { | ||
173 | + final String name = "FlowClassifier1"; | ||
174 | + final String description = "FlowClassifier1"; | ||
175 | + final String ethType = "IPv4"; | ||
176 | + final String protocol = "tcp"; | ||
177 | + final int minSrcPortRange = 5; | ||
178 | + final int maxSrcPortRange = 10; | ||
179 | + final int minDstPortRange = 5; | ||
180 | + final int maxDstPortRange = 10; | ||
181 | + final TenantId tenantId = TenantId.tenantId("1"); | ||
182 | + final IpPrefix srcIpPrefix = IpPrefix.valueOf("0.0.0.0/0"); | ||
183 | + final IpPrefix dstIpPrefix = IpPrefix.valueOf("10.10.10.10/0"); | ||
184 | + final VirtualPortId virtualSrcPort = id1; | ||
185 | + final VirtualPortId virtualDstPort = id2; | ||
186 | + | ||
187 | + DefaultFlowClassifier.Builder flowClassifierBuilder = new DefaultFlowClassifier.Builder(); | ||
188 | + final FlowClassifier flowClassifier = flowClassifierBuilder.setFlowClassifierId(id) | ||
189 | + .setTenantId(tenantId).setName(name).setDescription(description).setEtherType(ethType) | ||
190 | + .setProtocol(protocol).setMinSrcPortRange(minSrcPortRange).setMaxSrcPortRange(maxSrcPortRange) | ||
191 | + .setMinDstPortRange(minDstPortRange).setMaxDstPortRange(maxDstPortRange).setSrcIpPrefix(srcIpPrefix) | ||
192 | + .setDstIpPrefix(dstIpPrefix).setSrcPort(virtualSrcPort).setDstPort(virtualDstPort).build(); | ||
193 | + return flowClassifier; | ||
194 | + } | ||
195 | + | ||
196 | + private VirtualPort createVirtualPort() { | ||
197 | + Set<FixedIp> fixedIps; | ||
198 | + Map<String, String> propertyMap; | ||
199 | + Set<AllowedAddressPair> allowedAddressPairs; | ||
200 | + Set<SecurityGroup> securityGroups = Sets.newHashSet(); | ||
201 | + | ||
202 | + String macAddressStr = "fa:12:3e:56:ee:a2"; | ||
203 | + String ipAddress = "10.1.1.1"; | ||
204 | + String tenantNetworkId = "1234567"; | ||
205 | + String subnet = "1212"; | ||
206 | + String hostIdStr = "fa:e2:3e:56:ee:a2"; | ||
207 | + String deviceOwner = "james"; | ||
208 | + propertyMap = Maps.newHashMap(); | ||
209 | + propertyMap.putIfAbsent("deviceOwner", deviceOwner); | ||
210 | + | ||
211 | + TenantNetworkId networkId = TenantNetworkId.networkId(tenantNetworkId); | ||
212 | + MacAddress macAddress = MacAddress.valueOf(macAddressStr); | ||
213 | + BindingHostId bindingHostId = BindingHostId.bindingHostId(hostIdStr); | ||
214 | + FixedIp fixedIp = FixedIp.fixedIp(SubnetId.subnetId(subnet), | ||
215 | + IpAddress.valueOf(ipAddress)); | ||
216 | + fixedIps = Sets.newHashSet(); | ||
217 | + fixedIps.add(fixedIp); | ||
218 | + | ||
219 | + allowedAddressPairs = Sets.newHashSet(); | ||
220 | + AllowedAddressPair allowedAddressPair = AllowedAddressPair | ||
221 | + .allowedAddressPair(IpAddress.valueOf(ipAddress), | ||
222 | + MacAddress.valueOf(macAddressStr)); | ||
223 | + allowedAddressPairs.add(allowedAddressPair); | ||
224 | + | ||
225 | + VirtualPort d1 = new DefaultVirtualPort(id1, networkId, true, | ||
226 | + propertyMap, | ||
227 | + VirtualPort.State.ACTIVE, | ||
228 | + macAddress, tenantId, deviceId, | ||
229 | + fixedIps, bindingHostId, | ||
230 | + allowedAddressPairs, | ||
231 | + securityGroups); | ||
232 | + return d1; | ||
233 | + } | ||
234 | + | ||
235 | + @Test | ||
236 | + public void testInstallFlowClassifier() { | ||
237 | + | ||
238 | + ApplicationId appId = new DefaultApplicationId(1, "test"); | ||
239 | + FlowClassifierInstallerImpl flowClassifierInstaller = new FlowClassifierInstallerImpl(); | ||
240 | + flowClassifierInstaller.virtualPortService = virtualPortService; | ||
241 | + flowClassifierInstaller.vtnRscService = vtnRscService; | ||
242 | + flowClassifierInstaller.portPairService = portPairService; | ||
243 | + flowClassifierInstaller.portPairGroupService = portPairGroupService; | ||
244 | + flowClassifierInstaller.flowClassifierService = flowClassifierService; | ||
245 | + flowClassifierInstaller.driverService = driverService; | ||
246 | + flowClassifierInstaller.deviceService = deviceService; | ||
247 | + flowClassifierInstaller.hostService = hostService; | ||
248 | + flowClassifierInstaller.flowObjectiveService = flowObjectiveService; | ||
249 | + flowClassifierInstaller.appId = appId; | ||
250 | + | ||
251 | + final PortChain portChain = createPortChain(); | ||
252 | + NshServicePathId nshSpiId = NshServicePathId.of(10); | ||
253 | + | ||
254 | + portPairGroupService.createPortPairGroup(createPortPairGroup(portPairGroupId1)); | ||
255 | + portPairGroupService.createPortPairGroup(createPortPairGroup(portPairGroupId2)); | ||
256 | + portPairService.createPortPair(createPortPair(portPairId1)); | ||
257 | + portPairService.createPortPair(createPortPair(portPairId2)); | ||
258 | + FlowClassifier fc1 = createFlowClassifier(flowClassifierId1); | ||
259 | + FlowClassifier fc2 = createFlowClassifier(flowClassifierId2); | ||
260 | + flowClassifierService.createFlowClassifier(fc1); | ||
261 | + flowClassifierService.createFlowClassifier(fc2); | ||
262 | + | ||
263 | + List<VirtualPort> virtualPortList = Lists.newArrayList(); | ||
264 | + virtualPortList.add(createVirtualPort()); | ||
265 | + virtualPortService.createPorts(virtualPortList); | ||
266 | + | ||
267 | + expect(driverService.createHandler(deviceId)).andReturn(driverHandler).anyTimes(); | ||
268 | + replay(driverService); | ||
269 | + | ||
270 | + ConnectPoint connectPoint = flowClassifierInstaller.installFlowClassifier(portChain, nshSpiId); | ||
271 | + | ||
272 | + assertThat(connectPoint, is(HostLocation.NONE)); | ||
273 | + } | ||
274 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableList; | ... | @@ -28,7 +28,7 @@ import com.google.common.collect.ImmutableList; |
28 | /** | 28 | /** |
29 | * Provides implementation of the Flow Classifier Service. | 29 | * Provides implementation of the Flow Classifier Service. |
30 | */ | 30 | */ |
31 | -public class FlowClassifierManagerTestImpl implements FlowClassifierService { | 31 | +public class FlowClassifierAdapter implements FlowClassifierService { |
32 | 32 | ||
33 | private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>(); | 33 | private final ConcurrentMap<FlowClassifierId, FlowClassifier> flowClassifierStore = new ConcurrentHashMap<>(); |
34 | 34 | ... | ... |
... | @@ -16,16 +16,17 @@ | ... | @@ -16,16 +16,17 @@ |
16 | package org.onosproject.sfc.util; | 16 | package org.onosproject.sfc.util; |
17 | 17 | ||
18 | import org.onosproject.net.DeviceId; | 18 | import org.onosproject.net.DeviceId; |
19 | -import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
20 | import org.onosproject.net.flowobjective.FilteringObjective; | 19 | import org.onosproject.net.flowobjective.FilteringObjective; |
20 | +import org.onosproject.net.flowobjective.FlowObjectiveService; | ||
21 | import org.onosproject.net.flowobjective.ForwardingObjective; | 21 | import org.onosproject.net.flowobjective.ForwardingObjective; |
22 | import org.onosproject.net.flowobjective.NextObjective; | 22 | import org.onosproject.net.flowobjective.NextObjective; |
23 | 23 | ||
24 | /** | 24 | /** |
25 | * Testing version of implementation on FlowObjectiveService. | 25 | * Testing version of implementation on FlowObjectiveService. |
26 | */ | 26 | */ |
27 | -public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { | 27 | +public class FlowObjectiveAdapter implements FlowObjectiveService { |
28 | 28 | ||
29 | + private ForwardingObjective forwardingObjective; | ||
29 | @Override | 30 | @Override |
30 | public void filter(DeviceId deviceId, FilteringObjective filteringObjective) { | 31 | public void filter(DeviceId deviceId, FilteringObjective filteringObjective) { |
31 | 32 | ||
... | @@ -33,7 +34,7 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { | ... | @@ -33,7 +34,7 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { |
33 | 34 | ||
34 | @Override | 35 | @Override |
35 | public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) { | 36 | public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) { |
36 | - | 37 | + this.forwardingObjective = forwardingObjective; |
37 | } | 38 | } |
38 | 39 | ||
39 | @Override | 40 | @Override |
... | @@ -50,4 +51,8 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { | ... | @@ -50,4 +51,8 @@ public class FlowObjectiveServiceTestImpl implements FlowObjectiveService { |
50 | public void initPolicy(String policy) { | 51 | public void initPolicy(String policy) { |
51 | 52 | ||
52 | } | 53 | } |
54 | + | ||
55 | + public ForwardingObjective forwardingObjective() { | ||
56 | + return forwardingObjective; | ||
57 | + } | ||
53 | } | 58 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | + | ||
17 | +package org.onosproject.sfc.util; | ||
18 | + | ||
19 | +import org.onosproject.net.behaviour.ExtensionSelectorResolver; | ||
20 | +import org.onosproject.net.behaviour.ExtensionTreatmentResolver; | ||
21 | +import org.onosproject.net.driver.Behaviour; | ||
22 | +import org.onosproject.net.driver.Driver; | ||
23 | +import org.onosproject.net.driver.DriverData; | ||
24 | +import org.onosproject.net.driver.DriverHandler; | ||
25 | + | ||
26 | +public class MockDriverHandler implements DriverHandler { | ||
27 | + | ||
28 | + @Override | ||
29 | + public Driver driver() { | ||
30 | + return null; | ||
31 | + } | ||
32 | + | ||
33 | + @Override | ||
34 | + public DriverData data() { | ||
35 | + return null; | ||
36 | + } | ||
37 | + | ||
38 | + @Override | ||
39 | + public <T extends Behaviour> T behaviour(Class<T> behaviourClass) { | ||
40 | + if (behaviourClass == ExtensionSelectorResolver.class) { | ||
41 | + return (T) new MockExtensionSelectorResolver(); | ||
42 | + } else if (behaviourClass == ExtensionTreatmentResolver.class) { | ||
43 | + return (T) new MockExtensionTreatmentResolver(); | ||
44 | + } | ||
45 | + return null; | ||
46 | + } | ||
47 | + | ||
48 | + @Override | ||
49 | + public <T> T get(Class<T> serviceClass) { | ||
50 | + return null; | ||
51 | + } | ||
52 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.List; | ||
19 | + | ||
20 | +import org.onosproject.net.flow.criteria.ExtensionSelector; | ||
21 | +import org.onosproject.net.flow.criteria.ExtensionSelectorType; | ||
22 | +import org.onosproject.net.flow.instructions.ExtensionPropertyException; | ||
23 | + | ||
24 | +public class MockExtensionSelector implements ExtensionSelector { | ||
25 | + | ||
26 | + @Override | ||
27 | + public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException { | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public <T> T getPropertyValue(String key) throws ExtensionPropertyException { | ||
32 | + return null; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public List<String> getProperties() { | ||
37 | + return null; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public byte[] serialize() { | ||
42 | + return null; | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public void deserialize(byte[] data) { | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public ExtensionSelectorType type() { | ||
51 | + return null; | ||
52 | + } | ||
53 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionSelectorResolver.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import org.onosproject.net.behaviour.ExtensionSelectorResolver; | ||
19 | +import org.onosproject.net.driver.DriverData; | ||
20 | +import org.onosproject.net.driver.DriverHandler; | ||
21 | +import org.onosproject.net.flow.criteria.ExtensionSelector; | ||
22 | +import org.onosproject.net.flow.criteria.ExtensionSelectorType; | ||
23 | + | ||
24 | +public class MockExtensionSelectorResolver implements ExtensionSelectorResolver { | ||
25 | + | ||
26 | + @Override | ||
27 | + public DriverHandler handler() { | ||
28 | + return null; | ||
29 | + } | ||
30 | + | ||
31 | + @Override | ||
32 | + public void setHandler(DriverHandler handler) { | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public DriverData data() { | ||
37 | + return null; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void setData(DriverData data) { | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public ExtensionSelector getExtensionSelector(ExtensionSelectorType type) { | ||
46 | + return new MockExtensionSelector(); | ||
47 | + } | ||
48 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import java.util.List; | ||
19 | + | ||
20 | +import org.onosproject.net.flow.instructions.ExtensionPropertyException; | ||
21 | +import org.onosproject.net.flow.instructions.ExtensionTreatment; | ||
22 | +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; | ||
23 | + | ||
24 | +public class MockExtensionTreatment implements ExtensionTreatment { | ||
25 | + | ||
26 | + @Override | ||
27 | + public <T> void setPropertyValue(String key, T value) throws ExtensionPropertyException { | ||
28 | + } | ||
29 | + | ||
30 | + @Override | ||
31 | + public <T> T getPropertyValue(String key) throws ExtensionPropertyException { | ||
32 | + return null; | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public List<String> getProperties() { | ||
37 | + return null; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public byte[] serialize() { | ||
42 | + return null; | ||
43 | + } | ||
44 | + | ||
45 | + @Override | ||
46 | + public void deserialize(byte[] data) { | ||
47 | + } | ||
48 | + | ||
49 | + @Override | ||
50 | + public ExtensionTreatmentType type() { | ||
51 | + return null; | ||
52 | + } | ||
53 | + | ||
54 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
apps/vtn/sfcmgr/src/test/java/org/onosproject/sfc/util/MockExtensionTreatmentResolver.java
0 → 100644
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.sfc.util; | ||
17 | + | ||
18 | +import org.onosproject.net.behaviour.ExtensionTreatmentResolver; | ||
19 | +import org.onosproject.net.driver.DriverData; | ||
20 | +import org.onosproject.net.driver.DriverHandler; | ||
21 | +import org.onosproject.net.flow.instructions.ExtensionTreatment; | ||
22 | +import org.onosproject.net.flow.instructions.ExtensionTreatmentType; | ||
23 | + | ||
24 | +public class MockExtensionTreatmentResolver implements ExtensionTreatmentResolver { | ||
25 | + | ||
26 | + @Override | ||
27 | + public DriverHandler handler() { | ||
28 | + return null; | ||
29 | + } | ||
30 | + | ||
31 | + @Override | ||
32 | + public void setHandler(DriverHandler handler) { | ||
33 | + } | ||
34 | + | ||
35 | + @Override | ||
36 | + public DriverData data() { | ||
37 | + return null; | ||
38 | + } | ||
39 | + | ||
40 | + @Override | ||
41 | + public void setData(DriverData data) { | ||
42 | + } | ||
43 | + | ||
44 | + @Override | ||
45 | + public ExtensionTreatment getExtensionInstruction(ExtensionTreatmentType type) { | ||
46 | + return new MockExtensionTreatment(); | ||
47 | + } | ||
48 | + | ||
49 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -29,7 +29,7 @@ import org.onosproject.event.AbstractListenerManager; | ... | @@ -29,7 +29,7 @@ import org.onosproject.event.AbstractListenerManager; |
29 | /** | 29 | /** |
30 | * Provides implementation of the portChainService. | 30 | * Provides implementation of the portChainService. |
31 | */ | 31 | */ |
32 | -public class PortChainManagerTestImpl | 32 | +public class PortChainAdapter |
33 | extends AbstractListenerManager<PortChainEvent, PortChainListener> | 33 | extends AbstractListenerManager<PortChainEvent, PortChainListener> |
34 | implements PortChainService { | 34 | implements PortChainService { |
35 | 35 | ... | ... |
... | @@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpair.PortPairService; | ... | @@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpair.PortPairService; |
27 | /** | 27 | /** |
28 | * Provides implementation of the portPairService. | 28 | * Provides implementation of the portPairService. |
29 | */ | 29 | */ |
30 | -public class PortPairManagerTestImpl implements PortPairService { | 30 | +public class PortPairAdapter implements PortPairService { |
31 | 31 | ||
32 | private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>(); | 32 | private ConcurrentMap<PortPairId, PortPair> portPairStore = new ConcurrentHashMap<>(); |
33 | 33 | ... | ... |
... | @@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; | ... | @@ -27,7 +27,7 @@ import org.onosproject.vtnrsc.portpairgroup.PortPairGroupService; |
27 | /** | 27 | /** |
28 | * Provides implementation of the portPairGroupService. | 28 | * Provides implementation of the portPairGroupService. |
29 | */ | 29 | */ |
30 | -public class PortPairGroupManagerTestImpl implements PortPairGroupService { | 30 | +public class PortPairGroupAdapter implements PortPairGroupService { |
31 | 31 | ||
32 | private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>(); | 32 | private ConcurrentMap<PortPairGroupId, PortPairGroup> portPairGroupStore = new ConcurrentHashMap<>(); |
33 | 33 | ... | ... |
... | @@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; | ... | @@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.virtualport.VirtualPortService; |
31 | /** | 31 | /** |
32 | * Provides implementation of the VirtualPort APIs. | 32 | * Provides implementation of the VirtualPort APIs. |
33 | */ | 33 | */ |
34 | -public class VirtualPortManagerTestImpl implements VirtualPortService { | 34 | +public class VirtualPortAdapter implements VirtualPortService { |
35 | 35 | ||
36 | protected ConcurrentMap<VirtualPortId, VirtualPort> vPortStore = new ConcurrentHashMap<>(); | 36 | protected ConcurrentMap<VirtualPortId, VirtualPort> vPortStore = new ConcurrentHashMap<>(); |
37 | 37 | ... | ... |
... | @@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.service.VtnRscService; | ... | @@ -31,7 +31,7 @@ import org.onosproject.vtnrsc.service.VtnRscService; |
31 | /** | 31 | /** |
32 | * Provides implementation of the VtnRsc service. | 32 | * Provides implementation of the VtnRsc service. |
33 | */ | 33 | */ |
34 | -public class VtnRscManagerTestImpl implements VtnRscService { | 34 | +public class VtnRscAdapter implements VtnRscService { |
35 | @Override | 35 | @Override |
36 | public void addListener(VtnRscListener listener) { | 36 | public void addListener(VtnRscListener listener) { |
37 | } | 37 | } |
... | @@ -62,13 +62,12 @@ public class VtnRscManagerTestImpl implements VtnRscService { | ... | @@ -62,13 +62,12 @@ public class VtnRscManagerTestImpl implements VtnRscService { |
62 | 62 | ||
63 | @Override | 63 | @Override |
64 | public boolean isServiceFunction(VirtualPortId portId) { | 64 | public boolean isServiceFunction(VirtualPortId portId) { |
65 | - // TODO Auto-generated method stub | ||
66 | return false; | 65 | return false; |
67 | } | 66 | } |
68 | 67 | ||
69 | @Override | 68 | @Override |
70 | public DeviceId getSfToSffMaping(VirtualPortId portId) { | 69 | public DeviceId getSfToSffMaping(VirtualPortId portId) { |
71 | - return DeviceId.deviceId("www.google.com"); | 70 | + return DeviceId.deviceId("of:000000000000001"); |
72 | } | 71 | } |
73 | 72 | ||
74 | @Override | 73 | @Override | ... | ... |
... | @@ -15,15 +15,21 @@ | ... | @@ -15,15 +15,21 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.net.host; | 16 | package org.onosproject.net.host; |
17 | 17 | ||
18 | +import java.util.Set; | ||
19 | + | ||
18 | import org.onlab.packet.IpAddress; | 20 | import org.onlab.packet.IpAddress; |
19 | import org.onlab.packet.MacAddress; | 21 | import org.onlab.packet.MacAddress; |
20 | import org.onlab.packet.VlanId; | 22 | import org.onlab.packet.VlanId; |
23 | +import org.onosproject.net.Annotations; | ||
21 | import org.onosproject.net.ConnectPoint; | 24 | import org.onosproject.net.ConnectPoint; |
25 | +import org.onosproject.net.DefaultHost; | ||
22 | import org.onosproject.net.DeviceId; | 26 | import org.onosproject.net.DeviceId; |
23 | import org.onosproject.net.Host; | 27 | import org.onosproject.net.Host; |
24 | import org.onosproject.net.HostId; | 28 | import org.onosproject.net.HostId; |
29 | +import org.onosproject.net.HostLocation; | ||
30 | +import org.onosproject.net.provider.ProviderId; | ||
25 | 31 | ||
26 | -import java.util.Set; | 32 | +import com.google.common.collect.Sets; |
27 | 33 | ||
28 | /** | 34 | /** |
29 | * Test adapter for host service. | 35 | * Test adapter for host service. |
... | @@ -41,7 +47,13 @@ public class HostServiceAdapter implements HostService { | ... | @@ -41,7 +47,13 @@ public class HostServiceAdapter implements HostService { |
41 | 47 | ||
42 | @Override | 48 | @Override |
43 | public Host getHost(HostId hostId) { | 49 | public Host getHost(HostId hostId) { |
44 | - return null; | 50 | + ProviderId providerId = ProviderId.NONE; |
51 | + MacAddress mac = MacAddress.valueOf("fa:12:3e:56:ee:a2"); | ||
52 | + VlanId vlan = VlanId.NONE; | ||
53 | + HostLocation location = HostLocation.NONE; | ||
54 | + Set<IpAddress> ips = Sets.newHashSet(); | ||
55 | + Annotations annotations = null; | ||
56 | + return new DefaultHost(providerId, hostId, mac, vlan, location, ips, annotations); | ||
45 | } | 57 | } |
46 | 58 | ||
47 | @Override | 59 | @Override | ... | ... |
-
Please register or login to post a comment