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.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
31 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
36 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
38 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
39 * MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
40 * MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
41 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
42 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
47 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
49 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
51 /*-----------------------------------------------------------------------------
54 private final @NonNull FaultService faultService;
55 private final @NonNull EquipmentService equipmentService;
56 private final @NonNull MaintenanceService maintenanceService;
57 private final @NonNull AaiService aaiProviderClient;
58 private final @NonNull PerformanceManager performanceManager;
59 private final @NonNull EventHandlingService eventListenerHandler;
62 private final @NonNull String mountPointNodeName;
63 private final @NonNull NetconfAccessor acessor;
64 private final @NonNull DeviceManagerOnfConfiguration pollAlarmConfig;
66 /*-----------------------------------------------------------------------------
71 * Basic element for netconf device with ONF Core model V1.2
73 * @param acessor to manage device connection
74 * @param serviceProvider to get devicemanager services
76 public ONFCoreNetworkElement12Basic(@NonNull NetconfAccessor acessor,
77 @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration) {
80 this.mountPointNodeName = acessor.getNodeId().getValue();
81 this.acessor = acessor;
82 this.pollAlarmConfig = configuration;
84 this.faultService = serviceProvider.getFaultService();
85 this.equipmentService = serviceProvider.getEquipmentService();
86 this.maintenanceService = serviceProvider.getMaintenanceService();
87 this.aaiProviderClient = serviceProvider.getAaiService();
88 this.performanceManager = serviceProvider.getPerformanceManagerService();
89 this.eventListenerHandler = serviceProvider.getEventHandlingService();
94 /*-----------------------------------------------------------------------------
99 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
102 public void prepareCheck() {
103 synchronized (dmLock) {
104 boolean change = readNetworkElementAndInterfaces();
105 if (change || pollAlarmConfig.isPollAlarmsEnabled()) {
106 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
107 FaultData resultList = readAllCurrentProblemsOfNode();
108 faultService.initCurrentProblemStatus(nodeId, resultList);
109 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(),
110 getUuId(), problems, resultList.size());
115 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
116 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
118 /*-----------------------------------------------------------------------------
122 // public void initSynchronizationExtension() -> Shifted to super class
123 // private InstanceList readPTPClockInstances() -> Shifted to super class
126 /*-----------------------------------------------------------------------------
127 * Problem/Fault related functions
131 * Read during startup all relevant structure and status parameters from device
134 public void initialReadFromNetworkElement() {
136 LOG.debug("Get info about {}", getMountpoint());
138 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
139 LOG.debug("Removed all {} problems from database at registration", problems);
141 // Step 2.1: access data broker within this mount point
142 LOG.debug("DBRead start");
144 // Step 2.2: read ne from data store
145 readNetworkElementAndInterfaces();
146 LOG.debug("NETCONF read network element and interfaces completed");
147 equipment.readNetworkElementEquipment();
148 LOG.debug("NETCONF read equipment completed");
150 // Step 2.3: read the existing faults and add to DB
151 FaultData resultList = readAllCurrentProblemsOfNode();
152 LOG.debug("NETCONF read current problems completed");
153 equipment.addProblemsofNode(resultList);
155 faultService.initCurrentProblemStatus(nodeId, resultList);
156 LOG.debug("DB write current problems completed");
158 equipmentService.writeEquipment(equipment.getEquipmentData());
160 LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(),
165 * Remove all entries from list
168 public int removeAllCurrentProblemsOfNode() {
169 return faultService.removeAllCurrentProblemsOfNode(nodeId);
173 public void register() {
175 // Setup microwaveEventListener for notification service
176 doRegisterEventListener(acessor.getMountpoint());
178 // Register netconf stream
179 acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
181 // -- Read data from NE
182 initialReadFromNetworkElement();
184 // create automatic empty maintenance entry into db before reading and listening
186 maintenanceService.createIfNotExists(mountPointNodeName);
188 aaiProviderClient.onDeviceRegistered(mountPointNodeName);
189 // -- Register NE to performance manager
190 performanceManager.registration(mountPointNodeName, this);
192 //events will be already pushed by base devmgr (needs more clarification SDNC-1123)
193 //eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
194 //LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
195 //eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
196 LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName,
203 public void deregister() {
204 maintenanceService.deleteIfNotRequired(mountPointNodeName);
205 performanceManager.deRegistration(mountPointNodeName);
206 aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
210 public void close() throws Exception {
211 // Close to be implemented
216 public NetworkElementDeviceType getDeviceType() {
217 return NetworkElementDeviceType.Optical;