[ONOS-4166] Use device capapbility set using network config for path computation
Change-Id: I5f904f3838aafd5d1ab21d335043d9cfcdd2bce2
Showing
5 changed files
with
273 additions
and
141 deletions
| ... | @@ -60,6 +60,7 @@ import org.onosproject.incubator.net.tunnel.TunnelListener; | ... | @@ -60,6 +60,7 @@ import org.onosproject.incubator.net.tunnel.TunnelListener; |
| 60 | import org.onosproject.incubator.net.tunnel.TunnelName; | 60 | import org.onosproject.incubator.net.tunnel.TunnelName; |
| 61 | import org.onosproject.incubator.net.tunnel.TunnelService; | 61 | import org.onosproject.incubator.net.tunnel.TunnelService; |
| 62 | import org.onosproject.mastership.MastershipService; | 62 | import org.onosproject.mastership.MastershipService; |
| 63 | +import org.onosproject.net.config.NetworkConfigService; | ||
| 63 | import org.onosproject.net.DefaultAnnotations; | 64 | import org.onosproject.net.DefaultAnnotations; |
| 64 | import org.onosproject.net.DefaultAnnotations.Builder; | 65 | import org.onosproject.net.DefaultAnnotations.Builder; |
| 65 | import org.onosproject.net.Device; | 66 | import org.onosproject.net.Device; |
| ... | @@ -92,6 +93,7 @@ import org.onosproject.pce.pceservice.api.PceService; | ... | @@ -92,6 +93,7 @@ import org.onosproject.pce.pceservice.api.PceService; |
| 92 | import org.onosproject.pce.pcestore.PcePathInfo; | 93 | import org.onosproject.pce.pcestore.PcePathInfo; |
| 93 | import org.onosproject.pce.pcestore.PceccTunnelInfo; | 94 | import org.onosproject.pce.pcestore.PceccTunnelInfo; |
| 94 | import org.onosproject.pce.pcestore.api.PceStore; | 95 | import org.onosproject.pce.pcestore.api.PceStore; |
| 96 | +import org.onosproject.pcep.api.DeviceCapability; | ||
| 95 | import org.onosproject.store.serializers.KryoNamespaces; | 97 | import org.onosproject.store.serializers.KryoNamespaces; |
| 96 | import org.onosproject.store.service.DistributedSet; | 98 | import org.onosproject.store.service.DistributedSet; |
| 97 | import org.onosproject.store.service.Serializer; | 99 | import org.onosproject.store.service.Serializer; |
| ... | @@ -176,6 +178,9 @@ public class PceManager implements PceService { | ... | @@ -176,6 +178,9 @@ public class PceManager implements PceService { |
| 176 | protected DeviceService deviceService; | 178 | protected DeviceService deviceService; |
| 177 | 179 | ||
| 178 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 180 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 181 | + protected NetworkConfigService netCfgService; | ||
| 182 | + | ||
| 183 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
| 179 | protected LabelResourceAdminService labelRsrcAdminService; | 184 | protected LabelResourceAdminService labelRsrcAdminService; |
| 180 | 185 | ||
| 181 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 186 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| ... | @@ -304,6 +309,14 @@ public class PceManager implements PceService { | ... | @@ -304,6 +309,14 @@ public class PceManager implements PceService { |
| 304 | return false; | 309 | return false; |
| 305 | } | 310 | } |
| 306 | 311 | ||
| 312 | + // Get device config from netconfig, to ascertain that session with ingress is present. | ||
| 313 | + DeviceCapability cfg = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), DeviceCapability.class); | ||
| 314 | + if (cfg == null) { | ||
| 315 | + log.debug("No session to ingress."); | ||
| 316 | + pceStore.addFailedPathInfo(new PcePathInfo(src, dst, tunnelName, constraints, lspType)); | ||
| 317 | + return false; | ||
| 318 | + } | ||
| 319 | + | ||
| 307 | TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); | 320 | TunnelEndPoint srcEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(srcLsrId)); |
| 308 | TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); | 321 | TunnelEndPoint dstEndPoint = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(dstLsrId)); |
| 309 | 322 | ||
| ... | @@ -441,7 +454,7 @@ public class PceManager implements PceService { | ... | @@ -441,7 +454,7 @@ public class PceManager implements PceService { |
| 441 | bwConstraintValue = bwConstraint.bandwidth().bps(); | 454 | bwConstraintValue = bwConstraint.bandwidth().bps(); |
| 442 | } else if (constraint instanceof CostConstraint) { | 455 | } else if (constraint instanceof CostConstraint) { |
| 443 | costConstraint = (CostConstraint) constraint; | 456 | costConstraint = (CostConstraint) constraint; |
| 444 | - costType = costConstraint.type().name(); | 457 | + costType = costConstraint.type().name(); |
| 445 | } | 458 | } |
| 446 | } | 459 | } |
| 447 | 460 | ||
| ... | @@ -621,7 +634,8 @@ public class PceManager implements PceService { | ... | @@ -621,7 +634,8 @@ public class PceManager implements PceService { |
| 621 | while (it.hasNext() && cost > 0) { | 634 | while (it.hasNext() && cost > 0) { |
| 622 | Constraint constraint = it.next(); | 635 | Constraint constraint = it.next(); |
| 623 | if (constraint instanceof CapabilityConstraint) { | 636 | if (constraint instanceof CapabilityConstraint) { |
| 624 | - cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService) ? 1 : -1; | 637 | + cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService, |
| 638 | + netCfgService) ? 1 : -1; | ||
| 625 | } else { | 639 | } else { |
| 626 | cost = constraint.cost(edge.link(), resourceService::isAvailable); | 640 | cost = constraint.cost(edge.link(), resourceService::isAvailable); |
| 627 | } | 641 | } | ... | ... |
| ... | @@ -406,6 +406,7 @@ public final class PceccSrTeBeHandler { | ... | @@ -406,6 +406,7 @@ public final class PceccSrTeBeHandler { |
| 406 | 406 | ||
| 407 | /** | 407 | /** |
| 408 | * Install a rule for pushing unique global labels to the device. | 408 | * Install a rule for pushing unique global labels to the device. |
| 409 | + * | ||
| 409 | * @param deviceId device to which flow should be pushed | 410 | * @param deviceId device to which flow should be pushed |
| 410 | * @param labelId label for the device | 411 | * @param labelId label for the device |
| 411 | * @param type type of operation | 412 | * @param type type of operation |
| ... | @@ -437,6 +438,7 @@ public final class PceccSrTeBeHandler { | ... | @@ -437,6 +438,7 @@ public final class PceccSrTeBeHandler { |
| 437 | 438 | ||
| 438 | /** | 439 | /** |
| 439 | * Install a rule for pushing node labels to the device of other nodes. | 440 | * Install a rule for pushing node labels to the device of other nodes. |
| 441 | + * | ||
| 440 | * @param deviceId device to which flow should be pushed | 442 | * @param deviceId device to which flow should be pushed |
| 441 | * @param labelId label for the device | 443 | * @param labelId label for the device |
| 442 | * @param ipPrefix device for which label is pushed | 444 | * @param ipPrefix device for which label is pushed |
| ... | @@ -474,7 +476,8 @@ public final class PceccSrTeBeHandler { | ... | @@ -474,7 +476,8 @@ public final class PceccSrTeBeHandler { |
| 474 | } | 476 | } |
| 475 | 477 | ||
| 476 | /** | 478 | /** |
| 477 | - * Install a rule for pushing Adjacency labels to the device. | 479 | + * Install a rule for pushing Adjacency labels to the device. |
| 480 | + * | ||
| 478 | * @param deviceId device to which flow should be pushed | 481 | * @param deviceId device to which flow should be pushed |
| 479 | * @param labelId label for the adjacency | 482 | * @param labelId label for the adjacency |
| 480 | * @param srcPortNum local port of the adjacency | 483 | * @param srcPortNum local port of the adjacency | ... | ... |
| ... | @@ -15,12 +15,14 @@ | ... | @@ -15,12 +15,14 @@ |
| 15 | */ | 15 | */ |
| 16 | package org.onosproject.pce.pceservice.constraint; | 16 | package org.onosproject.pce.pceservice.constraint; |
| 17 | 17 | ||
| 18 | -import org.onosproject.net.AnnotationKeys; | ||
| 19 | import org.onosproject.net.Device; | 18 | import org.onosproject.net.Device; |
| 19 | +import org.onosproject.net.DeviceId; | ||
| 20 | import org.onosproject.net.Link; | 20 | import org.onosproject.net.Link; |
| 21 | +import org.onosproject.net.config.NetworkConfigService; | ||
| 21 | import org.onosproject.net.device.DeviceService; | 22 | import org.onosproject.net.device.DeviceService; |
| 22 | import org.onosproject.net.intent.ResourceContext; | 23 | import org.onosproject.net.intent.ResourceContext; |
| 23 | import org.onosproject.net.intent.constraint.BooleanConstraint; | 24 | import org.onosproject.net.intent.constraint.BooleanConstraint; |
| 25 | +import org.onosproject.pcep.api.DeviceCapability; | ||
| 24 | 26 | ||
| 25 | import java.util.Objects; | 27 | import java.util.Objects; |
| 26 | 28 | ||
| ... | @@ -32,11 +34,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; | ... | @@ -32,11 +34,7 @@ import static com.google.common.base.MoreObjects.toStringHelper; |
| 32 | public final class CapabilityConstraint extends BooleanConstraint { | 34 | public final class CapabilityConstraint extends BooleanConstraint { |
| 33 | 35 | ||
| 34 | private final CapabilityType capabilityType; | 36 | private final CapabilityType capabilityType; |
| 35 | - public static final String PCECC_CAPABILITY = "pceccCapability"; | ||
| 36 | - public static final String SR_CAPABILITY = "srCapability"; | ||
| 37 | - public static final String LABEL_STACK_CAPABILITY = "labelStackCapability"; | ||
| 38 | public static final String LSRID = "lsrId"; | 37 | public static final String LSRID = "lsrId"; |
| 39 | - public static final String L3 = "L3"; | ||
| 40 | public static final String TRUE = "true"; | 38 | public static final String TRUE = "true"; |
| 41 | 39 | ||
| 42 | /** | 40 | /** |
| ... | @@ -117,45 +115,33 @@ public final class CapabilityConstraint extends BooleanConstraint { | ... | @@ -117,45 +115,33 @@ public final class CapabilityConstraint extends BooleanConstraint { |
| 117 | * | 115 | * |
| 118 | * @param link to validate source and destination based on capability constraint | 116 | * @param link to validate source and destination based on capability constraint |
| 119 | * @param deviceService instance of DeviceService | 117 | * @param deviceService instance of DeviceService |
| 118 | + * @param netCfgService instance of NetworkConfigService | ||
| 120 | * @return true if link satisfies capability constraint otherwise false | 119 | * @return true if link satisfies capability constraint otherwise false |
| 121 | */ | 120 | */ |
| 122 | - public boolean isValidLink(Link link, DeviceService deviceService) { | 121 | + public boolean isValidLink(Link link, DeviceService deviceService, NetworkConfigService netCfgService) { |
| 123 | - if (deviceService == null) { | 122 | + if (deviceService == null || netCfgService == null) { |
| 124 | return false; | 123 | return false; |
| 125 | } | 124 | } |
| 126 | 125 | ||
| 127 | Device srcDevice = deviceService.getDevice(link.src().deviceId()); | 126 | Device srcDevice = deviceService.getDevice(link.src().deviceId()); |
| 128 | Device dstDevice = deviceService.getDevice(link.dst().deviceId()); | 127 | Device dstDevice = deviceService.getDevice(link.dst().deviceId()); |
| 129 | 128 | ||
| 130 | - //TODO: Usage of annotations are for transient solution. In future will be replaces with the | 129 | + //TODO: Usage of annotations are for transient solution. In future will be replaced with the |
| 131 | // network config service / Projection model. | 130 | // network config service / Projection model. |
| 132 | // L3 device | 131 | // L3 device |
| 133 | - if (srcDevice == null | 132 | + if (srcDevice == null || dstDevice == null) { |
| 134 | - || dstDevice == null | ||
| 135 | - || srcDevice.annotations().value(AnnotationKeys.TYPE) == null | ||
| 136 | - || dstDevice.annotations().value(AnnotationKeys.TYPE) == null | ||
| 137 | - || !srcDevice.annotations().value(AnnotationKeys.TYPE).equals(L3) | ||
| 138 | - || !dstDevice.annotations().value(AnnotationKeys.TYPE).equals(L3)) { | ||
| 139 | return false; | 133 | return false; |
| 140 | } | 134 | } |
| 141 | 135 | ||
| 142 | - String scrLsrId = srcDevice.annotations().value(LSRID); | 136 | + String srcLsrId = srcDevice.annotations().value(LSRID); |
| 143 | String dstLsrId = dstDevice.annotations().value(LSRID); | 137 | String dstLsrId = dstDevice.annotations().value(LSRID); |
| 144 | 138 | ||
| 145 | - Device srcCapDevice = null; | 139 | + DeviceCapability srcDeviceConfig = netCfgService.getConfig(DeviceId.deviceId(srcLsrId), |
| 146 | - Device dstCapDevice = null; | 140 | + DeviceCapability.class); |
| 147 | - | 141 | + DeviceCapability dstDeviceConfig = netCfgService.getConfig(DeviceId.deviceId(dstLsrId), |
| 148 | - // Get Capability device | 142 | + DeviceCapability.class); |
| 149 | - Iterable<Device> devices = deviceService.getAvailableDevices(); | ||
| 150 | - for (Device dev : devices) { | ||
| 151 | - if (dev.annotations().value(LSRID).equals(scrLsrId)) { | ||
| 152 | - srcCapDevice = dev; | ||
| 153 | - } else if (dev.annotations().value(LSRID).equals(dstLsrId)) { | ||
| 154 | - dstCapDevice = dev; | ||
| 155 | - } | ||
| 156 | - } | ||
| 157 | 143 | ||
| 158 | - if (srcCapDevice == null || dstCapDevice == null) { | 144 | + if (srcDeviceConfig == null || dstDeviceConfig == null) { |
| 159 | return false; | 145 | return false; |
| 160 | } | 146 | } |
| 161 | 147 | ||
| ... | @@ -163,23 +149,11 @@ public final class CapabilityConstraint extends BooleanConstraint { | ... | @@ -163,23 +149,11 @@ public final class CapabilityConstraint extends BooleanConstraint { |
| 163 | case WITH_SIGNALLING: | 149 | case WITH_SIGNALLING: |
| 164 | return true; | 150 | return true; |
| 165 | case WITHOUT_SIGNALLING_AND_WITHOUT_SR: | 151 | case WITHOUT_SIGNALLING_AND_WITHOUT_SR: |
| 166 | - if (srcCapDevice.annotations().value(PCECC_CAPABILITY) != null | 152 | + return srcDeviceConfig.localLabelCap() && dstDeviceConfig.localLabelCap(); |
| 167 | - && dstCapDevice.annotations().value(PCECC_CAPABILITY) != null) { | 153 | + |
| 168 | - return srcCapDevice.annotations().value(PCECC_CAPABILITY).equals(TRUE) | ||
| 169 | - && dstCapDevice.annotations().value(PCECC_CAPABILITY).equals(TRUE); | ||
| 170 | - } | ||
| 171 | - return false; | ||
| 172 | case SR_WITHOUT_SIGNALLING: | 154 | case SR_WITHOUT_SIGNALLING: |
| 173 | - if (srcCapDevice.annotations().value(LABEL_STACK_CAPABILITY) != null | 155 | + return srcDeviceConfig.srCap() && dstDeviceConfig.srCap() |
| 174 | - && dstCapDevice.annotations().value(LABEL_STACK_CAPABILITY) != null | 156 | + && srcDeviceConfig.labelStackCap() && dstDeviceConfig.labelStackCap(); |
| 175 | - && srcCapDevice.annotations().value(SR_CAPABILITY) != null | ||
| 176 | - && dstCapDevice.annotations().value(SR_CAPABILITY) != null) { | ||
| 177 | - return srcCapDevice.annotations().value(LABEL_STACK_CAPABILITY).equals(TRUE) | ||
| 178 | - && dstCapDevice.annotations().value(LABEL_STACK_CAPABILITY).equals(TRUE) | ||
| 179 | - && srcCapDevice.annotations().value(SR_CAPABILITY).equals(TRUE) | ||
| 180 | - && dstCapDevice.annotations().value(SR_CAPABILITY).equals(TRUE); | ||
| 181 | - } | ||
| 182 | - return false; | ||
| 183 | default: | 157 | default: |
| 184 | return false; | 158 | return false; |
| 185 | } | 159 | } | ... | ... |
| ... | @@ -40,6 +40,10 @@ import org.onosproject.net.PortNumber; | ... | @@ -40,6 +40,10 @@ import org.onosproject.net.PortNumber; |
| 40 | import org.onosproject.net.intent.Constraint; | 40 | import org.onosproject.net.intent.Constraint; |
| 41 | import org.onosproject.net.intent.IntentId; | 41 | import org.onosproject.net.intent.IntentId; |
| 42 | import org.onosproject.net.Device.Type; | 42 | import org.onosproject.net.Device.Type; |
| 43 | +import org.onosproject.net.config.Config; | ||
| 44 | +import org.onosproject.net.config.ConfigApplyDelegate; | ||
| 45 | +import org.onosproject.net.config.ConfigFactory; | ||
| 46 | +import org.onosproject.net.config.NetworkConfigRegistryAdapter; | ||
| 43 | import org.onosproject.net.intent.constraint.BandwidthConstraint; | 47 | import org.onosproject.net.intent.constraint.BandwidthConstraint; |
| 44 | import org.onosproject.net.device.DeviceServiceAdapter; | 48 | import org.onosproject.net.device.DeviceServiceAdapter; |
| 45 | import org.onosproject.net.resource.ContinuousResource; | 49 | import org.onosproject.net.resource.ContinuousResource; |
| ... | @@ -60,7 +64,11 @@ import org.onosproject.net.topology.TopologyVertex; | ... | @@ -60,7 +64,11 @@ import org.onosproject.net.topology.TopologyVertex; |
| 60 | import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; | 64 | import org.onosproject.pce.pceservice.constraint.CapabilityConstraint; |
| 61 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 65 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
| 62 | import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint; | 66 | import org.onosproject.pce.pceservice.constraint.SharedBandwidthConstraint; |
| 63 | - | 67 | +import org.onosproject.pcep.api.DeviceCapability; |
| 68 | +import com.fasterxml.jackson.databind.JsonNode; | ||
| 69 | +import com.fasterxml.jackson.databind.ObjectMapper; | ||
| 70 | +import com.fasterxml.jackson.databind.node.JsonNodeFactory; | ||
| 71 | +import com.fasterxml.jackson.databind.node.ObjectNode; | ||
| 64 | import com.google.common.collect.ImmutableList; | 72 | import com.google.common.collect.ImmutableList; |
| 65 | import com.google.common.collect.ImmutableSet; | 73 | import com.google.common.collect.ImmutableSet; |
| 66 | 74 | ||
| ... | @@ -94,6 +102,7 @@ public class PathComputationTest { | ... | @@ -94,6 +102,7 @@ public class PathComputationTest { |
| 94 | 102 | ||
| 95 | private final MockPathResourceService resourceService = new MockPathResourceService(); | 103 | private final MockPathResourceService resourceService = new MockPathResourceService(); |
| 96 | private final MockDeviceService deviceService = new MockDeviceService(); | 104 | private final MockDeviceService deviceService = new MockDeviceService(); |
| 105 | + private final MockNetConfigRegistryAdapter netConfigRegistry = new MockNetConfigRegistryAdapter(); | ||
| 97 | private PceManager pceManager = new PceManager(); | 106 | private PceManager pceManager = new PceManager(); |
| 98 | public static ProviderId providerId = new ProviderId("pce", "foo"); | 107 | public static ProviderId providerId = new ProviderId("pce", "foo"); |
| 99 | public static final String DEVICE1 = "D001"; | 108 | public static final String DEVICE1 = "D001"; |
| ... | @@ -123,6 +132,7 @@ public class PathComputationTest { | ... | @@ -123,6 +132,7 @@ public class PathComputationTest { |
| 123 | public void startUp() { | 132 | public void startUp() { |
| 124 | pceManager.resourceService = resourceService; | 133 | pceManager.resourceService = resourceService; |
| 125 | pceManager.deviceService = deviceService; | 134 | pceManager.deviceService = deviceService; |
| 135 | + pceManager.netCfgService = netConfigRegistry; | ||
| 126 | } | 136 | } |
| 127 | 137 | ||
| 128 | /** | 138 | /** |
| ... | @@ -164,6 +174,7 @@ public class PathComputationTest { | ... | @@ -164,6 +174,7 @@ public class PathComputationTest { |
| 164 | public void tearDown() { | 174 | public void tearDown() { |
| 165 | pceManager.resourceService = null; | 175 | pceManager.resourceService = null; |
| 166 | pceManager.deviceService = null; | 176 | pceManager.deviceService = null; |
| 177 | + pceManager.netCfgService = null; | ||
| 167 | } | 178 | } |
| 168 | 179 | ||
| 169 | /** | 180 | /** |
| ... | @@ -234,6 +245,7 @@ public class PathComputationTest { | ... | @@ -234,6 +245,7 @@ public class PathComputationTest { |
| 234 | } | 245 | } |
| 235 | } | 246 | } |
| 236 | 247 | ||
| 248 | + @Override | ||
| 237 | public double weight(TopologyEdge edge) { | 249 | public double weight(TopologyEdge edge) { |
| 238 | if (!constraints.iterator().hasNext()) { | 250 | if (!constraints.iterator().hasNext()) { |
| 239 | //Takes default cost/hopcount as 1 if no constraints specified | 251 | //Takes default cost/hopcount as 1 if no constraints specified |
| ... | @@ -247,7 +259,8 @@ public class PathComputationTest { | ... | @@ -247,7 +259,8 @@ public class PathComputationTest { |
| 247 | while (it.hasNext() && cost > 0) { | 259 | while (it.hasNext() && cost > 0) { |
| 248 | Constraint constraint = it.next(); | 260 | Constraint constraint = it.next(); |
| 249 | if (constraint instanceof CapabilityConstraint) { | 261 | if (constraint instanceof CapabilityConstraint) { |
| 250 | - cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService) ? 1 : -1; | 262 | + cost = ((CapabilityConstraint) constraint).isValidLink(edge.link(), deviceService, |
| 263 | + netConfigRegistry) ? 1 : -1; | ||
| 251 | } else { | 264 | } else { |
| 252 | cost = constraint.cost(edge.link(), resourceService::isAvailable); | 265 | cost = constraint.cost(edge.link(), resourceService::isAvailable); |
| 253 | } | 266 | } |
| ... | @@ -346,6 +359,63 @@ public class PathComputationTest { | ... | @@ -346,6 +359,63 @@ public class PathComputationTest { |
| 346 | } | 359 | } |
| 347 | } | 360 | } |
| 348 | 361 | ||
| 362 | + /* Mock test for network config registry. */ | ||
| 363 | + public static class MockNetConfigRegistryAdapter extends NetworkConfigRegistryAdapter { | ||
| 364 | + private ConfigFactory cfgFactory; | ||
| 365 | + private Map<DeviceId, DeviceCapability> classConfig = new HashMap<>(); | ||
| 366 | + | ||
| 367 | + @Override | ||
| 368 | + public void registerConfigFactory(ConfigFactory configFactory) { | ||
| 369 | + cfgFactory = configFactory; | ||
| 370 | + } | ||
| 371 | + | ||
| 372 | + @Override | ||
| 373 | + public void unregisterConfigFactory(ConfigFactory configFactory) { | ||
| 374 | + cfgFactory = null; | ||
| 375 | + } | ||
| 376 | + | ||
| 377 | + @Override | ||
| 378 | + public <S, C extends Config<S>> C addConfig(S subject, Class<C> configClass) { | ||
| 379 | + if (configClass == DeviceCapability.class) { | ||
| 380 | + DeviceCapability devCap = new DeviceCapability(); | ||
| 381 | + classConfig.put((DeviceId) subject, devCap); | ||
| 382 | + | ||
| 383 | + JsonNode node = new ObjectNode(new MockJsonNode()); | ||
| 384 | + ObjectMapper mapper = new ObjectMapper(); | ||
| 385 | + ConfigApplyDelegate delegate = new InternalApplyDelegate(); | ||
| 386 | + devCap.init((DeviceId) subject, null, node, mapper, delegate); | ||
| 387 | + return (C) devCap; | ||
| 388 | + } | ||
| 389 | + | ||
| 390 | + return null; | ||
| 391 | + } | ||
| 392 | + | ||
| 393 | + @Override | ||
| 394 | + public <S, C extends Config<S>> void removeConfig(S subject, Class<C> configClass) { | ||
| 395 | + classConfig.remove(subject); | ||
| 396 | + } | ||
| 397 | + | ||
| 398 | + @Override | ||
| 399 | + public <S, C extends Config<S>> C getConfig(S subject, Class<C> configClass) { | ||
| 400 | + if (configClass == DeviceCapability.class) { | ||
| 401 | + return (C) classConfig.get(subject); | ||
| 402 | + } | ||
| 403 | + return null; | ||
| 404 | + } | ||
| 405 | + | ||
| 406 | + private class MockJsonNode extends JsonNodeFactory { | ||
| 407 | + } | ||
| 408 | + | ||
| 409 | + // Auxiliary delegate to receive notifications about changes applied to | ||
| 410 | + // the network configuration - by the apps. | ||
| 411 | + private class InternalApplyDelegate implements ConfigApplyDelegate { | ||
| 412 | + @Override | ||
| 413 | + public void onApply(Config config) { | ||
| 414 | + //configs.put(config.subject(), config.node()); | ||
| 415 | + } | ||
| 416 | + } | ||
| 417 | + } | ||
| 418 | + | ||
| 349 | /** | 419 | /** |
| 350 | * All links with different costs with L1-L2 as least cost path. | 420 | * All links with different costs with L1-L2 as least cost path. |
| 351 | */ | 421 | */ |
| ... | @@ -614,24 +684,48 @@ public class PathComputationTest { | ... | @@ -614,24 +684,48 @@ public class PathComputationTest { |
| 614 | builder.set(LSRID, "1.1.1.1"); | 684 | builder.set(LSRID, "1.1.1.1"); |
| 615 | addDevice(DEVICE1, builder); | 685 | addDevice(DEVICE1, builder); |
| 616 | 686 | ||
| 687 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); | ||
| 688 | + device1Cap.setLabelStackCap(false) | ||
| 689 | + .setLocalLabelCap(false) | ||
| 690 | + .setSrCap(false) | ||
| 691 | + .apply(); | ||
| 692 | + | ||
| 617 | //Device2 | 693 | //Device2 |
| 618 | builder = DefaultAnnotations.builder(); | 694 | builder = DefaultAnnotations.builder(); |
| 619 | builder.set(AnnotationKeys.TYPE, L3); | 695 | builder.set(AnnotationKeys.TYPE, L3); |
| 620 | builder.set(LSRID, "2.2.2.2"); | 696 | builder.set(LSRID, "2.2.2.2"); |
| 621 | addDevice(DEVICE2, builder); | 697 | addDevice(DEVICE2, builder); |
| 622 | 698 | ||
| 699 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); | ||
| 700 | + device2Cap.setLabelStackCap(false) | ||
| 701 | + .setLocalLabelCap(false) | ||
| 702 | + .setSrCap(false) | ||
| 703 | + .apply(); | ||
| 704 | + | ||
| 623 | //Device3 | 705 | //Device3 |
| 624 | builder = DefaultAnnotations.builder(); | 706 | builder = DefaultAnnotations.builder(); |
| 625 | builder.set(AnnotationKeys.TYPE, L3); | 707 | builder.set(AnnotationKeys.TYPE, L3); |
| 626 | builder.set(LSRID, "3.3.3.3"); | 708 | builder.set(LSRID, "3.3.3.3"); |
| 627 | addDevice(DEVICE3, builder); | 709 | addDevice(DEVICE3, builder); |
| 628 | 710 | ||
| 711 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); | ||
| 712 | + device3Cap.setLabelStackCap(false) | ||
| 713 | + .setLocalLabelCap(false) | ||
| 714 | + .setSrCap(false) | ||
| 715 | + .apply(); | ||
| 716 | + | ||
| 629 | //Device4 | 717 | //Device4 |
| 630 | builder = DefaultAnnotations.builder(); | 718 | builder = DefaultAnnotations.builder(); |
| 631 | builder.set(AnnotationKeys.TYPE, L3); | 719 | builder.set(AnnotationKeys.TYPE, L3); |
| 632 | builder.set(LSRID, "4.4.4.4"); | 720 | builder.set(LSRID, "4.4.4.4"); |
| 633 | addDevice(DEVICE4, builder); | 721 | addDevice(DEVICE4, builder); |
| 634 | 722 | ||
| 723 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); | ||
| 724 | + device4Cap.setLabelStackCap(false) | ||
| 725 | + .setLocalLabelCap(false) | ||
| 726 | + .setSrCap(false) | ||
| 727 | + .apply(); | ||
| 728 | + | ||
| 635 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 729 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 636 | 730 | ||
| 637 | List<Link> links = new LinkedList<>(); | 731 | List<Link> links = new LinkedList<>(); |
| ... | @@ -663,32 +757,44 @@ public class PathComputationTest { | ... | @@ -663,32 +757,44 @@ public class PathComputationTest { |
| 663 | builder.set(AnnotationKeys.TYPE, L3); | 757 | builder.set(AnnotationKeys.TYPE, L3); |
| 664 | builder.set(LSRID, "1.1.1.1"); | 758 | builder.set(LSRID, "1.1.1.1"); |
| 665 | addDevice(DEVICE1, builder); | 759 | addDevice(DEVICE1, builder); |
| 666 | - builder.set(PCECC_CAPABILITY, "true"); | 760 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 667 | - addDevice(PCEPDEVICE1, builder); | 761 | + device1Cap.setLabelStackCap(false) |
| 762 | + .setLocalLabelCap(true) | ||
| 763 | + .setSrCap(false) | ||
| 764 | + .apply(); | ||
| 668 | 765 | ||
| 669 | //Device2 | 766 | //Device2 |
| 670 | builder = DefaultAnnotations.builder(); | 767 | builder = DefaultAnnotations.builder(); |
| 671 | builder.set(AnnotationKeys.TYPE, L3); | 768 | builder.set(AnnotationKeys.TYPE, L3); |
| 672 | builder.set(LSRID, "2.2.2.2"); | 769 | builder.set(LSRID, "2.2.2.2"); |
| 673 | addDevice(DEVICE2, builder); | 770 | addDevice(DEVICE2, builder); |
| 674 | - builder.set(PCECC_CAPABILITY, "true"); | 771 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 675 | - addDevice(PCEPDEVICE2, builder); | 772 | + device2Cap.setLabelStackCap(false) |
| 773 | + .setLocalLabelCap(true) | ||
| 774 | + .setSrCap(false) | ||
| 775 | + .apply(); | ||
| 676 | 776 | ||
| 677 | //Device3 | 777 | //Device3 |
| 678 | builder = DefaultAnnotations.builder(); | 778 | builder = DefaultAnnotations.builder(); |
| 679 | builder.set(AnnotationKeys.TYPE, L3); | 779 | builder.set(AnnotationKeys.TYPE, L3); |
| 680 | builder.set(LSRID, "3.3.3.3"); | 780 | builder.set(LSRID, "3.3.3.3"); |
| 681 | addDevice(DEVICE3, builder); | 781 | addDevice(DEVICE3, builder); |
| 682 | - builder.set(PCECC_CAPABILITY, "true"); | 782 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 683 | - addDevice(PCEPDEVICE3, builder); | 783 | + device3Cap.setLabelStackCap(false) |
| 784 | + .setLocalLabelCap(true) | ||
| 785 | + .setSrCap(false) | ||
| 786 | + .apply(); | ||
| 684 | 787 | ||
| 685 | //Device4 | 788 | //Device4 |
| 686 | builder = DefaultAnnotations.builder(); | 789 | builder = DefaultAnnotations.builder(); |
| 687 | builder.set(AnnotationKeys.TYPE, L3); | 790 | builder.set(AnnotationKeys.TYPE, L3); |
| 688 | builder.set(LSRID, "4.4.4.4"); | 791 | builder.set(LSRID, "4.4.4.4"); |
| 689 | addDevice(DEVICE4, builder); | 792 | addDevice(DEVICE4, builder); |
| 690 | - builder.set(PCECC_CAPABILITY, "true"); | 793 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 691 | - addDevice(PCEPDEVICE4, builder); | 794 | + device4Cap.setLabelStackCap(false) |
| 795 | + .setLocalLabelCap(true) | ||
| 796 | + .setSrCap(false) | ||
| 797 | + .apply(); | ||
| 692 | 798 | ||
| 693 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 799 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 694 | 800 | ||
| ... | @@ -721,36 +827,44 @@ public class PathComputationTest { | ... | @@ -721,36 +827,44 @@ public class PathComputationTest { |
| 721 | builder.set(AnnotationKeys.TYPE, L3); | 827 | builder.set(AnnotationKeys.TYPE, L3); |
| 722 | builder.set(LSRID, "1.1.1.1"); | 828 | builder.set(LSRID, "1.1.1.1"); |
| 723 | addDevice(DEVICE1, builder); | 829 | addDevice(DEVICE1, builder); |
| 724 | - builder.set(SR_CAPABILITY, "true"); | 830 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 725 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 831 | + device1Cap.setLabelStackCap(true) |
| 726 | - addDevice(PCEPDEVICE1, builder); | 832 | + .setLocalLabelCap(false) |
| 833 | + .setSrCap(true) | ||
| 834 | + .apply(); | ||
| 727 | 835 | ||
| 728 | //Device2 | 836 | //Device2 |
| 729 | builder = DefaultAnnotations.builder(); | 837 | builder = DefaultAnnotations.builder(); |
| 730 | builder.set(AnnotationKeys.TYPE, L3); | 838 | builder.set(AnnotationKeys.TYPE, L3); |
| 731 | builder.set(LSRID, "2.2.2.2"); | 839 | builder.set(LSRID, "2.2.2.2"); |
| 732 | addDevice(DEVICE2, builder); | 840 | addDevice(DEVICE2, builder); |
| 733 | - builder.set(SR_CAPABILITY, "true"); | 841 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 734 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 842 | + device2Cap.setLabelStackCap(true) |
| 735 | - addDevice(PCEPDEVICE2, builder); | 843 | + .setLocalLabelCap(false) |
| 844 | + .setSrCap(true) | ||
| 845 | + .apply(); | ||
| 736 | 846 | ||
| 737 | //Device3 | 847 | //Device3 |
| 738 | builder = DefaultAnnotations.builder(); | 848 | builder = DefaultAnnotations.builder(); |
| 739 | builder.set(AnnotationKeys.TYPE, L3); | 849 | builder.set(AnnotationKeys.TYPE, L3); |
| 740 | builder.set(LSRID, "3.3.3.3"); | 850 | builder.set(LSRID, "3.3.3.3"); |
| 741 | addDevice(DEVICE3, builder); | 851 | addDevice(DEVICE3, builder); |
| 742 | - builder.set(SR_CAPABILITY, "true"); | 852 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 743 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 853 | + device3Cap.setLabelStackCap(true) |
| 744 | - addDevice(PCEPDEVICE3, builder); | 854 | + .setLocalLabelCap(false) |
| 855 | + .setSrCap(true) | ||
| 856 | + .apply(); | ||
| 745 | 857 | ||
| 746 | //Device4 | 858 | //Device4 |
| 747 | builder = DefaultAnnotations.builder(); | 859 | builder = DefaultAnnotations.builder(); |
| 748 | builder.set(AnnotationKeys.TYPE, L3); | 860 | builder.set(AnnotationKeys.TYPE, L3); |
| 749 | builder.set(LSRID, "4.4.4.4"); | 861 | builder.set(LSRID, "4.4.4.4"); |
| 750 | addDevice(DEVICE4, builder); | 862 | addDevice(DEVICE4, builder); |
| 751 | - builder.set(SR_CAPABILITY, "true"); | 863 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 752 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 864 | + device4Cap.setLabelStackCap(true) |
| 753 | - addDevice(PCEPDEVICE4, builder); | 865 | + .setLocalLabelCap(false) |
| 866 | + .setSrCap(true) | ||
| 867 | + .apply(); | ||
| 754 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 868 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 755 | 869 | ||
| 756 | List<Link> links = new LinkedList<>(); | 870 | List<Link> links = new LinkedList<>(); |
| ... | @@ -783,36 +897,45 @@ public class PathComputationTest { | ... | @@ -783,36 +897,45 @@ public class PathComputationTest { |
| 783 | builder.set(AnnotationKeys.TYPE, L3); | 897 | builder.set(AnnotationKeys.TYPE, L3); |
| 784 | builder.set(LSRID, "1.1.1.1"); | 898 | builder.set(LSRID, "1.1.1.1"); |
| 785 | addDevice(DEVICE1, builder); | 899 | addDevice(DEVICE1, builder); |
| 786 | - builder.set(SR_CAPABILITY, "true"); | 900 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 787 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 901 | + device1Cap.setLabelStackCap(true) |
| 788 | - addDevice(PCEPDEVICE1, builder); | 902 | + .setLocalLabelCap(false) |
| 903 | + .setSrCap(true) | ||
| 904 | + .apply(); | ||
| 789 | 905 | ||
| 790 | //Device2 | 906 | //Device2 |
| 791 | builder = DefaultAnnotations.builder(); | 907 | builder = DefaultAnnotations.builder(); |
| 792 | builder.set(AnnotationKeys.TYPE, L3); | 908 | builder.set(AnnotationKeys.TYPE, L3); |
| 793 | builder.set(LSRID, "2.2.2.2"); | 909 | builder.set(LSRID, "2.2.2.2"); |
| 794 | addDevice(DEVICE2, builder); | 910 | addDevice(DEVICE2, builder); |
| 795 | - builder.set(SR_CAPABILITY, "true"); | 911 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 796 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 912 | + device2Cap.setLabelStackCap(true) |
| 797 | - addDevice(PCEPDEVICE2, builder); | 913 | + .setLocalLabelCap(false) |
| 914 | + .setSrCap(true) | ||
| 915 | + .apply(); | ||
| 798 | 916 | ||
| 799 | //Device3 | 917 | //Device3 |
| 800 | builder = DefaultAnnotations.builder(); | 918 | builder = DefaultAnnotations.builder(); |
| 801 | builder.set(AnnotationKeys.TYPE, L3); | 919 | builder.set(AnnotationKeys.TYPE, L3); |
| 802 | builder.set(LSRID, "3.3.3.3"); | 920 | builder.set(LSRID, "3.3.3.3"); |
| 803 | addDevice(DEVICE3, builder); | 921 | addDevice(DEVICE3, builder); |
| 804 | - builder.set(SR_CAPABILITY, "true"); | 922 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 805 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 923 | + device3Cap.setLabelStackCap(true) |
| 806 | - addDevice(PCEPDEVICE3, builder); | 924 | + .setLocalLabelCap(false) |
| 925 | + .setSrCap(true) | ||
| 926 | + .apply(); | ||
| 807 | 927 | ||
| 808 | //Device4 | 928 | //Device4 |
| 809 | builder = DefaultAnnotations.builder(); | 929 | builder = DefaultAnnotations.builder(); |
| 810 | builder.set(AnnotationKeys.TYPE, L3); | 930 | builder.set(AnnotationKeys.TYPE, L3); |
| 811 | builder.set(LSRID, "4.4.4.4"); | 931 | builder.set(LSRID, "4.4.4.4"); |
| 812 | addDevice(DEVICE4, builder); | 932 | addDevice(DEVICE4, builder); |
| 813 | - builder.set(SR_CAPABILITY, "true"); | 933 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 814 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 934 | + device4Cap.setLabelStackCap(true) |
| 815 | - addDevice(PCEPDEVICE4, builder); | 935 | + .setLocalLabelCap(false) |
| 936 | + .setSrCap(true) | ||
| 937 | + .apply(); | ||
| 938 | + | ||
| 816 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 939 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 817 | 940 | ||
| 818 | List<Link> links = new LinkedList<>(); | 941 | List<Link> links = new LinkedList<>(); |
| ... | @@ -842,36 +965,45 @@ public class PathComputationTest { | ... | @@ -842,36 +965,45 @@ public class PathComputationTest { |
| 842 | builder.set(AnnotationKeys.TYPE, L3); | 965 | builder.set(AnnotationKeys.TYPE, L3); |
| 843 | builder.set(LSRID, "1.1.1.1"); | 966 | builder.set(LSRID, "1.1.1.1"); |
| 844 | addDevice(DEVICE1, builder); | 967 | addDevice(DEVICE1, builder); |
| 845 | - builder.set(SR_CAPABILITY, "true"); | 968 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 846 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 969 | + device1Cap.setLabelStackCap(true) |
| 847 | - addDevice(PCEPDEVICE1, builder); | 970 | + .setLocalLabelCap(false) |
| 971 | + .setSrCap(true) | ||
| 972 | + .apply(); | ||
| 848 | 973 | ||
| 849 | //Device2 | 974 | //Device2 |
| 850 | builder = DefaultAnnotations.builder(); | 975 | builder = DefaultAnnotations.builder(); |
| 851 | builder.set(AnnotationKeys.TYPE, L3); | 976 | builder.set(AnnotationKeys.TYPE, L3); |
| 852 | builder.set(LSRID, "2.2.2.2"); | 977 | builder.set(LSRID, "2.2.2.2"); |
| 853 | addDevice(DEVICE2, builder); | 978 | addDevice(DEVICE2, builder); |
| 854 | - builder.set(SR_CAPABILITY, "true"); | 979 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 855 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 980 | + device2Cap.setLabelStackCap(true) |
| 856 | - addDevice(PCEPDEVICE2, builder); | 981 | + .setLocalLabelCap(false) |
| 982 | + .setSrCap(true) | ||
| 983 | + .apply(); | ||
| 857 | 984 | ||
| 858 | //Device3 | 985 | //Device3 |
| 859 | builder = DefaultAnnotations.builder(); | 986 | builder = DefaultAnnotations.builder(); |
| 860 | builder.set(AnnotationKeys.TYPE, L3); | 987 | builder.set(AnnotationKeys.TYPE, L3); |
| 861 | builder.set(LSRID, "3.3.3.3"); | 988 | builder.set(LSRID, "3.3.3.3"); |
| 862 | addDevice(DEVICE3, builder); | 989 | addDevice(DEVICE3, builder); |
| 863 | - builder.set(SR_CAPABILITY, "true"); | 990 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); |
| 864 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 991 | + device3Cap.setLabelStackCap(true) |
| 865 | - addDevice(PCEPDEVICE3, builder); | 992 | + .setLocalLabelCap(false) |
| 993 | + .setSrCap(true) | ||
| 994 | + .apply(); | ||
| 866 | 995 | ||
| 867 | //Device4 | 996 | //Device4 |
| 868 | builder = DefaultAnnotations.builder(); | 997 | builder = DefaultAnnotations.builder(); |
| 869 | builder.set(AnnotationKeys.TYPE, L3); | 998 | builder.set(AnnotationKeys.TYPE, L3); |
| 870 | builder.set(LSRID, "4.4.4.4"); | 999 | builder.set(LSRID, "4.4.4.4"); |
| 871 | addDevice(DEVICE4, builder); | 1000 | addDevice(DEVICE4, builder); |
| 872 | - builder.set(SR_CAPABILITY, "true"); | 1001 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 873 | - builder.set(LABEL_STACK_CAPABILITY, "true"); | 1002 | + device4Cap.setLabelStackCap(true) |
| 874 | - addDevice(PCEPDEVICE4, builder); | 1003 | + .setLocalLabelCap(false) |
| 1004 | + .setSrCap(true) | ||
| 1005 | + .apply(); | ||
| 1006 | + | ||
| 875 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 1007 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 876 | 1008 | ||
| 877 | List<Link> links = new LinkedList<>(); | 1009 | List<Link> links = new LinkedList<>(); |
| ... | @@ -969,24 +1101,33 @@ public class PathComputationTest { | ... | @@ -969,24 +1101,33 @@ public class PathComputationTest { |
| 969 | builder.set(AnnotationKeys.TYPE, L3); | 1101 | builder.set(AnnotationKeys.TYPE, L3); |
| 970 | builder.set(LSRID, "1.1.1.1"); | 1102 | builder.set(LSRID, "1.1.1.1"); |
| 971 | addDevice(DEVICE1, builder); | 1103 | addDevice(DEVICE1, builder); |
| 972 | - builder.set(PCECC_CAPABILITY, "true"); | 1104 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 973 | - addDevice(PCEPDEVICE1, builder); | 1105 | + device1Cap.setLabelStackCap(false) |
| 1106 | + .setLocalLabelCap(true) | ||
| 1107 | + .setSrCap(false) | ||
| 1108 | + .apply(); | ||
| 974 | 1109 | ||
| 975 | //Device2 | 1110 | //Device2 |
| 976 | builder = DefaultAnnotations.builder(); | 1111 | builder = DefaultAnnotations.builder(); |
| 977 | builder.set(AnnotationKeys.TYPE, L3); | 1112 | builder.set(AnnotationKeys.TYPE, L3); |
| 978 | builder.set(LSRID, "2.2.2.2"); | 1113 | builder.set(LSRID, "2.2.2.2"); |
| 979 | addDevice(DEVICE2, builder); | 1114 | addDevice(DEVICE2, builder); |
| 980 | - builder.set(PCECC_CAPABILITY, "true"); | 1115 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 981 | - addDevice(PCEPDEVICE2, builder); | 1116 | + device2Cap.setLabelStackCap(false) |
| 1117 | + .setLocalLabelCap(true) | ||
| 1118 | + .setSrCap(false) | ||
| 1119 | + .apply(); | ||
| 982 | 1120 | ||
| 983 | //Device4 | 1121 | //Device4 |
| 984 | builder = DefaultAnnotations.builder(); | 1122 | builder = DefaultAnnotations.builder(); |
| 985 | builder.set(AnnotationKeys.TYPE, L3); | 1123 | builder.set(AnnotationKeys.TYPE, L3); |
| 986 | builder.set(LSRID, "4.4.4.4"); | 1124 | builder.set(LSRID, "4.4.4.4"); |
| 987 | addDevice(DEVICE4, builder); | 1125 | addDevice(DEVICE4, builder); |
| 988 | - builder.set(PCECC_CAPABILITY, "true"); | 1126 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 989 | - addDevice(PCEPDEVICE4, builder); | 1127 | + device4Cap.setLabelStackCap(false) |
| 1128 | + .setLocalLabelCap(true) | ||
| 1129 | + .setSrCap(false) | ||
| 1130 | + .apply(); | ||
| 990 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 1131 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 991 | 1132 | ||
| 992 | List<Link> links = new LinkedList<>(); | 1133 | List<Link> links = new LinkedList<>(); |
| ... | @@ -1019,24 +1160,33 @@ public class PathComputationTest { | ... | @@ -1019,24 +1160,33 @@ public class PathComputationTest { |
| 1019 | builder.set(AnnotationKeys.TYPE, L3); | 1160 | builder.set(AnnotationKeys.TYPE, L3); |
| 1020 | builder.set(LSRID, "1.1.1.1"); | 1161 | builder.set(LSRID, "1.1.1.1"); |
| 1021 | addDevice(DEVICE2, builder); | 1162 | addDevice(DEVICE2, builder); |
| 1022 | - builder.set(PCECC_CAPABILITY, "true"); | 1163 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 1023 | - addDevice(PCEPDEVICE1, builder); | 1164 | + device1Cap.setLabelStackCap(false) |
| 1165 | + .setLocalLabelCap(true) | ||
| 1166 | + .setSrCap(false) | ||
| 1167 | + .apply(); | ||
| 1024 | 1168 | ||
| 1025 | //Device2 | 1169 | //Device2 |
| 1026 | builder = DefaultAnnotations.builder(); | 1170 | builder = DefaultAnnotations.builder(); |
| 1027 | builder.set(AnnotationKeys.TYPE, L3); | 1171 | builder.set(AnnotationKeys.TYPE, L3); |
| 1028 | builder.set(LSRID, "2.2.2.2"); | 1172 | builder.set(LSRID, "2.2.2.2"); |
| 1029 | addDevice(DEVICE2, builder); | 1173 | addDevice(DEVICE2, builder); |
| 1030 | - builder.set(PCECC_CAPABILITY, "true"); | 1174 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 1031 | - addDevice(PCEPDEVICE2, builder); | 1175 | + device2Cap.setLabelStackCap(false) |
| 1176 | + .setLocalLabelCap(true) | ||
| 1177 | + .setSrCap(false) | ||
| 1178 | + .apply(); | ||
| 1032 | 1179 | ||
| 1033 | //Device4 | 1180 | //Device4 |
| 1034 | builder = DefaultAnnotations.builder(); | 1181 | builder = DefaultAnnotations.builder(); |
| 1035 | builder.set(AnnotationKeys.TYPE, L3); | 1182 | builder.set(AnnotationKeys.TYPE, L3); |
| 1036 | builder.set(LSRID, "4.4.4.4"); | 1183 | builder.set(LSRID, "4.4.4.4"); |
| 1037 | addDevice(DEVICE4, builder); | 1184 | addDevice(DEVICE4, builder); |
| 1038 | - builder.set(PCECC_CAPABILITY, "true"); | 1185 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); |
| 1039 | - addDevice(PCEPDEVICE4, builder); | 1186 | + device4Cap.setLabelStackCap(false) |
| 1187 | + .setLocalLabelCap(true) | ||
| 1188 | + .setSrCap(false) | ||
| 1189 | + .apply(); | ||
| 1040 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); | 1190 | Set<Path> paths = computePath(link1, link2, link3, link4, constraints); |
| 1041 | 1191 | ||
| 1042 | assertThat(paths, is(new HashSet<>())); | 1192 | assertThat(paths, is(new HashSet<>())); | ... | ... |
| ... | @@ -102,12 +102,14 @@ import org.onosproject.net.topology.TopologyGraph; | ... | @@ -102,12 +102,14 @@ import org.onosproject.net.topology.TopologyGraph; |
| 102 | import org.onosproject.net.topology.TopologyListener; | 102 | import org.onosproject.net.topology.TopologyListener; |
| 103 | import org.onosproject.net.topology.TopologyServiceAdapter; | 103 | import org.onosproject.net.topology.TopologyServiceAdapter; |
| 104 | import org.onosproject.net.topology.TopologyVertex; | 104 | import org.onosproject.net.topology.TopologyVertex; |
| 105 | +import org.onosproject.pce.pceservice.PathComputationTest.MockNetConfigRegistryAdapter; | ||
| 105 | import org.onosproject.pce.pceservice.PathComputationTest.MockPathResourceService; | 106 | import org.onosproject.pce.pceservice.PathComputationTest.MockPathResourceService; |
| 106 | import org.onosproject.pce.pceservice.constraint.CostConstraint; | 107 | import org.onosproject.pce.pceservice.constraint.CostConstraint; |
| 107 | import org.onosproject.pce.pcestore.api.PceStore; | 108 | import org.onosproject.pce.pcestore.api.PceStore; |
| 108 | import org.onosproject.pce.util.LabelResourceAdapter; | 109 | import org.onosproject.pce.util.LabelResourceAdapter; |
| 109 | import org.onosproject.pce.util.PceStoreAdapter; | 110 | import org.onosproject.pce.util.PceStoreAdapter; |
| 110 | import org.onosproject.pce.util.TunnelServiceAdapter; | 111 | import org.onosproject.pce.util.TunnelServiceAdapter; |
| 112 | +import org.onosproject.pcep.api.DeviceCapability; | ||
| 111 | import org.onosproject.pce.util.FlowObjServiceAdapter; | 113 | import org.onosproject.pce.util.FlowObjServiceAdapter; |
| 112 | import org.onosproject.store.service.TestStorageService; | 114 | import org.onosproject.store.service.TestStorageService; |
| 113 | 115 | ||
| ... | @@ -130,6 +132,7 @@ public class PceManagerTest { | ... | @@ -130,6 +132,7 @@ public class PceManagerTest { |
| 130 | private TestStorageService storageService = new TestStorageService(); | 132 | private TestStorageService storageService = new TestStorageService(); |
| 131 | private PacketService packetService = new MockPacketService(); | 133 | private PacketService packetService = new MockPacketService(); |
| 132 | private MockDeviceService deviceService = new MockDeviceService(); | 134 | private MockDeviceService deviceService = new MockDeviceService(); |
| 135 | + private MockNetConfigRegistryAdapter netConfigRegistry = new PathComputationTest.MockNetConfigRegistryAdapter(); | ||
| 133 | private MockFlowObjService flowObjectiveService = new MockFlowObjService(); | 136 | private MockFlowObjService flowObjectiveService = new MockFlowObjService(); |
| 134 | private PceStore pceStore = new PceStoreAdapter(); | 137 | private PceStore pceStore = new PceStoreAdapter(); |
| 135 | private LabelResourceService labelResourceService = new LabelResourceAdapter(); | 138 | private LabelResourceService labelResourceService = new LabelResourceAdapter(); |
| ... | @@ -137,13 +140,9 @@ public class PceManagerTest { | ... | @@ -137,13 +140,9 @@ public class PceManagerTest { |
| 137 | public static ProviderId providerId = new ProviderId("pce", "foo"); | 140 | public static ProviderId providerId = new ProviderId("pce", "foo"); |
| 138 | private static final String L3 = "L3"; | 141 | private static final String L3 = "L3"; |
| 139 | private static final String LSRID = "lsrId"; | 142 | private static final String LSRID = "lsrId"; |
| 140 | - private static final String PCECC_CAPABILITY = "pceccCapability"; | ||
| 141 | - private static final String SR_CAPABILITY = "srCapability"; | ||
| 142 | - private static final String LABEL_STACK_CAPABILITY = "labelStackCapability"; | ||
| 143 | 143 | ||
| 144 | private TopologyGraph graph = null; | 144 | private TopologyGraph graph = null; |
| 145 | private Device deviceD1, deviceD2, deviceD3, deviceD4; | 145 | private Device deviceD1, deviceD2, deviceD3, deviceD4; |
| 146 | - private Device pcepDeviceD1, pcepDeviceD2, pcepDeviceD3, pcepDeviceD4; | ||
| 147 | private Link link1, link2, link3, link4; | 146 | private Link link1, link2, link3, link4; |
| 148 | protected static int flowsDownloaded; | 147 | protected static int flowsDownloaded; |
| 149 | private TunnelListener tunnelListener; | 148 | private TunnelListener tunnelListener; |
| ... | @@ -163,6 +162,7 @@ public class PceManagerTest { | ... | @@ -163,6 +162,7 @@ public class PceManagerTest { |
| 163 | pceManager.storageService = storageService; | 162 | pceManager.storageService = storageService; |
| 164 | pceManager.packetService = packetService; | 163 | pceManager.packetService = packetService; |
| 165 | pceManager.deviceService = deviceService; | 164 | pceManager.deviceService = deviceService; |
| 165 | + pceManager.netCfgService = netConfigRegistry; | ||
| 166 | pceManager.labelRsrcService = labelResourceService; | 166 | pceManager.labelRsrcService = labelResourceService; |
| 167 | pceManager.flowObjectiveService = flowObjectiveService; | 167 | pceManager.flowObjectiveService = flowObjectiveService; |
| 168 | pceManager.pceStore = pceStore; | 168 | pceManager.pceStore = pceStore; |
| ... | @@ -231,27 +231,6 @@ public class PceManagerTest { | ... | @@ -231,27 +231,6 @@ public class PceManagerTest { |
| 231 | builderDev4.set(AnnotationKeys.TYPE, L3); | 231 | builderDev4.set(AnnotationKeys.TYPE, L3); |
| 232 | builderDev4.set(LSRID, "4.4.4.4"); | 232 | builderDev4.set(LSRID, "4.4.4.4"); |
| 233 | 233 | ||
| 234 | - if (setSrCap) { | ||
| 235 | - builderDev1.set(SR_CAPABILITY, "true"); | ||
| 236 | - builderDev2.set(SR_CAPABILITY, "true"); | ||
| 237 | - builderDev3.set(SR_CAPABILITY, "true"); | ||
| 238 | - builderDev4.set(SR_CAPABILITY, "true"); | ||
| 239 | - } | ||
| 240 | - | ||
| 241 | - if (setPceccCap) { | ||
| 242 | - builderDev1.set(PCECC_CAPABILITY, "true"); | ||
| 243 | - builderDev2.set(PCECC_CAPABILITY, "true"); | ||
| 244 | - builderDev3.set(PCECC_CAPABILITY, "true"); | ||
| 245 | - builderDev4.set(PCECC_CAPABILITY, "true"); | ||
| 246 | - } | ||
| 247 | - | ||
| 248 | - if (setLabelStackCap) { | ||
| 249 | - builderDev1.set(LABEL_STACK_CAPABILITY, "true"); | ||
| 250 | - builderDev2.set(LABEL_STACK_CAPABILITY, "true"); | ||
| 251 | - builderDev3.set(LABEL_STACK_CAPABILITY, "true"); | ||
| 252 | - builderDev4.set(LABEL_STACK_CAPABILITY, "true"); | ||
| 253 | - } | ||
| 254 | - | ||
| 255 | deviceD1 = new MockDevice(D1.deviceId(), builderDev1.build()); | 234 | deviceD1 = new MockDevice(D1.deviceId(), builderDev1.build()); |
| 256 | deviceD2 = new MockDevice(D2.deviceId(), builderDev2.build()); | 235 | deviceD2 = new MockDevice(D2.deviceId(), builderDev2.build()); |
| 257 | deviceD3 = new MockDevice(D3.deviceId(), builderDev3.build()); | 236 | deviceD3 = new MockDevice(D3.deviceId(), builderDev3.build()); |
| ... | @@ -262,17 +241,29 @@ public class PceManagerTest { | ... | @@ -262,17 +241,29 @@ public class PceManagerTest { |
| 262 | deviceService.addDevice(deviceD3); | 241 | deviceService.addDevice(deviceD3); |
| 263 | deviceService.addDevice(deviceD4); | 242 | deviceService.addDevice(deviceD4); |
| 264 | 243 | ||
| 265 | - pcepDeviceD1 = new MockDevice(DeviceId.deviceId(PathComputationTest.PCEPDEVICE1), builderDev1.build()); | 244 | + DeviceCapability device1Cap = netConfigRegistry.addConfig(DeviceId.deviceId("1.1.1.1"), DeviceCapability.class); |
| 266 | - deviceService.addDevice(pcepDeviceD1); | 245 | + device1Cap.setLabelStackCap(setLabelStackCap) |
| 267 | - | 246 | + .setLocalLabelCap(setPceccCap) |
| 268 | - pcepDeviceD2 = new MockDevice(DeviceId.deviceId(PathComputationTest.PCEPDEVICE2), builderDev1.build()); | 247 | + .setSrCap(setSrCap) |
| 269 | - deviceService.addDevice(pcepDeviceD2); | 248 | + .apply(); |
| 270 | - | 249 | + |
| 271 | - pcepDeviceD3 = new MockDevice(DeviceId.deviceId(PathComputationTest.PCEPDEVICE3), builderDev1.build()); | 250 | + DeviceCapability device2Cap = netConfigRegistry.addConfig(DeviceId.deviceId("2.2.2.2"), DeviceCapability.class); |
| 272 | - deviceService.addDevice(pcepDeviceD3); | 251 | + device2Cap.setLabelStackCap(setLabelStackCap) |
| 273 | - | 252 | + .setLocalLabelCap(setPceccCap) |
| 274 | - pcepDeviceD4 = new MockDevice(DeviceId.deviceId(PathComputationTest.PCEPDEVICE4), builderDev1.build()); | 253 | + .setSrCap(setSrCap) |
| 275 | - deviceService.addDevice(pcepDeviceD4); | 254 | + .apply(); |
| 255 | + | ||
| 256 | + DeviceCapability device3Cap = netConfigRegistry.addConfig(DeviceId.deviceId("3.3.3.3"), DeviceCapability.class); | ||
| 257 | + device3Cap.setLabelStackCap(setLabelStackCap) | ||
| 258 | + .setLocalLabelCap(setPceccCap) | ||
| 259 | + .setSrCap(setSrCap) | ||
| 260 | + .apply(); | ||
| 261 | + | ||
| 262 | + DeviceCapability device4Cap = netConfigRegistry.addConfig(DeviceId.deviceId("4.4.4.4"), DeviceCapability.class); | ||
| 263 | + device4Cap.setLabelStackCap(setLabelStackCap) | ||
| 264 | + .setLocalLabelCap(setPceccCap) | ||
| 265 | + .setSrCap(setSrCap) | ||
| 266 | + .apply(); | ||
| 276 | 267 | ||
| 277 | if (bandwidth != 0) { | 268 | if (bandwidth != 0) { |
| 278 | List<Resource> resources = new LinkedList<>(); | 269 | List<Resource> resources = new LinkedList<>(); | ... | ... |
-
Please register or login to post a comment