2 * Copyright © 2017 AT&T and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.transportpce.networkmodel.listeners;
11 import java.util.LinkedList;
12 import org.opendaylight.transportpce.common.mapping.PortMapping;
13 import org.opendaylight.yang.gen.v1.http.org.opendaylight.transportpce.portmapping.rev210927.mapping.Mapping;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.ChangeNotification;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.CreateTechInfoNotification;
16 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OrgOpenroadmDeviceListener;
17 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.OtdrScanResult;
18 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.change.notification.Edit;
19 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.pack.Ports;
20 import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev181019.circuit.packs.CircuitPacks;
21 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
22 import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
23 import org.slf4j.Logger;
24 import org.slf4j.LoggerFactory;
26 public class DeviceListener221 implements OrgOpenroadmDeviceListener {
28 private static final Logger LOG = LoggerFactory.getLogger(DeviceListener221.class);
29 private final String nodeId;
30 private final PortMapping portMapping;
32 public DeviceListener221(String nodeId, PortMapping portMapping) {
35 this.portMapping = portMapping;
39 * Callback for change-notification.
42 * ChangeNotification object
45 @SuppressWarnings("unchecked")
46 public void onChangeNotification(ChangeNotification notification) {
47 if (notification.getEdit() == null) {
48 LOG.warn("unable to handle {} notificatin received - list of edit is null", ChangeNotification.QNAME);
51 for (Edit edit : notification.getEdit()) {
52 if (edit.getTarget() == null) {
55 // 1. Detect the org-openroadm-device object modified
56 switch (edit.getTarget().getTargetType().getSimpleName()) {
58 LinkedList<PathArgument> path = new LinkedList<>();
59 edit.getTarget().getPathArguments().forEach(p -> path.add(p));
60 InstanceIdentifier<Ports> portIID = (InstanceIdentifier<Ports>) InstanceIdentifier
62 String portName = InstanceIdentifier.keyOf(portIID).getPortName();
64 InstanceIdentifier<CircuitPacks> cpIID = (InstanceIdentifier<CircuitPacks>) InstanceIdentifier
66 String cpName = InstanceIdentifier.keyOf(cpIID).getCircuitPackName();
67 LOG.info("port {} of circruit-pack {} modified on device {}", portName, cpName, this.nodeId);
68 Mapping oldMapping = portMapping.getMapping(nodeId, cpName, portName);
69 if (oldMapping == null) {
72 Runnable handleNetconfEvent = new Runnable() {
75 portMapping.updateMapping(nodeId, oldMapping);
76 LOG.info("{} : mapping data for {} updated", nodeId,
77 oldMapping.getLogicalConnectionPoint());
80 Thread thread = new Thread(handleNetconfEvent);
84 LOG.debug("modification of type {} not managed yet", edit.getTarget().getTargetType());
91 public void onCreateTechInfoNotification(CreateTechInfoNotification notification) {
95 * Callback for otdr-scan-result.
98 * OtdrScanResult object
101 public void onOtdrScanResult(OtdrScanResult notification) {
102 LOG.info("Notification {} received {}", OtdrScanResult.QNAME, notification);