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
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.onf.ne;
20 import org.eclipse.jdt.annotation.NonNull;
21 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
33 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
34 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNotifications;
35 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
36 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
37 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
38 import org.opendaylight.yangtools.yang.common.QName;
39 import org.slf4j.Logger;
40 import org.slf4j.LoggerFactory;
43 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
45 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
46 * MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
47 * MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
48 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
49 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
54 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
56 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
58 /*-----------------------------------------------------------------------------
61 private final @NonNull FaultService faultService;
62 private final @NonNull EquipmentService equipmentService;
63 private final @NonNull MaintenanceService maintenanceService;
64 private final @NonNull AaiService aaiProviderClient;
65 private final @NonNull PerformanceManager performanceManager;
66 private final @NonNull EventHandlingService eventListenerHandler;
67 private final @NonNull DataProvider dataProvider;
70 private final @NonNull String mountPointNodeName;
71 private final @NonNull NetconfBindingAccessor acessor;
72 private final @NonNull DeviceManagerOnfConfiguration pollAlarmConfig;
74 private final NetconfNotifications notificationAccessor;
76 /*-----------------------------------------------------------------------------
81 * Basic element for netconf device with ONF Core model V1.2
83 * @param acessor to manage device connection
84 * @param serviceProvider to get devicemanager services
86 public ONFCoreNetworkElement12Basic(@NonNull NetconfBindingAccessor acessor,
87 @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration) {
90 this.mountPointNodeName = acessor.getNodeId().getValue();
91 this.acessor = acessor;
92 this.pollAlarmConfig = configuration;
94 this.faultService = serviceProvider.getFaultService();
95 this.equipmentService = serviceProvider.getEquipmentService();
96 this.maintenanceService = serviceProvider.getMaintenanceService();
97 this.aaiProviderClient = serviceProvider.getAaiService();
98 this.performanceManager = serviceProvider.getPerformanceManagerService();
99 this.eventListenerHandler = serviceProvider.getEventHandlingService();
100 this.dataProvider = serviceProvider.getDataProvider();
102 this.notificationAccessor = acessor.getNotificationAccessor().get();
106 /*-----------------------------------------------------------------------------
111 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
114 public void prepareCheck() {
115 synchronized (dmLock) {
116 boolean change = readNetworkElementAndInterfaces();
117 if (change || pollAlarmConfig.isPollAlarmsEnabled()) {
118 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
119 FaultData resultList = readAllCurrentProblemsOfNode();
120 faultService.initCurrentProblemStatus(nodeId, resultList);
121 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(),
122 getUuId(), problems, resultList.size());
127 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
128 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
130 /*-----------------------------------------------------------------------------
134 // public void initSynchronizationExtension() -> Shifted to super class
135 // private InstanceList readPTPClockInstances() -> Shifted to super class
138 /*-----------------------------------------------------------------------------
139 * Problem/Fault related functions
143 * Read during startup all relevant structure and status parameters from device
146 public void initialReadFromNetworkElement() {
148 LOG.debug("Get info about {}", getMountpoint());
150 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
151 LOG.debug("Removed all {} problems from database at registration", problems);
153 // Step 2.1: access data broker within this mount point
154 LOG.debug("DBRead start");
156 // Step 2.2: read ne from data store
157 readNetworkElementAndInterfaces();
158 LOG.debug("NETCONF read network element and interfaces completed");
159 equipment.readNetworkElementEquipment();
160 LOG.debug("NETCONF read equipment completed");
162 // Step 2.3: read the existing faults and add to DB
163 FaultData resultList = readAllCurrentProblemsOfNode();
164 LOG.debug("NETCONF read current problems completed");
165 equipment.addProblemsofNode(resultList);
167 faultService.initCurrentProblemStatus(nodeId, resultList);
168 LOG.debug("DB write current problems completed");
170 equipmentService.writeEquipment(equipment.getEquipmentData());
172 LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(),
178 * set core-model-capability
180 public void setCoreModel(@NonNull NetconfNode nNode) {
181 NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
183 String namespaceRevision;
184 QName QNAME_COREMODEL = QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern();
186 Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
187 namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL);
188 if (Capabilities.isNamespaceSupported(namespaceRevision)) {
189 eb.setCoreModelCapability(namespaceRevision);
191 eb.setCoreModelCapability("Unsupported");
193 dataProvider.updateNetworkConnection22(eb.build(), acessor.getNodeId().getValue());
196 * Remove all entries from list
199 public int removeAllCurrentProblemsOfNode() {
200 return faultService.removeAllCurrentProblemsOfNode(nodeId);
204 public void register() {
206 // Setup microwaveEventListener for notification service
207 doRegisterEventListener(acessor.getMountpoint());
209 // Register netconf stream
210 notificationAccessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
212 // Set core-model revision value in "core-model-capability" field
213 setCoreModel(acessor.getNetconfNode());
215 // -- Read data from NE
216 initialReadFromNetworkElement();
218 // create automatic empty maintenance entry into db before reading and listening
220 maintenanceService.createIfNotExists(mountPointNodeName);
222 aaiProviderClient.onDeviceRegistered(mountPointNodeName);
223 // -- Register NE to performance manager
224 performanceManager.registration(mountPointNodeName, this);
226 //events will be already pushed by base devmgr (needs more clarification SDNC-1123)
227 //eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
228 //LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
229 //eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
230 LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName,
237 public void deregister() {
238 maintenanceService.deleteIfNotRequired(mountPointNodeName);
239 performanceManager.deRegistration(mountPointNodeName);
240 aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
241 faultService.removeAllCurrentProblemsOfNode(acessor.getNodeId());
245 public void close() throws Exception {
246 // Close to be implemented
251 public NetworkElementDeviceType getDeviceType() {
252 return NetworkElementDeviceType.Optical;