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
37 * conditional packages.
39 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
40 * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
41 * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
42 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
43 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
44 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
49 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
51 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
53 /*-----------------------------------------------------------------------------
56 private final @NonNull FaultService faultService;
57 private final @NonNull EquipmentService equipmentService;
58 private final @NonNull MaintenanceService maintenanceService;
59 private final @NonNull AaiService aaiProviderClient;
60 private final @NonNull PerformanceManager performanceManager;
61 private final @NonNull EventHandlingService eventListenerHandler;
64 private final @NonNull String mountPointNodeName;
65 private final @NonNull NetconfAccessor acessor;
66 private final @NonNull DeviceManagerOnfConfiguration pollAlarmConfig;
68 /*-----------------------------------------------------------------------------
73 * Basic element for netconf device with ONF Core model V1.2
74 * @param acessor to manage device connection
75 * @param serviceProvider to get devicemanager services
77 public ONFCoreNetworkElement12Basic(@NonNull NetconfAccessor acessor,
78 @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration) {
81 this.mountPointNodeName = acessor.getNodeId().getValue();
82 this.acessor = acessor;
83 this.pollAlarmConfig = configuration;
85 this.faultService = serviceProvider.getFaultService();
86 this.equipmentService = serviceProvider.getEquipmentService();
87 this.maintenanceService = serviceProvider.getMaintenanceService();
88 this.aaiProviderClient = serviceProvider.getAaiService();
89 this.performanceManager = serviceProvider.getPerformanceManagerService();
90 this.eventListenerHandler = serviceProvider.getEventHandlingService();
95 /*-----------------------------------------------------------------------------
100 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
103 public void prepareCheck() {
104 synchronized (dmLock) {
105 boolean change = readNetworkElementAndInterfaces();
106 if (change || pollAlarmConfig.isPollAlarmsEnabled()) {
107 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
108 FaultData resultList = readAllCurrentProblemsOfNode();
109 faultService.initCurrentProblemStatus(nodeId, resultList);
110 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(),
111 getUuId(), problems, resultList.size());
116 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
117 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
119 /*-----------------------------------------------------------------------------
123 // public void initSynchronizationExtension() -> Shifted to super class
124 // private InstanceList readPTPClockInstances() -> Shifted to super class
127 /*-----------------------------------------------------------------------------
128 * Problem/Fault related functions
132 * Read during startup all relevant structure and status parameters from device
135 public synchronized void initialReadFromNetworkElement() {
137 LOG.debug("Get info about {}", getMountpoint());
139 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
140 LOG.debug("Removed all {} problems from database at registration", problems);
142 // Step 2.1: access data broker within this mount point
143 LOG.debug("DBRead start");
145 // Step 2.2: read ne from data store
146 readNetworkElementAndInterfaces();
147 equipment.readNetworkElementEquipment();
149 // Step 2.3: read the existing faults and add to DB
150 FaultData resultList = readAllCurrentProblemsOfNode();
151 equipment.addProblemsofNode(resultList);
153 faultService.initCurrentProblemStatus(nodeId, resultList);
154 equipmentService.writeEquipment(equipment.getEquipmentData());
156 LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(),
161 * Remove all entries from list
164 public int removeAllCurrentProblemsOfNode() {
165 return faultService.removeAllCurrentProblemsOfNode(nodeId);
169 public void register() {
171 // Setup microwaveEventListener for notification service
172 doRegisterEventListener(acessor.getMountpoint());
174 // Register netconf stream
175 acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
177 // -- Read data from NE
178 initialReadFromNetworkElement();
180 // create automatic empty maintenance entry into db before reading and listening
182 maintenanceService.createIfNotExists(mountPointNodeName);
184 aaiProviderClient.onDeviceRegistered(mountPointNodeName);
185 // -- Register NE to performance manager
186 performanceManager.registration(mountPointNodeName, this);
188 //events will be already pushed by base devmgr (needs more clarification SDNC-1123)
189 //eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
190 //LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
191 //eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
192 LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName, getDeviceType());
198 public void deregister() {
199 maintenanceService.deleteIfNotRequired(mountPointNodeName);
200 performanceManager.deRegistration(mountPointNodeName);
201 aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
205 public void close() throws Exception {
206 // Close to be implemented
211 public NetworkElementDeviceType getDeviceType() {
212 return NetworkElementDeviceType.Optical;