Avantika-Huawei
Committed by Gerrit Code Review

[ONOS-4163] Provider side changes to support stateful PCE and PCECC

Change-Id: I0a57ed1d1e505a2e94921fd5f5d92426a105ad12
Showing 20 changed files with 780 additions and 57 deletions
......@@ -52,6 +52,8 @@ import org.onosproject.pcepio.protocol.PcepOpenMsg;
import org.onosproject.pcepio.protocol.PcepOpenObject;
import org.onosproject.pcepio.protocol.PcepType;
import org.onosproject.pcepio.protocol.PcepVersion;
import org.onosproject.pcepio.types.IPv4RouterIdOfLocalNodeSubTlv;
import org.onosproject.pcepio.types.NodeAttributesTlv;
import org.onosproject.pcepio.types.PceccCapabilityTlv;
import org.onosproject.pcepio.types.StatefulPceCapabilityTlv;
import org.onosproject.pcepio.types.PcepErrorDetailInfo;
......@@ -136,7 +138,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
@Override
void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
log.debug("Message received in OPEN WAIT State");
log.info("Message received in OPEN WAIT State");
//check for open message
if (m.getType() != PcepType.OPEN) {
......@@ -166,6 +168,33 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
h.deadTime = DEADTIMER_MAXIMUM_VALUE;
}
}
LinkedList<PcepValueType> optionalTlvs = pOpenmsg.getPcepOpenObject().getOptionalTlv();
for (PcepValueType optionalTlv : optionalTlvs) {
if (optionalTlv instanceof NodeAttributesTlv) {
List<PcepValueType> subTlvs = ((NodeAttributesTlv) optionalTlv)
.getllNodeAttributesSubTLVs();
for (PcepValueType subTlv : subTlvs) {
if (subTlv instanceof IPv4RouterIdOfLocalNodeSubTlv) {
h.thispccId = PccId.pccId(IpAddress
.valueOf(((IPv4RouterIdOfLocalNodeSubTlv) subTlv).getInt()));
break;
}
}
break;
}
}
if (h.thispccId == null) {
final SocketAddress address = h.channel.getRemoteAddress();
if (!(address instanceof InetSocketAddress)) {
throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
}
final InetSocketAddress inetAddress = (InetSocketAddress) address;
h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
}
h.sendHandshakeOpenMessage();
h.pcepPacketStats.addOutPacket();
h.setState(KEEPWAIT);
......@@ -178,23 +207,16 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler {
KEEPWAIT(false) {
@Override
void processPcepMessage(PcepChannelHandler h, PcepMessage m) throws IOException, PcepParseException {
log.debug("message received in KEEPWAIT state");
log.info("message received in KEEPWAIT state");
//check for keep alive message
if (m.getType() != PcepType.KEEP_ALIVE) {
// When the message type is not keep alive message increment the wrong packet statistics
h.processUnknownMsg();
log.debug("message is not KEEPALIVE message");
log.error("message is not KEEPALIVE message");
} else {
// Set the client connected status
h.pcepPacketStats.addInPacket();
final SocketAddress address = h.channel.getRemoteAddress();
if (!(address instanceof InetSocketAddress)) {
throw new IOException("Invalid client connection. Pcc is indentifed based on IP");
}
log.debug("sending keep alive message in KEEPWAIT state");
final InetSocketAddress inetAddress = (InetSocketAddress) address;
h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress()));
h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion,
h.pcepPacketStats);
//Get pc instance and set capabilities
......
......@@ -25,7 +25,7 @@ import org.onosproject.pcepio.protocol.PcepLspObject;
import org.onosproject.pcepio.types.PcepErrorDetailInfo;
import org.onosproject.pcepio.types.PcepObjectHeader;
import org.onosproject.pcepio.types.PcepValueType;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import org.onosproject.pcepio.types.StatefulLspDbVerTlv;
import org.onosproject.pcepio.types.StatefulLspErrorCodeTlv;
import org.onosproject.pcepio.types.StatefulRsvpErrorSpecTlv;
......@@ -325,8 +325,8 @@ public class PcepLspObjectVer1 implements PcepLspObject {
switch (hType) {
case StatefulIPv4LspIdentidiersTlv.TYPE:
tlv = StatefulIPv4LspIdentidiersTlv.read(cb);
case StatefulIPv4LspIdentifiersTlv.TYPE:
tlv = StatefulIPv4LspIdentifiersTlv.read(cb);
break;
case StatefulLspErrorCodeTlv.TYPE:
iValue = cb.readInt();
......
......@@ -45,7 +45,7 @@ public class PathSetupTypeTlv implements PcepValueType {
*/
protected static final Logger log = LoggerFactory.getLogger(PathSetupTypeTlv.class);
public static final short TYPE = 0; //TODO : need to reassign the value as per RFC
public static final short TYPE = 28;
public static final short LENGTH = 4;
private final byte pst;
......
......@@ -28,7 +28,7 @@ import com.google.common.base.MoreObjects;
/**
* Provides StatefulIPv4LspIdentidiersTlv.
*/
public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
public class StatefulIPv4LspIdentifiersTlv implements PcepValueType {
/* IPV4-LSP-IDENTIFIERS TLV format
*
......@@ -50,7 +50,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
*/
protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentidiersTlv.class);
protected static final Logger log = LoggerFactory.getLogger(StatefulIPv4LspIdentifiersTlv.class);
public static final short TYPE = 18;
public static final short LENGTH = 16;
......@@ -70,7 +70,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
* @param extendedTunnelId extended tunnel id
* @param ipv4EgressAddress egress ipv4 address
*/
public StatefulIPv4LspIdentidiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
public StatefulIPv4LspIdentifiersTlv(int ipv4IngressAddress, short lspId, short tunnelId, int extendedTunnelId,
int ipv4EgressAddress) {
this.ipv4IngressAddress = ipv4IngressAddress;
......@@ -90,9 +90,9 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
* @param ipv4EgressAddress egress ipv4 address
* @return object of StatefulIPv4LspIdentidiersTlv
*/
public static StatefulIPv4LspIdentidiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
public static StatefulIPv4LspIdentifiersTlv of(int ipv4IngressAddress, short lspId, short tunnelId,
int extendedTunnelId, int ipv4EgressAddress) {
return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
ipv4EgressAddress);
}
......@@ -106,6 +106,15 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
}
/**
* Returns LSP id.
*
* @return lspId
*/
public short getLspId() {
return this.lspId;
}
/**
* Returns extendedTunnelId.
*
* @return extendedTunnelId
......@@ -157,8 +166,8 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
if (this == obj) {
return true;
}
if (obj instanceof StatefulIPv4LspIdentidiersTlv) {
StatefulIPv4LspIdentidiersTlv other = (StatefulIPv4LspIdentidiersTlv) obj;
if (obj instanceof StatefulIPv4LspIdentifiersTlv) {
StatefulIPv4LspIdentifiersTlv other = (StatefulIPv4LspIdentifiersTlv) obj;
return Objects.equals(this.ipv4IngressAddress, other.ipv4IngressAddress)
&& Objects.equals(this.lspId, other.lspId) && Objects.equals(this.tunnelId, other.tunnelId)
&& Objects.equals(this.extendedTunnelId, other.extendedTunnelId)
......@@ -193,7 +202,7 @@ public class StatefulIPv4LspIdentidiersTlv implements PcepValueType {
short tunnelId = c.readShort();
int extendedTunnelId = c.readInt();
int ipv4EgressAddress = c.readInt();
return new StatefulIPv4LspIdentidiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
return new StatefulIPv4LspIdentifiersTlv(ipv4IngressAddress, lspId, tunnelId, extendedTunnelId,
ipv4EgressAddress);
}
......
......@@ -555,4 +555,40 @@ public class PcepOpenMsgTest {
assertThat(testOpenMsg, is(openMsg));
}
/**
* This test case checks open object with LSR id encoded.
*/
@Test
public void openMessageTest16() throws PcepParseException, PcepOutOfBoundMessageException {
byte[] openMsg = new byte[] {0x20, 0x01, 0x00, 0x18, // common header
0x01, 0x10, 0x00, 0x14, // common object header
0x20, 0x05, 0x1E, 0x01, // OPEN object
(byte) 0xFF, 0x05, 0x00, 0x08, // Node attribute TLV
0x00, 0x11, 0x00, 0x04, // PCEP-LS-IPv4-ROUTER-ID sub tlv
0x02, 0x02, 0x02, 0x02
};
byte[] testOpenMsg = {0};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(openMsg);
PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
PcepMessage message = null;
message = reader.readFrom(buffer);
assertThat(message, instanceOf(PcepOpenMsg.class));
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
message.writeTo(buf);
testOpenMsg = buf.array();
int readLen = buf.writerIndex() - 0;
testOpenMsg = new byte[readLen];
buf.readBytes(testOpenMsg, 0, readLen);
assertThat(testOpenMsg, is(openMsg));
}
}
......
......@@ -184,14 +184,14 @@ public class PcepReportMsgExtTest {
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00,
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
0x09, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, //LSPA object
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x05, 0x20, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, //Bandwidth object
0x06, 0x10, 0x00, 0x0c, 0x00, 0x00, 0x01, 0x03, 0x00, 0x00, 0x00, 0x20, //Metric object
0x08, 0x10, 0x00, 0x34, 0x01, 0x08, 0x11, 0x01, //RRO object
0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01,
0x01, 0x01, 0x04, 0x00, 0x01, 0x08, 0x11, 0x01, //RRO IPv4 subobjects
0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x06, 0x06,
0x06, 0x06, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
0x01, 0x02, 0x04, 0x00, 0x01, 0x08, 0x12, 0x01,
......@@ -216,4 +216,83 @@ public class PcepReportMsgExtTest {
assertThat(testReportMsg, is(reportMsg));
}
/**
* Tests PCRpt msg with Path-Setup-Type TLV as SR.
*
* @throws PcepParseException
* @throws PcepOutOfBoundMessageException
*/
@Test
public void reportMessageTest43() throws PcepParseException, PcepOutOfBoundMessageException {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
0x00, 0x00, 0x00, 0x01,
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
};
byte[] testReportMsg = {0};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(reportMsg);
PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
PcepMessage message = null;
message = reader.readFrom(buffer);
assertThat(message, instanceOf(PcepReportMsg.class));
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
message.writeTo(buf);
int readLen = buf.writerIndex();
testReportMsg = new byte[readLen];
buf.readBytes(testReportMsg, 0, readLen);
assertThat(testReportMsg, is(reportMsg));
}
/**
* Tests PCRpt msg with Path-Setup-Type TLV as "without SR and without signalling".
*
* @throws PcepParseException
* @throws PcepOutOfBoundMessageException
*/
@Test
public void reportMessageTest44() throws PcepParseException, PcepOutOfBoundMessageException {
byte[] reportMsg = new byte[] {0x20, 0x0a, 0x00, (byte) 0x3C,
0x21, 0x10, 0x00, 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, //SRP object
0x00, 0x1c, 0x00, 0x04, // PATH-SETUP-TYPE TLV
0x00, 0x00, 0x00, 0x02,
0x20, 0x10, 0x00, 0x10, 0x00, 0x00, 0x10, 0x03, //LSP object
0x00, 0x11, 0x00, 0x02, 0x54, 0x31, 0x00, 0x00, //symbolic path tlv
0x07, 0x10, 0x00, 0x14, //ERO object
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x1f, 0x04, 0x00, //ERO IPv4 subobjects
0x01, 0x08, (byte) 0xb6, 0x02, 0x4e, 0x20, 0x04, 0x00,
};
byte[] testReportMsg = {0};
ChannelBuffer buffer = ChannelBuffers.dynamicBuffer();
buffer.writeBytes(reportMsg);
PcepMessageReader<PcepMessage> reader = PcepFactories.getGenericReader();
PcepMessage message = null;
message = reader.readFrom(buffer);
assertThat(message, instanceOf(PcepReportMsg.class));
ChannelBuffer buf = ChannelBuffers.dynamicBuffer();
message.writeTo(buf);
int readLen = buf.writerIndex();
testReportMsg = new byte[readLen];
buf.readBytes(testReportMsg, 0, readLen);
assertThat(testReportMsg, is(reportMsg));
}
}
......
......@@ -18,7 +18,10 @@ package org.onosproject.pcepio.types;
import com.google.common.testing.EqualsTester;
import org.junit.Test;
public class StatefulIPv4LspIdentidiersTlvTest {
/**
* Tests class StatefulIPv4LspIdentifiersTlv.
*/
public class StatefulIPv4LspIdentifiersTlvTest {
private final int ipv4IngressAddress = 1;
private final short lspId = 1;
......@@ -26,7 +29,7 @@ public class StatefulIPv4LspIdentidiersTlvTest {
private final int extendedTunnelId = 1;
private final int ipv4EgressAddress = 1;
private final StatefulIPv4LspIdentidiersTlv tlv1 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress, lspId,
private final StatefulIPv4LspIdentifiersTlv tlv1 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress, lspId,
tunnelId, extendedTunnelId, ipv4EgressAddress);
private final int ipv4IngressAddress1 = 1;
......@@ -35,7 +38,7 @@ public class StatefulIPv4LspIdentidiersTlvTest {
private final int extendedTunnelId1 = 1;
private final int ipv4EgressAddress1 = 1;
private final StatefulIPv4LspIdentidiersTlv tlv2 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress1, lspId1,
private final StatefulIPv4LspIdentifiersTlv tlv2 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress1, lspId1,
tunnelId1, extendedTunnelId1, ipv4EgressAddress1);
private final int ipv4IngressAddress2 = 2;
......@@ -44,9 +47,12 @@ public class StatefulIPv4LspIdentidiersTlvTest {
private final int extendedTunnelId2 = 2;
private final int ipv4EgressAddress2 = 2;
private final StatefulIPv4LspIdentidiersTlv tlv3 = StatefulIPv4LspIdentidiersTlv.of(ipv4IngressAddress2, lspId2,
private final StatefulIPv4LspIdentifiersTlv tlv3 = StatefulIPv4LspIdentifiersTlv.of(ipv4IngressAddress2, lspId2,
tunnelId2, extendedTunnelId2, ipv4EgressAddress2);
/**
* Tests equality of objects of class StatefulIPv4LspIdentifiersTlv.
*/
@Test
public void basics() {
new EqualsTester().addEqualityGroup(tlv1, tlv2).addEqualityGroup(tlv3).testEquals();
......
/*
* 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.provider.pcep.tunnel.impl;
/**
* Representation of LSP type.
*/
public enum LspType {
/**
* Signifies that path is created via signaling mode.
*/
WITH_SIGNALLING(0),
/**
* Signifies that path is created via SR mode.
*/
SR_WITHOUT_SIGNALLING(1),
/**
* Signifies that path is created via without signaling and without SR mode.
*/
WITHOUT_SIGNALLING_AND_WITHOUT_SR(2);
int value;
/**
* Assign val with the value as the LSP type.
*
* @param val LSP type
*/
LspType(int val) {
value = val;
}
/**
* Returns value of LSP type.
*
* @return LSP type
*/
public byte type() {
return (byte) value;
}
}
/*
* 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.provider.pcep.tunnel.impl;
/**
* 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";
}
/*
* 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.provider.pcep.tunnel.impl;
import org.onosproject.incubator.net.tunnel.Tunnel.State;
/**
* Representation of the PCEP LSP state.
*/
public enum PcepLspStatus {
/**
* Signifies that the LSP is not active.
*/
DOWN,
/**
* Signifies that the LSP is signalled.
*/
UP,
/**
* Signifies that the LSP is up and carrying traffic.
*/
ACTIVE,
/**
* Signifies that the LSP is being torn down, resources are being released.
*/
GOING_DOWN,
/**
* Signifies that the LSP is being signalled.
*/
GOING_UP;
/**
* Returns the applicable PCEP LSP status corresponding to ONOS tunnel state.
*
* @param tunnelState ONOS tunnel state
*/
public static PcepLspStatus getLspStatusFromTunnelStatus(State tunnelState) {
switch (tunnelState) {
case INIT:
return PcepLspStatus.DOWN;
case ESTABLISHED:
return PcepLspStatus.GOING_UP;
case ACTIVE:
return PcepLspStatus.UP;
case FAILED: // fall through
case INACTIVE: // LSP is administratively down.
default:
return PcepLspStatus.DOWN;
}
}
/**
* Returns the applicable ONOS tunnel state corresponding to PCEP LSP status.
*
* @param lspState PCEP LSP status
*/
public static State getTunnelStatusFromLspStatus(PcepLspStatus lspState) {
switch (lspState) {
case DOWN:
return State.FAILED;
case UP: // fall through
case ACTIVE:
return State.ACTIVE;
case GOING_DOWN:
return State.FAILED;
case GOING_UP:
return State.ESTABLISHED;
default:
return State.FAILED;
}
}
}
......@@ -20,7 +20,7 @@ import java.util.Objects;
import org.onosproject.incubator.net.tunnel.Tunnel;
import org.onosproject.net.ElementId;
import org.onosproject.net.Path;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import com.google.common.base.MoreObjects;
......@@ -43,7 +43,7 @@ public class PcepTunnelData {
private short tunnelId;
private int extTunnelId;
private short lspId;
private StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv;
private StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv;
/**
* Default constructor.
......@@ -203,7 +203,7 @@ public class PcepTunnelData {
* Sets statefulIpv4Identifiers tlv.
* @param value statefulIpv4Identifiers tlv
*/
public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentidiersTlv value) {
public void setStatefulIpv4IndentifierTlv(StatefulIPv4LspIdentifiersTlv value) {
this.statefulIpv4IndentifierTlv = value;
}
......@@ -329,7 +329,7 @@ public class PcepTunnelData {
*
* @return statefulIpv4Indentifier tlv
*/
public StatefulIPv4LspIdentidiersTlv statefulIpv4IndentifierTlv() {
public StatefulIPv4LspIdentifiersTlv statefulIpv4IndentifierTlv() {
return this.statefulIpv4IndentifierTlv;
}
......
......@@ -42,6 +42,7 @@ public class PcepClientAdapter implements PcepClient {
private ClientCapability capability;
private PcepVersion pcepVersion;
private boolean syncCompleted;
/**
* Initialize instance with specified parameters.
......@@ -109,11 +110,12 @@ public class PcepClientAdapter implements PcepClient {
@Override
public final boolean isSyncComplete() {
return false;
return syncCompleted;
}
@Override
public final void setIsSyncComplete(boolean value) {
syncCompleted = value;
}
@Override
......
......@@ -73,6 +73,9 @@ public class PcepClientControllerAdapter implements PcepClientController {
@Override
public PcepClient getClient(PccId pccId) {
if (null != connectedClients.get(pccId)) {
return connectedClients.get(pccId);
}
PcepClientAdapter pc = new PcepClientAdapter();
if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103))
|| pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) {
......@@ -81,6 +84,7 @@ public class PcepClientControllerAdapter implements PcepClientController {
pc.setCapability(new ClientCapability(true, true, true));
}
pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1);
connectedClients.put(pccId, pc);
return pc;
}
......
......@@ -20,6 +20,10 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......@@ -36,7 +40,9 @@ 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.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.IpElementId;
......@@ -44,7 +50,7 @@ import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
/**
* Test for PCEP release tunnel.
......@@ -77,7 +83,7 @@ public class PcepReleaseTunnelProviderTest {
public void testCasePcepReleaseTunnel() {
Tunnel tunnel;
Path path;
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
......@@ -103,14 +109,18 @@ public class PcepReleaseTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
// for releasing tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
......@@ -127,7 +137,7 @@ public class PcepReleaseTunnelProviderTest {
public void testCasePcepReleaseTunnel2() {
Tunnel tunnel;
Path path;
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
......@@ -153,14 +163,18 @@ public class PcepReleaseTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
// for releasing tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
......@@ -170,6 +184,114 @@ public class PcepReleaseTunnelProviderTest {
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
}
/**
* Tests releasing SR based tunnel.
*/
@Test
public void testCasePcepReleaseSrTunnel() {
Tunnel tunnel;
Path path;
List<Link> links = new ArrayList<>();
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
// for releasing tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
/**
* Tests releasing tunnel without SR and without signalling.
*/
@Test
public void testCasePcepReleaseTunnelWithoutSigSr() {
Tunnel tunnel;
Path path;
List<Link> links = new ArrayList<>();
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
IpAddress srcIp = IpAddress.valueOf(0xB6024E20);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xB6024E21);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
// for releasing tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
tunnelProvider.releaseTunnel(tunnel);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
@After
public void tearDown() throws IOException {
tunnelProvider.deactivate();
......
......@@ -20,6 +20,10 @@ import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.Matchers.nullValue;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......@@ -36,7 +40,9 @@ 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.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.IpElementId;
......@@ -75,7 +81,7 @@ public class PcepSetupTunnelProviderTest {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
......@@ -98,9 +104,13 @@ public class PcepSetupTunnelProviderTest {
path = new DefaultPath(pid, links, 10, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
......@@ -114,7 +124,7 @@ public class PcepSetupTunnelProviderTest {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010103);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
......@@ -137,14 +147,104 @@ public class PcepSetupTunnelProviderTest {
path = new DefaultPath(pid, links, 10, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
}
/**
* Sends PCInitiate msg to setup a SR based tunnel.
*/
@Test
public void testCasePcepSetupSrTunnel() {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xC010102);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 10, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
/**
* Sends PCInitiate msg to setup a tunnel without signalling and without SR.
*/
@Test
public void testCasePcepSetupTunnelWithoutSigSr() {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xC010102);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 10, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
@After
public void tearDown() throws IOException {
tunnelProvider.deactivate();
......
......@@ -15,7 +15,12 @@
*/
package org.onosproject.provider.pcep.tunnel.impl;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......@@ -30,7 +35,9 @@ 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.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.IpElementId;
......@@ -62,7 +69,7 @@ public class PcepTunnelProviderTest {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
......@@ -85,11 +92,17 @@ public class PcepTunnelProviderTest {
path = new DefaultPath(pid, links, 10, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
tunnelProvider.setupTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
@After
......@@ -99,4 +112,4 @@ public class PcepTunnelProviderTest {
tunnelProvider.pcepClientController = null;
tunnelProvider.tunnelProviderRegistry = null;
}
}
}
\ No newline at end of file
......
......@@ -20,6 +20,7 @@ import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNot.not;
import static org.onosproject.net.DefaultAnnotations.EMPTY;
import static org.onosproject.provider.pcep.tunnel.impl.PcepAnnotationKeys.LSP_SIG_TYPE;
import java.io.IOException;
import java.util.ArrayList;
......@@ -36,7 +37,9 @@ 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.net.Annotations;
import org.onosproject.net.ConnectPoint;
import org.onosproject.net.DefaultAnnotations;
import org.onosproject.net.DefaultLink;
import org.onosproject.net.DefaultPath;
import org.onosproject.net.IpElementId;
......@@ -44,8 +47,11 @@ import org.onosproject.net.Link;
import org.onosproject.net.Path;
import org.onosproject.net.PortNumber;
import org.onosproject.net.provider.ProviderId;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv;
import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITH_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.SR_WITHOUT_SIGNALLING;
import static org.onosproject.provider.pcep.tunnel.impl.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR;
/**
* Test for PCEP update tunnel.
*/
......@@ -78,7 +84,7 @@ public class PcepUpdateTunnelProviderTest {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xD010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
......@@ -101,14 +107,18 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
// for updating tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
......@@ -126,7 +136,7 @@ public class PcepUpdateTunnelProviderTest {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<Link>();
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xC010103);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
......@@ -149,14 +159,18 @@ public class PcepUpdateTunnelProviderTest {
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITH_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, EMPTY);
path, annotations);
// for updating tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
......@@ -166,6 +180,110 @@ public class PcepUpdateTunnelProviderTest {
assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false));
}
/**
* Sends update message to PCC for SR based tunnel.
*/
@Test
public void testCasePcepUpdateSrTunnel() {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xD010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xD010102);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, SR_WITHOUT_SIGNALLING.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
// for updating tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
/**
* Sends update message to PCC for tunnel without signalling and without SR.
*/
@Test
public void testCasePcepUpdateTunnelWithoutSigSr() {
Tunnel tunnel;
Path path;
ProviderId pid = new ProviderId("pcep", PROVIDER_ID);
List<Link> links = new ArrayList<>();
IpAddress srcIp = IpAddress.valueOf(0xD010101);
IpElementId srcElementId = IpElementId.ipElement(srcIp);
IpAddress dstIp = IpAddress.valueOf(0xD010102);
IpElementId dstElementId = IpElementId.ipElement(dstIp);
IpTunnelEndPoint ipTunnelEndPointSrc;
ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp);
IpTunnelEndPoint ipTunnelEndPointDst;
ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp);
ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023));
ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023));
Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst)
.type(Link.Type.DIRECT).build();
links.add(link);
path = new DefaultPath(pid, links, 20, EMPTY);
Annotations annotations = DefaultAnnotations.builder()
.set(LSP_SIG_TYPE, WITHOUT_SIGNALLING_AND_WITHOUT_SR.name())
.build();
tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS,
new DefaultGroupId(0), TunnelId.valueOf("1"), TunnelName.tunnelName("T123"),
path, annotations);
// for updating tunnel tunnel should exist in db
PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE);
pcepTunnelData.setPlspId(1);
StatefulIPv4LspIdentifiersTlv tlv = new StatefulIPv4LspIdentifiersTlv(0, (short) 1, (short) 2, 3, 4);
pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv);
tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData);
tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData);
tunnelProvider.updateTunnel(tunnel, path);
assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue()));
}
@After
public void tearDown() throws IOException {
tunnelProvider.deactivate();
......
......@@ -94,17 +94,17 @@ public class TunnelServiceAdapter implements TunnelService {
@Override
public Collection<TunnelSubscription> queryTunnelSubscription(ApplicationId consumerId) {
return null;
return Collections.emptySet();
}
@Override
public Collection<Tunnel> queryTunnel(Tunnel.Type type) {
return null;
return Collections.emptySet();
}
@Override
public Collection<Tunnel> queryTunnel(TunnelEndPoint src, TunnelEndPoint dst) {
return null;
return Collections.emptySet();
}
@Override
......