X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Flisteners%2FLldpListener221.java;fp=networkmodel%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Ftransportpce%2Fnetworkmodel%2Flisteners%2FLldpListener221.java;h=0a2bc8022d0c890441bc8e7e39e4fbfa22bcac3d;hb=62924bb3518025fcdc8500128454054e7011559b;hp=0000000000000000000000000000000000000000;hpb=41f5183ed09a0096f512615a7cb26c257081ecbd;p=transportpce.git diff --git a/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/LldpListener221.java b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/LldpListener221.java new file mode 100644 index 000000000..0a2bc8022 --- /dev/null +++ b/networkmodel/src/main/java/org/opendaylight/transportpce/networkmodel/listeners/LldpListener221.java @@ -0,0 +1,47 @@ +/* + * Copyright © 2017 AT&T and others. All rights reserved. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v1.0 which accompanies this distribution, + * and is available at http://www.eclipse.org/legal/epl-v10.html + */ + +package org.opendaylight.transportpce.networkmodel.listeners; + +import org.opendaylight.transportpce.networkmodel.R2RLinkDiscovery; +import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.LldpNbrInfoChange; +import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.OrgOpenroadmLldpListener; +import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceNotificationType; +import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev150608.NodeId; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class LldpListener221 implements OrgOpenroadmLldpListener { + + private static final Logger LOG = LoggerFactory.getLogger(LldpListener221.class); + private final R2RLinkDiscovery linkDiscovery; + private final NodeId nodeId; + + public LldpListener221(final R2RLinkDiscovery linkDiscovery, final String nodeId) { + this.linkDiscovery = linkDiscovery; + this.nodeId = new NodeId(nodeId); + } + + /** + * Callback for lldp-nbr-info-change. + * @param notification LldpNbrInfoChange object + */ + @Override + public void onLldpNbrInfoChange(LldpNbrInfoChange notification) { + LOG.info("Notification {} received {}", LldpNbrInfoChange.QNAME, notification); + if (notification.getNotificationType().equals(ResourceNotificationType.ResourceCreation)) { + linkDiscovery.createR2RLink(nodeId,notification.getResource(), + notification.getNbrInfo().getRemoteSysName(), + notification.getNbrInfo().getRemotePortId()); + } else if (notification.getNotificationType().equals(ResourceNotificationType.ResourceDeletion)) { + linkDiscovery.deleteR2RLink(nodeId,notification.getResource(), + notification.getNbrInfo().getRemoteSysName(), + notification.getNbrInfo().getRemotePortId()); + } + } +}