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
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==========================================================================
17 ******************************************************************************/
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.service.AaiService;
22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
30 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
35 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
36 * conditional packages.
38 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
39 * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
40 * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
41 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
42 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
43 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
48 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
50 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
52 /*-----------------------------------------------------------------------------
55 private final @NonNull FaultService faultService;
56 private final @NonNull EquipmentService equipmentService;
57 private final @NonNull MaintenanceService maintenanceService;
58 private final @NonNull AaiService aaiProviderClient;
59 private final @NonNull PerformanceManager performanceManager;
60 private final @NonNull EventHandlingService eventListenerHandler;
63 private final @NonNull String mountPointNodeName;
64 private final @NonNull NetconfAccessor acessor;
66 /*-----------------------------------------------------------------------------
71 * Basic element for netconf device with ONF Core model V1.2
72 * @param acessor to manage device connection
73 * @param serviceProvider to get devicemanager services
75 public ONFCoreNetworkElement12Basic(@NonNull NetconfAccessor acessor,
76 @NonNull DeviceManagerServiceProvider serviceProvider) {
79 this.mountPointNodeName = acessor.getNodeId().getValue();
80 this.acessor = acessor;
82 this.faultService = serviceProvider.getFaultService();
83 this.equipmentService = serviceProvider.getEquipmentService();
84 this.maintenanceService = serviceProvider.getMaintenanceService();
85 this.aaiProviderClient = serviceProvider.getAaiService();
86 this.performanceManager = serviceProvider.getPerformanceManagerService();
87 this.eventListenerHandler = serviceProvider.getEventHandlingService();
92 /*-----------------------------------------------------------------------------
97 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
100 public void prepareCheck() {
101 synchronized (dmLock) {
102 boolean change = readNetworkElementAndInterfaces();
104 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
105 FaultData resultList = readAllCurrentProblemsOfNode();
106 faultService.initCurrentProblemStatus(nodeId, resultList);
107 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(),
108 getUuId(), problems, resultList.size());
113 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
114 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
116 /*-----------------------------------------------------------------------------
120 // public void initSynchronizationExtension() -> Shifted to super class
121 // private InstanceList readPTPClockInstances() -> Shifted to super class
124 /*-----------------------------------------------------------------------------
125 * Problem/Fault related functions
129 * Read during startup all relevant structure and status parameters from device
132 public synchronized void initialReadFromNetworkElement() {
134 LOG.debug("Get info about {}", getMountpoint());
136 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
137 LOG.debug("Removed all {} problems from database at registration", problems);
139 // Step 2.1: access data broker within this mount point
140 LOG.debug("DBRead start");
142 // Step 2.2: read ne from data store
143 readNetworkElementAndInterfaces();
144 equipment.readNetworkElementEquipment();
146 // Step 2.3: read the existing faults and add to DB
147 FaultData resultList = readAllCurrentProblemsOfNode();
148 equipment.addProblemsofNode(resultList);
150 faultService.initCurrentProblemStatus(nodeId, resultList);
151 equipmentService.writeEquipment(equipment.getEquipmentData());
153 LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(),
158 * Remove all entries from list
161 public int removeAllCurrentProblemsOfNode() {
162 return faultService.removeAllCurrentProblemsOfNode(nodeId);
166 public void register() {
168 // Setup microwaveEventListener for notification service
169 doRegisterEventListener(acessor.getMountpoint());
171 // Register netconf stream
172 acessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream);
174 // -- Read data from NE
175 initialReadFromNetworkElement();
177 // create automatic empty maintenance entry into db before reading and listening
179 maintenanceService.createIfNotExists(mountPointNodeName);
181 aaiProviderClient.onDeviceRegistered(mountPointNodeName);
182 // -- Register NE to performance manager
183 performanceManager.registration(mountPointNodeName, this);
185 eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
186 eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
187 LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName, getDeviceType());
193 public void deregister() {
194 maintenanceService.deleteIfNotRequired(mountPointNodeName);
195 performanceManager.deRegistration(mountPointNodeName);
196 aaiProviderClient.onDeviceUnregistered(mountPointNodeName);
200 public void close() throws Exception {
201 // Close to be implemented
206 public NetworkElementDeviceType getDeviceType() {
207 return NetworkElementDeviceType.Optical;