Bump upstream dependencies to Ca
[transportpce.git] / networkmodel / src / main / java / org / opendaylight / transportpce / networkmodel / listeners / LldpListener221.java
1 /*
2  * Copyright © 2017 AT&T and others.  All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.transportpce.networkmodel.listeners;
10
11 import org.eclipse.jdt.annotation.NonNull;
12 import org.opendaylight.mdsal.binding.api.NotificationService.Listener;
13 import org.opendaylight.transportpce.networkmodel.R2RLinkDiscovery;
14 import org.opendaylight.yang.gen.v1.http.org.openroadm.lldp.rev181019.LldpNbrInfoChange;
15 import org.opendaylight.yang.gen.v1.http.org.openroadm.resource.types.rev181019.ResourceNotificationType;
16 import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.network.rev180226.NodeId;
17 import org.slf4j.Logger;
18 import org.slf4j.LoggerFactory;
19
20 public class LldpListener221 implements Listener<LldpNbrInfoChange> {
21
22     private static final Logger LOG = LoggerFactory.getLogger(LldpListener221.class);
23     private final R2RLinkDiscovery linkDiscovery;
24     private final NodeId nodeId;
25
26     public LldpListener221(final R2RLinkDiscovery linkDiscovery, final String nodeId) {
27         this.linkDiscovery = linkDiscovery;
28         this.nodeId = new NodeId(nodeId);
29     }
30
31     /**
32      * Callback for lldp-nbr-info-change.
33      * @param notification LldpNbrInfoChange object
34      */
35     @Override
36     public void onNotification(@NonNull LldpNbrInfoChange notification) {
37         LOG.info("Notification {} received {}", LldpNbrInfoChange.QNAME, notification);
38         if (notification.getNotificationType().equals(ResourceNotificationType.ResourceCreation)) {
39             linkDiscovery.createR2RLink(nodeId,notification.getResource(),
40                                                 notification.getNbrInfo().getRemoteSysName(),
41                                                 notification.getNbrInfo().getRemotePortId());
42         } else if (notification.getNotificationType().equals(ResourceNotificationType.ResourceDeletion)) {
43             linkDiscovery.deleteR2RLink(nodeId,notification.getResource(),
44                                                 notification.getNbrInfo().getRemoteSysName(),
45                                                 notification.getNbrInfo().getRemotePortId());
46         }
47     }
48 }