Avantika-Huawei

[ONOS-4170] [ONOS-4163] PCE APP side changes : PceManager (code + UT)

Change-Id: I43db98b2fa3c5930b989d4fa3e2c00f7fa65c5ca
(cherry picked from commit dbdf7723)
......@@ -23,13 +23,24 @@ import java.util.List;
import java.util.ListIterator;
import java.util.LinkedList;
import org.onlab.packet.MplsLabel;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.resource.label.DefaultLabelResource;
import org.onosproject.incubator.net.resource.label.LabelResource;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flow.DefaultTrafficSelector;
import org.onosproject.net.flow.DefaultTrafficTreatment;
import org.onosproject.net.flow.TrafficSelector;
import org.onosproject.net.flow.TrafficTreatment;
import org.onosproject.net.flowobjective.DefaultForwardingObjective;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.Objective;
import org.onosproject.pce.pcestore.api.PceStore;
import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
import org.onosproject.pce.pcestore.PceccTunnelInfo;
......@@ -58,6 +69,8 @@ public final class BasicPceccHandler {
private static BasicPceccHandler crHandlerInstance = null;
private LabelResourceService labelRsrcService;
private PceStore pceStore;
private FlowObjectiveService flowObjectiveService;
private ApplicationId appId;
/**
* Initializes default values.
......@@ -83,8 +96,11 @@ public final class BasicPceccHandler {
* @param labelRsrcService label resource service
* @param pceStore pce label store
*/
public void initialize(LabelResourceService labelRsrcService, PceStore pceStore) {
public void initialize(LabelResourceService labelRsrcService, FlowObjectiveService flowObjectiveService,
ApplicationId appId, PceStore pceStore) {
this.labelRsrcService = labelRsrcService;
this.flowObjectiveService = flowObjectiveService;
this.appId = appId;
this.pceStore = pceStore;
}
......@@ -106,8 +122,8 @@ public final class BasicPceccHandler {
if ((linkList != null) && (linkList.size() > 0)) {
// Sequence through reverse order to push local labels into devices
// Generation of labels from egress to ingress
for (ListIterator iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) {
Link link = (Link) iterator.previous();
for (ListIterator<Link> iterator = linkList.listIterator(linkList.size()); iterator.hasPrevious();) {
Link link = iterator.previous();
DeviceId dstDeviceId = link.dst().deviceId();
DeviceId srcDeviceId = link.src().deviceId();
labelRscList = labelRsrcService.applyFromDevicePool(dstDeviceId, applyNum);
......@@ -131,16 +147,14 @@ public final class BasicPceccHandler {
}
// Push into destination device
//TODO: uncomment below lines once installLocalLabelRule() method is ready
// Destination device IN port is link.dst().port()
//installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush,
// LabelType.IN, Objective.Operation.ADD);
installLocalLabelRule(dstDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.ADD);
// Push into source device
//TODO: uncomment below lines once installLocalLabelRule() method is ready
// Source device OUT port will be link.dst().port(). Means its remote port used to send packet.
//installLocalLabelRule(srcDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush,
// LabelType.OUT, Objective.Operation.ADD);
installLocalLabelRule(srcDeviceId, labelId, dstPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.ADD);
// Add or update pcecc tunnel info in pce store.
updatePceccTunnelInfoInStore(srcDeviceId, dstDeviceId, labelId, dstPort,
......@@ -183,7 +197,7 @@ public final class BasicPceccHandler {
if ((lspLabelInfoList != null) && (lspLabelInfoList.size() > 0)) {
for (int i = 0; i < lspLabelInfoList.size(); ++i) {
LspLocalLabelInfo lspLocalLabelInfo =
(DefaultLspLocalLabelInfo) lspLabelInfoList.get(i);
lspLabelInfoList.get(i);
LspLocalLabelInfo.Builder lspLocalLabelInfoBuilder = null;
if (dstDeviceId.equals(lspLocalLabelInfo.deviceId())) {
lspLocalLabelInfoBuilder = DefaultLspLocalLabelInfo.builder(lspLocalLabelInfo);
......@@ -264,7 +278,7 @@ public final class BasicPceccHandler {
List<LspLocalLabelInfo> lspLocalLabelInfoList = pceccTunnelInfo.lspLocalLabelInfoList();
if ((lspLocalLabelInfoList != null) && (lspLocalLabelInfoList.size() > 0)) {
for (Iterator<LspLocalLabelInfo> iterator = lspLocalLabelInfoList.iterator(); iterator.hasNext();) {
LspLocalLabelInfo lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
LspLocalLabelInfo lspLocalLabelInfo = iterator.next();
DeviceId deviceId = lspLocalLabelInfo.deviceId();
LabelResourceId inLabelId = lspLocalLabelInfo.inLabelId();
LabelResourceId outLabelId = lspLocalLabelInfo.outLabelId();
......@@ -278,15 +292,13 @@ public final class BasicPceccHandler {
// Push into device
if ((inLabelId != null) && (inPort != null)) {
//TODO: uncomment below lines once installLocalLabelRule() method is ready
//installLocalLabelRule(deviceId, inLabelId, inPort, tunnelId, isLastLabelToPush,
// LabelType.IN, Objective.Operation.REMOVE);
installLocalLabelRule(deviceId, inLabelId, inPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.IN_LABEL.value), Objective.Operation.REMOVE);
}
if ((outLabelId != null) && (outPort != null)) {
//TODO: uncomment below lines once installLocalLabelRule() method is ready
//installLocalLabelRule(deviceId, outLabelId, outPort, tunnelId, isLastLabelToPush,
// LabelType.OUT, Objective.Operation.REMOVE);
installLocalLabelRule(deviceId, outLabelId, outPort, tunnel.tunnelId(), isLastLabelToPush,
Long.valueOf(LabelType.OUT_LABEL.value), Objective.Operation.REMOVE);
}
// List is stored from egress to ingress. So, using IN label id to release.
......@@ -315,4 +327,35 @@ public final class BasicPceccHandler {
log.error("Unable to find PCECC tunnel info in store for a tunnel {}.", tunnel.toString());
}
}
// Install a rule for pushing local labels to the device which is specific to path.
private void installLocalLabelRule(DeviceId deviceId, LabelResourceId labelId,
PortNumber portNum, TunnelId tunnelId,
Boolean isBos, Long labelType,
Objective.Operation type) {
checkNotNull(flowObjectiveService);
checkNotNull(appId);
TrafficSelector.Builder selectorBuilder = DefaultTrafficSelector.builder();
selectorBuilder.matchMplsLabel(MplsLabel.mplsLabel(labelId.id().intValue()));
selectorBuilder.matchInPort(portNum);
selectorBuilder.matchTunnelId(Long.parseLong(tunnelId.id()));
selectorBuilder.matchMplsBos(isBos);
selectorBuilder.matchMetadata(labelType);
TrafficTreatment treatment = DefaultTrafficTreatment.builder().build();
ForwardingObjective.Builder forwardingObjective = DefaultForwardingObjective.builder()
.withSelector(selectorBuilder.build())
.withTreatment(treatment)
.withFlag(ForwardingObjective.Flag.VERSATILE)
.fromApp(appId)
.makePermanent();
if (type.equals(Objective.Operation.ADD)) {
flowObjectiveService.forward(deviceId, forwardingObjective.add());
} else {
flowObjectiveService.forward(deviceId, forwardingObjective.remove());
}
}
}
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.pceservice;
/**
* Collection of keys for annotation for PCEP tunnels.
*/
public final class PcepAnnotationKeys {
/**
* Prohibits instantiation.
*/
private PcepAnnotationKeys() {
}
/**
* Annotation key for bandwidth.
* The value for this key is interpreted as Mbps.
*/
public static final String BANDWIDTH = "bandwidth";
/**
* Annotation key for the LSP signaling type.
*/
public static final String LSP_SIG_TYPE = "lspSigType";
/**
* Annotation key for the PCC tunnel id.
*/
public static final String PCC_TUNNEL_ID = "PccTunnelId";
/**
* Annotation key for the LSP id assigned per tunnel per session.
*/
public static final String PLSP_ID = "PLspId";
/**
* Annotation key for the LSP id assigned per tunnel.
*/
public static final String LOCAL_LSP_ID = "localLspId";
/**
* Annotation key for the identification of initiated LSP.
*/
public static final String PCE_INIT = "pceInit";
/**
* Annotation key for the cost type.
*/
public static final String COST_TYPE = "costType";
/**
* Annotation key for the Delegation.
* Whether LSPs are delegated or not.
*/
public static final String DELEGATE = "delegate";
}
......@@ -15,6 +15,7 @@
*/
package org.onosproject.pce.pceservice;
import org.onlab.util.Identifier;
import org.onosproject.net.resource.ResourceConsumer;
import com.google.common.annotations.Beta;
......@@ -25,9 +26,7 @@ import org.onosproject.net.resource.ResourceConsumerId;
* resource allocations.
*/
@Beta
public final class TunnelConsumerId implements ResourceConsumer {
private final long value;
public final class TunnelConsumerId extends Identifier<Long> implements ResourceConsumer {
/**
* Creates a tunnel resource consumer identifier from the specified long value.
......@@ -43,7 +42,7 @@ public final class TunnelConsumerId implements ResourceConsumer {
* Initializes object for serializer.
*/
public TunnelConsumerId() {
this.value = 0;
super(0L);
}
/**
......@@ -54,43 +53,25 @@ public final class TunnelConsumerId implements ResourceConsumer {
* resource consumer id
*/
public TunnelConsumerId(long value) {
this.value = value;
super(value);
}
/**
* Returns the tunnel resource consumer id value in long format.
* Returns the backing identifier value.
*
* @return value the tunnel resource consumer id's long value
* @return value backing identifier value
*/
public long value() {
return value;
}
@Override
public int hashCode() {
return Long.hashCode(value);
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (!(obj instanceof TunnelConsumerId)) {
return false;
}
TunnelConsumerId that = (TunnelConsumerId) obj;
return this.value == that.value;
return identifier;
}
@Override
public String toString() {
return "0x" + Long.toHexString(value);
return "0x" + Long.toHexString(identifier);
}
@Override
public ResourceConsumerId consumerId() {
// TODO
return null;
return ResourceConsumerId.of(this);
}
}
......
/*
* Copyright 2016 Open Networking Laboratory
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
......
......@@ -31,6 +31,8 @@ import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.core.DefaultGroupId;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
......@@ -45,11 +47,11 @@ import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.Path;
import org.onosproject.pce.pcestore.api.LspLocalLabelInfo;
import org.onosproject.pce.pcestore.api.PceStore;
import org.onosproject.pce.pcestore.PceccTunnelInfo;
import org.onosproject.pce.pcestore.DefaultLspLocalLabelInfo;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pce.util.LabelResourceAdapter;
import org.onosproject.pce.util.PceStoreAdapter;
......@@ -67,6 +69,9 @@ public class BasicPceccHandlerTest {
private BasicPceccHandler pceccHandler;
protected LabelResourceService labelRsrcService;
protected PceStore pceStore;
private FlowObjectiveService flowObjectiveService;
private CoreService coreService;
private ApplicationId appId;
private TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(23423));
private TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf(32421));
private DefaultGroupId groupId = new DefaultGroupId(92034);
......@@ -92,7 +97,10 @@ public class BasicPceccHandlerTest {
pceccHandler = BasicPceccHandler.getInstance();
labelRsrcService = new LabelResourceAdapter();
pceStore = new PceStoreAdapter();
pceccHandler.initialize(labelRsrcService, pceStore);
flowObjectiveService = new PceManagerTest.MockFlowObjService();
coreService = new PceManagerTest.MockCoreService();
appId = coreService.registerApplication("org.onosproject.pce");
pceccHandler.initialize(labelRsrcService, flowObjectiveService, appId, pceStore);
// Cretae tunnel test
// Link
......@@ -190,7 +198,7 @@ public class BasicPceccHandlerTest {
iterator = lspLocalLabelInfoList.iterator();
// Retrieve values and check device5
lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
lspLocalLabelInfo = iterator.next();
deviceId = lspLocalLabelInfo.deviceId();
inLabelId = lspLocalLabelInfo.inLabelId();
outLabelId = lspLocalLabelInfo.outLabelId();
......@@ -205,7 +213,7 @@ public class BasicPceccHandlerTest {
// Next element check
// Retrieve values and check device4
lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
lspLocalLabelInfo = iterator.next();
deviceId = lspLocalLabelInfo.deviceId();
inLabelId = lspLocalLabelInfo.inLabelId();
outLabelId = lspLocalLabelInfo.outLabelId();
......@@ -220,7 +228,7 @@ public class BasicPceccHandlerTest {
// Next element check
// Retrieve values and check device3
lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
lspLocalLabelInfo = iterator.next();
deviceId = lspLocalLabelInfo.deviceId();
inLabelId = lspLocalLabelInfo.inLabelId();
outLabelId = lspLocalLabelInfo.outLabelId();
......@@ -235,7 +243,7 @@ public class BasicPceccHandlerTest {
// Next element check
// Retrieve values and check device2
lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
lspLocalLabelInfo = iterator.next();
deviceId = lspLocalLabelInfo.deviceId();
inLabelId = lspLocalLabelInfo.inLabelId();
outLabelId = lspLocalLabelInfo.outLabelId();
......@@ -250,7 +258,7 @@ public class BasicPceccHandlerTest {
// Next element check
// Retrieve values and check device1
lspLocalLabelInfo = (DefaultLspLocalLabelInfo) iterator.next();
lspLocalLabelInfo = iterator.next();
deviceId = lspLocalLabelInfo.deviceId();
inLabelId = lspLocalLabelInfo.inLabelId();
outLabelId = lspLocalLabelInfo.outLabelId();
......
......@@ -96,20 +96,20 @@ public class PathComputationTest {
private final MockDeviceService deviceService = new MockDeviceService();
private PceManager pceManager = new PceManager();
public static ProviderId providerId = new ProviderId("pce", "foo");
private static final String DEVICE1 = "D001";
private static final String DEVICE2 = "D002";
private static final String DEVICE3 = "D003";
private static final String DEVICE4 = "D004";
private static final String DEVICE5 = "D005";
public static final String DEVICE1 = "D001";
public static final String DEVICE2 = "D002";
public static final String DEVICE3 = "D003";
public static final String DEVICE4 = "D004";
public static final String DEVICE5 = "D005";
public static final String PCEPDEVICE1 = "PD001";
public static final String PCEPDEVICE2 = "PD002";
public static final String PCEPDEVICE3 = "PD003";
public static final String PCEPDEVICE4 = "PD004";
private static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001"));
private static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002"));
private static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003"));
private static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004"));
private static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005"));
public static final TopologyVertex D1 = new DefaultTopologyVertex(DeviceId.deviceId("D001"));
public static final TopologyVertex D2 = new DefaultTopologyVertex(DeviceId.deviceId("D002"));
public static final TopologyVertex D3 = new DefaultTopologyVertex(DeviceId.deviceId("D003"));
public static final TopologyVertex D4 = new DefaultTopologyVertex(DeviceId.deviceId("D004"));
public static final TopologyVertex D5 = new DefaultTopologyVertex(DeviceId.deviceId("D005"));
private static final String ANNOTATION_COST = "cost";
private static final String ANNOTATION_TE_COST = "teCost";
private static final String UNKNOWN = "unknown";
......@@ -130,7 +130,7 @@ public class PathComputationTest {
*
* @return graph path search algorithm
*/
private AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() {
public static AbstractGraphPathSearch<TopologyVertex, TopologyEdge> graphSearch() {
return new DijkstraGraphSearch<>();
}
......@@ -143,7 +143,7 @@ public class PathComputationTest {
* @param port2 destination port
* @return link
*/
private Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) {
public static Link addLink(String device, long port, String device2, long port2, boolean setCost, int value) {
ConnectPoint src = new ConnectPoint(DeviceId.deviceId(device), PortNumber.portNumber(port));
ConnectPoint dst = new ConnectPoint(DeviceId.deviceId(device2), PortNumber.portNumber(port2));
Link curLink;
......@@ -256,19 +256,37 @@ public class PathComputationTest {
}
}
private Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) {
/**
* Returns the path in Path object format.
*/
public static Path networkPath(org.onlab.graph.Path<TopologyVertex, TopologyEdge> path) {
List<Link> links = path.edges().stream().map(TopologyEdge::link).collect(Collectors.toList());
return new DefaultPath(CORE_PROVIDER_ID, links, path.cost());
}
/**
* Test Resource service for path computation.
* Tests Resource service for path computation.
*/
private class MockPathResourceService extends ResourceServiceAdapter {
public class MockPathResourceService extends ResourceServiceAdapter {
private final Map<Resource, ResourceConsumer> assignment = new HashMap<>();
private Map<ResourceId, List<ResourceAllocation>> resourcesAllocations = new HashMap<>();
@Override
public Optional<ResourceAllocation> allocate(ResourceConsumer consumer, Resource resources) {
List<ResourceAllocation> allocations = allocate(consumer, ImmutableList.of(resources));
if (allocations.isEmpty()) {
return Optional.empty();
}
assert allocations.size() == 1;
ResourceAllocation allocation = allocations.get(0);
assert allocation.resource().equals(resources);
// cast is ensured by the assertions above
return Optional.of(allocation);
}
@Override
public List<ResourceAllocation> allocate(ResourceConsumer consumer, List<Resource> resources) {
for (Resource resource: resources) {
if (resource instanceof ContinuousResource) {
......
......@@ -33,6 +33,8 @@ import org.junit.Before;
import org.junit.Test;
import org.onosproject.incubator.net.resource.label.LabelResourceId;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
import org.onosproject.incubator.net.resource.label.LabelResourceAdminService;
import org.onosproject.incubator.net.resource.label.LabelResourceService;
import org.onosproject.incubator.net.tunnel.LabelStack;
......@@ -41,6 +43,7 @@ import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.DeviceId;
import org.onosproject.net.PortNumber;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.Path;
import org.onosproject.pce.pcestore.api.PceStore;
import org.onosproject.net.provider.ProviderId;
......@@ -61,6 +64,9 @@ public class PceccSrTeBeHandlerTest {
protected LabelResourceAdminService labelRsrcAdminService;
protected LabelResourceService labelRsrcService;
protected PceStore pceStore;
private FlowObjectiveService flowObjectiveService;
private CoreService coreService;
private ApplicationId appId;
private ProviderId providerId;
private DeviceId deviceId1;
private DeviceId deviceId2;
......@@ -88,8 +94,11 @@ public class PceccSrTeBeHandlerTest {
srTeHandler = PceccSrTeBeHandler.getInstance();
labelRsrcService = new LabelResourceAdapter();
labelRsrcAdminService = new LabelResourceAdapter();
flowObjectiveService = new PceManagerTest.MockFlowObjService();
coreService = new PceManagerTest.MockCoreService();
appId = coreService.registerApplication("org.onosproject.pce");
pceStore = new PceStoreAdapter();
srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, pceStore);
srTeHandler.initialize(labelRsrcAdminService, labelRsrcService, flowObjectiveService, appId, pceStore);
// Creates path
// Creates list of links
......@@ -446,39 +455,39 @@ public class PceccSrTeBeHandlerTest {
// check node-label of deviceId1
List<LabelResourceId> labelList = labelStack.labelResources();
Iterator<LabelResourceId> iterator = labelList.iterator();
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(4097)));
// check adjacency label of deviceId1
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(5122)));
// check node-label of deviceId2
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(4098)));
// check adjacency label of deviceId2
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(5123)));
// check node-label of deviceId3
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(4099)));
// check adjacency label of deviceId3
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(5124)));
// check node-label of deviceId4
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(4100)));
// check adjacency label of deviceId4
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(5125)));
// check node-label of deviceId5
labelId = (LabelResourceId) iterator.next();
labelId = iterator.next();
assertThat(labelId, is(LabelResourceId.labelResourceId(4101)));
}
}
......
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.util;
import java.util.List;
import org.onosproject.net.DeviceId;
import org.onosproject.net.flowobjective.FilteringObjective;
import org.onosproject.net.flowobjective.FlowObjectiveService;
import org.onosproject.net.flowobjective.ForwardingObjective;
import org.onosproject.net.flowobjective.NextObjective;
/**
* Test implementation of FlowObjectiveService.
*/
public class FlowObjServiceAdapter implements FlowObjectiveService {
private ForwardingObjective forwardingObjective;
@Override
public void filter(DeviceId deviceId, FilteringObjective filteringObjective) {
}
@Override
public void forward(DeviceId deviceId, ForwardingObjective forwardingObjective) {
this.forwardingObjective = forwardingObjective;
}
@Override
public void next(DeviceId deviceId, NextObjective nextObjective) {
}
@Override
public int allocateNextId() {
return 0;
}
@Override
public void initPolicy(String policy) {
}
public ForwardingObjective forwardingObjective() {
return forwardingObjective;
}
@Override
public List<String> getNextMappings() {
return null;
}
}
/*
* Copyright 2016-present Open Networking Laboratory
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.onosproject.pce.util;
import java.util.Collection;
import org.onosproject.core.ApplicationId;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.Tunnel.Type;
import org.onosproject.incubator.net.tunnel.TunnelEndPoint;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelListener;
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.incubator.net.tunnel.TunnelService;
import org.onosproject.incubator.net.tunnel.TunnelSubscription;
import org.onosproject.net.Annotations;
import org.onosproject.net.DeviceId;
import org.onosproject.net.ElementId;
import org.onosproject.net.Path;
/**
* Provides test implementation of class TunnelService.
*/
public class TunnelServiceAdapter implements TunnelService {
@Override
public void addListener(TunnelListener listener) {
// TODO Auto-generated method stub
}
@Override
public void removeListener(TunnelListener listener) {
// TODO Auto-generated method stub
}
@Override
public Tunnel borrowTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelName tunnelName,
Annotations... annotations) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
Annotations... annotations) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> borrowTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type,
Annotations... annotations) {
// TODO Auto-generated method stub
return null;
}
@Override
public TunnelId setupTunnel(ApplicationId producerId, ElementId srcElementId, Tunnel tunnel, Path path) {
// TODO Auto-generated method stub
return null;
}
@Override
public boolean downTunnel(ApplicationId producerId, TunnelId tunnelId) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean returnTunnel(ApplicationId consumerId, TunnelId tunnelId, Annotations... annotations) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean returnTunnel(ApplicationId consumerId, TunnelName tunnelName, Annotations... annotations) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst, Type type,
Annotations... annotations) {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean returnTunnel(ApplicationId consumerId, TunnelEndPoint src, TunnelEndPoint dst,
Annotations... annotations) {
// TODO Auto-generated method stub
return false;
}
@Override
public Tunnel queryTunnel(TunnelId tunnelId) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> queryTunnel(Type type) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
// TODO Auto-generated method stub
return null;
}
@Override
public Collection<Tunnel> queryAllTunnels() {
// TODO Auto-generated method stub
return null;
}
@Override
public int tunnelCount() {
// TODO Auto-generated method stub
return 0;
}
@Override
public Iterable<Tunnel> getTunnels(DeviceId deviceId) {
// TODO Auto-generated method stub
return null;
}
}
......@@ -56,4 +56,15 @@ public final class PcepAnnotationKeys {
* Annotation key for the identification of initiated LSP.
*/
public static final String PCE_INIT = "pceInit";
/**
* Annotation key for the cost type.
*/
public static final String COST_TYPE = "costType";
/**
* Annotation key for the Delegation.
* Whether LSPs are delegated or not
*/
public static final String DELEGATE = "delegate";
}
......