Priyanka B
Committed by Gerrit Code Review

[ONOS-4167] Identify the impacted tunnels based on network events, notify to PCE…

… app and trigger MBB flow.

Change-Id: I1766f4afbc0ee2f4c05c75cf788c91f9df8aaa9a
Showing 19 changed files with 323 additions and 28 deletions
......@@ -19,7 +19,6 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.Matchers.nullValue;
import static org.onosproject.net.Link.Type.DIRECT;
import java.util.Iterator;
......@@ -29,7 +28,6 @@ import java.util.LinkedList;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onlab.packet.IpAddress;
import org.onosproject.core.ApplicationId;
import org.onosproject.core.CoreService;
......@@ -165,6 +163,7 @@ public class BasicPceccHandlerTest {
@After
public void tearDown() throws Exception {
PceManagerTest.flowsDownloaded = 0;
}
/**
......
......@@ -129,7 +129,7 @@ public class PceManagerTest {
private Device deviceD1, deviceD2, deviceD3, deviceD4;
private Device pcepDeviceD1, pcepDeviceD2, pcepDeviceD3, pcepDeviceD4;
private Link link1, link2, link3, link4;
private static int flowsDownloaded;
protected static int flowsDownloaded;
private TunnelListener tunnelListener;
@Before
......
......@@ -158,6 +158,7 @@ public class PceccSrTeBeHandlerTest {
@After
public void tearDown() throws Exception {
PceManagerTest.flowsDownloaded = 0;
}
/**
......
/*
* 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.pcep.controller;
import java.util.Objects;
import com.google.common.base.MoreObjects;
/**
* Representation of LSP info, it will be unique for each LSP.
*/
public class LspKey {
private int plspId;
private short localLspId;
/**
* Creates new instance of LspInfo.
*
* @param plspId LSP id assigned per tunnel per session
* @param localLspId LSP id assigned per tunnel
*/
public LspKey(int plspId, short localLspId) {
this.plspId = plspId;
this.localLspId = localLspId;
}
/**
* Obtains PLSP id.
*
* @return LSP id assigned per tunnel per session
*/
public int plspId() {
return plspId;
}
/**
* Obtains local LSP id.
*
* @return LSP id assigned per tunnel
*/
public short localLspId() {
return localLspId;
}
@Override
public int hashCode() {
return Objects.hash(plspId, localLspId);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof LspKey) {
LspKey other = (LspKey) obj;
return Objects.equals(plspId, other.plspId)
&& Objects.equals(localLspId, other.localLspId);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("plspId", plspId)
.add("localLspId", localLspId)
.toString();
}
}
\ No newline at end of file
......@@ -149,4 +149,20 @@ public interface PcepClient {
* @param pccId PCEP client ID
*/
void deleteNode(PccId pccId);
/**
* Sets D flag for the given LSP and its LSP info.
*
* @param lspKey contains LSP info
* @param dFlag delegation flag in LSP object
*/
void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag);
/**
* Returns delegation flag for the given LSP info.
*
* @param lspKey contains LSP info
* @return delegation flag
*/
Boolean delegationInfo(LspKey lspKey);
}
......
......@@ -20,11 +20,13 @@ import java.net.InetSocketAddress;
import java.net.SocketAddress;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepPacketStats;
......@@ -67,6 +69,7 @@ public class PcepClientImpl implements PcepClientDriver {
private byte deadTime;
private byte sessionId;
private PcepPacketStatsImpl pktStats;
private Map<LspKey, Boolean> lspDelegationInfo;
@Override
public void init(PccId pccId, PcepVersion pcepVersion, PcepPacketStats pktStats) {
......@@ -241,6 +244,16 @@ public class PcepClientImpl implements PcepClientDriver {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
@Override
public boolean isOptical() {
return false;
}
......
......@@ -29,14 +29,14 @@ public interface PcepBandwidthObject {
*
* @return bandwidth value
*/
int getBandwidth();
float getBandwidth();
/**
* Sets bandwidth with specified value.
*
* @param iBandwidth Bandwidth's value
*/
void setBandwidth(int iBandwidth);
void setBandwidth(float iBandwidth);
/**
* Writes the BandwidthObject into channel buffer.
......
......@@ -51,6 +51,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
public static final byte BANDWIDTH_OBJ_TYPE = 1;
public static final byte BANDWIDTH_OBJ_CLASS = 5;
public static final byte BANDWIDTH_OBJECT_VERSION = 1;
public static final int NO_OF_BITS = 8;
public static final short BANDWIDTH_OBJ_MINIMUM_LENGTH = 8;
static final PcepObjectHeader DEFAULT_BANDWIDTH_OBJECT_HEADER = new PcepObjectHeader(BANDWIDTH_OBJ_CLASS,
......@@ -58,7 +59,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
BANDWIDTH_OBJ_MINIMUM_LENGTH);
private PcepObjectHeader bandwidthObjHeader;
private int iBandwidth;
private float iBandwidth;
/**
* Constructor to bandwidth object header and bandwidth.
......@@ -66,7 +67,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
* @param bandwidthObjHeader bandwidth object header
* @param iBandwidth bandwidth value
*/
public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, int iBandwidth) {
public PcepBandwidthObjectVer1(PcepObjectHeader bandwidthObjHeader, float iBandwidth) {
this.bandwidthObjHeader = bandwidthObjHeader;
this.iBandwidth = iBandwidth;
}
......@@ -76,7 +77,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
*
* @param iBandwidth bandwidth value
*/
public PcepBandwidthObjectVer1(int iBandwidth) {
public PcepBandwidthObjectVer1(float iBandwidth) {
this.bandwidthObjHeader = DEFAULT_BANDWIDTH_OBJECT_HEADER;
this.iBandwidth = iBandwidth;
}
......@@ -100,12 +101,12 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
}
@Override
public int getBandwidth() {
public float getBandwidth() {
return this.iBandwidth;
}
@Override
public void setBandwidth(int iBandwidth) {
public void setBandwidth(float iBandwidth) {
this.iBandwidth = iBandwidth;
}
......@@ -119,12 +120,25 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
public static PcepBandwidthObject read(ChannelBuffer cb) throws PcepParseException {
PcepObjectHeader bandwidthObjHeader;
int iBandwidth;
float bandwidth;
bandwidthObjHeader = PcepObjectHeader.read(cb);
iBandwidth = cb.readInt();
bandwidth = ieeeToFloatRead(cb.readInt()) * NO_OF_BITS;
return new PcepBandwidthObjectVer1(bandwidthObjHeader, iBandwidth);
return new PcepBandwidthObjectVer1(bandwidthObjHeader, bandwidth);
}
/**
* Parse the IEEE floating point notation and returns it in normal float.
*
* @param iVal IEEE floating point number
* @return normal float
*/
public static float ieeeToFloatRead(int iVal) {
iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8)
| ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF));
return Float.intBitsToFloat(iVal);
}
@Override
......@@ -138,7 +152,7 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject {
throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex);
}
cb.writeInt(iBandwidth);
cb.writeInt(Float.floatToIntBits(iBandwidth));
short hLength = (short) (cb.writerIndex() - objStartIndex);
cb.setShort(objLenIndex, hLength);
//will be helpful during print().
......
......@@ -16,8 +16,10 @@
package org.onosproject.pcepio.protocol.ver1;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.ListIterator;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.onosproject.pcepio.exceptions.PcepParseException;
......@@ -399,10 +401,47 @@ public class PcepEroObjectVer1 implements PcepEroObject {
}
@Override
public int hashCode() {
return Objects.hash(eroObjHeader, subObjectList);
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass()).omitNullValues()
.add("EroObjHeader", eroObjHeader)
.add("SubObjects", subObjectList)
.toString();
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PcepEroObjectVer1) {
int countObjSubTlv = 0;
int countOtherSubTlv = 0;
boolean isCommonSubTlv = true;
PcepEroObjectVer1 other = (PcepEroObjectVer1) obj;
Iterator<PcepValueType> objListIterator = other.subObjectList.iterator();
countOtherSubTlv = other.subObjectList.size();
countObjSubTlv = subObjectList.size();
if (countObjSubTlv != countOtherSubTlv) {
return false;
} else {
while (objListIterator.hasNext() && isCommonSubTlv) {
PcepValueType subTlv = objListIterator.next();
if (subObjectList.contains(subTlv)) {
isCommonSubTlv = Objects.equals(subObjectList.get(subObjectList.indexOf(subTlv)),
other.subObjectList.get(other.subObjectList.indexOf(subTlv)));
} else {
isCommonSubTlv = false;
}
}
return isCommonSubTlv && Objects.equals(eroObjHeader, other.eroObjHeader);
}
}
return false;
}
}
......
......@@ -16,6 +16,8 @@
package org.onosproject.pcepio.types;
import java.util.Objects;
import org.jboss.netty.buffer.ChannelBuffer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
......@@ -212,6 +214,27 @@ public class PcepObjectHeader {
}
@Override
public int hashCode() {
return Objects.hash(objClass, objType, bPFlag, bIFlag, objLen);
}
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj instanceof PcepObjectHeader) {
PcepObjectHeader other = (PcepObjectHeader) obj;
return Objects.equals(objClass, other.objClass)
&& Objects.equals(objType, other.objType)
&& Objects.equals(bPFlag, other.bPFlag)
&& Objects.equals(bIFlag, other.bIFlag)
&& Objects.equals(objLen, other.objLen);
}
return false;
}
@Override
public String toString() {
return MoreObjects.toStringHelper(getClass())
.add("ObjectClass", objClass)
......
......@@ -17,12 +17,15 @@ package org.onosproject.provider.pcep.topology.impl;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepSyncStatus;
import org.onosproject.pcepio.protocol.PcepFactories;
......@@ -45,6 +48,7 @@ public class PcepClientAdapter implements PcepClient {
private PcepVersion pcepVersion;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
/**
* Initialize instance with specified parameters.
......@@ -147,4 +151,14 @@ public class PcepClientAdapter implements PcepClient {
@Override
public void deleteNode(PccId pccId) {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
}
......
......@@ -17,11 +17,14 @@ package org.onosproject.provider.pcep.tunnel.impl;
import static org.junit.Assert.assertNotNull;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.RejectedExecutionException;
import org.jboss.netty.channel.Channel;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepSyncStatus;
......@@ -45,6 +48,7 @@ public class PcepClientAdapter implements PcepClient {
private PcepVersion pcepVersion;
private PcepSyncStatus lspDbSyncStatus;
private PcepSyncStatus labelDbSyncStatus;
private Map<LspKey, Boolean> lspDelegationInfo = new HashMap<>();
/**
* Initialize instance with specified parameters.
......@@ -147,4 +151,14 @@ public class PcepClientAdapter implements PcepClient {
@Override
public void deleteNode(PccId pccId) {
}
@Override
public void setLspAndDelegationInfo(LspKey lspKey, boolean dFlag) {
lspDelegationInfo.put(lspKey, dFlag);
}
@Override
public Boolean delegationInfo(LspKey lspKey) {
return lspDelegationInfo.get(lspKey);
}
}
......
......@@ -24,8 +24,6 @@ import java.util.concurrent.ConcurrentHashMap;
import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Deactivate;
import org.onlab.packet.IpAddress;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcep.controller.PcepClient;
import org.onosproject.pcep.controller.PcepClientController;
......@@ -75,16 +73,11 @@ public class PcepClientControllerAdapter implements PcepClientController {
@Override
public PcepClient getClient(PccId pccId) {
if (null != connectedClients.get(pccId)) {
if (connectedClients.get(pccId) != null) {
return connectedClients.get(pccId);
}
PcepClientAdapter pc = new PcepClientAdapter();
if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
|| pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
pc.setCapability(new ClientCapability(true, false, false, false, false));
} else {
pc.setCapability(new ClientCapability(true, true, true, false, false));
}
pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
connectedClients.put(pccId, pc);
return pc;
......
......@@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
/**
......@@ -64,12 +68,16 @@ public class PcepReleaseTunnelProviderTest {
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Before
public void setUp() throws IOException {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper;
tunnelProvider.cfgService = new ComponentConfigAdapter();
......@@ -125,6 +133,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -179,6 +189,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E22))).setCapability(
new ClientCapability(true, false, false, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
......@@ -233,6 +245,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -287,6 +301,8 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xB6024E20))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -298,5 +314,7 @@ public class PcepReleaseTunnelProviderTest {
tunnelProvider.controller = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
}
}
......
......@@ -40,6 +40,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -49,7 +50,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
/**
* Test for PCEP setup tunnel.
......@@ -62,12 +66,16 @@ public class PcepSetupTunnelProviderTest {
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Before
public void setUp() throws IOException {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.cfgService = new ComponentConfigAdapter();
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.activate();
......@@ -111,6 +119,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -154,6 +164,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010103))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
......@@ -197,6 +209,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -240,6 +254,8 @@ public class PcepSetupTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -251,5 +267,7 @@ public class PcepSetupTunnelProviderTest {
tunnelProvider.controller = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
}
}
......
......@@ -35,6 +35,7 @@ import org.onosproject.incubator.net.tunnel.IpTunnelEndPoint;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.incubator.net.tunnel.TunnelId;
import org.onosproject.incubator.net.tunnel.TunnelName;
import org.onosproject.mastership.MastershipServiceAdapter;
import org.onosproject.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
......@@ -44,7 +45,10 @@ import org.onosproject.net.IpElementId;
import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.device.DeviceServiceAdapter;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.cfg.ComponentConfigAdapter;
public class PcepTunnelProviderTest {
......@@ -55,6 +59,8 @@ public class PcepTunnelProviderTest {
private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter();
private final PcepControllerAdapter ctl = new PcepControllerAdapter();
private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter();
private final DeviceServiceAdapter deviceService = new DeviceServiceAdapter();
private final MastershipServiceAdapter mastershipService = new MastershipServiceAdapter();
@Test
public void testCasePcepSetupTunnel() {
......@@ -62,6 +68,8 @@ public class PcepTunnelProviderTest {
tunnelProvider.tunnelProviderRegistry = registry;
tunnelProvider.pcepClientController = controller;
tunnelProvider.controller = ctl;
tunnelProvider.deviceService = deviceService;
tunnelProvider.mastershipService = mastershipService;
tunnelProvider.cfgService = new ComponentConfigAdapter();
tunnelProvider.tunnelService = tunnelService;
tunnelProvider.activate();
......@@ -99,6 +107,8 @@ public class PcepTunnelProviderTest {
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
controller.getClient(PccId.pccId(IpAddress.valueOf(0xC010101))).setCapability(
new ClientCapability(true, true, true, true, true));
tunnelProvider.setupTunnel(tunnel, path);
......@@ -109,6 +119,8 @@ public class PcepTunnelProviderTest {
public void tearDown() throws IOException {
tunnelProvider.deactivate();
tunnelProvider.controller = null;
tunnelProvider.deviceService = null;
tunnelProvider.mastershipService = null;
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
}
......
......@@ -47,6 +47,10 @@ import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcep.controller.ClientCapability;
import org.onosproject.pcep.controller.LspKey;
import org.onosproject.pcep.controller.PccId;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
......@@ -99,7 +103,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -108,6 +112,8 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
......@@ -124,6 +130,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......@@ -137,7 +149,7 @@ public class PcepUpdateTunnelProviderTest {
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010103);
IpAddress srcIp = IpAddress.valueOf(0xD010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xD010102);
......@@ -151,7 +163,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -161,6 +173,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -176,6 +190,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
}
......@@ -203,7 +223,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -213,6 +233,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -228,6 +250,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......@@ -255,7 +283,7 @@ public class PcepUpdateTunnelProviderTest {
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10024));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
......@@ -265,6 +293,8 @@ public class PcepUpdateTunnelProviderTest {
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.set(PcepAnnotationKeys.PLSP_ID, "1")
.set(PcepAnnotationKeys.LOCAL_LSP_ID, "1")
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
......@@ -280,6 +310,12 @@ public class PcepUpdateTunnelProviderTest {
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
PccId pccId = PccId.pccId(IpAddress.valueOf(0xD010101));
PcepClientAdapter pc = new PcepClientAdapter();
pc.init(pccId, PcepVersion.PCEP_1);
controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true);
controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true));
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
......