2c164d8268ef7699f7434aac1bb7286fd867d7da
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
20
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.eclipse.jdt.annotation.Nullable;
23 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener;
24 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService;
25 import org.opendaylight.mdsal.binding.api.DataBroker;
26 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
27 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
28 import org.opendaylight.yangtools.concepts.ListenerRegistration;
29 import org.slf4j.Logger;
30 import org.slf4j.LoggerFactory;
31
32 public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectListener {
33
34     private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerNetconfConnectHandler.class);
35
36     private ListenerRegistration<DeviceManagerNetconfConnectHandler> registerNetconfNodeConnectListener;
37
38     public DeviceManagerNetconfConnectHandler(@Nullable NetconfNodeStateService netconfNodeStateService) {
39         if (netconfNodeStateService == null) {
40             registerNetconfNodeConnectListener = new ListenerRegistration<DeviceManagerNetconfConnectHandler>() {
41                 @Override
42                 public void close() {
43                 }
44                 @Override
45                 public @NonNull DeviceManagerNetconfConnectHandler getInstance() {
46                     return DeviceManagerNetconfConnectHandler.this;
47                 }
48             };
49         } else {
50                         this.registerNetconfNodeConnectListener = netconfNodeStateService.registerNetconfNodeConnectListener(this);
51                 }
52     }
53
54     @Override
55     public void onEnterConnected(NodeId nNodeId, NetconfNode netconfNode, DataBroker netconfNodeDataBroker) {
56         LOG.info("onEnterConnected {}", nNodeId);
57         //o-ran-interfaces .. spec for RAN Devices to be used as fingerprint
58     }
59
60     @Override
61     public void onLeaveConnected(NodeId nNodeId) {
62         LOG.info("onLeaveConnected {}", nNodeId);
63     }
64
65     @Override
66     public void close() throws Exception {
67          registerNetconfNodeConnectListener.close();
68     }
69
70 }