2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt
4 * =================================================================================================
5 * Copyright (C) 2020 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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
18 package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl;
20 import java.util.Optional;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
26 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
28 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
29 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
30 import org.opendaylight.yangtools.concepts.ListenerRegistration;
31 import org.opendaylight.yangtools.yang.binding.NotificationListener;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
39 public class NtsNetworkElement implements NetworkElement {
41 private static final Logger LOG = LoggerFactory.getLogger(NtsNetworkElement.class);
43 private final NetconfBindingAccessor netconfAccessor;
45 @SuppressWarnings("unused")
46 private final DataProvider databaseService;
47 private final NotificationListenerImpl notificationListener;
49 private @NonNull ListenerRegistration<NotificationListener> listenerRegistrationresult;
51 NtsNetworkElement(NetconfBindingAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) {
52 LOG.debug("Create {}", NtsNetworkElement.class.getSimpleName());
53 this.netconfAccessor = netconfAccess;
54 this.databaseService = serviceProvider.getDataProvider();
55 this.notificationListener = new NotificationListenerImpl(netconfAccess,serviceProvider);
56 this.listenerRegistrationresult = null;
60 public void deregister() {
61 if(this.listenerRegistrationresult!=null) {
62 this.listenerRegistrationresult.close();
67 public NodeId getNodeId() {
68 return netconfAccessor.getNodeId();
72 public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) {
73 return Optional.empty();
77 public void warmstart() {
81 public void register() {
82 if (netconfAccessor.isNotificationsRFC5277Supported()) {
83 listenerRegistrationresult = netconfAccessor.doRegisterNotificationListener(this.notificationListener);
84 // Register default (NETCONF) stream
85 netconfAccessor.registerNotificationsStream();
86 LOG.debug("registered for notifications");
88 LOG.warn("unable to register for notifications. RFC5277 not supported");
93 public NetworkElementDeviceType getDeviceType() {
94 return NetworkElementDeviceType.NtsManager;
98 public Optional<NetconfAccessor> getAcessor() {
99 return Optional.of(this.netconfAccessor);