[ONOS] cherry picked from 1.6, bandwidth, CR and resilency fix
Change-Id: Ifd7bf886d2725db1f5e2f7a1eac739d9a446f868
Showing
9 changed files
with
110 additions
and
21 deletions
... | @@ -114,7 +114,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; | ... | @@ -114,7 +114,6 @@ import static org.onosproject.incubator.net.tunnel.Tunnel.Type.MPLS; |
114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; | 114 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.INIT; |
115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; | 115 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.ESTABLISHED; |
116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; | 116 | import static org.onosproject.incubator.net.tunnel.Tunnel.State.UNSTABLE; |
117 | -import static org.onosproject.incubator.net.tunnel.Tunnel.State.FAILED; | ||
118 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; | 117 | import static org.onosproject.pce.pceservice.LspType.WITH_SIGNALLING; |
119 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; | 118 | import static org.onosproject.pce.pceservice.LspType.SR_WITHOUT_SIGNALLING; |
120 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 119 | import static org.onosproject.pce.pceservice.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
... | @@ -1178,10 +1177,6 @@ public class PceManager implements PceService { | ... | @@ -1178,10 +1177,6 @@ public class PceManager implements PceService { |
1178 | tunnel.tunnelName().value(), constraints, lspType)); | 1177 | tunnel.tunnelName().value(), constraints, lspType)); |
1179 | } | 1178 | } |
1180 | 1179 | ||
1181 | - if (tunnel.state() == FAILED) { | ||
1182 | - // Check whether this ONOS instance is master, if yes, recompute and send update. | ||
1183 | - checkForMasterAndUpdateTunnel(tunnel.path().src().deviceId(), tunnel); | ||
1184 | - } | ||
1185 | break; | 1180 | break; |
1186 | 1181 | ||
1187 | case TUNNEL_REMOVED: | 1182 | case TUNNEL_REMOVED: | ... | ... |
... | @@ -107,8 +107,6 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { | ... | @@ -107,8 +107,6 @@ public final class BgpLinkAttrMaxLinkBandwidth implements BgpValueType { |
107 | * @return normal float | 107 | * @return normal float |
108 | */ | 108 | */ |
109 | static float ieeeToFloatRead(int iVal) { | 109 | static float ieeeToFloatRead(int iVal) { |
110 | - iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) | ||
111 | - | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); | ||
112 | 110 | ||
113 | return Float.intBitsToFloat(iVal); | 111 | return Float.intBitsToFloat(iVal); |
114 | } | 112 | } | ... | ... |
... | @@ -115,8 +115,6 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType { | ... | @@ -115,8 +115,6 @@ public class BgpLinkAttrUnRsrvdLinkBandwidth implements BgpValueType { |
115 | * @return normal float | 115 | * @return normal float |
116 | */ | 116 | */ |
117 | static float ieeeToFloatRead(int iVal) { | 117 | static float ieeeToFloatRead(int iVal) { |
118 | - iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) | ||
119 | - | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); | ||
120 | 118 | ||
121 | return Float.intBitsToFloat(iVal); | 119 | return Float.intBitsToFloat(iVal); |
122 | } | 120 | } | ... | ... |
... | @@ -135,8 +135,6 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -135,8 +135,6 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
135 | * @return normal float | 135 | * @return normal float |
136 | */ | 136 | */ |
137 | public static float ieeeToFloatRead(int iVal) { | 137 | public static float ieeeToFloatRead(int iVal) { |
138 | - iVal = (((iVal & 0xFF) << 24) | ((iVal & 0xFF00) << 8) | ||
139 | - | ((iVal & 0xFF0000) >> 8) | ((iVal >> 24) & 0xFF)); | ||
140 | 138 | ||
141 | return Float.intBitsToFloat(iVal); | 139 | return Float.intBitsToFloat(iVal); |
142 | } | 140 | } |
... | @@ -152,7 +150,16 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { | ... | @@ -152,7 +150,16 @@ public class PcepBandwidthObjectVer1 implements PcepBandwidthObject { |
152 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); | 150 | throw new PcepParseException("Failed to write bandwidth object header. Index " + objLenIndex); |
153 | } | 151 | } |
154 | 152 | ||
155 | - cb.writeInt(Float.floatToIntBits(iBandwidth)); | 153 | + //Convert to bytes per second |
154 | + float bwBytes = iBandwidth / 8.0f; | ||
155 | + //Bytes/sec to IEEE floating format | ||
156 | + int bandwidth = Float.floatToIntBits(bwBytes); | ||
157 | + | ||
158 | + cb.writeByte(bandwidth >>> 24); | ||
159 | + cb.writeByte(bandwidth >> 16 & 0xff); | ||
160 | + cb.writeByte(bandwidth >> 8 & 0xff); | ||
161 | + cb.writeByte(bandwidth & 0xff); | ||
162 | + | ||
156 | short hLength = (short) (cb.writerIndex() - objStartIndex); | 163 | short hLength = (short) (cb.writerIndex() - objStartIndex); |
157 | cb.setShort(objLenIndex, hLength); | 164 | cb.setShort(objLenIndex, hLength); |
158 | //will be helpful during print(). | 165 | //will be helpful during print(). | ... | ... |
... | @@ -491,6 +491,8 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi | ... | @@ -491,6 +491,8 @@ public class BgpTopologyProvider extends AbstractProvider implements DeviceProvi |
491 | switch (tlv.getType()) { | 491 | switch (tlv.getType()) { |
492 | case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH: | 492 | case LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH: |
493 | maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth(); | 493 | maxReservableBw = ((BgpLinkAttrMaxLinkBandwidth) tlv).linkAttrMaxLinkBandwidth(); |
494 | + //will get in bits/second , convert to MBPS to store in network config service | ||
495 | + maxReservableBw = maxReservableBw / 1000000; | ||
494 | break; | 496 | break; |
495 | default: // do nothing | 497 | default: // do nothing |
496 | } | 498 | } | ... | ... |
... | @@ -1005,7 +1005,8 @@ public class BgpTopologyProviderTest { | ... | @@ -1005,7 +1005,8 @@ public class BgpTopologyProviderTest { |
1005 | linkStateAttr.add(tlv); | 1005 | linkStateAttr.add(tlv); |
1006 | tlv = BgpLinkAttrTeDefaultMetric.of(20); | 1006 | tlv = BgpLinkAttrTeDefaultMetric.of(20); |
1007 | linkStateAttr.add(tlv); | 1007 | linkStateAttr.add(tlv); |
1008 | - tlv = BgpLinkAttrMaxLinkBandwidth.of(70, LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH); | 1008 | + tlv = BgpLinkAttrMaxLinkBandwidth.of((float) 70 * 1_000_000L, |
1009 | + LinkStateAttributes.ATTR_LINK_MAX_RES_BANDWIDTH); | ||
1009 | linkStateAttr.add(tlv); | 1010 | linkStateAttr.add(tlv); |
1010 | linkPathAttributes.add(new LinkStateAttributes(linkStateAttr)); | 1011 | linkPathAttributes.add(new LinkStateAttributes(linkStateAttr)); |
1011 | details.setPathAttribute(linkPathAttributes); | 1012 | details.setPathAttribute(linkPathAttributes); | ... | ... |
... | @@ -89,11 +89,14 @@ import org.onosproject.pcepio.types.PcepValueType; | ... | @@ -89,11 +89,14 @@ import org.onosproject.pcepio.types.PcepValueType; |
89 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; | 89 | import org.onosproject.pcepio.types.StatefulIPv4LspIdentifiersTlv; |
90 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; | 90 | import org.onosproject.pcepio.types.SymbolicPathNameTlv; |
91 | import org.onosproject.pcep.controller.LspType; | 91 | import org.onosproject.pcep.controller.LspType; |
92 | +import org.onosproject.pcepio.protocol.PcepAttribute; | ||
93 | +import org.onosproject.pcepio.protocol.PcepBandwidthObject; | ||
92 | import org.onosproject.pcep.controller.SrpIdGenerators; | 94 | import org.onosproject.pcep.controller.SrpIdGenerators; |
93 | import org.onosproject.pcep.controller.PcepAnnotationKeys; | 95 | import org.onosproject.pcep.controller.PcepAnnotationKeys; |
94 | import org.osgi.service.component.ComponentContext; | 96 | import org.osgi.service.component.ComponentContext; |
95 | import org.slf4j.Logger; | 97 | import org.slf4j.Logger; |
96 | 98 | ||
99 | +import static org.onosproject.pcep.controller.PcepAnnotationKeys.BANDWIDTH; | ||
97 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; | 100 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; |
98 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; | 101 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.LSP_SIG_TYPE; |
99 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT; | 102 | import static org.onosproject.pcep.controller.PcepAnnotationKeys.PCE_INIT; |
... | @@ -530,8 +533,23 @@ public class BgpcepFlowRuleProvider extends AbstractProvider | ... | @@ -530,8 +533,23 @@ public class BgpcepFlowRuleProvider extends AbstractProvider |
530 | .setSubObjects(subObjects) | 533 | .setSubObjects(subObjects) |
531 | .build(); | 534 | .build(); |
532 | 535 | ||
536 | + float iBandwidth = 0; | ||
537 | + if (tunnel.annotations().value(BANDWIDTH) != null) { | ||
538 | + //iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH))); | ||
539 | + iBandwidth = Float.parseFloat(tunnel.annotations().value(BANDWIDTH)); | ||
540 | + } | ||
541 | + // build bandwidth object | ||
542 | + PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject() | ||
543 | + .setBandwidth(iBandwidth) | ||
544 | + .build(); | ||
545 | + // build pcep attribute | ||
546 | + PcepAttribute pcepAttribute = pc.factory().buildPcepAttribute() | ||
547 | + .setBandwidthObject(bandwidthObject) | ||
548 | + .build(); | ||
549 | + | ||
533 | PcepMsgPath msgPath = pc.factory().buildPcepMsgPath() | 550 | PcepMsgPath msgPath = pc.factory().buildPcepMsgPath() |
534 | .setEroObject(eroObj) | 551 | .setEroObject(eroObj) |
552 | + .setPcepAttribute(pcepAttribute) | ||
535 | .build(); | 553 | .build(); |
536 | 554 | ||
537 | PcepUpdateRequest updateReq = pc.factory().buildPcepUpdateRequest() | 555 | PcepUpdateRequest updateReq = pc.factory().buildPcepUpdateRequest() | ... | ... |
... | @@ -66,6 +66,7 @@ import org.onosproject.net.Path; | ... | @@ -66,6 +66,7 @@ import org.onosproject.net.Path; |
66 | import org.onosproject.net.PortNumber; | 66 | import org.onosproject.net.PortNumber; |
67 | import org.onosproject.net.SparseAnnotations; | 67 | import org.onosproject.net.SparseAnnotations; |
68 | import org.onosproject.net.device.DeviceService; | 68 | import org.onosproject.net.device.DeviceService; |
69 | +import org.onosproject.net.link.LinkService; | ||
69 | import org.onosproject.net.provider.AbstractProvider; | 70 | import org.onosproject.net.provider.AbstractProvider; |
70 | import org.onosproject.net.provider.ProviderId; | 71 | import org.onosproject.net.provider.ProviderId; |
71 | import org.onosproject.pcep.api.PcepController; | 72 | import org.onosproject.pcep.api.PcepController; |
... | @@ -213,6 +214,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -213,6 +214,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
213 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | 214 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
214 | protected DeviceService deviceService; | 215 | protected DeviceService deviceService; |
215 | 216 | ||
217 | + @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) | ||
218 | + protected LinkService linkService; | ||
219 | + | ||
216 | TunnelProviderService service; | 220 | TunnelProviderService service; |
217 | 221 | ||
218 | HashMap<String, TunnelId> tunnelMap = new HashMap<String, TunnelId>(); | 222 | HashMap<String, TunnelId> tunnelMap = new HashMap<String, TunnelId>(); |
... | @@ -609,6 +613,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -609,6 +613,7 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
609 | if (tunnel.type() == MPLS) { | 613 | if (tunnel.type() == MPLS) { |
610 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); | 614 | pcepTunnelApiMapper.removeFromCoreTunnelRequestQueue(tunnel.id()); |
611 | service.tunnelRemoved(tunnel); | 615 | service.tunnelRemoved(tunnel); |
616 | + return; | ||
612 | } | 617 | } |
613 | 618 | ||
614 | Tunnel tunnelOld = tunnelQueryById(tunnel.id()); | 619 | Tunnel tunnelOld = tunnelQueryById(tunnel.id()); |
... | @@ -1012,9 +1017,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1012,9 +1017,9 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1012 | //build ERO object | 1017 | //build ERO object |
1013 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); | 1018 | PcepEroObject eroobj = pc.factory().buildEroObject().setSubObjects(llSubObjects).build(); |
1014 | 1019 | ||
1015 | - int iBandwidth = DEFAULT_BANDWIDTH_VALUE; | 1020 | + float iBandwidth = DEFAULT_BANDWIDTH_VALUE; |
1016 | if (tunnel.annotations().value(BANDWIDTH) != null) { | 1021 | if (tunnel.annotations().value(BANDWIDTH) != null) { |
1017 | - iBandwidth = Float.floatToIntBits(Float.parseFloat(tunnel.annotations().value(BANDWIDTH))); | 1022 | + iBandwidth = Float.valueOf(tunnel.annotations().value(BANDWIDTH)); |
1018 | } | 1023 | } |
1019 | // build bandwidth object | 1024 | // build bandwidth object |
1020 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); | 1025 | PcepBandwidthObject bandwidthObject = pc.factory().buildBandwidthObject().setBandwidth(iBandwidth).build(); |
... | @@ -1680,8 +1685,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1680,8 +1685,8 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1680 | bandwidth, lspType, | 1685 | bandwidth, lspType, |
1681 | tunnel.annotations().value(COST_TYPE)); | 1686 | tunnel.annotations().value(COST_TYPE)); |
1682 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( | 1687 | td = new DefaultTunnelDescription(null, tunnelEndPointSrc, tunnelEndPointDst, MPLS, new DefaultGroupId( |
1683 | - 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), path, labelStack, | 1688 | + 0), providerId, TunnelName.tunnelName(new String(pathNameTlv.getValue())), |
1684 | - annotations); | 1689 | + tunnel.path(), labelStack, annotations); |
1685 | tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); | 1690 | tunnelUpdateInDelegatedCase(pccId, annotations, td, providerId); |
1686 | } | 1691 | } |
1687 | removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, tunnelState); | 1692 | removeOrUpdatetunnel(tunnel, pccId, lspObj, providerId, tunnelState); |
... | @@ -1743,12 +1748,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid | ... | @@ -1743,12 +1748,29 @@ public class PcepTunnelProvider extends AbstractProvider implements TunnelProvid |
1743 | 1748 | ||
1744 | IPv4SubObject ipv4SubObj = (IPv4SubObject) subObj; | 1749 | IPv4SubObject ipv4SubObj = (IPv4SubObject) subObj; |
1745 | if (!isSrcSet) { | 1750 | if (!isSrcSet) { |
1746 | - IpAddress srcIp = IpAddress.valueOf(ipv4SubObj.getIpAddress()); | 1751 | + Iterable<Link> links = linkService.getActiveLinks(); |
1747 | - src = new ConnectPoint(IpElementId.ipElement(srcIp), PortNumber.portNumber(0)); | 1752 | + for (Link l : links) { |
1753 | + if (l.src().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) { | ||
1754 | + src = l.src(); | ||
1755 | + isSrcSet = true; | ||
1756 | + break; | ||
1757 | + } else if (l.dst().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) { | ||
1758 | + src = l.dst(); | ||
1748 | isSrcSet = true; | 1759 | isSrcSet = true; |
1760 | + break; | ||
1761 | + } | ||
1762 | + } | ||
1749 | } else { | 1763 | } else { |
1750 | - IpAddress dstIp = IpAddress.valueOf(ipv4SubObj.getIpAddress()); | 1764 | + Iterable<Link> links = linkService.getActiveLinks(); |
1751 | - dst = new ConnectPoint(IpElementId.ipElement(dstIp), PortNumber.portNumber(0)); | 1765 | + for (Link l : links) { |
1766 | + if (l.src().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) { | ||
1767 | + dst = l.src(); | ||
1768 | + break; | ||
1769 | + } else if (l.dst().port().equals(PortNumber.portNumber(ipv4SubObj.getIpAddress()))) { | ||
1770 | + dst = l.dst(); | ||
1771 | + break; | ||
1772 | + } | ||
1773 | + } | ||
1752 | Link link = DefaultLink.builder() | 1774 | Link link = DefaultLink.builder() |
1753 | .providerId(providerId) | 1775 | .providerId(providerId) |
1754 | .src(src) | 1776 | .src(src) | ... | ... |
... | @@ -28,6 +28,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; | ... | @@ -28,6 +28,7 @@ import static org.onosproject.pcep.controller.PcepAnnotationKeys.DELEGATE; |
28 | import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; | 28 | import static org.onosproject.pcep.controller.LspType.WITHOUT_SIGNALLING_AND_WITHOUT_SR; |
29 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; | 29 | import static org.onosproject.pcep.controller.PcepSyncStatus.SYNCED; |
30 | import static org.onosproject.net.Device.Type.ROUTER; | 30 | import static org.onosproject.net.Device.Type.ROUTER; |
31 | +import static org.onosproject.net.Link.State.ACTIVE; | ||
31 | import static org.onosproject.net.MastershipRole.MASTER; | 32 | import static org.onosproject.net.MastershipRole.MASTER; |
32 | 33 | ||
33 | import java.io.IOException; | 34 | import java.io.IOException; |
... | @@ -62,15 +63,20 @@ import org.onosproject.incubator.net.tunnel.TunnelProviderService; | ... | @@ -62,15 +63,20 @@ import org.onosproject.incubator.net.tunnel.TunnelProviderService; |
62 | import org.onosproject.incubator.net.tunnel.Tunnel.State; | 63 | import org.onosproject.incubator.net.tunnel.Tunnel.State; |
63 | import org.onosproject.mastership.MastershipServiceAdapter; | 64 | import org.onosproject.mastership.MastershipServiceAdapter; |
64 | import org.onosproject.net.AnnotationKeys; | 65 | import org.onosproject.net.AnnotationKeys; |
66 | +import org.onosproject.net.ConnectPoint; | ||
65 | import org.onosproject.net.DefaultAnnotations; | 67 | import org.onosproject.net.DefaultAnnotations; |
66 | import org.onosproject.net.DefaultDevice; | 68 | import org.onosproject.net.DefaultDevice; |
69 | +import org.onosproject.net.DefaultLink; | ||
67 | import org.onosproject.net.Device; | 70 | import org.onosproject.net.Device; |
68 | import org.onosproject.net.DeviceId; | 71 | import org.onosproject.net.DeviceId; |
69 | import org.onosproject.net.ElementId; | 72 | import org.onosproject.net.ElementId; |
73 | +import org.onosproject.net.Link; | ||
70 | import org.onosproject.net.MastershipRole; | 74 | import org.onosproject.net.MastershipRole; |
71 | import org.onosproject.net.Path; | 75 | import org.onosproject.net.Path; |
76 | +import org.onosproject.net.PortNumber; | ||
72 | import org.onosproject.net.SparseAnnotations; | 77 | import org.onosproject.net.SparseAnnotations; |
73 | import org.onosproject.net.device.DeviceServiceAdapter; | 78 | import org.onosproject.net.device.DeviceServiceAdapter; |
79 | +import org.onosproject.net.link.LinkServiceAdapter; | ||
74 | import org.onosproject.net.provider.ProviderId; | 80 | import org.onosproject.net.provider.ProviderId; |
75 | import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; | 81 | import org.onosproject.pcepio.exceptions.PcepOutOfBoundMessageException; |
76 | import org.onosproject.pcepio.exceptions.PcepParseException; | 82 | import org.onosproject.pcepio.exceptions.PcepParseException; |
... | @@ -82,6 +88,7 @@ import org.onosproject.pcep.controller.ClientCapability; | ... | @@ -82,6 +88,7 @@ import org.onosproject.pcep.controller.ClientCapability; |
82 | import org.onosproject.pcep.controller.LspKey; | 88 | import org.onosproject.pcep.controller.LspKey; |
83 | import org.onosproject.pcep.controller.PccId; | 89 | import org.onosproject.pcep.controller.PccId; |
84 | 90 | ||
91 | +import com.google.common.collect.FluentIterable; | ||
85 | import com.google.common.collect.ImmutableSet; | 92 | import com.google.common.collect.ImmutableSet; |
86 | 93 | ||
87 | /** | 94 | /** |
... | @@ -99,8 +106,23 @@ public class PcepTunnelAddedTest { | ... | @@ -99,8 +106,23 @@ public class PcepTunnelAddedTest { |
99 | private final MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter(); | 106 | private final MockTunnelServiceAdapter tunnelService = new MockTunnelServiceAdapter(); |
100 | public final MockDeviceService deviceService = new MockDeviceService(); | 107 | public final MockDeviceService deviceService = new MockDeviceService(); |
101 | private final MockMasterShipService masterShipService = new MockMasterShipService(); | 108 | private final MockMasterShipService masterShipService = new MockMasterShipService(); |
109 | + private final MockLinkService linkService = new MockLinkService(); | ||
102 | private final MockTunnelAdminService tunnelAdminService = new MockTunnelAdminService(); | 110 | private final MockTunnelAdminService tunnelAdminService = new MockTunnelAdminService(); |
103 | 111 | ||
112 | + private class MockLinkService extends LinkServiceAdapter { | ||
113 | + LinkedList<Link> links = new LinkedList<>(); | ||
114 | + void addLink(Link link) { | ||
115 | + links.add(link); | ||
116 | + } | ||
117 | + | ||
118 | + @Override | ||
119 | + public Iterable<Link> getActiveLinks() { | ||
120 | + | ||
121 | + return FluentIterable.from(links) | ||
122 | + .filter(input -> input.state() == ACTIVE); | ||
123 | + } | ||
124 | + } | ||
125 | + | ||
104 | private class MockTunnelAdminService implements TunnelAdminService { | 126 | private class MockTunnelAdminService implements TunnelAdminService { |
105 | 127 | ||
106 | @Override | 128 | @Override |
... | @@ -275,6 +297,7 @@ public class PcepTunnelAddedTest { | ... | @@ -275,6 +297,7 @@ public class PcepTunnelAddedTest { |
275 | tunnelProvider.tunnelService = tunnelService; | 297 | tunnelProvider.tunnelService = tunnelService; |
276 | tunnelProvider.tunnelAdminService = tunnelAdminService; | 298 | tunnelProvider.tunnelAdminService = tunnelAdminService; |
277 | tunnelProvider.service = registry.register(tunnelProvider); | 299 | tunnelProvider.service = registry.register(tunnelProvider); |
300 | + tunnelProvider.linkService = linkService; | ||
278 | tunnelProvider.activate(); | 301 | tunnelProvider.activate(); |
279 | } | 302 | } |
280 | 303 | ||
... | @@ -326,6 +349,14 @@ public class PcepTunnelAddedTest { | ... | @@ -326,6 +349,14 @@ public class PcepTunnelAddedTest { |
326 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( | 349 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( |
327 | new ClientCapability(true, true, true, true, true)); | 350 | new ClientCapability(true, true, true, true, true)); |
328 | masterShipService.setMaster(true); | 351 | masterShipService.setMaster(true); |
352 | + Link link = DefaultLink.builder() | ||
353 | + .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) | ||
354 | + .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) | ||
355 | + .state(ACTIVE) | ||
356 | + .type(Link.Type.DIRECT) | ||
357 | + .providerId(ProviderId.NONE) | ||
358 | + .build(); | ||
359 | + linkService.addLink(link); | ||
329 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); | 360 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
330 | 361 | ||
331 | assertThat(registry.tunnelIdCounter, is((long) 1)); | 362 | assertThat(registry.tunnelIdCounter, is((long) 1)); |
... | @@ -444,6 +475,14 @@ public class PcepTunnelAddedTest { | ... | @@ -444,6 +475,14 @@ public class PcepTunnelAddedTest { |
444 | controller.getClient(pccId).setLspDbSyncStatus(SYNCED); | 475 | controller.getClient(pccId).setLspDbSyncStatus(SYNCED); |
445 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); | 476 | controller.getClient(pccId).setCapability(new ClientCapability(true, true, true, true, true)); |
446 | 477 | ||
478 | + Link link = DefaultLink.builder() | ||
479 | + .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) | ||
480 | + .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) | ||
481 | + .state(ACTIVE) | ||
482 | + .type(Link.Type.DIRECT) | ||
483 | + .providerId(ProviderId.NONE) | ||
484 | + .build(); | ||
485 | + linkService.addLink(link); | ||
447 | PcepClientAdapter pc = new PcepClientAdapter(); | 486 | PcepClientAdapter pc = new PcepClientAdapter(); |
448 | pc.init(pccId, PcepVersion.PCEP_1); | 487 | pc.init(pccId, PcepVersion.PCEP_1); |
449 | controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); | 488 | controller.getClient(pccId).setLspAndDelegationInfo(new LspKey(1, (short) 1), true); |
... | @@ -505,6 +544,14 @@ public class PcepTunnelAddedTest { | ... | @@ -505,6 +544,14 @@ public class PcepTunnelAddedTest { |
505 | deviceService.addDevice(device); | 544 | deviceService.addDevice(device); |
506 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( | 545 | controller.getClient(PccId.pccId(IpAddress.valueOf("1.1.1.1"))).setCapability( |
507 | new ClientCapability(true, true, true, true, true)); | 546 | new ClientCapability(true, true, true, true, true)); |
547 | + Link link = DefaultLink.builder() | ||
548 | + .src(new ConnectPoint(device.id(), PortNumber.portNumber(16843009))) | ||
549 | + .dst(new ConnectPoint(device.id(), PortNumber.portNumber(84215045))) | ||
550 | + .state(ACTIVE) | ||
551 | + .type(Link.Type.DIRECT) | ||
552 | + .providerId(ProviderId.NONE) | ||
553 | + .build(); | ||
554 | + linkService.addLink(link); | ||
508 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); | 555 | controller.processClientMessage(PccId.pccId(IpAddress.valueOf("1.1.1.1")), message); |
509 | assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), | 556 | assertThat(tunnelService.tunnelIdAsKeyStore.values().iterator().next().annotations().value(DELEGATE), |
510 | is("false")); | 557 | is("false")); |
... | @@ -624,6 +671,7 @@ public class PcepTunnelAddedTest { | ... | @@ -624,6 +671,7 @@ public class PcepTunnelAddedTest { |
624 | tunnelProvider.tunnelAdminService = null; | 671 | tunnelProvider.tunnelAdminService = null; |
625 | tunnelProvider.deviceService = null; | 672 | tunnelProvider.deviceService = null; |
626 | tunnelProvider.mastershipService = null; | 673 | tunnelProvider.mastershipService = null; |
674 | + tunnelProvider.linkService = null; | ||
627 | tunnelProvider.service = null; | 675 | tunnelProvider.service = null; |
628 | } | 676 | } |
629 | } | 677 | } | ... | ... |
-
Please register or login to post a comment