cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 1 | /* |
Brian O'Connor | 5ab426f | 2016-04-09 01:19:45 -0700 | [diff] [blame] | 2 | * Copyright 2015-present Open Networking Laboratory |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 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.provider.pcep.topology.impl; |
| 17 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 18 | import org.apache.felix.scr.annotations.Activate; |
| 19 | import org.apache.felix.scr.annotations.Component; |
| 20 | import org.apache.felix.scr.annotations.Deactivate; |
| 21 | import org.apache.felix.scr.annotations.Reference; |
| 22 | import org.apache.felix.scr.annotations.ReferenceCardinality; |
| 23 | import org.onlab.packet.ChassisId; |
| 24 | import org.onosproject.cluster.ClusterService; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 25 | import org.onosproject.mastership.MastershipAdminService; |
| 26 | import org.onosproject.mastership.MastershipService; |
| 27 | import org.onosproject.net.ConnectPoint; |
| 28 | import org.onosproject.net.DefaultAnnotations; |
| 29 | import org.onosproject.net.Device; |
| 30 | import org.onosproject.net.DeviceId; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 31 | import org.onosproject.net.Link.Type; |
| 32 | import org.onosproject.net.MastershipRole; |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 33 | import org.onosproject.net.OchPort; |
| 34 | import org.onosproject.net.OduCltPort; |
| 35 | import org.onosproject.net.OmsPort; |
| 36 | import org.onosproject.net.Port; |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame] | 37 | import org.onosproject.net.PortNumber; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 38 | import org.onosproject.net.device.DefaultDeviceDescription; |
| 39 | import org.onosproject.net.device.DefaultPortDescription; |
| 40 | import org.onosproject.net.device.DeviceDescription; |
| 41 | import org.onosproject.net.device.DeviceProvider; |
| 42 | import org.onosproject.net.device.DeviceProviderRegistry; |
| 43 | import org.onosproject.net.device.DeviceProviderService; |
| 44 | import org.onosproject.net.device.DeviceService; |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 45 | import org.onosproject.net.device.OchPortDescription; |
| 46 | import org.onosproject.net.device.OduCltPortDescription; |
| 47 | import org.onosproject.net.device.OmsPortDescription; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 48 | import org.onosproject.net.device.PortDescription; |
| 49 | import org.onosproject.net.link.DefaultLinkDescription; |
| 50 | import org.onosproject.net.link.LinkDescription; |
| 51 | import org.onosproject.net.link.LinkProvider; |
| 52 | import org.onosproject.net.link.LinkProviderRegistry; |
| 53 | import org.onosproject.net.link.LinkProviderService; |
| 54 | import org.onosproject.net.link.LinkService; |
| 55 | import org.onosproject.net.provider.AbstractProvider; |
| 56 | import org.onosproject.net.provider.ProviderId; |
| 57 | import org.onosproject.pcep.api.PcepController; |
| 58 | import org.onosproject.pcep.api.PcepDpid; |
| 59 | import org.onosproject.pcep.api.PcepLink; |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 60 | import org.onosproject.pcep.api.PcepLink.PortType; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 61 | import org.onosproject.pcep.api.PcepLinkListener; |
| 62 | import org.onosproject.pcep.api.PcepOperator.OperationType; |
| 63 | import org.onosproject.pcep.api.PcepSwitch; |
| 64 | import org.onosproject.pcep.api.PcepSwitchListener; |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 65 | import org.onosproject.pcep.controller.PccId; |
| 66 | import org.onosproject.pcep.controller.PcepClient; |
| 67 | import org.onosproject.pcep.controller.PcepClientController; |
| 68 | import org.onosproject.pcep.controller.PcepNodeListener; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 69 | import org.slf4j.Logger; |
| 70 | import org.slf4j.LoggerFactory; |
| 71 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 72 | import java.util.ArrayList; |
| 73 | import java.util.HashMap; |
| 74 | import java.util.List; |
| 75 | |
| 76 | import static com.google.common.base.Preconditions.checkNotNull; |
| 77 | import static org.onosproject.net.DeviceId.deviceId; |
| 78 | import static org.onosproject.pcep.api.PcepDpid.uri; |
| 79 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 80 | /** |
| 81 | * Provider which uses an PCEP controller to detect network infrastructure |
| 82 | * topology. |
| 83 | */ |
| 84 | @Component(immediate = true) |
| 85 | public class PcepTopologyProvider extends AbstractProvider |
| 86 | implements LinkProvider, DeviceProvider { |
| 87 | |
Priyanka B | 9bee080 | 2016-04-27 22:06:02 +0530 | [diff] [blame] | 88 | /** |
| 89 | * Creates instance of PCEP topology provider. |
| 90 | */ |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 91 | public PcepTopologyProvider() { |
Priyanka B | 9bee080 | 2016-04-27 22:06:02 +0530 | [diff] [blame] | 92 | super(new ProviderId("l3", "org.onosproject.provider.pcep")); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 93 | } |
| 94 | |
| 95 | private static final Logger log = LoggerFactory |
| 96 | .getLogger(PcepTopologyProvider.class); |
| 97 | |
| 98 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 99 | protected LinkProviderRegistry linkProviderRegistry; |
| 100 | |
| 101 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 102 | protected DeviceProviderRegistry deviceProviderRegistry; |
| 103 | |
| 104 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 105 | protected PcepController controller; |
| 106 | |
| 107 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 108 | protected DeviceService deviceService; |
| 109 | |
| 110 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 111 | protected LinkService linkService; |
| 112 | |
| 113 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 114 | protected MastershipAdminService mastershipAdminService; |
| 115 | |
| 116 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 117 | protected MastershipService mastershipService; |
| 118 | |
| 119 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 120 | protected ClusterService clusterService; |
| 121 | |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 122 | @Reference(cardinality = ReferenceCardinality.MANDATORY_UNARY) |
| 123 | protected PcepClientController pcepClientController; |
| 124 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 125 | private DeviceProviderService deviceProviderService; |
| 126 | private LinkProviderService linkProviderService; |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 127 | |
| 128 | private HashMap<Long, List<PortDescription>> portMap = new HashMap<>(); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 129 | private InternalLinkProvider listener = new InternalLinkProvider(); |
| 130 | |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 131 | /* |
| 132 | * For the client supporting SR capability. |
| 133 | */ |
| 134 | public static final String SR_CAPABILITY = "srCapability"; |
| 135 | |
| 136 | /* |
| 137 | * For the client supporting PCECC capability. |
| 138 | */ |
| 139 | public static final String PCECC_CAPABILITY = "pceccCapability"; |
| 140 | |
| 141 | /* |
| 142 | * For the client supporting label stack capability. |
| 143 | */ |
| 144 | public static final String LABEL_STACK_CAPABILITY = "labelStackCapability"; |
| 145 | |
| 146 | public static final String LSRID = "lsrId"; |
| 147 | private static final String UNKNOWN = "unknown"; |
| 148 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 149 | @Activate |
| 150 | public void activate() { |
| 151 | linkProviderService = linkProviderRegistry.register(this); |
| 152 | deviceProviderService = deviceProviderRegistry.register(this); |
| 153 | controller.addListener(listener); |
| 154 | controller.addLinkListener(listener); |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 155 | pcepClientController.addNodeListener(listener); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 156 | } |
| 157 | |
| 158 | @Deactivate |
| 159 | public void deactivate() { |
| 160 | linkProviderRegistry.unregister(this); |
| 161 | linkProviderService = null; |
| 162 | controller.removeListener(listener); |
| 163 | controller.removeLinkListener(listener); |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 164 | pcepClientController.removeNodeListener(listener); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 165 | } |
| 166 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 167 | private List<PortDescription> buildPortDescriptions(PcepDpid dpid, |
| 168 | Port port, |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 169 | PortType portType) { |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 170 | |
| 171 | List<PortDescription> portList; |
| 172 | |
| 173 | if (portMap.containsKey(dpid.value())) { |
| 174 | portList = portMap.get(dpid.value()); |
| 175 | } else { |
| 176 | portList = new ArrayList<>(); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 177 | } |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 178 | if (port != null && portType != null) { |
| 179 | portList.add(buildPortDescription(port, portType)); |
| 180 | } |
| 181 | |
| 182 | portMap.put(dpid.value(), portList); |
| 183 | return portList; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 184 | } |
| 185 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 186 | private PortDescription buildPortDescription(Port port, PortType portType) { |
| 187 | PortDescription portDescription; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 188 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 189 | switch (portType) { |
| 190 | case OCH_PORT: |
| 191 | OchPort ochp = (OchPort) port; |
| 192 | portDescription = new OchPortDescription(ochp.number(), ochp.isEnabled(), |
| 193 | ochp.signalType(), ochp.isTunable(), |
| 194 | ochp.lambda()); |
| 195 | break; |
| 196 | case ODU_PORT: |
| 197 | OduCltPort odup = (OduCltPort) port; |
| 198 | portDescription = new OduCltPortDescription(odup.number(), odup.isEnabled(), |
| 199 | odup.signalType()); |
| 200 | break; |
| 201 | case OMS_PORT: |
| 202 | OmsPort op = (OmsPort) port; |
| 203 | portDescription = new OmsPortDescription(op.number(), op.isEnabled(), op.minFrequency(), |
| 204 | op.maxFrequency(), op.grid()); |
| 205 | break; |
| 206 | default: |
| 207 | portDescription = new DefaultPortDescription(port.number(), port.isEnabled()); |
| 208 | break; |
| 209 | } |
| 210 | return portDescription; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /** |
chengfan | 3e61879 | 2015-06-28 21:42:01 +0800 | [diff] [blame] | 214 | * Build a link description from a pcep link. |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 215 | * |
chengfan | 3e61879 | 2015-06-28 21:42:01 +0800 | [diff] [blame] | 216 | * @param pceLink pcep link |
| 217 | * @return LinkDescription onos link description |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 218 | */ |
| 219 | private LinkDescription buildLinkDescription(PcepLink pceLink) { |
| 220 | LinkDescription ld; |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 221 | checkNotNull(pceLink); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 222 | DeviceId srcDeviceID = deviceId(uri(pceLink.linkSrcDeviceID())); |
| 223 | DeviceId dstDeviceID = deviceId(uri(pceLink.linkDstDeviceId())); |
| 224 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 225 | deviceProviderService |
| 226 | .updatePorts(srcDeviceID, |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 227 | buildPortDescriptions(pceLink.linkSrcDeviceID(), |
| 228 | pceLink.linkSrcPort(), pceLink.portType())); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 229 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 230 | deviceProviderService |
| 231 | .updatePorts(dstDeviceID, |
| 232 | buildPortDescriptions(pceLink.linkDstDeviceId(), |
| 233 | pceLink.linkDstPort(), pceLink.portType())); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 234 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 235 | ConnectPoint src = new ConnectPoint(srcDeviceID, pceLink.linkSrcPort().number()); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 236 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 237 | ConnectPoint dst = new ConnectPoint(dstDeviceID, pceLink.linkDstPort().number()); |
| 238 | |
| 239 | DefaultAnnotations extendedAttributes = DefaultAnnotations |
| 240 | .builder() |
| 241 | .set("subType", String.valueOf(pceLink.linkSubType())) |
| 242 | .set("workState", pceLink.linkState()) |
| 243 | .set("distance", String.valueOf(pceLink.linkDistance())) |
| 244 | .set("capType", pceLink.linkCapacityType().toLowerCase()) |
| 245 | .set("avail_" + pceLink.linkCapacityType().toLowerCase(), |
| 246 | String.valueOf(pceLink.linkAvailValue())) |
| 247 | .set("max_" + pceLink.linkCapacityType().toLowerCase(), |
| 248 | String.valueOf(pceLink.linkMaxValue())).build(); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 249 | // construct the link |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 250 | ld = new DefaultLinkDescription(src, dst, Type.OPTICAL, extendedAttributes); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 251 | return ld; |
| 252 | } |
| 253 | |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 254 | private class InternalLinkProvider |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 255 | implements PcepSwitchListener, PcepLinkListener, PcepNodeListener { |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 256 | |
| 257 | @Override |
| 258 | public void switchAdded(PcepDpid dpid) { |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 259 | if (deviceProviderService == null) { |
| 260 | return; |
| 261 | } |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 262 | DeviceId deviceId = deviceId(uri(dpid)); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 263 | PcepSwitch sw = controller.getSwitch(dpid); |
| 264 | checkNotNull(sw, "device should not null."); |
| 265 | // The default device type is switch. |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 266 | ChassisId cId = new ChassisId(dpid.value()); |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 267 | Device.Type deviceType; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 268 | |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 269 | switch (sw.getDeviceType()) { |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 270 | case ROADM: |
| 271 | deviceType = Device.Type.ROADM; |
| 272 | break; |
| 273 | case OTN: |
| 274 | deviceType = Device.Type.SWITCH; |
| 275 | break; |
| 276 | case ROUTER: |
| 277 | deviceType = Device.Type.ROUTER; |
| 278 | break; |
| 279 | default: |
| 280 | deviceType = Device.Type.OTHER; |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 281 | } |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 282 | |
| 283 | DeviceDescription description = new DefaultDeviceDescription( |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 284 | deviceId.uri(), |
| 285 | deviceType, |
| 286 | sw.manufacturerDescription(), |
| 287 | sw.hardwareDescription(), |
| 288 | sw.softwareDescription(), |
| 289 | sw.serialNumber(), |
| 290 | cId); |
| 291 | deviceProviderService.deviceConnected(deviceId, description); |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 292 | |
| 293 | } |
| 294 | |
| 295 | @Override |
| 296 | public void switchRemoved(PcepDpid dpid) { |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 297 | if (deviceProviderService == null || linkProviderService == null) { |
| 298 | return; |
| 299 | } |
| 300 | deviceProviderService.deviceDisconnected(deviceId(uri(dpid))); |
| 301 | |
| 302 | linkProviderService.linksVanished(DeviceId.deviceId(uri(dpid))); |
| 303 | } |
| 304 | |
| 305 | @Override |
| 306 | public void switchChanged(PcepDpid dpid) { |
| 307 | // TODO Auto-generated method stub |
| 308 | |
| 309 | } |
| 310 | |
| 311 | @Override |
Jonathan Hart | 51539b8 | 2015-10-29 09:53:04 -0700 | [diff] [blame] | 312 | public void handlePceplink(PcepLink link) { |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 313 | |
| 314 | OperationType operType = link.getOperationType(); |
| 315 | LinkDescription ld = buildLinkDescription(link); |
| 316 | if (ld == null) { |
| 317 | log.error("Invalid link info."); |
| 318 | return; |
| 319 | } |
| 320 | switch (operType) { |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 321 | case ADD: |
| 322 | case UPDATE: |
| 323 | linkProviderService.linkDetected(ld); |
| 324 | break; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 325 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 326 | case DELETE: |
| 327 | linkProviderService.linkVanished(ld); |
| 328 | break; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 329 | |
chengfan | 359abf7 | 2015-07-02 23:33:16 +0800 | [diff] [blame] | 330 | default: |
| 331 | break; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 332 | |
| 333 | } |
| 334 | } |
| 335 | |
Priyanka B | 94395bf | 2016-05-21 18:39:46 +0530 | [diff] [blame] | 336 | @Override |
| 337 | public void addNode(PcepClient pc) { |
| 338 | if (deviceProviderService == null) { |
| 339 | return; |
| 340 | } |
| 341 | |
| 342 | //Right now device URI for PCEP devices is their LSRID |
| 343 | DeviceId deviceId = deviceId(uri(new PcepDpid(pc.getPccId().id().getIp4Address().toInt()))); |
| 344 | ChassisId cId = new ChassisId(); |
| 345 | |
| 346 | Device.Type deviceType = Device.Type.ROUTER; |
| 347 | |
| 348 | DefaultAnnotations.Builder annotationBuilder = DefaultAnnotations.builder(); |
| 349 | //PCC capabilities (SR, PCECC and PCECC-SR) |
| 350 | annotationBuilder.set(SR_CAPABILITY, String.valueOf(pc.capability().srCapability())); |
| 351 | annotationBuilder.set(PCECC_CAPABILITY, String.valueOf(pc.capability().pceccCapability())); |
| 352 | annotationBuilder.set(LABEL_STACK_CAPABILITY, String.valueOf(pc.capability().labelStackCapability())); |
| 353 | //PccId is the lsrId contained in openMsg, if not present it will be the socket address |
| 354 | annotationBuilder.set(LSRID, String.valueOf(pc.getPccId().id())); |
| 355 | |
| 356 | DeviceDescription description = new DefaultDeviceDescription( |
| 357 | deviceId.uri(), |
| 358 | deviceType, |
| 359 | UNKNOWN, |
| 360 | UNKNOWN, |
| 361 | UNKNOWN, |
| 362 | UNKNOWN, |
| 363 | cId, |
| 364 | annotationBuilder.build()); |
| 365 | |
| 366 | deviceProviderService.deviceConnected(deviceId, description); |
| 367 | } |
| 368 | |
| 369 | @Override |
| 370 | public void deleteNode(PccId pccId) { |
| 371 | if (deviceProviderService == null || deviceService == null) { |
| 372 | return; |
| 373 | } |
| 374 | //TODO: In device manager, in deviceDisconnected() method, get the device but null check is not validated |
| 375 | if (deviceService.getDevice(DeviceId.deviceId(uri(new PcepDpid(pccId.id() |
| 376 | .getIp4Address().toInt())))) == null) { |
| 377 | return; |
| 378 | } |
| 379 | deviceProviderService.deviceDisconnected(deviceId(uri(new PcepDpid(pccId.id().getIp4Address().toInt())))); |
| 380 | } |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | @Override |
| 384 | public void triggerProbe(DeviceId deviceId) { |
| 385 | // TODO Auto-generated method stub |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 386 | } |
| 387 | |
| 388 | @Override |
| 389 | public void roleChanged(DeviceId deviceId, MastershipRole newRole) { |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 390 | } |
| 391 | |
| 392 | @Override |
| 393 | public boolean isReachable(DeviceId deviceId) { |
| 394 | // TODO Auto-generated method stub |
cheng fan | 7716ec9 | 2015-05-31 01:53:19 +0800 | [diff] [blame] | 395 | return true; |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 396 | } |
Saurav Das | a2d3750 | 2016-03-25 17:50:40 -0700 | [diff] [blame] | 397 | |
| 398 | @Override |
| 399 | public void changePortState(DeviceId deviceId, PortNumber portNumber, |
| 400 | boolean enable) { |
| 401 | // TODO Auto-generated method stub |
| 402 | } |
cheng fan | 48e832c | 2015-05-29 01:54:47 +0800 | [diff] [blame] | 403 | } |