Committed by
Gerrit Code Review
[ONOS-5187] Compute path with Explicit path objects
Change-Id: Id34dbef9bd6cfa9971d0d10adf4bbc141f03a913
Showing
22 changed files
with
567 additions
and
39 deletions
... | @@ -105,5 +105,10 @@ | ... | @@ -105,5 +105,10 @@ |
105 | <groupId>org.onosproject</groupId> | 105 | <groupId>org.onosproject</groupId> |
106 | <artifactId>onos-app-pcep-api</artifactId> | 106 | <artifactId>onos-app-pcep-api</artifactId> |
107 | </dependency> | 107 | </dependency> |
108 | + <dependency> | ||
109 | + <groupId>org.easymock</groupId> | ||
110 | + <artifactId>easymock</artifactId> | ||
111 | + <scope>test</scope> | ||
112 | + </dependency> | ||
108 | </dependencies> | 113 | </dependencies> |
109 | </project> | 114 | </project> | ... | ... |
... | @@ -24,10 +24,13 @@ import org.onosproject.cli.AbstractShellCommand; | ... | @@ -24,10 +24,13 @@ import org.onosproject.cli.AbstractShellCommand; |
24 | import org.onosproject.incubator.net.tunnel.Tunnel; | 24 | import org.onosproject.incubator.net.tunnel.Tunnel; |
25 | import org.onosproject.incubator.net.tunnel.TunnelId; | 25 | import org.onosproject.incubator.net.tunnel.TunnelId; |
26 | import org.onosproject.net.AnnotationKeys; | 26 | import org.onosproject.net.AnnotationKeys; |
27 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
27 | import org.onosproject.pce.pceservice.api.PceService; | 28 | import org.onosproject.pce.pceservice.api.PceService; |
28 | 29 | ||
29 | import org.slf4j.Logger; | 30 | import org.slf4j.Logger; |
30 | 31 | ||
32 | +import java.util.List; | ||
33 | + | ||
31 | /** | 34 | /** |
32 | * Supports quering PCE path. | 35 | * Supports quering PCE path. |
33 | */ | 36 | */ |
... | @@ -72,6 +75,9 @@ public class PceQueryPathCommand extends AbstractShellCommand { | ... | @@ -72,6 +75,9 @@ public class PceQueryPathCommand extends AbstractShellCommand { |
72 | * @param tunnel pce tunnel | 75 | * @param tunnel pce tunnel |
73 | */ | 76 | */ |
74 | void display(Tunnel tunnel) { | 77 | void display(Tunnel tunnel) { |
78 | + List<ExplicitPathInfo> explicitPathInfoList = AbstractShellCommand.get(PceService.class) | ||
79 | + .explicitPathInfoList(tunnel.tunnelName().value()); | ||
80 | + | ||
75 | print("\npath-id : %s \n" + | 81 | print("\npath-id : %s \n" + |
76 | "source : %s \n" + | 82 | "source : %s \n" + |
77 | "destination : %s \n" + | 83 | "destination : %s \n" + |
... | @@ -84,5 +90,13 @@ public class PceQueryPathCommand extends AbstractShellCommand { | ... | @@ -84,5 +90,13 @@ public class PceQueryPathCommand extends AbstractShellCommand { |
84 | tunnel.path().dst().deviceId().toString(), | 90 | tunnel.path().dst().deviceId().toString(), |
85 | tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE), | 91 | tunnel.type().name(), tunnel.tunnelName(), tunnel.annotations().value(COST_TYPE), |
86 | tunnel.annotations().value(AnnotationKeys.BANDWIDTH)); | 92 | tunnel.annotations().value(AnnotationKeys.BANDWIDTH)); |
93 | + if (explicitPathInfoList != null) { | ||
94 | + for (ExplicitPathInfo e : explicitPathInfoList) { | ||
95 | + print("explicitPathObjects : \n" + | ||
96 | + " type : %s \n" + | ||
97 | + " value : %s ", | ||
98 | + String.valueOf(e.type().type()), e.value().toString()); | ||
99 | + } | ||
100 | + } | ||
87 | } | 101 | } |
88 | } | 102 | } | ... | ... |
... | @@ -15,27 +15,35 @@ | ... | @@ -15,27 +15,35 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pce.cli; | 16 | package org.onosproject.pce.cli; |
17 | 17 | ||
18 | +import static org.onosproject.net.Link.State.ACTIVE; | ||
19 | +import static org.onosproject.net.Link.Type.DIRECT; | ||
18 | import static org.slf4j.LoggerFactory.getLogger; | 20 | import static org.slf4j.LoggerFactory.getLogger; |
19 | 21 | ||
20 | import java.util.Collection; | 22 | import java.util.Collection; |
21 | import java.util.List; | 23 | import java.util.List; |
22 | import java.util.LinkedList; | 24 | import java.util.LinkedList; |
23 | 25 | ||
26 | +import com.google.common.collect.Lists; | ||
27 | + | ||
24 | import org.apache.karaf.shell.commands.Argument; | 28 | import org.apache.karaf.shell.commands.Argument; |
25 | import org.apache.karaf.shell.commands.Command; | 29 | import org.apache.karaf.shell.commands.Command; |
26 | import org.apache.karaf.shell.commands.Option; | 30 | import org.apache.karaf.shell.commands.Option; |
27 | - | ||
28 | import org.onlab.util.DataRateUnit; | 31 | import org.onlab.util.DataRateUnit; |
29 | import org.onosproject.cli.AbstractShellCommand; | 32 | import org.onosproject.cli.AbstractShellCommand; |
30 | import org.onosproject.incubator.net.tunnel.Tunnel; | 33 | import org.onosproject.incubator.net.tunnel.Tunnel; |
31 | import org.onosproject.incubator.net.tunnel.TunnelService; | 34 | import org.onosproject.incubator.net.tunnel.TunnelService; |
35 | +import org.onosproject.net.ConnectPoint; | ||
36 | +import org.onosproject.net.DefaultLink; | ||
32 | import org.onosproject.net.DeviceId; | 37 | import org.onosproject.net.DeviceId; |
38 | +import org.onosproject.net.NetworkResource; | ||
39 | +import org.onosproject.net.PortNumber; | ||
33 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 40 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
34 | import org.onosproject.net.intent.Constraint; | 41 | import org.onosproject.net.intent.Constraint; |
42 | +import org.onosproject.net.provider.ProviderId; | ||
43 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
35 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 44 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
36 | import org.onosproject.pce.pceservice.LspType; | 45 | import org.onosproject.pce.pceservice.LspType; |
37 | import org.onosproject.pce.pceservice.api.PceService; | 46 | import org.onosproject.pce.pceservice.api.PceService; |
38 | - | ||
39 | import org.slf4j.Logger; | 47 | import org.slf4j.Logger; |
40 | 48 | ||
41 | /** | 49 | /** |
... | @@ -44,6 +52,16 @@ import org.slf4j.Logger; | ... | @@ -44,6 +52,16 @@ import org.slf4j.Logger; |
44 | @Command(scope = "onos", name = "pce-setup-path", description = "Supports creating pce path.") | 52 | @Command(scope = "onos", name = "pce-setup-path", description = "Supports creating pce path.") |
45 | public class PceSetupPathCommand extends AbstractShellCommand { | 53 | public class PceSetupPathCommand extends AbstractShellCommand { |
46 | private final Logger log = getLogger(getClass()); | 54 | private final Logger log = getLogger(getClass()); |
55 | + public static final byte SUBTYPE_DEVICEID = 0; | ||
56 | + public static final byte SUBTYPE_LINK = 1; | ||
57 | + public static final byte SUBTYPE_INDEX = 1; | ||
58 | + public static final byte TYPE_INDEX = 0; | ||
59 | + | ||
60 | + public static final byte DEVICEID_INDEX = 2; | ||
61 | + public static final byte SOURCE_DEVICEID_INDEX = 2; | ||
62 | + public static final byte SOURCE_PORTNO_INDEX = 3; | ||
63 | + public static final byte DESTINATION_DEVICEID_INDEX = 4; | ||
64 | + public static final byte DESTINATION_PORTNO_INDEX = 5; | ||
47 | 65 | ||
48 | @Argument(index = 0, name = "src", description = "source device.", required = true, multiValued = false) | 66 | @Argument(index = 0, name = "src", description = "source device.", required = true, multiValued = false) |
49 | String src = null; | 67 | String src = null; |
... | @@ -69,6 +87,15 @@ public class PceSetupPathCommand extends AbstractShellCommand { | ... | @@ -69,6 +87,15 @@ public class PceSetupPathCommand extends AbstractShellCommand { |
69 | + "Data rate unit is in BPS.", required = false, multiValued = false) | 87 | + "Data rate unit is in BPS.", required = false, multiValued = false) |
70 | double bandwidth = 0.0; | 88 | double bandwidth = 0.0; |
71 | 89 | ||
90 | + @Option(name = "-e", aliases = "--explicitPathObjects", description = "List of strict and loose hopes", | ||
91 | + required = false, multiValued = true) | ||
92 | + String[] explicitPathInfoStrings; | ||
93 | + | ||
94 | + //explicitPathInfo format : Type/SubType/Value(DeviceId or Link info) | ||
95 | + //If Value is Device : Type/SubType/deviceId | ||
96 | + //If Value is Link : Type/SubType/SourceDeviceId/SourcePortNo/DestinationDeviceId/DestinationPortNo | ||
97 | + List<ExplicitPathInfo> explicitPathInfo = Lists.newLinkedList(); | ||
98 | + | ||
72 | @Override | 99 | @Override |
73 | protected void execute() { | 100 | protected void execute() { |
74 | log.info("executing pce-setup-path"); | 101 | log.info("executing pce-setup-path"); |
... | @@ -114,7 +141,50 @@ public class PceSetupPathCommand extends AbstractShellCommand { | ... | @@ -114,7 +141,50 @@ public class PceSetupPathCommand extends AbstractShellCommand { |
114 | CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1]; | 141 | CostConstraint.Type costType = CostConstraint.Type.values()[cost - 1]; |
115 | listConstrnt.add(CostConstraint.of(costType)); | 142 | listConstrnt.add(CostConstraint.of(costType)); |
116 | 143 | ||
117 | - if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType)) { | 144 | + if (explicitPathInfoStrings != null) { |
145 | + for (String str : explicitPathInfoStrings) { | ||
146 | + String[] splitted = str.split("/"); | ||
147 | + DeviceId deviceId; | ||
148 | + NetworkResource res = null; | ||
149 | + PortNumber portNo; | ||
150 | + int explicitPathType = Integer.parseInt(splitted[TYPE_INDEX]); | ||
151 | + if ((explicitPathType < 0) || (explicitPathType > 1)) { | ||
152 | + error("Explicit path validation failed"); | ||
153 | + return; | ||
154 | + } | ||
155 | + | ||
156 | + //subtype 0 = deviceId, 1 = link | ||
157 | + //subtype is required to store either as deviceId or Link | ||
158 | + if (splitted[DEVICEID_INDEX] != null && Integer.parseInt(splitted[SUBTYPE_INDEX]) == SUBTYPE_DEVICEID) { | ||
159 | + res = DeviceId.deviceId(splitted[DEVICEID_INDEX]); | ||
160 | + } else if (Integer.parseInt(splitted[SUBTYPE_INDEX]) == SUBTYPE_LINK | ||
161 | + && splitted[SOURCE_DEVICEID_INDEX] != null | ||
162 | + && splitted[SOURCE_PORTNO_INDEX] != null | ||
163 | + && splitted[DESTINATION_DEVICEID_INDEX] != null | ||
164 | + && splitted[DESTINATION_PORTNO_INDEX] != null) { | ||
165 | + | ||
166 | + deviceId = DeviceId.deviceId(splitted[SOURCE_DEVICEID_INDEX]); | ||
167 | + portNo = PortNumber.portNumber(splitted[SOURCE_PORTNO_INDEX]); | ||
168 | + ConnectPoint cpSrc = new ConnectPoint(deviceId, portNo); | ||
169 | + deviceId = DeviceId.deviceId(splitted[DESTINATION_DEVICEID_INDEX]); | ||
170 | + portNo = PortNumber.portNumber(splitted[DESTINATION_PORTNO_INDEX]); | ||
171 | + ConnectPoint cpDst = new ConnectPoint(deviceId, portNo); | ||
172 | + res = DefaultLink.builder() | ||
173 | + .providerId(ProviderId.NONE) | ||
174 | + .src(cpSrc) | ||
175 | + .dst(cpDst) | ||
176 | + .type(DIRECT) | ||
177 | + .state(ACTIVE) | ||
178 | + .build(); | ||
179 | + } else { | ||
180 | + error("Explicit path validation failed"); | ||
181 | + return; | ||
182 | + } | ||
183 | + ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.values()[explicitPathType], res); | ||
184 | + explicitPathInfo.add(obj); | ||
185 | + } | ||
186 | + } | ||
187 | + if (!service.setupPath(srcDevice, dstDevice, name, listConstrnt, lspType, explicitPathInfo)) { | ||
118 | error("Path creation failed."); | 188 | error("Path creation failed."); |
119 | } | 189 | } |
120 | } | 190 | } | ... | ... |
... | @@ -18,14 +18,18 @@ package org.onosproject.pce.pceservice; | ... | @@ -18,14 +18,18 @@ package org.onosproject.pce.pceservice; |
18 | 18 | ||
19 | import static com.google.common.base.MoreObjects.toStringHelper; | 19 | import static com.google.common.base.MoreObjects.toStringHelper; |
20 | 20 | ||
21 | +import java.util.Collection; | ||
22 | +import java.util.List; | ||
21 | import java.util.Objects; | 23 | import java.util.Objects; |
22 | 24 | ||
25 | +import org.onlab.rest.BaseResource; | ||
23 | import org.onlab.util.DataRateUnit; | 26 | import org.onlab.util.DataRateUnit; |
24 | import org.onosproject.incubator.net.tunnel.Tunnel; | 27 | import org.onosproject.incubator.net.tunnel.Tunnel; |
25 | import org.onosproject.incubator.net.tunnel.TunnelId; | 28 | import org.onosproject.incubator.net.tunnel.TunnelId; |
26 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 29 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
27 | import org.onosproject.net.intent.Constraint; | 30 | import org.onosproject.net.intent.Constraint; |
28 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 31 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
32 | +import org.onosproject.pce.pcestore.api.PceStore; | ||
29 | 33 | ||
30 | /** | 34 | /** |
31 | * Implementation of an entity which provides functionalities of pce path. | 35 | * Implementation of an entity which provides functionalities of pce path. |
... | @@ -39,6 +43,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -39,6 +43,7 @@ public final class DefaultPcePath implements PcePath { |
39 | private String name; // symbolic-path-name | 43 | private String name; // symbolic-path-name |
40 | private Constraint costConstraint; // cost constraint | 44 | private Constraint costConstraint; // cost constraint |
41 | private Constraint bandwidthConstraint; // bandwidth constraint | 45 | private Constraint bandwidthConstraint; // bandwidth constraint |
46 | + private Collection<ExplicitPathInfo> explicitPathInfo; //list of explicit path info | ||
42 | 47 | ||
43 | /** | 48 | /** |
44 | * Initializes PCE path attributes. | 49 | * Initializes PCE path attributes. |
... | @@ -50,10 +55,11 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -50,10 +55,11 @@ public final class DefaultPcePath implements PcePath { |
50 | * @param name symbolic-path-name | 55 | * @param name symbolic-path-name |
51 | * @param costConstrnt cost constraint | 56 | * @param costConstrnt cost constraint |
52 | * @param bandwidthConstrnt bandwidth constraint | 57 | * @param bandwidthConstrnt bandwidth constraint |
58 | + * @param explicitPathInfo list of explicit path info | ||
53 | */ | 59 | */ |
54 | private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType, | 60 | private DefaultPcePath(TunnelId id, String src, String dst, LspType lspType, |
55 | - String name, Constraint costConstrnt, Constraint bandwidthConstrnt) { | 61 | + String name, Constraint costConstrnt, Constraint bandwidthConstrnt, |
56 | - | 62 | + Collection<ExplicitPathInfo> explicitPathInfo) { |
57 | this.id = id; | 63 | this.id = id; |
58 | this.source = src; | 64 | this.source = src; |
59 | this.destination = dst; | 65 | this.destination = dst; |
... | @@ -61,6 +67,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -61,6 +67,7 @@ public final class DefaultPcePath implements PcePath { |
61 | this.name = name; | 67 | this.name = name; |
62 | this.costConstraint = costConstrnt; | 68 | this.costConstraint = costConstrnt; |
63 | this.bandwidthConstraint = bandwidthConstrnt; | 69 | this.bandwidthConstraint = bandwidthConstrnt; |
70 | + this.explicitPathInfo = explicitPathInfo; | ||
64 | } | 71 | } |
65 | 72 | ||
66 | @Override | 73 | @Override |
... | @@ -114,6 +121,11 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -114,6 +121,11 @@ public final class DefaultPcePath implements PcePath { |
114 | } | 121 | } |
115 | 122 | ||
116 | @Override | 123 | @Override |
124 | + public Collection<ExplicitPathInfo> explicitPathInfo() { | ||
125 | + return explicitPathInfo; | ||
126 | + } | ||
127 | + | ||
128 | + @Override | ||
117 | public PcePath copy(PcePath path) { | 129 | public PcePath copy(PcePath path) { |
118 | if (null != path.source()) { | 130 | if (null != path.source()) { |
119 | this.source = path.source(); | 131 | this.source = path.source(); |
... | @@ -138,7 +150,8 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -138,7 +150,8 @@ public final class DefaultPcePath implements PcePath { |
138 | 150 | ||
139 | @Override | 151 | @Override |
140 | public int hashCode() { | 152 | public int hashCode() { |
141 | - return Objects.hash(id, source, destination, lspType, name, costConstraint, bandwidthConstraint); | 153 | + return Objects.hash(id, source, destination, lspType, name, costConstraint, bandwidthConstraint, |
154 | + explicitPathInfo); | ||
142 | } | 155 | } |
143 | 156 | ||
144 | @Override | 157 | @Override |
... | @@ -154,7 +167,8 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -154,7 +167,8 @@ public final class DefaultPcePath implements PcePath { |
154 | && Objects.equals(lspType, that.lspType) | 167 | && Objects.equals(lspType, that.lspType) |
155 | && Objects.equals(name, that.name) | 168 | && Objects.equals(name, that.name) |
156 | && Objects.equals(costConstraint, that.costConstraint) | 169 | && Objects.equals(costConstraint, that.costConstraint) |
157 | - && Objects.equals(bandwidthConstraint, that.bandwidthConstraint); | 170 | + && Objects.equals(bandwidthConstraint, that.bandwidthConstraint) |
171 | + && Objects.equals(explicitPathInfo, that.explicitPathInfo); | ||
158 | } | 172 | } |
159 | return false; | 173 | return false; |
160 | } | 174 | } |
... | @@ -170,6 +184,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -170,6 +184,7 @@ public final class DefaultPcePath implements PcePath { |
170 | .add("name", name) | 184 | .add("name", name) |
171 | .add("costConstraint", costConstraint) | 185 | .add("costConstraint", costConstraint) |
172 | .add("bandwidthConstraint", bandwidthConstraint) | 186 | .add("bandwidthConstraint", bandwidthConstraint) |
187 | + .add("explicitPathInfo", explicitPathInfo) | ||
173 | .toString(); | 188 | .toString(); |
174 | } | 189 | } |
175 | 190 | ||
... | @@ -185,7 +200,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -185,7 +200,7 @@ public final class DefaultPcePath implements PcePath { |
185 | /** | 200 | /** |
186 | * Builder class for pce path. | 201 | * Builder class for pce path. |
187 | */ | 202 | */ |
188 | - public static final class Builder implements PcePath.Builder { | 203 | + public static final class Builder extends BaseResource implements PcePath.Builder { |
189 | private TunnelId id; | 204 | private TunnelId id; |
190 | private String source; | 205 | private String source; |
191 | private String destination; | 206 | private String destination; |
... | @@ -193,6 +208,7 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -193,6 +208,7 @@ public final class DefaultPcePath implements PcePath { |
193 | private String name; | 208 | private String name; |
194 | private Constraint costConstraint; | 209 | private Constraint costConstraint; |
195 | private Constraint bandwidthConstraint; | 210 | private Constraint bandwidthConstraint; |
211 | + private Collection<ExplicitPathInfo> explicitPathInfo; | ||
196 | 212 | ||
197 | @Override | 213 | @Override |
198 | public Builder id(String id) { | 214 | public Builder id(String id) { |
... | @@ -240,6 +256,12 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -240,6 +256,12 @@ public final class DefaultPcePath implements PcePath { |
240 | } | 256 | } |
241 | 257 | ||
242 | @Override | 258 | @Override |
259 | + public Builder explicitPathInfo(Collection<ExplicitPathInfo> explicitPathInfo) { | ||
260 | + this.explicitPathInfo = explicitPathInfo; | ||
261 | + return this; | ||
262 | + } | ||
263 | + | ||
264 | + @Override | ||
243 | public Builder of(Tunnel tunnel) { | 265 | public Builder of(Tunnel tunnel) { |
244 | this.id = TunnelId.valueOf(tunnel.tunnelId().id()); | 266 | this.id = TunnelId.valueOf(tunnel.tunnelId().id()); |
245 | this.source = tunnel.path().src().deviceId().toString(); | 267 | this.source = tunnel.path().src().deviceId().toString(); |
... | @@ -264,13 +286,20 @@ public final class DefaultPcePath implements PcePath { | ... | @@ -264,13 +286,20 @@ public final class DefaultPcePath implements PcePath { |
264 | DataRateUnit.valueOf("BPS")); | 286 | DataRateUnit.valueOf("BPS")); |
265 | } | 287 | } |
266 | 288 | ||
289 | + PceStore pceStore = get(PceStore.class); | ||
290 | + List<ExplicitPathInfo> explicitPathInfoList = pceStore | ||
291 | + .getTunnelNameExplicitPathInfoMap(tunnel.tunnelName().value()); | ||
292 | + if (explicitPathInfoList != null) { | ||
293 | + this.explicitPathInfo = explicitPathInfoList; | ||
294 | + } | ||
295 | + | ||
267 | return this; | 296 | return this; |
268 | } | 297 | } |
269 | 298 | ||
270 | @Override | 299 | @Override |
271 | public PcePath build() { | 300 | public PcePath build() { |
272 | return new DefaultPcePath(id, source, destination, lspType, name, | 301 | return new DefaultPcePath(id, source, destination, lspType, name, |
273 | - costConstraint, bandwidthConstraint); | 302 | + costConstraint, bandwidthConstraint, explicitPathInfo); |
274 | } | 303 | } |
275 | } | 304 | } |
276 | } | 305 | } | ... | ... |
1 | +/* | ||
2 | + * Copyright 2016-present 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.pce.pceservice; | ||
17 | + | ||
18 | +import org.onosproject.net.NetworkResource; | ||
19 | + | ||
20 | +import com.google.common.annotations.Beta; | ||
21 | + | ||
22 | +import java.util.Objects; | ||
23 | + | ||
24 | +/** | ||
25 | + * Representation of explicit path info consists of contraints (strict / loose) to compute path. | ||
26 | + */ | ||
27 | +@Beta | ||
28 | +public final class ExplicitPathInfo { | ||
29 | + | ||
30 | + private final Type type; | ||
31 | + | ||
32 | + //Can be Link or DeviceId | ||
33 | + private final NetworkResource value; | ||
34 | + | ||
35 | + public enum Type { | ||
36 | + /** | ||
37 | + * Signifies that path includes strict node or link. | ||
38 | + */ | ||
39 | + STRICT(0), | ||
40 | + | ||
41 | + /** | ||
42 | + * Signifies that path includes loose node or link. | ||
43 | + */ | ||
44 | + LOOSE(1); | ||
45 | + | ||
46 | + int value; | ||
47 | + | ||
48 | + /** | ||
49 | + * Assign val with the value as the type. | ||
50 | + * | ||
51 | + * @param val type | ||
52 | + */ | ||
53 | + Type(int val) { | ||
54 | + value = val; | ||
55 | + } | ||
56 | + | ||
57 | + /** | ||
58 | + * Returns value of type. | ||
59 | + * | ||
60 | + * @return type | ||
61 | + */ | ||
62 | + public byte type() { | ||
63 | + return (byte) value; | ||
64 | + } | ||
65 | + } | ||
66 | + | ||
67 | + /** | ||
68 | + * Creates instance of explicit path object. | ||
69 | + * | ||
70 | + * @param type specifies whether strict or loose node/link | ||
71 | + * @param value specifies deviceId or link | ||
72 | + */ | ||
73 | + public ExplicitPathInfo(Type type, NetworkResource value) { | ||
74 | + this.type = type; | ||
75 | + this.value = value; | ||
76 | + } | ||
77 | + | ||
78 | + /** | ||
79 | + * Returns explicit path type. | ||
80 | + * | ||
81 | + * @return explicit path type as strict/loose | ||
82 | + */ | ||
83 | + public Type type() { | ||
84 | + return type; | ||
85 | + } | ||
86 | + | ||
87 | + /** | ||
88 | + * Returns deviceId or link. | ||
89 | + * | ||
90 | + * @return deviceId or link | ||
91 | + */ | ||
92 | + public NetworkResource value() { | ||
93 | + return value; | ||
94 | + } | ||
95 | + | ||
96 | + @Override | ||
97 | + public int hashCode() { | ||
98 | + return Objects.hash(type, value); | ||
99 | + } | ||
100 | + | ||
101 | + @Override | ||
102 | + public boolean equals(Object obj) { | ||
103 | + if (this == obj) { | ||
104 | + return true; | ||
105 | + } | ||
106 | + if (obj instanceof ExplicitPathInfo) { | ||
107 | + final ExplicitPathInfo other = (ExplicitPathInfo) obj; | ||
108 | + return Objects.equals(this.type, other.type) | ||
109 | + && Objects.equals(this.value, other.value); | ||
110 | + } | ||
111 | + return false; | ||
112 | + } | ||
113 | +} |
This diff is collapsed. Click to expand it.
... | @@ -19,7 +19,8 @@ package org.onosproject.pce.pceservice; | ... | @@ -19,7 +19,8 @@ package org.onosproject.pce.pceservice; |
19 | import org.onosproject.incubator.net.tunnel.Tunnel; | 19 | import org.onosproject.incubator.net.tunnel.Tunnel; |
20 | import org.onosproject.incubator.net.tunnel.TunnelId; | 20 | import org.onosproject.incubator.net.tunnel.TunnelId; |
21 | import org.onosproject.net.intent.Constraint; | 21 | import org.onosproject.net.intent.Constraint; |
22 | -import org.onosproject.pce.pceservice.DefaultPcePath.Builder; | 22 | + |
23 | +import java.util.Collection; | ||
23 | 24 | ||
24 | /** | 25 | /** |
25 | * Abstraction of an entity which provides functionalities of pce path. | 26 | * Abstraction of an entity which provides functionalities of pce path. |
... | @@ -97,6 +98,13 @@ public interface PcePath { | ... | @@ -97,6 +98,13 @@ public interface PcePath { |
97 | Constraint bandwidthConstraint(); | 98 | Constraint bandwidthConstraint(); |
98 | 99 | ||
99 | /** | 100 | /** |
101 | + * Returns the list of explicit path objects. | ||
102 | + * | ||
103 | + * @return list of explicit path objects | ||
104 | + */ | ||
105 | + Collection<ExplicitPathInfo> explicitPathInfo(); | ||
106 | + | ||
107 | + /** | ||
100 | * Copies only non-null or non-zero member variables. | 108 | * Copies only non-null or non-zero member variables. |
101 | * | 109 | * |
102 | * @param id path-id | 110 | * @param id path-id |
... | @@ -174,6 +182,14 @@ public interface PcePath { | ... | @@ -174,6 +182,14 @@ public interface PcePath { |
174 | Builder of(Tunnel tunnel); | 182 | Builder of(Tunnel tunnel); |
175 | 183 | ||
176 | /** | 184 | /** |
185 | + * Returns the builder object of ExplicitPathInfo. | ||
186 | + * | ||
187 | + * @param explicitPathInfo list of explicit path obj | ||
188 | + * @return builder object of ExplicitPathInfo | ||
189 | + */ | ||
190 | + Builder explicitPathInfo(Collection<ExplicitPathInfo> explicitPathInfo); | ||
191 | + | ||
192 | + /** | ||
177 | * Builds object of pce path. | 193 | * Builds object of pce path. |
178 | * | 194 | * |
179 | * @return object of pce path. | 195 | * @return object of pce path. | ... | ... |
... | @@ -19,6 +19,7 @@ import java.util.List; | ... | @@ -19,6 +19,7 @@ import java.util.List; |
19 | 19 | ||
20 | import org.onosproject.net.DeviceId; | 20 | import org.onosproject.net.DeviceId; |
21 | import org.onosproject.net.intent.Constraint; | 21 | import org.onosproject.net.intent.Constraint; |
22 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
22 | import org.onosproject.pce.pceservice.LspType; | 23 | import org.onosproject.pce.pceservice.LspType; |
23 | import org.onosproject.incubator.net.tunnel.Tunnel; | 24 | import org.onosproject.incubator.net.tunnel.Tunnel; |
24 | import org.onosproject.incubator.net.tunnel.TunnelId; | 25 | import org.onosproject.incubator.net.tunnel.TunnelId; |
... | @@ -42,6 +43,20 @@ public interface PceService { | ... | @@ -42,6 +43,20 @@ public interface PceService { |
42 | boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType); | 43 | boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType); |
43 | 44 | ||
44 | /** | 45 | /** |
46 | + * Creates new path based on constraints and LSP type. | ||
47 | + * | ||
48 | + * @param src source device | ||
49 | + * @param dst destination device | ||
50 | + * @param tunnelName name of the tunnel | ||
51 | + * @param constraints list of constraints to be applied on path | ||
52 | + * @param lspType type of path to be setup | ||
53 | + * @param explicitPathInfo list of explicit path info | ||
54 | + * @return false on failure and true on successful path creation | ||
55 | + */ | ||
56 | + boolean setupPath(DeviceId src, DeviceId dst, String tunnelName, List<Constraint> constraints, LspType lspType, | ||
57 | + List<ExplicitPathInfo> explicitPathInfo); | ||
58 | + | ||
59 | + /** | ||
45 | * Updates an existing path. | 60 | * Updates an existing path. |
46 | * | 61 | * |
47 | * @param tunnelId tunnel identifier | 62 | * @param tunnelId tunnel identifier |
... | @@ -72,4 +87,12 @@ public interface PceService { | ... | @@ -72,4 +87,12 @@ public interface PceService { |
72 | * @return tunnel if path exists, otherwise null | 87 | * @return tunnel if path exists, otherwise null |
73 | */ | 88 | */ |
74 | Tunnel queryPath(TunnelId tunnelId); | 89 | Tunnel queryPath(TunnelId tunnelId); |
90 | + | ||
91 | + /** | ||
92 | + * Returns list of explicit path info. | ||
93 | + * | ||
94 | + * @param tunnelName tunnel name | ||
95 | + * @return list of explicit path info | ||
96 | + */ | ||
97 | + List<ExplicitPathInfo> explicitPathInfoList(String tunnelName); | ||
75 | } | 98 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; | ... | @@ -19,6 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; |
19 | 19 | ||
20 | import com.google.common.collect.ImmutableSet; | 20 | import com.google.common.collect.ImmutableSet; |
21 | 21 | ||
22 | +import java.util.List; | ||
22 | import java.util.Map; | 23 | import java.util.Map; |
23 | import java.util.stream.Collectors; | 24 | import java.util.stream.Collectors; |
24 | 25 | ||
... | @@ -33,6 +34,7 @@ import org.onlab.util.KryoNamespace; | ... | @@ -33,6 +34,7 @@ import org.onlab.util.KryoNamespace; |
33 | import org.onosproject.incubator.net.tunnel.TunnelId; | 34 | import org.onosproject.incubator.net.tunnel.TunnelId; |
34 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 35 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
35 | import org.onosproject.net.resource.ResourceConsumer; | 36 | import org.onosproject.net.resource.ResourceConsumer; |
37 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
36 | import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; | 38 | import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; |
37 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 39 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
38 | import org.onosproject.pce.pceservice.TunnelConsumerId; | 40 | import org.onosproject.pce.pceservice.TunnelConsumerId; |
... | @@ -69,6 +71,9 @@ public class DistributedPceStore implements PceStore { | ... | @@ -69,6 +71,9 @@ public class DistributedPceStore implements PceStore { |
69 | // List of Failed path info | 71 | // List of Failed path info |
70 | private DistributedSet<PcePathInfo> failedPathSet; | 72 | private DistributedSet<PcePathInfo> failedPathSet; |
71 | 73 | ||
74 | + // Maintains tunnel name mapped to explicit path info | ||
75 | + private ConsistentMap<String, List<ExplicitPathInfo>> tunnelNameExplicitPathInfoMap; | ||
76 | + | ||
72 | private static final Serializer SERIALIZER = Serializer | 77 | private static final Serializer SERIALIZER = Serializer |
73 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) | 78 | .using(new KryoNamespace.Builder().register(KryoNamespaces.API) |
74 | .register(PcePathInfo.class) | 79 | .register(PcePathInfo.class) |
... | @@ -99,6 +104,16 @@ public class DistributedPceStore implements PceStore { | ... | @@ -99,6 +104,16 @@ public class DistributedPceStore implements PceStore { |
99 | .build() | 104 | .build() |
100 | .asDistributedSet(); | 105 | .asDistributedSet(); |
101 | 106 | ||
107 | + tunnelNameExplicitPathInfoMap = storageService.<String, List<ExplicitPathInfo>>consistentMapBuilder() | ||
108 | + .withName("onos-pce-explicitpathinfo") | ||
109 | + .withSerializer(Serializer.using( | ||
110 | + new KryoNamespace.Builder() | ||
111 | + .register(KryoNamespaces.API) | ||
112 | + .register(ExplicitPathInfo.class) | ||
113 | + .register(ExplicitPathInfo.Type.class) | ||
114 | + .build())) | ||
115 | + .build(); | ||
116 | + | ||
102 | log.info("Started"); | 117 | log.info("Started"); |
103 | } | 118 | } |
104 | 119 | ||
... | @@ -181,4 +196,18 @@ public class DistributedPceStore implements PceStore { | ... | @@ -181,4 +196,18 @@ public class DistributedPceStore implements PceStore { |
181 | } | 196 | } |
182 | return true; | 197 | return true; |
183 | } | 198 | } |
199 | + | ||
200 | + @Override | ||
201 | + public boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo) { | ||
202 | + checkNotNull(tunnelName); | ||
203 | + checkNotNull(explicitPathInfo); | ||
204 | + return tunnelNameExplicitPathInfoMap.put(tunnelName, explicitPathInfo) != null ? true : false; | ||
205 | + } | ||
206 | + | ||
207 | + @Override | ||
208 | + public List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName) { | ||
209 | + checkNotNull(tunnelName); | ||
210 | + return tunnelNameExplicitPathInfoMap.get(tunnelName).value(); | ||
211 | + } | ||
212 | + | ||
184 | } | 213 | } | ... | ... |
... | @@ -22,6 +22,7 @@ import java.util.Objects; | ... | @@ -22,6 +22,7 @@ import java.util.Objects; |
22 | 22 | ||
23 | import org.onosproject.net.DeviceId; | 23 | import org.onosproject.net.DeviceId; |
24 | import org.onosproject.net.intent.Constraint; | 24 | import org.onosproject.net.intent.Constraint; |
25 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
25 | import org.onosproject.pce.pceservice.LspType; | 26 | import org.onosproject.pce.pceservice.LspType; |
26 | 27 | ||
27 | /** | 28 | /** |
... | @@ -40,6 +41,8 @@ public final class PcePathInfo { | ... | @@ -40,6 +41,8 @@ public final class PcePathInfo { |
40 | 41 | ||
41 | private LspType lspType; // lsp type | 42 | private LspType lspType; // lsp type |
42 | 43 | ||
44 | + private List<ExplicitPathInfo> explicitPathInfo; //Explicit path info to compute explicit path | ||
45 | + | ||
43 | /** | 46 | /** |
44 | * Initialization of member variables. | 47 | * Initialization of member variables. |
45 | * | 48 | * |
... | @@ -48,17 +51,20 @@ public final class PcePathInfo { | ... | @@ -48,17 +51,20 @@ public final class PcePathInfo { |
48 | * @param name tunnel name | 51 | * @param name tunnel name |
49 | * @param constraints list of constraints | 52 | * @param constraints list of constraints |
50 | * @param lspType lsp type | 53 | * @param lspType lsp type |
54 | + * @param explicitPathInfo explicit path info | ||
51 | */ | 55 | */ |
52 | public PcePathInfo(DeviceId src, | 56 | public PcePathInfo(DeviceId src, |
53 | DeviceId dst, | 57 | DeviceId dst, |
54 | String name, | 58 | String name, |
55 | List<Constraint> constraints, | 59 | List<Constraint> constraints, |
56 | - LspType lspType) { | 60 | + LspType lspType, |
61 | + List<ExplicitPathInfo> explicitPathInfo) { | ||
57 | this.src = src; | 62 | this.src = src; |
58 | this.dst = dst; | 63 | this.dst = dst; |
59 | this.name = name; | 64 | this.name = name; |
60 | this.constraints = constraints; | 65 | this.constraints = constraints; |
61 | this.lspType = lspType; | 66 | this.lspType = lspType; |
67 | + this.explicitPathInfo = explicitPathInfo; | ||
62 | } | 68 | } |
63 | 69 | ||
64 | /** | 70 | /** |
... | @@ -70,6 +76,7 @@ public final class PcePathInfo { | ... | @@ -70,6 +76,7 @@ public final class PcePathInfo { |
70 | this.name = null; | 76 | this.name = null; |
71 | this.constraints = null; | 77 | this.constraints = null; |
72 | this.lspType = null; | 78 | this.lspType = null; |
79 | + this.explicitPathInfo = null; | ||
73 | } | 80 | } |
74 | 81 | ||
75 | /** | 82 | /** |
... | @@ -162,9 +169,27 @@ public final class PcePathInfo { | ... | @@ -162,9 +169,27 @@ public final class PcePathInfo { |
162 | this.lspType = lspType; | 169 | this.lspType = lspType; |
163 | } | 170 | } |
164 | 171 | ||
172 | + /** | ||
173 | + * Returns list of explicit path info. | ||
174 | + * | ||
175 | + * @return list of explicit path info | ||
176 | + */ | ||
177 | + public List<ExplicitPathInfo> explicitPathInfo() { | ||
178 | + return explicitPathInfo; | ||
179 | + } | ||
180 | + | ||
181 | + /** | ||
182 | + * Sets list of explicit path info. | ||
183 | + * | ||
184 | + * @param explicitPathInfo list of explicit path info | ||
185 | + */ | ||
186 | + public void explicitPathInfo(List<ExplicitPathInfo> explicitPathInfo) { | ||
187 | + this.explicitPathInfo = explicitPathInfo; | ||
188 | + } | ||
189 | + | ||
165 | @Override | 190 | @Override |
166 | public int hashCode() { | 191 | public int hashCode() { |
167 | - return Objects.hash(src, dst, name, constraints, lspType); | 192 | + return Objects.hash(src, dst, name, constraints, lspType, explicitPathInfo); |
168 | } | 193 | } |
169 | 194 | ||
170 | @Override | 195 | @Override |
... | @@ -178,7 +203,8 @@ public final class PcePathInfo { | ... | @@ -178,7 +203,8 @@ public final class PcePathInfo { |
178 | Objects.equals(this.dst, other.dst) && | 203 | Objects.equals(this.dst, other.dst) && |
179 | Objects.equals(this.name, other.name) && | 204 | Objects.equals(this.name, other.name) && |
180 | Objects.equals(this.constraints, other.constraints) && | 205 | Objects.equals(this.constraints, other.constraints) && |
181 | - Objects.equals(this.lspType, other.lspType); | 206 | + Objects.equals(this.lspType, other.lspType) && |
207 | + Objects.equals(this.explicitPathInfo, other.explicitPathInfo); | ||
182 | } | 208 | } |
183 | return false; | 209 | return false; |
184 | } | 210 | } |
... | @@ -187,11 +213,12 @@ public final class PcePathInfo { | ... | @@ -187,11 +213,12 @@ public final class PcePathInfo { |
187 | public String toString() { | 213 | public String toString() { |
188 | return MoreObjects.toStringHelper(getClass()) | 214 | return MoreObjects.toStringHelper(getClass()) |
189 | .omitNullValues() | 215 | .omitNullValues() |
190 | - .add("Source", src.toString()) | 216 | + .add("Source", src) |
191 | - .add("Destination", dst.toString()) | 217 | + .add("Destination", dst) |
192 | - .add("Name", name.toString()) | 218 | + .add("Name", name) |
193 | - .add("Constraints", constraints.toString()) | 219 | + .add("Constraints", constraints) |
194 | - .add("LspType", lspType.toString()) | 220 | + .add("explicitPathInfo", explicitPathInfo) |
221 | + .add("LspType", lspType) | ||
195 | .toString(); | 222 | .toString(); |
196 | } | 223 | } |
197 | } | 224 | } | ... | ... |
... | @@ -15,8 +15,11 @@ | ... | @@ -15,8 +15,11 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.pce.pcestore.api; | 16 | package org.onosproject.pce.pcestore.api; |
17 | 17 | ||
18 | +import java.util.List; | ||
19 | + | ||
18 | import org.onosproject.incubator.net.tunnel.TunnelId; | 20 | import org.onosproject.incubator.net.tunnel.TunnelId; |
19 | import org.onosproject.net.resource.ResourceConsumer; | 21 | import org.onosproject.net.resource.ResourceConsumer; |
22 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
20 | import org.onosproject.pce.pcestore.PcePathInfo; | 23 | import org.onosproject.pce.pcestore.PcePathInfo; |
21 | 24 | ||
22 | import java.util.Map; | 25 | import java.util.Map; |
... | @@ -107,4 +110,21 @@ public interface PceStore { | ... | @@ -107,4 +110,21 @@ public interface PceStore { |
107 | * @return success or failure | 110 | * @return success or failure |
108 | */ | 111 | */ |
109 | boolean removeFailedPathInfo(PcePathInfo failedPathInfo); | 112 | boolean removeFailedPathInfo(PcePathInfo failedPathInfo); |
113 | + | ||
114 | + /** | ||
115 | + * Adds explicit path info to the map with corresponding tunnel name. | ||
116 | + * | ||
117 | + * @param tunnelName tunnel name as key | ||
118 | + * @param explicitPathInfo list of explicit path objects | ||
119 | + * @return whether it is added to map | ||
120 | + */ | ||
121 | + boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo); | ||
122 | + | ||
123 | + /** | ||
124 | + * Gets explicit path info based on tunnel name. | ||
125 | + * | ||
126 | + * @param tunnelName tunnel name as key | ||
127 | + * @return list of explicit path info | ||
128 | + */ | ||
129 | + List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName); | ||
110 | } | 130 | } | ... | ... |
... | @@ -16,21 +16,47 @@ | ... | @@ -16,21 +16,47 @@ |
16 | 16 | ||
17 | package org.onosproject.pce.pceservice; | 17 | package org.onosproject.pce.pceservice; |
18 | 18 | ||
19 | +import com.google.common.collect.Lists; | ||
20 | + | ||
21 | +import org.junit.After; | ||
22 | +import org.junit.Before; | ||
19 | import org.junit.Test; | 23 | import org.junit.Test; |
20 | 24 | ||
21 | import static org.hamcrest.MatcherAssert.assertThat; | 25 | import static org.hamcrest.MatcherAssert.assertThat; |
22 | import static org.hamcrest.Matchers.is; | 26 | import static org.hamcrest.Matchers.is; |
27 | +import static org.onosproject.pce.pceservice.PathComputationTest.D2; | ||
28 | +import static org.easymock.EasyMock.createMock; | ||
23 | 29 | ||
24 | import com.google.common.testing.EqualsTester; | 30 | import com.google.common.testing.EqualsTester; |
25 | 31 | ||
32 | + | ||
33 | +import org.onlab.osgi.ServiceDirectory; | ||
34 | +import org.onlab.osgi.TestServiceDirectory; | ||
35 | +import org.onlab.rest.BaseResource; | ||
26 | import org.onosproject.incubator.net.tunnel.TunnelId; | 36 | import org.onosproject.incubator.net.tunnel.TunnelId; |
27 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 37 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
38 | +import org.onosproject.pce.pcestore.api.PceStore; | ||
28 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 39 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
29 | 40 | ||
41 | +import java.util.List; | ||
42 | + | ||
30 | /** | 43 | /** |
31 | * Unit tests for DefaultPcePath class. | 44 | * Unit tests for DefaultPcePath class. |
32 | */ | 45 | */ |
33 | public class DefaultPcePathTest { | 46 | public class DefaultPcePathTest { |
47 | + private PceStore pceStore = createMock(PceStore.class); | ||
48 | + | ||
49 | + @Before | ||
50 | + public void setup() { | ||
51 | + | ||
52 | + ServiceDirectory testDirectory = new TestServiceDirectory() | ||
53 | + .add(PceStore.class, pceStore); | ||
54 | + BaseResource.setServiceDirectory(testDirectory); | ||
55 | + } | ||
56 | + | ||
57 | + @After | ||
58 | + public void tearDownTest() { | ||
59 | + } | ||
34 | /** | 60 | /** |
35 | * Checks the operation of equals() methods. | 61 | * Checks the operation of equals() methods. |
36 | */ | 62 | */ |
... | @@ -43,7 +69,9 @@ public class DefaultPcePathTest { | ... | @@ -43,7 +69,9 @@ public class DefaultPcePathTest { |
43 | final String dst1 = "bee"; | 69 | final String dst1 = "bee"; |
44 | final String type1 = "1"; | 70 | final String type1 = "1"; |
45 | final String name1 = "pcc"; | 71 | final String name1 = "pcc"; |
46 | - | 72 | + final List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList(); |
73 | + ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId()); | ||
74 | + explicitPathInfoList.add(obj); | ||
47 | PcePath path1 = DefaultPcePath.builder() | 75 | PcePath path1 = DefaultPcePath.builder() |
48 | .source(src1) | 76 | .source(src1) |
49 | .destination(dst1) | 77 | .destination(dst1) |
... | @@ -51,6 +79,7 @@ public class DefaultPcePathTest { | ... | @@ -51,6 +79,7 @@ public class DefaultPcePathTest { |
51 | .name(name1) | 79 | .name(name1) |
52 | .costConstraint(cost1) | 80 | .costConstraint(cost1) |
53 | .bandwidthConstraint(bandwidth1) | 81 | .bandwidthConstraint(bandwidth1) |
82 | + .explicitPathInfo(explicitPathInfoList) | ||
54 | .build(); | 83 | .build(); |
55 | path1.id(TunnelId.valueOf("1")); | 84 | path1.id(TunnelId.valueOf("1")); |
56 | 85 | ||
... | @@ -62,6 +91,7 @@ public class DefaultPcePathTest { | ... | @@ -62,6 +91,7 @@ public class DefaultPcePathTest { |
62 | .name(name1) | 91 | .name(name1) |
63 | .costConstraint(cost1) | 92 | .costConstraint(cost1) |
64 | .bandwidthConstraint(bandwidth1) | 93 | .bandwidthConstraint(bandwidth1) |
94 | + .explicitPathInfo(explicitPathInfoList) | ||
65 | .build(); | 95 | .build(); |
66 | samePath1.id(TunnelId.valueOf("1")); | 96 | samePath1.id(TunnelId.valueOf("1")); |
67 | 97 | ||
... | @@ -80,6 +110,7 @@ public class DefaultPcePathTest { | ... | @@ -80,6 +110,7 @@ public class DefaultPcePathTest { |
80 | .name(name2) | 110 | .name(name2) |
81 | .costConstraint(cost2) | 111 | .costConstraint(cost2) |
82 | .bandwidthConstraint(bandwidth2) | 112 | .bandwidthConstraint(bandwidth2) |
113 | + .explicitPathInfo(explicitPathInfoList) | ||
83 | .build(); | 114 | .build(); |
84 | path2.id(TunnelId.valueOf("2")); | 115 | path2.id(TunnelId.valueOf("2")); |
85 | 116 | ||
... | @@ -97,7 +128,9 @@ public class DefaultPcePathTest { | ... | @@ -97,7 +128,9 @@ public class DefaultPcePathTest { |
97 | final String dst = "deccan"; | 128 | final String dst = "deccan"; |
98 | final String type = "2"; | 129 | final String type = "2"; |
99 | final String name = "pcc4"; | 130 | final String name = "pcc4"; |
100 | - | 131 | + final List<ExplicitPathInfo> explicitPathInfoList = Lists.newLinkedList(); |
132 | + ExplicitPathInfo obj = new ExplicitPathInfo(ExplicitPathInfo.Type.LOOSE, D2.deviceId()); | ||
133 | + explicitPathInfoList.add(obj); | ||
101 | PcePath path = DefaultPcePath.builder() | 134 | PcePath path = DefaultPcePath.builder() |
102 | .source(src) | 135 | .source(src) |
103 | .destination(dst) | 136 | .destination(dst) |
... | @@ -105,6 +138,7 @@ public class DefaultPcePathTest { | ... | @@ -105,6 +138,7 @@ public class DefaultPcePathTest { |
105 | .name(name) | 138 | .name(name) |
106 | .costConstraint(cost) | 139 | .costConstraint(cost) |
107 | .bandwidthConstraint(bandwidth) | 140 | .bandwidthConstraint(bandwidth) |
141 | + .explicitPathInfo(explicitPathInfoList) | ||
108 | .build(); | 142 | .build(); |
109 | 143 | ||
110 | assertThat(path.source(), is(src)); | 144 | assertThat(path.source(), is(src)); | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -120,7 +120,7 @@ public class DistributedPceStoreTest { | ... | @@ -120,7 +120,7 @@ public class DistributedPceStoreTest { |
120 | Constraint bandwidth1 = BandwidthConstraint.of(200, DataRateUnit.BPS); | 120 | Constraint bandwidth1 = BandwidthConstraint.of(200, DataRateUnit.BPS); |
121 | constraints1.add(bandwidth1); | 121 | constraints1.add(bandwidth1); |
122 | 122 | ||
123 | - failedPathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1); | 123 | + failedPathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null); |
124 | 124 | ||
125 | // Creates failedPathInfo2 | 125 | // Creates failedPathInfo2 |
126 | DeviceId src2 = DeviceId.deviceId("foo2"); | 126 | DeviceId src2 = DeviceId.deviceId("foo2"); |
... | @@ -131,7 +131,7 @@ public class DistributedPceStoreTest { | ... | @@ -131,7 +131,7 @@ public class DistributedPceStoreTest { |
131 | Constraint bandwidth2 = BandwidthConstraint.of(400, DataRateUnit.BPS); | 131 | Constraint bandwidth2 = BandwidthConstraint.of(400, DataRateUnit.BPS); |
132 | constraints2.add(bandwidth2); | 132 | constraints2.add(bandwidth2); |
133 | 133 | ||
134 | - failedPathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2); | 134 | + failedPathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2, null); |
135 | 135 | ||
136 | // Creates failedPathInfo3 | 136 | // Creates failedPathInfo3 |
137 | DeviceId src3 = DeviceId.deviceId("foo3"); | 137 | DeviceId src3 = DeviceId.deviceId("foo3"); |
... | @@ -142,7 +142,7 @@ public class DistributedPceStoreTest { | ... | @@ -142,7 +142,7 @@ public class DistributedPceStoreTest { |
142 | Constraint bandwidth3 = BandwidthConstraint.of(500, DataRateUnit.BPS); | 142 | Constraint bandwidth3 = BandwidthConstraint.of(500, DataRateUnit.BPS); |
143 | constraints3.add(bandwidth3); | 143 | constraints3.add(bandwidth3); |
144 | 144 | ||
145 | - failedPathInfo3 = new PcePathInfo(src3, dst3, name3, constraints3, lspType3); | 145 | + failedPathInfo3 = new PcePathInfo(src3, dst3, name3, constraints3, lspType3, null); |
146 | 146 | ||
147 | // Creates failedPathInfo4 | 147 | // Creates failedPathInfo4 |
148 | DeviceId src4 = DeviceId.deviceId("foo4"); | 148 | DeviceId src4 = DeviceId.deviceId("foo4"); |
... | @@ -153,7 +153,7 @@ public class DistributedPceStoreTest { | ... | @@ -153,7 +153,7 @@ public class DistributedPceStoreTest { |
153 | Constraint bandwidth4 = BandwidthConstraint.of(600, DataRateUnit.BPS); | 153 | Constraint bandwidth4 = BandwidthConstraint.of(600, DataRateUnit.BPS); |
154 | constraints4.add(bandwidth4); | 154 | constraints4.add(bandwidth4); |
155 | 155 | ||
156 | - failedPathInfo4 = new PcePathInfo(src4, dst4, name4, constraints4, lspType4); | 156 | + failedPathInfo4 = new PcePathInfo(src4, dst4, name4, constraints4, lspType4, null); |
157 | } | 157 | } |
158 | 158 | ||
159 | @After | 159 | @After | ... | ... |
... | @@ -53,10 +53,10 @@ public class PcePathInfoTest { | ... | @@ -53,10 +53,10 @@ public class PcePathInfoTest { |
53 | Constraint bandwidth13 = BandwidthConstraint.of(300, DataRateUnit.BPS); | 53 | Constraint bandwidth13 = BandwidthConstraint.of(300, DataRateUnit.BPS); |
54 | constraints1.add(bandwidth13); | 54 | constraints1.add(bandwidth13); |
55 | 55 | ||
56 | - PcePathInfo pathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1); | 56 | + PcePathInfo pathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null); |
57 | 57 | ||
58 | // create same object as above object | 58 | // create same object as above object |
59 | - PcePathInfo samePathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1); | 59 | + PcePathInfo samePathInfo1 = new PcePathInfo(src1, dst1, name1, constraints1, lspType1, null); |
60 | 60 | ||
61 | // Create different object. | 61 | // Create different object. |
62 | DeviceId src2 = DeviceId.deviceId("foo2"); | 62 | DeviceId src2 = DeviceId.deviceId("foo2"); |
... | @@ -69,7 +69,7 @@ public class PcePathInfoTest { | ... | @@ -69,7 +69,7 @@ public class PcePathInfoTest { |
69 | Constraint bandwidth22 = BandwidthConstraint.of(800, DataRateUnit.BPS); | 69 | Constraint bandwidth22 = BandwidthConstraint.of(800, DataRateUnit.BPS); |
70 | constraints2.add(bandwidth22); | 70 | constraints2.add(bandwidth22); |
71 | 71 | ||
72 | - PcePathInfo pathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2); | 72 | + PcePathInfo pathInfo2 = new PcePathInfo(src2, dst2, name2, constraints2, lspType2, null); |
73 | 73 | ||
74 | new EqualsTester().addEqualityGroup(pathInfo1, samePathInfo1) | 74 | new EqualsTester().addEqualityGroup(pathInfo1, samePathInfo1) |
75 | .addEqualityGroup(pathInfo2) | 75 | .addEqualityGroup(pathInfo2) |
... | @@ -93,7 +93,7 @@ public class PcePathInfoTest { | ... | @@ -93,7 +93,7 @@ public class PcePathInfoTest { |
93 | Constraint bandwidth3 = BandwidthConstraint.of(300, DataRateUnit.BPS); | 93 | Constraint bandwidth3 = BandwidthConstraint.of(300, DataRateUnit.BPS); |
94 | constraints.add(bandwidth3); | 94 | constraints.add(bandwidth3); |
95 | 95 | ||
96 | - PcePathInfo pathInfo = new PcePathInfo(src, dst, name, constraints, lspType); | 96 | + PcePathInfo pathInfo = new PcePathInfo(src, dst, name, constraints, lspType, null); |
97 | 97 | ||
98 | assertThat(src, is(pathInfo.src())); | 98 | assertThat(src, is(pathInfo.src())); |
99 | assertThat(dst, is(pathInfo.dst())); | 99 | assertThat(dst, is(pathInfo.dst())); | ... | ... |
... | @@ -22,13 +22,14 @@ import java.util.concurrent.ConcurrentMap; | ... | @@ -22,13 +22,14 @@ import java.util.concurrent.ConcurrentMap; |
22 | 22 | ||
23 | import java.util.HashMap; | 23 | import java.util.HashMap; |
24 | import java.util.HashSet; | 24 | import java.util.HashSet; |
25 | +import java.util.List; | ||
25 | import java.util.Map; | 26 | import java.util.Map; |
26 | import java.util.Set; | 27 | import java.util.Set; |
27 | import java.util.stream.Collectors; | 28 | import java.util.stream.Collectors; |
28 | 29 | ||
29 | import org.onosproject.incubator.net.tunnel.TunnelId; | 30 | import org.onosproject.incubator.net.tunnel.TunnelId; |
30 | -import org.onosproject.net.DeviceId; | ||
31 | import org.onosproject.net.resource.ResourceConsumer; | 31 | import org.onosproject.net.resource.ResourceConsumer; |
32 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
32 | import org.onosproject.pce.pcestore.PcePathInfo; | 33 | import org.onosproject.pce.pcestore.PcePathInfo; |
33 | import org.onosproject.pce.pcestore.api.PceStore; | 34 | import org.onosproject.pce.pcestore.api.PceStore; |
34 | 35 | ||
... | @@ -43,8 +44,8 @@ public class PceStoreAdapter implements PceStore { | ... | @@ -43,8 +44,8 @@ public class PceStoreAdapter implements PceStore { |
43 | // Set of Path info | 44 | // Set of Path info |
44 | private Set<PcePathInfo> failedPathInfoSet = new HashSet<>(); | 45 | private Set<PcePathInfo> failedPathInfoSet = new HashSet<>(); |
45 | 46 | ||
46 | - // Locally maintain LSRID to device id mapping for better performance. | 47 | + // Locally maintain with tunnel name as key and corresponding list of explicit path object |
47 | - private Map<String, DeviceId> lsrIdDeviceIdMap = new HashMap<>(); | 48 | + private Map<String, List<ExplicitPathInfo>> tunnelNameExplicitPathInfoMap = new HashMap<>(); |
48 | 49 | ||
49 | @Override | 50 | @Override |
50 | public boolean existsTunnelInfo(TunnelId tunnelId) { | 51 | public boolean existsTunnelInfo(TunnelId tunnelId) { |
... | @@ -108,4 +109,15 @@ public class PceStoreAdapter implements PceStore { | ... | @@ -108,4 +109,15 @@ public class PceStoreAdapter implements PceStore { |
108 | } | 109 | } |
109 | return true; | 110 | return true; |
110 | } | 111 | } |
112 | + | ||
113 | + @Override | ||
114 | + public boolean tunnelNameExplicitPathInfoMap(String tunnelName, List<ExplicitPathInfo> explicitPathInfo) { | ||
115 | + tunnelNameExplicitPathInfoMap.put(tunnelName, explicitPathInfo); | ||
116 | + return false; | ||
117 | + } | ||
118 | + | ||
119 | + @Override | ||
120 | + public List<ExplicitPathInfo> getTunnelNameExplicitPathInfoMap(String tunnelName) { | ||
121 | + return tunnelNameExplicitPathInfoMap.get(tunnelName); | ||
122 | + } | ||
111 | } | 123 | } | ... | ... |
... | @@ -16,9 +16,22 @@ | ... | @@ -16,9 +16,22 @@ |
16 | package org.onosproject.pcerest; | 16 | package org.onosproject.pcerest; |
17 | 17 | ||
18 | import static com.google.common.base.Preconditions.checkNotNull; | 18 | import static com.google.common.base.Preconditions.checkNotNull; |
19 | +import static org.onosproject.net.Link.State.ACTIVE; | ||
20 | +import static org.onosproject.net.Link.Type.DIRECT; | ||
21 | + | ||
22 | +import com.fasterxml.jackson.databind.node.ArrayNode; | ||
23 | +import com.google.common.collect.ImmutableList; | ||
24 | +import com.google.common.collect.Lists; | ||
19 | 25 | ||
20 | import org.onosproject.codec.CodecContext; | 26 | import org.onosproject.codec.CodecContext; |
21 | import org.onosproject.codec.JsonCodec; | 27 | import org.onosproject.codec.JsonCodec; |
28 | +import org.onosproject.net.ConnectPoint; | ||
29 | +import org.onosproject.net.DefaultLink; | ||
30 | +import org.onosproject.net.DeviceId; | ||
31 | +import org.onosproject.net.NetworkResource; | ||
32 | +import org.onosproject.net.PortNumber; | ||
33 | +import org.onosproject.net.provider.ProviderId; | ||
34 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
22 | import org.onosproject.pce.pceservice.PcePath; | 35 | import org.onosproject.pce.pceservice.PcePath; |
23 | import org.onosproject.pce.pceservice.DefaultPcePath; | 36 | import org.onosproject.pce.pceservice.DefaultPcePath; |
24 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 37 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
... | @@ -29,6 +42,11 @@ import org.slf4j.LoggerFactory; | ... | @@ -29,6 +42,11 @@ import org.slf4j.LoggerFactory; |
29 | import com.fasterxml.jackson.databind.node.ObjectNode; | 42 | import com.fasterxml.jackson.databind.node.ObjectNode; |
30 | import com.fasterxml.jackson.databind.JsonNode; | 43 | import com.fasterxml.jackson.databind.JsonNode; |
31 | 44 | ||
45 | +import java.util.Collection; | ||
46 | +import java.util.Collections; | ||
47 | +import java.util.LinkedList; | ||
48 | +import java.util.List; | ||
49 | + | ||
32 | /** | 50 | /** |
33 | * PCE path json codec. | 51 | * PCE path json codec. |
34 | */ | 52 | */ |
... | @@ -42,7 +60,13 @@ public final class PcePathCodec extends JsonCodec<PcePath> { | ... | @@ -42,7 +60,13 @@ public final class PcePathCodec extends JsonCodec<PcePath> { |
42 | private static final String COST = "cost"; | 60 | private static final String COST = "cost"; |
43 | private static final String BANDWIDTH = "bandwidth"; | 61 | private static final String BANDWIDTH = "bandwidth"; |
44 | private static final String PATH_ID = "pathId"; | 62 | private static final String PATH_ID = "pathId"; |
63 | + private static final String EXPLICIT_PATH_INFO = "explicitPathInfo"; | ||
45 | private static final String MISSING_MEMBER_MESSAGE = " member is required in pce-path"; | 64 | private static final String MISSING_MEMBER_MESSAGE = " member is required in pce-path"; |
65 | + public static final String JSON_NOT_NULL = "JsonNode can not be null"; | ||
66 | + public static final byte SOURCE_DEVICEID_INDEX = 0; | ||
67 | + public static final byte SOURCE_PORTNO_INDEX = 1; | ||
68 | + public static final byte DESTINATION_DEVICEID_INDEX = 2; | ||
69 | + public static final byte DESTINATION_PORTNO_INDEX = 3; | ||
46 | 70 | ||
47 | @Override | 71 | @Override |
48 | public PcePath decode(ObjectNode json, CodecContext context) { | 72 | public PcePath decode(ObjectNode json, CodecContext context) { |
... | @@ -114,9 +138,87 @@ public final class PcePathCodec extends JsonCodec<PcePath> { | ... | @@ -114,9 +138,87 @@ public final class PcePathCodec extends JsonCodec<PcePath> { |
114 | } | 138 | } |
115 | } | 139 | } |
116 | 140 | ||
141 | + // Retrieve explicit path info | ||
142 | + JsonNode explicitPathInfo = json.get(EXPLICIT_PATH_INFO); | ||
143 | + if (explicitPathInfo != null) { | ||
144 | + List<ExplicitPathInfo> explicitPathInfoList = | ||
145 | + ImmutableList.copyOf(jsonNodeToExplicitPathInfo(explicitPathInfo)); | ||
146 | + if (explicitPathInfoList != null) { | ||
147 | + resultBuilder.explicitPathInfo(explicitPathInfoList); | ||
148 | + } | ||
149 | + } | ||
150 | + | ||
117 | return resultBuilder.build(); | 151 | return resultBuilder.build(); |
118 | } | 152 | } |
119 | 153 | ||
154 | + private ExplicitPathInfo createListOfExplicitPathObj(JsonNode node) { | ||
155 | + int explicitPathType = Integer.parseInt(node.get("type").asText()); | ||
156 | + DeviceId deviceId; | ||
157 | + PortNumber portNo; | ||
158 | + NetworkResource res; | ||
159 | + LinkedList<ExplicitPathInfo> list = Lists.newLinkedList(); | ||
160 | + if ((explicitPathType < 0) || (explicitPathType > 1)) { | ||
161 | + return null; | ||
162 | + } | ||
163 | + ExplicitPathInfo.Type type = ExplicitPathInfo.Type.values()[explicitPathType]; | ||
164 | + String subType = node.get("subtype").asText(); | ||
165 | + if (Integer.parseInt(subType) == 0) { | ||
166 | + res = DeviceId.deviceId(node.get("value").asText()); | ||
167 | + } else if (Integer.parseInt(subType) == 1) { | ||
168 | + | ||
169 | + String[] splitted = node.get("value").asText().split("/"); | ||
170 | + | ||
171 | + if (splitted[SOURCE_DEVICEID_INDEX] != null | ||
172 | + && splitted[SOURCE_PORTNO_INDEX] != null | ||
173 | + && splitted[DESTINATION_DEVICEID_INDEX] != null | ||
174 | + && splitted[DESTINATION_PORTNO_INDEX] != null) { | ||
175 | + return null; | ||
176 | + } | ||
177 | + deviceId = DeviceId.deviceId(splitted[SOURCE_DEVICEID_INDEX]); | ||
178 | + portNo = PortNumber.portNumber(splitted[SOURCE_PORTNO_INDEX]); | ||
179 | + ConnectPoint cpSrc = new ConnectPoint(deviceId, portNo); | ||
180 | + deviceId = DeviceId.deviceId(splitted[DESTINATION_DEVICEID_INDEX]); | ||
181 | + portNo = PortNumber.portNumber(splitted[DESTINATION_PORTNO_INDEX]); | ||
182 | + ConnectPoint cpDst = new ConnectPoint(deviceId, portNo); | ||
183 | + res = DefaultLink.builder() | ||
184 | + .providerId(ProviderId.NONE) | ||
185 | + .src(cpSrc) | ||
186 | + .dst(cpDst) | ||
187 | + .type(DIRECT) | ||
188 | + .state(ACTIVE) | ||
189 | + .build(); | ||
190 | + } else { | ||
191 | + return null; | ||
192 | + } | ||
193 | + | ||
194 | + return new ExplicitPathInfo(type, res); | ||
195 | + } | ||
196 | + | ||
197 | + private Collection<ExplicitPathInfo> jsonNodeToExplicitPathInfo(JsonNode explicitPathInfo) { | ||
198 | + checkNotNull(explicitPathInfo, JSON_NOT_NULL); | ||
199 | + | ||
200 | + Integer i = 0; | ||
201 | + NetworkResource res; | ||
202 | + LinkedList<ExplicitPathInfo> list = Lists.newLinkedList(); | ||
203 | + if (explicitPathInfo.isArray()) { | ||
204 | + for (JsonNode node : explicitPathInfo) { | ||
205 | + ExplicitPathInfo obj = createListOfExplicitPathObj(node); | ||
206 | + if (obj == null) { | ||
207 | + return null; | ||
208 | + } | ||
209 | + list.add(obj); | ||
210 | + } | ||
211 | + } else { | ||
212 | + ExplicitPathInfo obj = createListOfExplicitPathObj(explicitPathInfo); | ||
213 | + if (obj == null) { | ||
214 | + return null; | ||
215 | + } | ||
216 | + list.add(obj); | ||
217 | + } | ||
218 | + | ||
219 | + return Collections.unmodifiableCollection(list); | ||
220 | + } | ||
221 | + | ||
120 | @Override | 222 | @Override |
121 | public ObjectNode encode(PcePath path, CodecContext context) { | 223 | public ObjectNode encode(PcePath path, CodecContext context) { |
122 | checkNotNull(path, "path output cannot be null"); | 224 | checkNotNull(path, "path output cannot be null"); |
... | @@ -133,6 +235,18 @@ public final class PcePathCodec extends JsonCodec<PcePath> { | ... | @@ -133,6 +235,18 @@ public final class PcePathCodec extends JsonCodec<PcePath> { |
133 | .put(COST, ((CostConstraint) path.costConstraint()).type().type()) | 235 | .put(COST, ((CostConstraint) path.costConstraint()).type().type()) |
134 | .put(BANDWIDTH, ((BandwidthConstraint) path.bandwidthConstraint()).bandwidth().bps()); | 236 | .put(BANDWIDTH, ((BandwidthConstraint) path.bandwidthConstraint()).bandwidth().bps()); |
135 | 237 | ||
238 | + if (path.explicitPathInfo() != null && !path.explicitPathInfo().isEmpty()) { | ||
239 | + ArrayNode arrayNode = context.mapper().createArrayNode(); | ||
240 | + for (ExplicitPathInfo e : path.explicitPathInfo()) { | ||
241 | + ObjectNode node = context.mapper() | ||
242 | + .createObjectNode() | ||
243 | + .put("type", e.type().toString()) | ||
244 | + .put("value", e.value().toString()); | ||
245 | + arrayNode.add(node); | ||
246 | + } | ||
247 | + result.set(EXPLICIT_PATH_INFO, arrayNode); | ||
248 | + } | ||
249 | + | ||
136 | result.set(CONSTRAINT, constraintNode); | 250 | result.set(CONSTRAINT, constraintNode); |
137 | return result; | 251 | return result; |
138 | } | 252 | } | ... | ... |
... | @@ -35,11 +35,13 @@ import javax.ws.rs.Produces; | ... | @@ -35,11 +35,13 @@ import javax.ws.rs.Produces; |
35 | import javax.ws.rs.core.MediaType; | 35 | import javax.ws.rs.core.MediaType; |
36 | import javax.ws.rs.core.Response; | 36 | import javax.ws.rs.core.Response; |
37 | 37 | ||
38 | +import com.google.common.collect.ImmutableList; | ||
38 | import org.onosproject.incubator.net.tunnel.Tunnel; | 39 | import org.onosproject.incubator.net.tunnel.Tunnel; |
39 | import org.onosproject.incubator.net.tunnel.TunnelId; | 40 | import org.onosproject.incubator.net.tunnel.TunnelId; |
40 | import org.onosproject.incubator.net.tunnel.TunnelService; | 41 | import org.onosproject.incubator.net.tunnel.TunnelService; |
41 | import org.onosproject.net.DeviceId; | 42 | import org.onosproject.net.DeviceId; |
42 | import org.onosproject.net.intent.Constraint; | 43 | import org.onosproject.net.intent.Constraint; |
44 | +import org.onosproject.pce.pceservice.ExplicitPathInfo; | ||
43 | import org.onosproject.pce.pceservice.api.PceService; | 45 | import org.onosproject.pce.pceservice.api.PceService; |
44 | import org.onosproject.pce.pceservice.PcePath; | 46 | import org.onosproject.pce.pceservice.PcePath; |
45 | import org.onosproject.pce.pceservice.DefaultPcePath; | 47 | import org.onosproject.pce.pceservice.DefaultPcePath; |
... | @@ -150,8 +152,14 @@ public class PcePathWebResource extends AbstractWebResource { | ... | @@ -150,8 +152,14 @@ public class PcePathWebResource extends AbstractWebResource { |
150 | // Add cost | 152 | // Add cost |
151 | listConstrnt.add(path.costConstraint()); | 153 | listConstrnt.add(path.costConstraint()); |
152 | 154 | ||
155 | + List<ExplicitPathInfo> explicitPathInfoList = null; | ||
156 | + if (explicitPathInfoList != null) { | ||
157 | + explicitPathInfoList = ImmutableList.copyOf(path.explicitPathInfo()); | ||
158 | + } | ||
159 | + | ||
153 | Boolean issuccess = nullIsNotFound(get(PceService.class) | 160 | Boolean issuccess = nullIsNotFound(get(PceService.class) |
154 | - .setupPath(srcDevice, dstDevice, path.name(), listConstrnt, lspType), | 161 | + .setupPath(srcDevice, dstDevice, path.name(), listConstrnt, |
162 | + lspType, explicitPathInfoList), | ||
155 | PCE_SETUP_PATH_FAILED); | 163 | PCE_SETUP_PATH_FAILED); |
156 | return Response.status(OK).entity(issuccess.toString()).build(); | 164 | return Response.status(OK).entity(issuccess.toString()).build(); |
157 | } catch (IOException e) { | 165 | } catch (IOException e) { | ... | ... |
... | @@ -64,6 +64,7 @@ import org.onosproject.net.DeviceId; | ... | @@ -64,6 +64,7 @@ import org.onosproject.net.DeviceId; |
64 | import org.onosproject.net.Link; | 64 | import org.onosproject.net.Link; |
65 | import org.onosproject.pce.pceservice.api.PceService; | 65 | import org.onosproject.pce.pceservice.api.PceService; |
66 | import org.onosproject.pce.pceservice.PcepAnnotationKeys; | 66 | import org.onosproject.pce.pceservice.PcepAnnotationKeys; |
67 | +import org.onosproject.pce.pcestore.api.PceStore; | ||
67 | import org.onosproject.net.Path; | 68 | import org.onosproject.net.Path; |
68 | import org.onosproject.net.PortNumber; | 69 | import org.onosproject.net.PortNumber; |
69 | import org.onosproject.net.provider.ProviderId; | 70 | import org.onosproject.net.provider.ProviderId; |
... | @@ -73,6 +74,7 @@ import org.onosproject.net.provider.ProviderId; | ... | @@ -73,6 +74,7 @@ import org.onosproject.net.provider.ProviderId; |
73 | */ | 74 | */ |
74 | public class PcePathResourceTest extends PceResourceTest { | 75 | public class PcePathResourceTest extends PceResourceTest { |
75 | private final PceService pceService = createMock(PceService.class); | 76 | private final PceService pceService = createMock(PceService.class); |
77 | + private final PceStore pceStore = createMock(PceStore.class); | ||
76 | private final TunnelService tunnelService = createMock(TunnelService.class); | 78 | private final TunnelService tunnelService = createMock(TunnelService.class); |
77 | private final TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); | 79 | private final TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423)); |
78 | private final TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); | 80 | private final TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421)); |
... | @@ -102,6 +104,7 @@ public class PcePathResourceTest extends PceResourceTest { | ... | @@ -102,6 +104,7 @@ public class PcePathResourceTest extends PceResourceTest { |
102 | MockPceCodecContext context = new MockPceCodecContext(); | 104 | MockPceCodecContext context = new MockPceCodecContext(); |
103 | ServiceDirectory testDirectory = new TestServiceDirectory().add(PceService.class, pceService) | 105 | ServiceDirectory testDirectory = new TestServiceDirectory().add(PceService.class, pceService) |
104 | .add(TunnelService.class, tunnelService) | 106 | .add(TunnelService.class, tunnelService) |
107 | + .add(PceStore.class, pceStore) | ||
105 | .add(CodecService.class, context.codecManager()); | 108 | .add(CodecService.class, context.codecManager()); |
106 | BaseResource.setServiceDirectory(testDirectory); | 109 | BaseResource.setServiceDirectory(testDirectory); |
107 | 110 | ||
... | @@ -233,7 +236,7 @@ public class PcePathResourceTest extends PceResourceTest { | ... | @@ -233,7 +236,7 @@ public class PcePathResourceTest extends PceResourceTest { |
233 | */ | 236 | */ |
234 | @Test | 237 | @Test |
235 | public void testPost() { | 238 | public void testPost() { |
236 | - expect(pceService.setupPath(anyObject(), anyObject(), anyObject(), anyObject(), anyObject())) | 239 | + expect(pceService.setupPath(anyObject(), anyObject(), anyObject(), anyObject(), anyObject(), anyObject())) |
237 | .andReturn(true) | 240 | .andReturn(true) |
238 | .anyTimes(); | 241 | .anyTimes(); |
239 | replay(pceService); | 242 | replay(pceService); | ... | ... |
1 | {"path": {"source":"11.0.0.1", | 1 | {"path": {"source":"11.0.0.1", |
2 | "destination":"11.0.0.2", | 2 | "destination":"11.0.0.2", |
3 | - "pathType":"2", | 3 | + "pathType":"0", |
4 | - "name":"pcc2", | 4 | + "name":"rsvp11", |
5 | - "description":"path-create", | ||
6 | "constraint": | 5 | "constraint": |
7 | - {"cost":2, | 6 | + {"cost":1, |
8 | - "bandwidth":200.0 | 7 | + "bandwidth":300 |
8 | + }, | ||
9 | + "explicitPathInfo" : | ||
10 | + {"type":1, | ||
11 | + "subtype":0, | ||
12 | + "value":"11.0.0.2" | ||
9 | } | 13 | } |
10 | } | 14 | } |
11 | } | 15 | } | ... | ... |
... | @@ -507,7 +507,9 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { | ... | @@ -507,7 +507,9 @@ public class PceWebTopovMessageHandler extends UiMessageHandler { |
507 | break; | 507 | break; |
508 | } | 508 | } |
509 | 509 | ||
510 | - path = pceService.setupPath((DeviceId) src, (DeviceId) dst, tunnelName, listConstrnt, lspTypeVal); | 510 | + //TODO: need to get explicit paths [temporarily using null as the value] |
511 | + path = pceService.setupPath((DeviceId) src, (DeviceId) dst, tunnelName, listConstrnt, lspTypeVal, | ||
512 | + null); | ||
511 | if (!path) { | 513 | if (!path) { |
512 | log.error("setup path is failed"); | 514 | log.error("setup path is failed"); |
513 | return; | 515 | return; | ... | ... |
-
Please register or login to post a comment