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 org.opendaylight.transportpce.networkmodel.R2RLinkDiscovery;
12 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.LldpNbrInfoChange;
13 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.OrgOpenroadmLldpListener;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceNotificationType;
15 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NodeId;
16 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory;
19 public class LldpListener221 implements OrgOpenroadmLldpListener {
21 private static final Logger LOG = LoggerFactory.getLogger(LldpListener221.class);
22 private final R2RLinkDiscovery linkDiscovery;
23 private final NodeId nodeId;
25 public LldpListener221(final R2RLinkDiscovery linkDiscovery, final String nodeId) {
26 this.linkDiscovery = linkDiscovery;
27 this.nodeId = new NodeId(nodeId);
31 * Callback for lldp-nbr-info-change.
32 * @param notification LldpNbrInfoChange object
35 public void onLldpNbrInfoChange(LldpNbrInfoChange notification) {
36 LOG.info("Notification {} received {}", LldpNbrInfoChange.QNAME, notification);
37 if (notification.getNotificationType().equals(ResourceNotificationType.ResourceCreation)) {
38 linkDiscovery.createR2RLink(nodeId,notification.getResource(),
39 notification.getNbrInfo().getRemoteSysName(),
40 notification.getNbrInfo().getRemotePortId());
41 } else if (notification.getNotificationType().equals(ResourceNotificationType.ResourceDeletion)) {
42 linkDiscovery.deleteR2RLink(nodeId,notification.getResource(),
43 notification.getNbrInfo().getRemoteSysName(),
44 notification.getNbrInfo().getRemotePortId());