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.base.netconf;
20 import java.util.List;
22 import javax.annotation.Nonnull;
23 import javax.annotation.Nullable;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.container.Capabilities;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.netconf.util.GenericTransactionUtils;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.base.toggleAlarmFilter.NotificationDelayService;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.ProviderClient;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.service.HtDatabaseEventsService;
30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfEventListener12;
31 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
32 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
33 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClient;
34 import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.MaintenanceService;
35 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
36 import org.opendaylight.controller.md.sal.common.api.data.LogicalDatastoreType;
37 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.NetworkElement;
38 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
39 import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.logical.termination.point.g.Lp;
40 import org.slf4j.Logger;
41 import org.slf4j.LoggerFactory;
44 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
45 * conditional packages.
47 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
48 * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
49 * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
50 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
51 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
52 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
57 @SuppressWarnings("deprecation")
58 public class ONFCoreNetworkElement12 extends ONFCoreNetworkElement12Base
59 implements ONFCoreNetworkElementCallback, NotificationActor<AttributeValueChangedNotificationXml> {
61 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12.class);
63 /*-----------------------------------------------------------------------------
66 private final @Nonnull NetconfEventListener12 netconfEventListener;
67 private final NotificationWorker<AttributeValueChangedNotificationXml> notificationQueue;
69 /*-----------------------------------------------------------------------------
76 * @param mountPointNodeName as String
77 * @param capabilities of the specific network element
78 * @param netconfNodeDataBroker for the network element specific data
79 * @param webSocketService to forward event notifications
80 * @param databaseService to access the database
81 * @param dcaeProvider to forward problem / change notifications
83 ONFCoreNetworkElement12(String mountPointNodeName, Capabilities capabilities,
84 DataBroker netconfNodeDataBroker, WebSocketServiceClient webSocketService,
85 HtDatabaseEventsService databaseService, ProviderClient dcaeProvider, @Nullable ProviderClient aotsmClient,
86 MaintenanceService maintenanceService,
87 NotificationDelayService<ProblemNotificationXml> notificationDelayService ) {
89 super(mountPointNodeName, netconfNodeDataBroker, capabilities);
91 this.netconfEventListener = new NetconfEventListener12(mountPointNodeName, webSocketService,
92 databaseService, dcaeProvider, aotsmClient, maintenanceService, notificationDelayService, this);
93 this.notificationQueue = new NotificationWorker<>(1, 100, this);
98 /*-----------------------------------------------------------------------------
103 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
106 public void prepareCheck() {
107 synchronized (dmLock) {
108 boolean change = readNetworkElementAndInterfaces();
110 int problems = netconfEventListener.removeAllCurrentProblemsOfNode();
111 List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
112 netconfEventListener.initCurrentProblemStatus(resultList);
113 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(),
114 getUuId(), problems, resultList.size());
119 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
120 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
122 /*-----------------------------------------------------------------------------
126 // public void initSynchronizationExtension() -> Shifted to super class
127 // private InstanceList readPTPClockInstances() -> Shifted to super class
129 /*-----------------------------------------------------------------------------
130 * Services for NE/Device synchronization
134 * Handling of specific Notifications from NE, indicating changes and need for synchronization.
136 * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
137 * <attribute-name>/equipment-pac/equipment-current-problems</attribute-name>
138 * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value>
139 * </attribute-value-changed-notification>
140 * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
141 * <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name>
142 * <object-id-ref>Hybrid-Z</object-id-ref>
143 * <new-value>SHELF-1.1.0.0,IDU-1.55.0.0,ODU-1.56.0.0,IDU-1.65.0.0</new-value>
144 * </attribute-value-changed-notification>
149 public void notificationFromNeListener(AttributeValueChangedNotificationXml notificationXml) {
150 notificationQueue.put(notificationXml);
154 public void notificationActor(AttributeValueChangedNotificationXml notificationXml) {
156 LOG.debug("Enter change notification listener");
157 if (LOG.isTraceEnabled()) {
158 LOG.trace("Notification: {}", notificationXml);
160 if (notificationXml.getAttributeName().equals("/equipment-pac/equipment-current-problems")) {
161 syncEquipmentPac(notificationXml.getObjectId());
162 } else if (notificationXml.getAttributeName()
163 .equals("/network-element/extension[value-name=\"top-level-equipment\"]/value")) {
164 initialReadFromNetworkElement();
166 LOG.debug("Leave change notification listener");
170 * Synchronize problems for a specific equipment-pac
172 * @param uuidString of the equipment-pac
174 private synchronized void syncEquipmentPac(String uuidString) {
176 int problems = netconfEventListener.removeObjectsCurrentProblemsOfNode(uuidString);
177 LOG.debug("Removed {} problems for uuid {}", problems, uuidString);
179 List<ProblemNotificationXml> resultList = getEquipment().addProblemsofNodeObject(uuidString);
180 netconfEventListener.initCurrentProblemStatus(resultList);
181 LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString);
186 /*-----------------------------------------------------------------------------
187 * Problem/Fault related functions
191 * Read during startup all relevant structure and status parameters from device
194 public synchronized void initialReadFromNetworkElement() {
195 // optionalNe.getLtp().get(0).getLp();
196 LOG.debug("Get info about {}", getMountPointNodeName());
198 int problems = netconfEventListener.removeAllCurrentProblemsOfNode();
199 LOG.debug("Removed all {} problems from database at registration", problems);
201 // Step 2.1: access data broker within this mount point
202 LOG.debug("DBRead start");
204 // Step 2.2: read ne from data store
205 readNetworkElementAndInterfaces();
206 getEquipment().readNetworkElementEquipment();
208 // Step 2.3: read the existing faults and add to DB
209 List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
210 getEquipment().addProblemsofNode(resultList);
212 netconfEventListener.initCurrentProblemStatus(resultList);
214 netconfEventListener.writeEquipment(getEquipment());
216 LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(),
224 * Read the NetworkElement part from database.
226 * @return Optional with NetworkElement or empty
229 private NetworkElement readNetworkElement() {
230 // Step 2.2: construct data and the relative iid
231 // The schema path to identify an instance is
232 // <i>CoreModel-CoreNetworkModule-ObjectClasses/NetworkElement</i>
233 // Read to the config data store
234 return GenericTransactionUtils.readData(getNetconfNodeDataBroker(), LogicalDatastoreType.OPERATIONAL,
239 * Read element from class that could be not available
241 * @param ltp layer termination point
242 * @return List with extension parameters or empty list
245 private static List<Extension> getExtensionList(@Nullable Lp ltp) {
246 if (ltp != null && ltp.getExtension() != null) {
247 return ltp.getExtension();
249 return EMPTYLTPEXTENSIONLIST;
254 * Remove all entries from list
257 public int removeAllCurrentProblemsOfNode() {
258 return netconfEventListener.removeAllCurrentProblemsOfNode();
263 public void close() throws Exception {