Committed by
Gerrit Code Review
[ONOS-4209] Unsuccessful PCEP session formation between ONOS and IOS XR
Change-Id: Ic509c50c5cef39e5f1a5319570f8c9406177b788
Showing
14 changed files
with
528 additions
and
94 deletions
1 | +/* | ||
2 | + * Copyright 2016 Open Networking Laboratory | ||
3 | + * | ||
4 | + * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | + * you may not use this file except in compliance with the License. | ||
6 | + * You may obtain a copy of the License at | ||
7 | + * | ||
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | + * | ||
10 | + * Unless required by applicable law or agreed to in writing, software | ||
11 | + * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | + * See the License for the specific language governing permissions and | ||
14 | + * limitations under the License. | ||
15 | + */ | ||
16 | +package org.onosproject.pcep.controller; | ||
17 | + | ||
18 | +import java.util.Objects; | ||
19 | + | ||
20 | +import com.google.common.base.MoreObjects; | ||
21 | + | ||
22 | +/** | ||
23 | + * Representation of capabilities supported by client. | ||
24 | + */ | ||
25 | +public class ClientCapability { | ||
26 | + private boolean pceccCapability; | ||
27 | + private boolean statefulPceCapability; | ||
28 | + private boolean pcInstantiationCapability; | ||
29 | + | ||
30 | + /** | ||
31 | + * Creates new instance of client capability. | ||
32 | + * | ||
33 | + * @param pceccCapability represents PCECC capability | ||
34 | + * @param statefulPceCapability represents stateful PCE capability | ||
35 | + * @param pcInstantiationCapability represents PC initiation capability | ||
36 | + */ | ||
37 | + public ClientCapability(boolean pceccCapability, boolean statefulPceCapability, boolean pcInstantiationCapability) { | ||
38 | + this.pceccCapability = pceccCapability; | ||
39 | + this.statefulPceCapability = statefulPceCapability; | ||
40 | + this.pcInstantiationCapability = pcInstantiationCapability; | ||
41 | + } | ||
42 | + | ||
43 | + /** | ||
44 | + * Obtains PCECC capability. | ||
45 | + * | ||
46 | + * @return true if client supports PCECC capability otherwise false | ||
47 | + */ | ||
48 | + public boolean pceccCapability() { | ||
49 | + return pceccCapability; | ||
50 | + } | ||
51 | + | ||
52 | + /** | ||
53 | + * Obtains stateful PCE capability. | ||
54 | + * | ||
55 | + * @return true if client supports stateful PCE capability otherwise false | ||
56 | + */ | ||
57 | + public boolean statefulPceCapability() { | ||
58 | + return statefulPceCapability; | ||
59 | + } | ||
60 | + | ||
61 | + /** | ||
62 | + * Obtains PC initiation capability. | ||
63 | + * | ||
64 | + * @return true if client supports PC initiation capability otherwise false | ||
65 | + */ | ||
66 | + public boolean pcInstantiationCapability() { | ||
67 | + return pcInstantiationCapability; | ||
68 | + } | ||
69 | + | ||
70 | + @Override | ||
71 | + public int hashCode() { | ||
72 | + return Objects.hash(pceccCapability, statefulPceCapability, pcInstantiationCapability); | ||
73 | + } | ||
74 | + | ||
75 | + @Override | ||
76 | + public boolean equals(Object obj) { | ||
77 | + if (this == obj) { | ||
78 | + return true; | ||
79 | + } | ||
80 | + if (obj instanceof ClientCapability) { | ||
81 | + ClientCapability other = (ClientCapability) obj; | ||
82 | + return Objects.equals(pceccCapability, other.pceccCapability) | ||
83 | + && Objects.equals(statefulPceCapability, other.statefulPceCapability) | ||
84 | + && Objects.equals(pcInstantiationCapability, other.pcInstantiationCapability); | ||
85 | + } | ||
86 | + return false; | ||
87 | + } | ||
88 | + | ||
89 | + @Override | ||
90 | + public String toString() { | ||
91 | + return MoreObjects.toStringHelper(getClass()) | ||
92 | + .add("pceccCapability", pceccCapability) | ||
93 | + .add("statefulPceCapability", statefulPceCapability) | ||
94 | + .add("pcInstantiationCapability", pcInstantiationCapability) | ||
95 | + .toString(); | ||
96 | + } | ||
97 | +} | ||
... | \ No newline at end of file | ... | \ No newline at end of file |
... | @@ -107,4 +107,18 @@ public interface PcepClient { | ... | @@ -107,4 +107,18 @@ public interface PcepClient { |
107 | * @return true/false if the synchronization is completed/not completed | 107 | * @return true/false if the synchronization is completed/not completed |
108 | */ | 108 | */ |
109 | boolean isSyncComplete(); | 109 | boolean isSyncComplete(); |
110 | + | ||
111 | + /** | ||
112 | + * Sets capability negotiated during open message exchange. | ||
113 | + * | ||
114 | + * @param capability supported by client | ||
115 | + */ | ||
116 | + void setCapability(ClientCapability capability); | ||
117 | + | ||
118 | + /** | ||
119 | + * Obtains capability supported by client. | ||
120 | + * | ||
121 | + * @return capability supported by client | ||
122 | + */ | ||
123 | + ClientCapability capability(); | ||
110 | } | 124 | } | ... | ... |
... | @@ -38,6 +38,7 @@ import org.jboss.netty.handler.timeout.IdleStateEvent; | ... | @@ -38,6 +38,7 @@ import org.jboss.netty.handler.timeout.IdleStateEvent; |
38 | import org.jboss.netty.handler.timeout.IdleStateHandler; | 38 | import org.jboss.netty.handler.timeout.IdleStateHandler; |
39 | import org.jboss.netty.handler.timeout.ReadTimeoutException; | 39 | import org.jboss.netty.handler.timeout.ReadTimeoutException; |
40 | import org.onlab.packet.IpAddress; | 40 | import org.onlab.packet.IpAddress; |
41 | +import org.onosproject.pcep.controller.ClientCapability; | ||
41 | import org.onosproject.pcep.controller.PccId; | 42 | import org.onosproject.pcep.controller.PccId; |
42 | import org.onosproject.pcep.controller.driver.PcepClientDriver; | 43 | import org.onosproject.pcep.controller.driver.PcepClientDriver; |
43 | import org.onosproject.pcepio.exceptions.PcepParseException; | 44 | import org.onosproject.pcepio.exceptions.PcepParseException; |
... | @@ -51,7 +52,6 @@ import org.onosproject.pcepio.protocol.PcepOpenMsg; | ... | @@ -51,7 +52,6 @@ import org.onosproject.pcepio.protocol.PcepOpenMsg; |
51 | import org.onosproject.pcepio.protocol.PcepOpenObject; | 52 | import org.onosproject.pcepio.protocol.PcepOpenObject; |
52 | import org.onosproject.pcepio.protocol.PcepType; | 53 | import org.onosproject.pcepio.protocol.PcepType; |
53 | import org.onosproject.pcepio.protocol.PcepVersion; | 54 | import org.onosproject.pcepio.protocol.PcepVersion; |
54 | -import org.onosproject.pcepio.types.ErrorObjListWithOpen; | ||
55 | import org.onosproject.pcepio.types.PceccCapabilityTlv; | 55 | import org.onosproject.pcepio.types.PceccCapabilityTlv; |
56 | import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; | 56 | import org.onosproject.pcepio.types.StatefulPceCapabilityTlv; |
57 | import org.onosproject.pcepio.types.PcepErrorDetailInfo; | 57 | import org.onosproject.pcepio.types.PcepErrorDetailInfo; |
... | @@ -74,6 +74,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -74,6 +74,7 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
74 | private byte sessionId = 0; | 74 | private byte sessionId = 0; |
75 | private byte keepAliveTime; | 75 | private byte keepAliveTime; |
76 | private byte deadTime; | 76 | private byte deadTime; |
77 | + private ClientCapability capability; | ||
77 | private PcepPacketStatsImpl pcepPacketStats; | 78 | private PcepPacketStatsImpl pcepPacketStats; |
78 | static final int MAX_WRONG_COUNT_PACKET = 5; | 79 | static final int MAX_WRONG_COUNT_PACKET = 5; |
79 | static final int BYTE_MASK = 0xFF; | 80 | static final int BYTE_MASK = 0xFF; |
... | @@ -146,8 +147,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -146,8 +147,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
146 | 147 | ||
147 | h.pcepPacketStats.addInPacket(); | 148 | h.pcepPacketStats.addInPacket(); |
148 | PcepOpenMsg pOpenmsg = (PcepOpenMsg) m; | 149 | PcepOpenMsg pOpenmsg = (PcepOpenMsg) m; |
149 | - // do Capability validation. | 150 | + //Do Capability negotiation. |
150 | - if (h.capabilityValidation(pOpenmsg)) { | 151 | + h.capabilityNegotiation(pOpenmsg); |
151 | log.debug("Sending handshake OPEN message"); | 152 | log.debug("Sending handshake OPEN message"); |
152 | h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId(); | 153 | h.sessionId = pOpenmsg.getPcepOpenObject().getSessionId(); |
153 | h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion(); | 154 | h.pcepVersion = pOpenmsg.getPcepOpenObject().getVersion(); |
... | @@ -168,13 +169,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -168,13 +169,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
168 | h.sendHandshakeOpenMessage(); | 169 | h.sendHandshakeOpenMessage(); |
169 | h.pcepPacketStats.addOutPacket(); | 170 | h.pcepPacketStats.addOutPacket(); |
170 | h.setState(KEEPWAIT); | 171 | h.setState(KEEPWAIT); |
171 | - } else { | ||
172 | - log.debug("Capability validation failed. Sending PCEP-ERROR message to PCC."); | ||
173 | - // Send PCEP-ERROR message. | ||
174 | - PcepErrorMsg errMsg = h.getErrorMsg(PcepErrorDetailInfo.ERROR_TYPE_2, | ||
175 | - PcepErrorDetailInfo.ERROR_VALUE_2); | ||
176 | - h.channel.write(Collections.singletonList(errMsg)); | ||
177 | - } | ||
178 | } | 172 | } |
179 | } | 173 | } |
180 | }, | 174 | }, |
... | @@ -203,6 +197,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -203,6 +197,8 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
203 | h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress())); | 197 | h.thispccId = PccId.pccId(IpAddress.valueOf(inetAddress.getAddress())); |
204 | h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion, | 198 | h.pc = h.controller.getPcepClientInstance(h.thispccId, h.sessionId, h.pcepVersion, |
205 | h.pcepPacketStats); | 199 | h.pcepPacketStats); |
200 | + //Get pc instance and set capabilities | ||
201 | + h.pc.setCapability(h.capability); | ||
206 | // set the status of pcc as connected | 202 | // set the status of pcc as connected |
207 | h.pc.setConnected(true); | 203 | h.pc.setConnected(true); |
208 | h.pc.setChannel(h.channel); | 204 | h.pc.setChannel(h.channel); |
... | @@ -493,17 +489,12 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -493,17 +489,12 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
493 | channel.write(Collections.singletonList(msg)); | 489 | channel.write(Collections.singletonList(msg)); |
494 | } | 490 | } |
495 | 491 | ||
496 | - /** | 492 | + //Capability negotiation |
497 | - * Capability Validation. | 493 | + private void capabilityNegotiation(PcepOpenMsg pOpenmsg) { |
498 | - * | ||
499 | - * @param pOpenmsg pcep open message | ||
500 | - * @return success or failure | ||
501 | - */ | ||
502 | - private boolean capabilityValidation(PcepOpenMsg pOpenmsg) { | ||
503 | LinkedList<PcepValueType> tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv(); | 494 | LinkedList<PcepValueType> tlvList = pOpenmsg.getPcepOpenObject().getOptionalTlv(); |
504 | - boolean bFoundPceccCapability = false; | 495 | + boolean pceccCapability = false; |
505 | - boolean bFoundStatefulPceCapability = false; | 496 | + boolean statefulPceCapability = false; |
506 | - boolean bFoundPcInstantiationCapability = false; | 497 | + boolean pcInstantiationCapability = false; |
507 | 498 | ||
508 | ListIterator<PcepValueType> listIterator = tlvList.listIterator(); | 499 | ListIterator<PcepValueType> listIterator = tlvList.listIterator(); |
509 | while (listIterator.hasNext()) { | 500 | while (listIterator.hasNext()) { |
... | @@ -511,21 +502,20 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -511,21 +502,20 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
511 | 502 | ||
512 | switch (tlv.getType()) { | 503 | switch (tlv.getType()) { |
513 | case PceccCapabilityTlv.TYPE: | 504 | case PceccCapabilityTlv.TYPE: |
514 | - bFoundPceccCapability = true; | 505 | + pceccCapability = true; |
515 | break; | 506 | break; |
516 | case StatefulPceCapabilityTlv.TYPE: | 507 | case StatefulPceCapabilityTlv.TYPE: |
517 | - bFoundStatefulPceCapability = true; | 508 | + statefulPceCapability = true; |
518 | StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv; | 509 | StatefulPceCapabilityTlv stetefulPcCapTlv = (StatefulPceCapabilityTlv) tlv; |
519 | if (stetefulPcCapTlv.getIFlag()) { | 510 | if (stetefulPcCapTlv.getIFlag()) { |
520 | - bFoundPcInstantiationCapability = true; | 511 | + pcInstantiationCapability = true; |
521 | } | 512 | } |
522 | break; | 513 | break; |
523 | default: | 514 | default: |
524 | continue; | 515 | continue; |
525 | } | 516 | } |
526 | } | 517 | } |
527 | - | 518 | + this.capability = new ClientCapability(pceccCapability, statefulPceCapability, pcInstantiationCapability); |
528 | - return (bFoundPceccCapability && bFoundStatefulPceCapability && bFoundPcInstantiationCapability); | ||
529 | } | 519 | } |
530 | 520 | ||
531 | /** | 521 | /** |
... | @@ -579,23 +569,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -579,23 +569,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
579 | 569 | ||
580 | llerrObj.add(errObj); | 570 | llerrObj.add(errObj); |
581 | 571 | ||
582 | - if (state == ChannelState.OPENWAIT) { | ||
583 | - //If Error caught in Openmessage | ||
584 | - PcepOpenObject openObj = null; | ||
585 | - ErrorObjListWithOpen errorObjListWithOpen = null; | ||
586 | - | ||
587 | - if (0 != sessionId) { | ||
588 | - openObj = factory1.buildOpenObject().setSessionId(sessionId).build(); | ||
589 | - errorObjListWithOpen = new ErrorObjListWithOpen(llerrObj, openObj); | ||
590 | - } else { | ||
591 | - errorObjListWithOpen = new ErrorObjListWithOpen(llerrObj, null); | ||
592 | - } | ||
593 | - | ||
594 | - errMsg = factory1.buildPcepErrorMsg() | ||
595 | - .setErrorObjListWithOpen(errorObjListWithOpen) | ||
596 | - .build(); | ||
597 | - } else { | ||
598 | - | ||
599 | //If Error caught in other than Openmessage | 572 | //If Error caught in other than Openmessage |
600 | LinkedList<PcepError> llPcepErr = new LinkedList<>(); | 573 | LinkedList<PcepError> llPcepErr = new LinkedList<>(); |
601 | 574 | ||
... | @@ -612,7 +585,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { | ... | @@ -612,7 +585,6 @@ class PcepChannelHandler extends IdleStateAwareChannelHandler { |
612 | errMsg = factory1.buildPcepErrorMsg() | 585 | errMsg = factory1.buildPcepErrorMsg() |
613 | .setPcepErrorInfo(errInfo) | 586 | .setPcepErrorInfo(errInfo) |
614 | .build(); | 587 | .build(); |
615 | - } | ||
616 | return errMsg; | 588 | return errMsg; |
617 | } | 589 | } |
618 | 590 | ... | ... |
... | @@ -18,6 +18,7 @@ package org.onosproject.pcep.controller.impl; | ... | @@ -18,6 +18,7 @@ package org.onosproject.pcep.controller.impl; |
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | import java.util.Collections; | 19 | import java.util.Collections; |
20 | import java.util.HashSet; | 20 | import java.util.HashSet; |
21 | +import java.util.LinkedList; | ||
21 | import java.util.Set; | 22 | import java.util.Set; |
22 | import java.util.concurrent.ConcurrentHashMap; | 23 | import java.util.concurrent.ConcurrentHashMap; |
23 | 24 | ||
... | @@ -31,12 +32,20 @@ import org.onosproject.pcep.controller.PcepClientController; | ... | @@ -31,12 +32,20 @@ import org.onosproject.pcep.controller.PcepClientController; |
31 | import org.onosproject.pcep.controller.PcepClientListener; | 32 | import org.onosproject.pcep.controller.PcepClientListener; |
32 | import org.onosproject.pcep.controller.PcepEventListener; | 33 | import org.onosproject.pcep.controller.PcepEventListener; |
33 | import org.onosproject.pcep.controller.driver.PcepAgent; | 34 | import org.onosproject.pcep.controller.driver.PcepAgent; |
35 | +import org.onosproject.pcepio.protocol.PcepError; | ||
36 | +import org.onosproject.pcepio.protocol.PcepErrorInfo; | ||
37 | +import org.onosproject.pcepio.protocol.PcepErrorMsg; | ||
38 | +import org.onosproject.pcepio.protocol.PcepErrorObject; | ||
39 | +import org.onosproject.pcepio.protocol.PcepFactory; | ||
34 | import org.onosproject.pcepio.protocol.PcepMessage; | 40 | import org.onosproject.pcepio.protocol.PcepMessage; |
35 | import org.slf4j.Logger; | 41 | import org.slf4j.Logger; |
36 | import org.slf4j.LoggerFactory; | 42 | import org.slf4j.LoggerFactory; |
37 | 43 | ||
38 | import com.google.common.collect.Sets; | 44 | import com.google.common.collect.Sets; |
39 | 45 | ||
46 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; | ||
47 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; | ||
48 | + | ||
40 | /** | 49 | /** |
41 | * Implementation of PCEP client controller. | 50 | * Implementation of PCEP client controller. |
42 | */ | 51 | */ |
... | @@ -126,6 +135,24 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -126,6 +135,24 @@ public class PcepClientControllerImpl implements PcepClientController { |
126 | break; | 135 | break; |
127 | case ERROR: | 136 | case ERROR: |
128 | break; | 137 | break; |
138 | + case INITIATE: | ||
139 | + if (!pc.capability().pcInstantiationCapability()) { | ||
140 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19, | ||
141 | + ERROR_VALUE_5))); | ||
142 | + } | ||
143 | + break; | ||
144 | + case UPDATE: | ||
145 | + if (!pc.capability().statefulPceCapability()) { | ||
146 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19, | ||
147 | + ERROR_VALUE_5))); | ||
148 | + } | ||
149 | + break; | ||
150 | + case LABEL_UPDATE: | ||
151 | + if (!pc.capability().pceccCapability()) { | ||
152 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), ERROR_TYPE_19, | ||
153 | + ERROR_VALUE_5))); | ||
154 | + } | ||
155 | + break; | ||
129 | case CLOSE: | 156 | case CLOSE: |
130 | log.info("Sending Close Message to {" + pccId.toString() + "}"); | 157 | log.info("Sending Close Message to {" + pccId.toString() + "}"); |
131 | pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); | 158 | pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); |
... | @@ -133,21 +160,18 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -133,21 +160,18 @@ public class PcepClientControllerImpl implements PcepClientController { |
133 | pc.disconnectClient(); | 160 | pc.disconnectClient(); |
134 | break; | 161 | break; |
135 | case REPORT: | 162 | case REPORT: |
136 | - for (PcepEventListener l : pcepEventListener) { | 163 | + //Only update the listener if respective capability is supported else send PCEP-ERR msg |
137 | - l.handleMessage(pccId, msg); | 164 | + if (pc.capability().statefulPceCapability()) { |
138 | - } | 165 | + for (PcepEventListener l : pcepEventListener) { |
139 | - break; | 166 | + l.handleMessage(pccId, msg); |
140 | - case UPDATE: | 167 | + } |
141 | - for (PcepEventListener l : pcepEventListener) { | 168 | + } else { |
142 | - l.handleMessage(pccId, msg); | 169 | + // Send PCEP-ERROR message. |
143 | - } | 170 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), |
144 | - break; | 171 | + ERROR_TYPE_19, ERROR_VALUE_5))); |
145 | - case INITIATE: | ||
146 | - for (PcepEventListener l : pcepEventListener) { | ||
147 | - l.handleMessage(pccId, msg); | ||
148 | } | 172 | } |
149 | break; | 173 | break; |
150 | - case LABEL_UPDATE: | 174 | + case LABEL_RANGE_RESERV: |
151 | break; | 175 | break; |
152 | case MAX: | 176 | case MAX: |
153 | break; | 177 | break; |
... | @@ -168,6 +192,34 @@ public class PcepClientControllerImpl implements PcepClientController { | ... | @@ -168,6 +192,34 @@ public class PcepClientControllerImpl implements PcepClientController { |
168 | } | 192 | } |
169 | 193 | ||
170 | /** | 194 | /** |
195 | + * Returns pcep error message with specific error type and value. | ||
196 | + * | ||
197 | + * @param factory represents pcep factory | ||
198 | + * @param errorType pcep error type | ||
199 | + * @param errorValue pcep error value | ||
200 | + * @return pcep error message | ||
201 | + */ | ||
202 | + public PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) { | ||
203 | + LinkedList<PcepError> llPcepErr = new LinkedList<>(); | ||
204 | + | ||
205 | + LinkedList<PcepErrorObject> llerrObj = new LinkedList<>(); | ||
206 | + PcepErrorMsg errMsg; | ||
207 | + | ||
208 | + PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType) | ||
209 | + .build(); | ||
210 | + | ||
211 | + llerrObj.add(errObj); | ||
212 | + PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build(); | ||
213 | + | ||
214 | + llPcepErr.add(pcepErr); | ||
215 | + | ||
216 | + PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build(); | ||
217 | + | ||
218 | + errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build(); | ||
219 | + return errMsg; | ||
220 | + } | ||
221 | + | ||
222 | + /** | ||
171 | * Implementation of an Pcep Agent which is responsible for | 223 | * Implementation of an Pcep Agent which is responsible for |
172 | * keeping track of connected clients and the state in which | 224 | * keeping track of connected clients and the state in which |
173 | * they are. | 225 | * they are. | ... | ... |
... | @@ -24,6 +24,7 @@ import java.util.concurrent.RejectedExecutionException; | ... | @@ -24,6 +24,7 @@ import java.util.concurrent.RejectedExecutionException; |
24 | 24 | ||
25 | import org.jboss.netty.channel.Channel; | 25 | import org.jboss.netty.channel.Channel; |
26 | import org.onlab.packet.IpAddress; | 26 | import org.onlab.packet.IpAddress; |
27 | +import org.onosproject.pcep.controller.ClientCapability; | ||
27 | import org.onosproject.pcep.controller.PccId; | 28 | import org.onosproject.pcep.controller.PccId; |
28 | import org.onosproject.pcep.controller.PcepPacketStats; | 29 | import org.onosproject.pcep.controller.PcepPacketStats; |
29 | import org.onosproject.pcep.controller.driver.PcepAgent; | 30 | import org.onosproject.pcep.controller.driver.PcepAgent; |
... | @@ -57,6 +58,7 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -57,6 +58,7 @@ public class PcepClientImpl implements PcepClientDriver { |
57 | private PccId pccId; | 58 | private PccId pccId; |
58 | private PcepAgent agent; | 59 | private PcepAgent agent; |
59 | 60 | ||
61 | + private ClientCapability capability; | ||
60 | private PcepVersion pcepVersion; | 62 | private PcepVersion pcepVersion; |
61 | private byte keepAliveTime; | 63 | private byte keepAliveTime; |
62 | private byte deadTime; | 64 | private byte deadTime; |
... | @@ -76,6 +78,16 @@ public class PcepClientImpl implements PcepClientDriver { | ... | @@ -76,6 +78,16 @@ public class PcepClientImpl implements PcepClientDriver { |
76 | } | 78 | } |
77 | 79 | ||
78 | @Override | 80 | @Override |
81 | + public void setCapability(ClientCapability capability) { | ||
82 | + this.capability = capability; | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public ClientCapability capability() { | ||
87 | + return capability; | ||
88 | + } | ||
89 | + | ||
90 | + @Override | ||
79 | public final void sendMessage(PcepMessage m) { | 91 | public final void sendMessage(PcepMessage m) { |
80 | log.debug("Sending message to {}", channel.getRemoteAddress()); | 92 | log.debug("Sending message to {}", channel.getRemoteAddress()); |
81 | try { | 93 | try { | ... | ... |
... | @@ -57,6 +57,26 @@ public final class PcepErrorDetailInfo { | ... | @@ -57,6 +57,26 @@ public final class PcepErrorDetailInfo { |
57 | 10 Reception of an invalid object | 57 | 10 Reception of an invalid object |
58 | Error-value=1: reception of an object with P flag not set although the P flag must be | 58 | Error-value=1: reception of an object with P flag not set although the P flag must be |
59 | set according to this specification. | 59 | set according to this specification. |
60 | + | ||
61 | + Reference draft-ietf-pce-stateful-pce-11, section : 8.4 | ||
62 | + 19 Invalid Operation | ||
63 | + Error-value=1: Attempted LSP Update Request for a non- | ||
64 | + delegated LSP. The PCEP-ERROR Object | ||
65 | + is followed by the LSP Object that | ||
66 | + identifies the LSP. | ||
67 | + Error-value=2: Attempted LSP Update Request if the | ||
68 | + stateful PCE capability was not | ||
69 | + advertised. | ||
70 | + Error-value=3: Attempted LSP Update Request for an LSP | ||
71 | + identified by an unknown PLSP-ID. | ||
72 | + Error-value=4: A PCE indicates to a PCC that it has | ||
73 | + exceeded the resource limit allocated | ||
74 | + for its state, and thus it cannot | ||
75 | + accept and process its LSP State Report | ||
76 | + message. | ||
77 | + Error-value=5: Attempted LSP State Report if active | ||
78 | + stateful PCE capability was not | ||
79 | + advertised. | ||
60 | */ | 80 | */ |
61 | public static final byte ERROR_TYPE_1 = 1; | 81 | public static final byte ERROR_TYPE_1 = 1; |
62 | public static final byte ERROR_TYPE_2 = 2; | 82 | public static final byte ERROR_TYPE_2 = 2; |
... | @@ -68,6 +88,7 @@ public final class PcepErrorDetailInfo { | ... | @@ -68,6 +88,7 @@ public final class PcepErrorDetailInfo { |
68 | public static final byte ERROR_TYPE_8 = 8; | 88 | public static final byte ERROR_TYPE_8 = 8; |
69 | public static final byte ERROR_TYPE_9 = 9; | 89 | public static final byte ERROR_TYPE_9 = 9; |
70 | public static final byte ERROR_TYPE_10 = 10; | 90 | public static final byte ERROR_TYPE_10 = 10; |
91 | + public static final byte ERROR_TYPE_19 = 19; | ||
71 | 92 | ||
72 | // Error Values | 93 | // Error Values |
73 | public static final byte ERROR_VALUE_1 = 1; | 94 | public static final byte ERROR_VALUE_1 = 1; | ... | ... |
... | @@ -234,7 +234,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -234,7 +234,11 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
234 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); | 234 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); |
235 | return; | 235 | return; |
236 | } | 236 | } |
237 | - pcepSetupTunnel(tunnel, path, pc); | 237 | + |
238 | + //If stateful and PC Initiation capability is not supported by client not sending Initiate msg | ||
239 | + if (pc.capability().pcInstantiationCapability()) { | ||
240 | + pcepSetupTunnel(tunnel, path, pc); | ||
241 | + } | ||
238 | } | 242 | } |
239 | 243 | ||
240 | @Override | 244 | @Override |
... | @@ -263,7 +267,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -263,7 +267,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
263 | + ((IpElementId) srcElement).ipAddress().toString()); | 267 | + ((IpElementId) srcElement).ipAddress().toString()); |
264 | return; | 268 | return; |
265 | } | 269 | } |
266 | - pcepSetupTunnel(tunnel, path, pc); | 270 | + |
271 | + if (pc.capability().pcInstantiationCapability()) { | ||
272 | + pcepSetupTunnel(tunnel, path, pc); | ||
273 | + } | ||
267 | } | 274 | } |
268 | 275 | ||
269 | @Override | 276 | @Override |
... | @@ -287,7 +294,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -287,7 +294,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
287 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); | 294 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); |
288 | return; | 295 | return; |
289 | } | 296 | } |
290 | - pcepReleaseTunnel(tunnel, pc); | 297 | + |
298 | + if (pc.capability().pcInstantiationCapability()) { | ||
299 | + pcepReleaseTunnel(tunnel, pc); | ||
300 | + } | ||
291 | } | 301 | } |
292 | 302 | ||
293 | @Override | 303 | @Override |
... | @@ -315,7 +325,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -315,7 +325,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
315 | + ((IpElementId) srcElement).ipAddress().toString()); | 325 | + ((IpElementId) srcElement).ipAddress().toString()); |
316 | return; | 326 | return; |
317 | } | 327 | } |
318 | - pcepReleaseTunnel(tunnel, pc); | 328 | + |
329 | + if (pc.capability().pcInstantiationCapability()) { | ||
330 | + pcepReleaseTunnel(tunnel, pc); | ||
331 | + } | ||
319 | } | 332 | } |
320 | 333 | ||
321 | @Override | 334 | @Override |
... | @@ -338,7 +351,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -338,7 +351,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
338 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); | 351 | + ((IpTunnelEndPoint) tunnel.src()).ip().toString()); |
339 | return; | 352 | return; |
340 | } | 353 | } |
341 | - pcepUpdateTunnel(tunnel, path, pc); | 354 | + |
355 | + if (pc.capability().statefulPceCapability()) { | ||
356 | + pcepUpdateTunnel(tunnel, path, pc); | ||
357 | + } | ||
342 | } | 358 | } |
343 | 359 | ||
344 | @Override | 360 | @Override |
... | @@ -367,7 +383,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -367,7 +383,10 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
367 | + ((IpElementId) srcElement).ipAddress().toString()); | 383 | + ((IpElementId) srcElement).ipAddress().toString()); |
368 | return; | 384 | return; |
369 | } | 385 | } |
370 | - pcepUpdateTunnel(tunnel, path, pc); | 386 | + |
387 | + if (pc.capability().statefulPceCapability()) { | ||
388 | + pcepUpdateTunnel(tunnel, path, pc); | ||
389 | + } | ||
371 | } | 390 | } |
372 | 391 | ||
373 | @Override | 392 | @Override | ... | ... |
providers/pcep/tunnel/src/test/java/org/onosproject/provider/pcep/tunnel/impl/PcepClientAdapter.java
... | @@ -21,6 +21,7 @@ import java.util.List; | ... | @@ -21,6 +21,7 @@ import java.util.List; |
21 | import java.util.concurrent.RejectedExecutionException; | 21 | import java.util.concurrent.RejectedExecutionException; |
22 | 22 | ||
23 | import org.jboss.netty.channel.Channel; | 23 | import org.jboss.netty.channel.Channel; |
24 | +import org.onosproject.pcep.controller.ClientCapability; | ||
24 | import org.onosproject.pcep.controller.PccId; | 25 | import org.onosproject.pcep.controller.PccId; |
25 | import org.onosproject.pcep.controller.PcepClient; | 26 | import org.onosproject.pcep.controller.PcepClient; |
26 | import org.onosproject.pcepio.protocol.PcepFactories; | 27 | import org.onosproject.pcepio.protocol.PcepFactories; |
... | @@ -28,6 +29,9 @@ import org.onosproject.pcepio.protocol.PcepFactory; | ... | @@ -28,6 +29,9 @@ import org.onosproject.pcepio.protocol.PcepFactory; |
28 | import org.onosproject.pcepio.protocol.PcepMessage; | 29 | import org.onosproject.pcepio.protocol.PcepMessage; |
29 | import org.onosproject.pcepio.protocol.PcepVersion; | 30 | import org.onosproject.pcepio.protocol.PcepVersion; |
30 | 31 | ||
32 | +/** | ||
33 | + * Representation of PCEP client adapter. | ||
34 | + */ | ||
31 | public class PcepClientAdapter implements PcepClient { | 35 | public class PcepClientAdapter implements PcepClient { |
32 | 36 | ||
33 | private Channel channel; | 37 | private Channel channel; |
... | @@ -35,9 +39,16 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -35,9 +39,16 @@ public class PcepClientAdapter implements PcepClient { |
35 | 39 | ||
36 | private boolean connected; | 40 | private boolean connected; |
37 | private PccId pccId; | 41 | private PccId pccId; |
42 | + private ClientCapability capability; | ||
38 | 43 | ||
39 | private PcepVersion pcepVersion; | 44 | private PcepVersion pcepVersion; |
40 | 45 | ||
46 | + /** | ||
47 | + * Initialize instance with specified parameters. | ||
48 | + * | ||
49 | + * @param pccId PCC id | ||
50 | + * @param pcepVersion PCEP message version | ||
51 | + */ | ||
41 | public void init(PccId pccId, PcepVersion pcepVersion) { | 52 | public void init(PccId pccId, PcepVersion pcepVersion) { |
42 | this.pccId = pccId; | 53 | this.pccId = pccId; |
43 | this.pcepVersion = pcepVersion; | 54 | this.pcepVersion = pcepVersion; |
... | @@ -104,4 +115,14 @@ public class PcepClientAdapter implements PcepClient { | ... | @@ -104,4 +115,14 @@ public class PcepClientAdapter implements PcepClient { |
104 | @Override | 115 | @Override |
105 | public final void setIsSyncComplete(boolean value) { | 116 | public final void setIsSyncComplete(boolean value) { |
106 | } | 117 | } |
118 | + | ||
119 | + @Override | ||
120 | + public void setCapability(ClientCapability capability) { | ||
121 | + this.capability = capability; | ||
122 | + } | ||
123 | + | ||
124 | + @Override | ||
125 | + public ClientCapability capability() { | ||
126 | + return capability; | ||
127 | + } | ||
107 | } | 128 | } | ... | ... |
... | @@ -18,23 +18,36 @@ package org.onosproject.provider.pcep.tunnel.impl; | ... | @@ -18,23 +18,36 @@ package org.onosproject.provider.pcep.tunnel.impl; |
18 | import java.util.Collection; | 18 | import java.util.Collection; |
19 | import java.util.Collections; | 19 | import java.util.Collections; |
20 | import java.util.HashSet; | 20 | import java.util.HashSet; |
21 | +import java.util.LinkedList; | ||
21 | import java.util.Set; | 22 | import java.util.Set; |
22 | import java.util.concurrent.ConcurrentHashMap; | 23 | import java.util.concurrent.ConcurrentHashMap; |
23 | 24 | ||
24 | import org.apache.felix.scr.annotations.Activate; | 25 | import org.apache.felix.scr.annotations.Activate; |
25 | import org.apache.felix.scr.annotations.Deactivate; | 26 | import org.apache.felix.scr.annotations.Deactivate; |
26 | import org.onlab.packet.IpAddress; | 27 | import org.onlab.packet.IpAddress; |
28 | +import org.onosproject.pcep.controller.ClientCapability; | ||
27 | import org.onosproject.pcep.controller.PccId; | 29 | import org.onosproject.pcep.controller.PccId; |
28 | import org.onosproject.pcep.controller.PcepClient; | 30 | import org.onosproject.pcep.controller.PcepClient; |
29 | import org.onosproject.pcep.controller.PcepClientController; | 31 | import org.onosproject.pcep.controller.PcepClientController; |
30 | import org.onosproject.pcep.controller.PcepClientListener; | 32 | import org.onosproject.pcep.controller.PcepClientListener; |
31 | import org.onosproject.pcep.controller.PcepEventListener; | 33 | import org.onosproject.pcep.controller.PcepEventListener; |
32 | import org.onosproject.pcep.controller.driver.PcepAgent; | 34 | import org.onosproject.pcep.controller.driver.PcepAgent; |
35 | +import org.onosproject.pcepio.protocol.PcepError; | ||
36 | +import org.onosproject.pcepio.protocol.PcepErrorInfo; | ||
37 | +import org.onosproject.pcepio.protocol.PcepErrorMsg; | ||
38 | +import org.onosproject.pcepio.protocol.PcepErrorObject; | ||
39 | +import org.onosproject.pcepio.protocol.PcepFactory; | ||
33 | import org.onosproject.pcepio.protocol.PcepMessage; | 40 | import org.onosproject.pcepio.protocol.PcepMessage; |
34 | import org.onosproject.pcepio.protocol.PcepVersion; | 41 | import org.onosproject.pcepio.protocol.PcepVersion; |
35 | 42 | ||
36 | import com.google.common.collect.Sets; | 43 | import com.google.common.collect.Sets; |
37 | 44 | ||
45 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_TYPE_19; | ||
46 | +import static org.onosproject.pcepio.types.PcepErrorDetailInfo.ERROR_VALUE_5; | ||
47 | + | ||
48 | +/** | ||
49 | + * Representation of PCEP client controller adapter. | ||
50 | + */ | ||
38 | public class PcepClientControllerAdapter implements PcepClientController { | 51 | public class PcepClientControllerAdapter implements PcepClientController { |
39 | 52 | ||
40 | protected ConcurrentHashMap<PccId, PcepClient> connectedClients = | 53 | protected ConcurrentHashMap<PccId, PcepClient> connectedClients = |
... | @@ -60,9 +73,14 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -60,9 +73,14 @@ public class PcepClientControllerAdapter implements PcepClientController { |
60 | 73 | ||
61 | @Override | 74 | @Override |
62 | public PcepClient getClient(PccId pccId) { | 75 | public PcepClient getClient(PccId pccId) { |
63 | - //return connectedClients.get(pccIpAddress); | ||
64 | PcepClientAdapter pc = new PcepClientAdapter(); | 76 | PcepClientAdapter pc = new PcepClientAdapter(); |
65 | - pc.init(PccId.pccId(IpAddress.valueOf(0xac000001)), PcepVersion.PCEP_1); | 77 | + if (pccId.ipAddress().equals(IpAddress.valueOf(0xC010103)) |
78 | + || pccId.ipAddress().equals(IpAddress.valueOf(0xB6024E22))) { | ||
79 | + pc.setCapability(new ClientCapability(true, false, false)); | ||
80 | + } else { | ||
81 | + pc.setCapability(new ClientCapability(true, true, true)); | ||
82 | + } | ||
83 | + pc.init(PccId.pccId(pccId.ipAddress()), PcepVersion.PCEP_1); | ||
66 | return pc; | 84 | return pc; |
67 | } | 85 | } |
68 | 86 | ||
... | @@ -119,22 +137,35 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -119,22 +137,35 @@ public class PcepClientControllerAdapter implements PcepClientController { |
119 | //log.debug("Sending Close Message to { }", pccIpAddress.toString()); | 137 | //log.debug("Sending Close Message to { }", pccIpAddress.toString()); |
120 | pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); | 138 | pc.sendMessage(Collections.singletonList(pc.factory().buildCloseMsg().build())); |
121 | break; | 139 | break; |
122 | - case REPORT: | 140 | + case INITIATE: |
123 | - for (PcepEventListener l : pcepEventListener) { | 141 | + if (!pc.capability().pcInstantiationCapability()) { |
124 | - l.handleMessage(pccId, msg); | 142 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), |
143 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
125 | } | 144 | } |
126 | break; | 145 | break; |
127 | - case UPDATE: | 146 | + case REPORT: |
128 | - for (PcepEventListener l : pcepEventListener) { | 147 | + //Only update the listener if respective capability is supported else send PCEP-ERR msg |
129 | - l.handleMessage(pccId, msg); | 148 | + if (pc.capability().statefulPceCapability()) { |
149 | + for (PcepEventListener l : pcepEventListener) { | ||
150 | + l.handleMessage(pccId, msg); | ||
151 | + } | ||
152 | + } else { | ||
153 | + // Send PCEP-ERROR message. | ||
154 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
155 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
130 | } | 156 | } |
131 | break; | 157 | break; |
132 | - case INITIATE: | 158 | + case UPDATE: |
133 | - for (PcepEventListener l : pcepEventListener) { | 159 | + if (!pc.capability().statefulPceCapability()) { |
134 | - l.handleMessage(pccId, msg); | 160 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), |
161 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
135 | } | 162 | } |
136 | break; | 163 | break; |
137 | case LABEL_UPDATE: | 164 | case LABEL_UPDATE: |
165 | + if (!pc.capability().pceccCapability()) { | ||
166 | + pc.sendMessage(Collections.singletonList(getErrMsg(pc.factory(), | ||
167 | + ERROR_TYPE_19, ERROR_VALUE_5))); | ||
168 | + } | ||
138 | break; | 169 | break; |
139 | case MAX: | 170 | case MAX: |
140 | break; | 171 | break; |
... | @@ -154,6 +185,26 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -154,6 +185,26 @@ public class PcepClientControllerAdapter implements PcepClientController { |
154 | } | 185 | } |
155 | } | 186 | } |
156 | 187 | ||
188 | + private PcepErrorMsg getErrMsg(PcepFactory factory, byte errorType, byte errorValue) { | ||
189 | + LinkedList<PcepError> llPcepErr = new LinkedList<>(); | ||
190 | + | ||
191 | + LinkedList<PcepErrorObject> llerrObj = new LinkedList<>(); | ||
192 | + PcepErrorMsg errMsg; | ||
193 | + | ||
194 | + PcepErrorObject errObj = factory.buildPcepErrorObject().setErrorValue(errorValue).setErrorType(errorType) | ||
195 | + .build(); | ||
196 | + | ||
197 | + llerrObj.add(errObj); | ||
198 | + PcepError pcepErr = factory.buildPcepError().setErrorObjList(llerrObj).build(); | ||
199 | + | ||
200 | + llPcepErr.add(pcepErr); | ||
201 | + | ||
202 | + PcepErrorInfo errInfo = factory.buildPcepErrorInfo().setPcepErrorList(llPcepErr).build(); | ||
203 | + | ||
204 | + errMsg = factory.buildPcepErrorMsg().setPcepErrorInfo(errInfo).build(); | ||
205 | + return errMsg; | ||
206 | + } | ||
207 | + | ||
157 | /** | 208 | /** |
158 | * Implementation of an Pcep Agent which is responsible for | 209 | * Implementation of an Pcep Agent which is responsible for |
159 | * keeping track of connected clients and the state in which | 210 | * keeping track of connected clients and the state in which |
... | @@ -200,5 +251,4 @@ public class PcepClientControllerAdapter implements PcepClientController { | ... | @@ -200,5 +251,4 @@ public class PcepClientControllerAdapter implements PcepClientController { |
200 | processClientMessage(pccId, m); | 251 | processClientMessage(pccId, m); |
201 | } | 252 | } |
202 | } | 253 | } |
203 | - | ||
204 | } | 254 | } | ... | ... |
... | @@ -15,6 +15,10 @@ | ... | @@ -15,6 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.provider.pcep.tunnel.impl; | 16 | package org.onosproject.provider.pcep.tunnel.impl; |
17 | 17 | ||
18 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
19 | +import static org.hamcrest.Matchers.nullValue; | ||
20 | +import static org.hamcrest.core.Is.is; | ||
21 | +import static org.hamcrest.core.IsNot.not; | ||
18 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 22 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
19 | 23 | ||
20 | import java.io.IOException; | 24 | import java.io.IOException; |
... | @@ -22,6 +26,7 @@ import java.util.ArrayList; | ... | @@ -22,6 +26,7 @@ import java.util.ArrayList; |
22 | import java.util.List; | 26 | import java.util.List; |
23 | 27 | ||
24 | import org.junit.After; | 28 | import org.junit.After; |
29 | +import org.junit.Before; | ||
25 | import org.junit.Test; | 30 | import org.junit.Test; |
26 | import org.onlab.packet.IpAddress; | 31 | import org.onlab.packet.IpAddress; |
27 | import org.onosproject.cfg.ComponentConfigAdapter; | 32 | import org.onosproject.cfg.ComponentConfigAdapter; |
... | @@ -41,19 +46,21 @@ import org.onosproject.net.PortNumber; | ... | @@ -41,19 +46,21 @@ import org.onosproject.net.PortNumber; |
41 | import org.onosproject.net.provider.ProviderId; | 46 | import org.onosproject.net.provider.ProviderId; |
42 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; | 47 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; |
43 | 48 | ||
44 | - | 49 | +/** |
50 | + * Test for PCEP release tunnel. | ||
51 | + */ | ||
45 | public class PcepReleaseTunnelProviderTest { | 52 | public class PcepReleaseTunnelProviderTest { |
46 | 53 | ||
47 | - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; | 54 | + public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
48 | - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); | 55 | + private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
49 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); | 56 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); |
50 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 57 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
51 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 58 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
52 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); | 59 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); |
53 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 60 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
54 | 61 | ||
55 | - @Test | 62 | + @Before |
56 | - public void testCasePcepReleaseTunnel() { | 63 | + public void setUp() throws IOException { |
57 | tunnelProvider.tunnelProviderRegistry = registry; | 64 | tunnelProvider.tunnelProviderRegistry = registry; |
58 | tunnelProvider.pcepClientController = controller; | 65 | tunnelProvider.pcepClientController = controller; |
59 | tunnelProvider.controller = ctl; | 66 | tunnelProvider.controller = ctl; |
... | @@ -61,7 +68,13 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -61,7 +68,13 @@ public class PcepReleaseTunnelProviderTest { |
61 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; | 68 | tunnelProvider.pcepTunnelApiMapper = pcepTunnelAPIMapper; |
62 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 69 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
63 | tunnelProvider.activate(); | 70 | tunnelProvider.activate(); |
71 | + } | ||
64 | 72 | ||
73 | + /** | ||
74 | + * Release tunnel with negotiated capability. | ||
75 | + */ | ||
76 | + @Test | ||
77 | + public void testCasePcepReleaseTunnel() { | ||
65 | Tunnel tunnel; | 78 | Tunnel tunnel; |
66 | Path path; | 79 | Path path; |
67 | List<Link> links = new ArrayList<Link>(); | 80 | List<Link> links = new ArrayList<Link>(); |
... | @@ -104,8 +117,58 @@ public class PcepReleaseTunnelProviderTest { | ... | @@ -104,8 +117,58 @@ public class PcepReleaseTunnelProviderTest { |
104 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 117 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
105 | 118 | ||
106 | tunnelProvider.releaseTunnel(tunnel); | 119 | tunnelProvider.releaseTunnel(tunnel); |
120 | + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | ||
107 | } | 121 | } |
108 | 122 | ||
123 | + /** | ||
124 | + * Doesn't send initiate message because PCC doesn't supports PCInitiate and stateful capability. | ||
125 | + */ | ||
126 | + @Test | ||
127 | + public void testCasePcepReleaseTunnel2() { | ||
128 | + Tunnel tunnel; | ||
129 | + Path path; | ||
130 | + List<Link> links = new ArrayList<Link>(); | ||
131 | + | ||
132 | + ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | ||
133 | + | ||
134 | + IpAddress srcIp = IpAddress.valueOf(0xB6024E22); | ||
135 | + IpElementId srcElementId = IpElementId.ipElement(srcIp); | ||
136 | + | ||
137 | + IpAddress dstIp = IpAddress.valueOf(0xB6024E21); | ||
138 | + IpElementId dstElementId = IpElementId.ipElement(dstIp); | ||
139 | + | ||
140 | + IpTunnelEndPoint ipTunnelEndPointSrc; | ||
141 | + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); | ||
142 | + | ||
143 | + IpTunnelEndPoint ipTunnelEndPointDst; | ||
144 | + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); | ||
145 | + | ||
146 | + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | ||
147 | + | ||
148 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | ||
149 | + | ||
150 | + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | ||
151 | + .type(Link.Type.DIRECT).build(); | ||
152 | + links.add(link); | ||
153 | + | ||
154 | + path = new DefaultPath(pid, links, 20, EMPTY); | ||
155 | + | ||
156 | + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | ||
157 | + new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), | ||
158 | + path, EMPTY); | ||
159 | + | ||
160 | + // for releasing tunnel tunnel should exist in db | ||
161 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.DELETE); | ||
162 | + pcepTunnelData.setPlspId(1); | ||
163 | + StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); | ||
164 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); | ||
165 | + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
166 | + | ||
167 | + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | ||
168 | + | ||
169 | + tunnelProvider.releaseTunnel(tunnel); | ||
170 | + assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | ||
171 | + } | ||
109 | 172 | ||
110 | @After | 173 | @After |
111 | public void tearDown() throws IOException { | 174 | public void tearDown() throws IOException { | ... | ... |
... | @@ -16,12 +16,17 @@ | ... | @@ -16,12 +16,17 @@ |
16 | package org.onosproject.provider.pcep.tunnel.impl; | 16 | package org.onosproject.provider.pcep.tunnel.impl; |
17 | 17 | ||
18 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 18 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
19 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
20 | +import static org.hamcrest.core.Is.is; | ||
21 | +import static org.hamcrest.core.IsNot.not; | ||
22 | +import static org.hamcrest.Matchers.nullValue; | ||
19 | 23 | ||
20 | import java.io.IOException; | 24 | import java.io.IOException; |
21 | import java.util.ArrayList; | 25 | import java.util.ArrayList; |
22 | import java.util.List; | 26 | import java.util.List; |
23 | 27 | ||
24 | import org.junit.After; | 28 | import org.junit.After; |
29 | +import org.junit.Before; | ||
25 | import org.junit.Test; | 30 | import org.junit.Test; |
26 | import org.onlab.packet.IpAddress; | 31 | import org.onlab.packet.IpAddress; |
27 | import org.onosproject.cfg.ComponentConfigAdapter; | 32 | import org.onosproject.cfg.ComponentConfigAdapter; |
... | @@ -40,26 +45,33 @@ import org.onosproject.net.Path; | ... | @@ -40,26 +45,33 @@ import org.onosproject.net.Path; |
40 | import org.onosproject.net.PortNumber; | 45 | import org.onosproject.net.PortNumber; |
41 | import org.onosproject.net.provider.ProviderId; | 46 | import org.onosproject.net.provider.ProviderId; |
42 | 47 | ||
48 | +/** | ||
49 | + * Test for PCEP setup tunnel. | ||
50 | + */ | ||
43 | public class PcepSetupTunnelProviderTest { | 51 | public class PcepSetupTunnelProviderTest { |
44 | 52 | ||
45 | - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; | 53 | + public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
46 | - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); | 54 | + private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
47 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); | 55 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); |
48 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 56 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
49 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 57 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
50 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 58 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
51 | 59 | ||
52 | - @Test | 60 | + @Before |
53 | - public void testCasePcepSetupTunnel() { | 61 | + public void setUp() throws IOException { |
54 | - | ||
55 | tunnelProvider.tunnelProviderRegistry = registry; | 62 | tunnelProvider.tunnelProviderRegistry = registry; |
56 | tunnelProvider.pcepClientController = controller; | 63 | tunnelProvider.pcepClientController = controller; |
57 | tunnelProvider.controller = ctl; | 64 | tunnelProvider.controller = ctl; |
58 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 65 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
59 | tunnelProvider.tunnelService = tunnelService; | 66 | tunnelProvider.tunnelService = tunnelService; |
60 | tunnelProvider.activate(); | 67 | tunnelProvider.activate(); |
68 | + } | ||
61 | 69 | ||
62 | - | 70 | + /** |
71 | + * Send PcInitiate message to PCC. | ||
72 | + */ | ||
73 | + @Test | ||
74 | + public void testCasePcepSetupTunnel() { | ||
63 | Tunnel tunnel; | 75 | Tunnel tunnel; |
64 | Path path; | 76 | Path path; |
65 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | 77 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
... | @@ -91,6 +103,46 @@ public class PcepSetupTunnelProviderTest { | ... | @@ -91,6 +103,46 @@ public class PcepSetupTunnelProviderTest { |
91 | path, EMPTY); | 103 | path, EMPTY); |
92 | 104 | ||
93 | tunnelProvider.setupTunnel(tunnel, path); | 105 | tunnelProvider.setupTunnel(tunnel, path); |
106 | + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | ||
107 | + } | ||
108 | + | ||
109 | + /** | ||
110 | + * Doesn't send PCInitiate message because PCC doesn't supports PCInitiate and stateful capability. | ||
111 | + */ | ||
112 | + @Test | ||
113 | + public void testCasePcepSetupTunnel2() { | ||
114 | + Tunnel tunnel; | ||
115 | + Path path; | ||
116 | + ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | ||
117 | + List<Link> links = new ArrayList<Link>(); | ||
118 | + IpAddress srcIp = IpAddress.valueOf(0xC010103); | ||
119 | + IpElementId srcElementId = IpElementId.ipElement(srcIp); | ||
120 | + | ||
121 | + IpAddress dstIp = IpAddress.valueOf(0xC010102); | ||
122 | + IpElementId dstElementId = IpElementId.ipElement(dstIp); | ||
123 | + | ||
124 | + IpTunnelEndPoint ipTunnelEndPointSrc; | ||
125 | + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); | ||
126 | + | ||
127 | + IpTunnelEndPoint ipTunnelEndPointDst; | ||
128 | + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); | ||
129 | + | ||
130 | + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | ||
131 | + | ||
132 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | ||
133 | + | ||
134 | + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | ||
135 | + .type(Link.Type.DIRECT).build(); | ||
136 | + links.add(link); | ||
137 | + | ||
138 | + path = new DefaultPath(pid, links, 10, EMPTY); | ||
139 | + | ||
140 | + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | ||
141 | + new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), | ||
142 | + path, EMPTY); | ||
143 | + | ||
144 | + tunnelProvider.setupTunnel(tunnel, path); | ||
145 | + assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | ||
94 | } | 146 | } |
95 | 147 | ||
96 | @After | 148 | @After | ... | ... |
... | @@ -42,8 +42,8 @@ import org.onosproject.cfg.ComponentConfigAdapter; | ... | @@ -42,8 +42,8 @@ import org.onosproject.cfg.ComponentConfigAdapter; |
42 | 42 | ||
43 | public class PcepTunnelProviderTest { | 43 | public class PcepTunnelProviderTest { |
44 | 44 | ||
45 | - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; | 45 | + public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
46 | - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); | 46 | + private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
47 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); | 47 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); |
48 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 48 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
49 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 49 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | ... | ... |
... | @@ -15,6 +15,10 @@ | ... | @@ -15,6 +15,10 @@ |
15 | */ | 15 | */ |
16 | package org.onosproject.provider.pcep.tunnel.impl; | 16 | package org.onosproject.provider.pcep.tunnel.impl; |
17 | 17 | ||
18 | +import static org.hamcrest.MatcherAssert.assertThat; | ||
19 | +import static org.hamcrest.Matchers.nullValue; | ||
20 | +import static org.hamcrest.core.Is.is; | ||
21 | +import static org.hamcrest.core.IsNot.not; | ||
18 | import static org.onosproject.net.DefaultAnnotations.EMPTY; | 22 | import static org.onosproject.net.DefaultAnnotations.EMPTY; |
19 | 23 | ||
20 | import java.io.IOException; | 24 | import java.io.IOException; |
... | @@ -22,6 +26,7 @@ import java.util.ArrayList; | ... | @@ -22,6 +26,7 @@ import java.util.ArrayList; |
22 | import java.util.List; | 26 | import java.util.List; |
23 | 27 | ||
24 | import org.junit.After; | 28 | import org.junit.After; |
29 | +import org.junit.Before; | ||
25 | import org.junit.Test; | 30 | import org.junit.Test; |
26 | import org.onlab.packet.IpAddress; | 31 | import org.onlab.packet.IpAddress; |
27 | import org.onosproject.cfg.ComponentConfigAdapter; | 32 | import org.onosproject.cfg.ComponentConfigAdapter; |
... | @@ -41,20 +46,21 @@ import org.onosproject.net.PortNumber; | ... | @@ -41,20 +46,21 @@ import org.onosproject.net.PortNumber; |
41 | import org.onosproject.net.provider.ProviderId; | 46 | import org.onosproject.net.provider.ProviderId; |
42 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; | 47 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentidiersTlv; |
43 | 48 | ||
44 | - | 49 | +/** |
50 | + * Test for PCEP update tunnel. | ||
51 | + */ | ||
45 | public class PcepUpdateTunnelProviderTest { | 52 | public class PcepUpdateTunnelProviderTest { |
46 | 53 | ||
47 | - static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; | 54 | + public static final String PROVIDER_ID = "org.onosproject.provider.tunnel.pcep"; |
48 | - PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); | 55 | + private PcepTunnelProvider tunnelProvider = new PcepTunnelProvider(); |
49 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); | 56 | private final TunnelProviderRegistryAdapter registry = new TunnelProviderRegistryAdapter(); |
50 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); | 57 | private final PcepClientControllerAdapter controller = new PcepClientControllerAdapter(); |
51 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); | 58 | private final PcepControllerAdapter ctl = new PcepControllerAdapter(); |
52 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); | 59 | private final PcepTunnelApiMapper pcepTunnelAPIMapper = new PcepTunnelApiMapper(); |
53 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); | 60 | private final TunnelServiceAdapter tunnelService = new TunnelServiceAdapter(); |
54 | 61 | ||
55 | - | 62 | + @Before |
56 | - @Test | 63 | + public void setUp() throws IOException { |
57 | - public void testCasePcepUpdateTunnel() { | ||
58 | tunnelProvider.tunnelProviderRegistry = registry; | 64 | tunnelProvider.tunnelProviderRegistry = registry; |
59 | tunnelProvider.pcepClientController = controller; | 65 | tunnelProvider.pcepClientController = controller; |
60 | tunnelProvider.controller = ctl; | 66 | tunnelProvider.controller = ctl; |
... | @@ -62,7 +68,13 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -62,7 +68,13 @@ public class PcepUpdateTunnelProviderTest { |
62 | tunnelProvider.cfgService = new ComponentConfigAdapter(); | 68 | tunnelProvider.cfgService = new ComponentConfigAdapter(); |
63 | tunnelProvider.tunnelService = tunnelService; | 69 | tunnelProvider.tunnelService = tunnelService; |
64 | tunnelProvider.activate(); | 70 | tunnelProvider.activate(); |
71 | + } | ||
65 | 72 | ||
73 | + /** | ||
74 | + * Send update message to PCC. | ||
75 | + */ | ||
76 | + @Test | ||
77 | + public void testCasePcepUpdateTunnel() { | ||
66 | Tunnel tunnel; | 78 | Tunnel tunnel; |
67 | Path path; | 79 | Path path; |
68 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | 80 | ProviderId pid = new ProviderId("pcep", PROVIDER_ID); |
... | @@ -103,6 +115,55 @@ public class PcepUpdateTunnelProviderTest { | ... | @@ -103,6 +115,55 @@ public class PcepUpdateTunnelProviderTest { |
103 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | 115 | tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); |
104 | 116 | ||
105 | tunnelProvider.updateTunnel(tunnel, path); | 117 | tunnelProvider.updateTunnel(tunnel, path); |
118 | + assertThat(tunnelProvider.pcepTunnelApiMapper, not(nullValue())); | ||
119 | + } | ||
120 | + | ||
121 | + /** | ||
122 | + * Doesn't send update message because PCC doesn't supports PCE stateful capability. | ||
123 | + */ | ||
124 | + @Test | ||
125 | + public void testCasePcepUpdateTunnel2() { | ||
126 | + Tunnel tunnel; | ||
127 | + Path path; | ||
128 | + ProviderId pid = new ProviderId("pcep", PROVIDER_ID); | ||
129 | + List<Link> links = new ArrayList<Link>(); | ||
130 | + IpAddress srcIp = IpAddress.valueOf(0xC010103); | ||
131 | + IpElementId srcElementId = IpElementId.ipElement(srcIp); | ||
132 | + | ||
133 | + IpAddress dstIp = IpAddress.valueOf(0xD010102); | ||
134 | + IpElementId dstElementId = IpElementId.ipElement(dstIp); | ||
135 | + | ||
136 | + IpTunnelEndPoint ipTunnelEndPointSrc; | ||
137 | + ipTunnelEndPointSrc = IpTunnelEndPoint.ipTunnelPoint(srcIp); | ||
138 | + | ||
139 | + IpTunnelEndPoint ipTunnelEndPointDst; | ||
140 | + ipTunnelEndPointDst = IpTunnelEndPoint.ipTunnelPoint(dstIp); | ||
141 | + | ||
142 | + ConnectPoint src = new ConnectPoint(srcElementId, PortNumber.portNumber(10023)); | ||
143 | + | ||
144 | + ConnectPoint dst = new ConnectPoint(dstElementId, PortNumber.portNumber(10023)); | ||
145 | + | ||
146 | + Link link = DefaultLink.builder().providerId(pid).src(src).dst(dst) | ||
147 | + .type(Link.Type.DIRECT).build(); | ||
148 | + links.add(link); | ||
149 | + | ||
150 | + path = new DefaultPath(pid, links, 20, EMPTY); | ||
151 | + | ||
152 | + tunnel = new DefaultTunnel(pid, ipTunnelEndPointSrc, ipTunnelEndPointDst, Tunnel.Type.MPLS, | ||
153 | + new DefaultGroupId(0), TunnelId.valueOf(1), TunnelName.tunnelName("T123"), | ||
154 | + path, EMPTY); | ||
155 | + | ||
156 | + // for updating tunnel tunnel should exist in db | ||
157 | + PcepTunnelData pcepTunnelData = new PcepTunnelData(tunnel, path, RequestType.UPDATE); | ||
158 | + pcepTunnelData.setPlspId(1); | ||
159 | + StatefulIPv4LspIdentidiersTlv tlv = new StatefulIPv4LspIdentidiersTlv(0, (short) 1, (short) 2, 3, 4); | ||
160 | + pcepTunnelData.setStatefulIpv4IndentifierTlv(tlv); | ||
161 | + tunnelProvider.pcepTunnelApiMapper.addToTunnelIdMap(pcepTunnelData); | ||
162 | + | ||
163 | + tunnelProvider.pcepTunnelApiMapper.handleCreateTunnelRequestQueue(1, pcepTunnelData); | ||
164 | + | ||
165 | + tunnelProvider.updateTunnel(tunnel, path); | ||
166 | + assertThat(tunnelProvider.pcepTunnelApiMapper.checkFromTunnelRequestQueue(1), is(false)); | ||
106 | } | 167 | } |
107 | 168 | ||
108 | @After | 169 | @After | ... | ... |
-
Please register or login to post a comment