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.onfcore;
20 import java.util.List;
21 import org.eclipse.jdt.annotation.NonNull;
22 import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.NetconfEventListenerHandler12;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationDelayService;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.INetconfAcessor;
31 import org.opendaylight.mdsal.binding.api.DataBroker;
32 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementDeviceType;
33 import org.slf4j.Logger;
34 import org.slf4j.LoggerFactory;
37 * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
38 * conditional packages.
40 * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
41 * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
42 * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
43 * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
44 * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
45 * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
50 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base
51 implements ONFCoreNetworkElementCallback, NotificationActor<AttributeValueChangedNotificationXml> {
53 private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
55 /*-----------------------------------------------------------------------------
58 private final @NonNull NetconfEventListenerHandler12 netconfEventListener;
59 private final NotificationWorker<AttributeValueChangedNotificationXml> notificationQueue;
61 /*-----------------------------------------------------------------------------
68 * @param mountPointNodeName as String
69 * @param capabilities of the specific network element
70 * @param netconfNodeDataBroker for the network element specific data
71 * @param webSocketService to forward event notifications
72 * @param databaseService to access the database
73 * @param dcaeProvider to forward problem / change notifications
75 ONFCoreNetworkElement12Basic(INetconfAcessor acessor, String mountPointNodeName, Capabilities capabilities,
76 DataBroker netconfNodeDataBroker, WebSocketServiceClientInternal webSocketService,
77 DataProvider databaseService, DcaeForwarderInternal aotsDcaeForwarder,
78 NotificationDelayService<ProblemNotificationXml> notificationDelayService ) {
80 super(acessor, mountPointNodeName, netconfNodeDataBroker, capabilities);
82 this.netconfEventListener = new NetconfEventListenerHandler12(mountPointNodeName, webSocketService,
83 databaseService, aotsDcaeForwarder, notificationDelayService, this);
84 this.notificationQueue = new NotificationWorker<>(1, 100, this);
89 /*-----------------------------------------------------------------------------
94 * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
97 public void prepareCheck() {
98 synchronized (dmLock) {
99 boolean change = readNetworkElementAndInterfaces();
101 int problems = netconfEventListener.removeAllCurrentProblemsOfNode();
102 List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
103 netconfEventListener.initCurrentProblemStatus(resultList);
104 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountPointNodeName(),
105 getUuId(), problems, resultList.size());
110 // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
111 // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
113 /*-----------------------------------------------------------------------------
117 // public void initSynchronizationExtension() -> Shifted to super class
118 // private InstanceList readPTPClockInstances() -> Shifted to super class
120 /*-----------------------------------------------------------------------------
121 * Services for NE/Device synchronization
125 * Handling of specific Notifications from NE, indicating changes and need for synchronization.
127 * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
128 * <attribute-name>/equipment-pac/equipment-current-problems</attribute-name>
129 * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value>
130 * </attribute-value-changed-notification>
131 * <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
132 * <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name>
133 * <object-id-ref>Hybrid-Z</object-id-ref>
134 * <new-value>SHELF-1.1.0.0,IDU-1.55.0.0,ODU-1.56.0.0,IDU-1.65.0.0</new-value>
135 * </attribute-value-changed-notification>
140 public void notificationFromNeListener(AttributeValueChangedNotificationXml notificationXml) {
141 notificationQueue.put(notificationXml);
145 public void notificationActor(AttributeValueChangedNotificationXml notificationXml) {
147 LOG.debug("Enter change notification listener");
148 if (LOG.isTraceEnabled()) {
149 LOG.trace("Notification: {}", notificationXml);
151 if (notificationXml.getAttributeName().equals("/equipment-pac/equipment-current-problems")) {
152 syncEquipmentPac(notificationXml.getObjectId());
153 } else if (notificationXml.getAttributeName()
154 .equals("/network-element/extension[value-name=\"top-level-equipment\"]/value")) {
155 initialReadFromNetworkElement();
157 LOG.debug("Leave change notification listener");
161 * Synchronize problems for a specific equipment-pac
163 * @param uuidString of the equipment-pac
165 private synchronized void syncEquipmentPac(String uuidString) {
167 int problems = netconfEventListener.removeObjectsCurrentProblemsOfNode(uuidString);
168 LOG.debug("Removed {} problems for uuid {}", problems, uuidString);
170 List<ProblemNotificationXml> resultList = equipment.addProblemsofNodeObject(uuidString);
171 netconfEventListener.initCurrentProblemStatus(resultList);
172 LOG.debug("Added {} problems for uuid {}", resultList.size(), uuidString);
177 /*-----------------------------------------------------------------------------
178 * Problem/Fault related functions
182 * Read during startup all relevant structure and status parameters from device
185 public synchronized void initialReadFromNetworkElement() {
186 // optionalNe.getLtp().get(0).getLp();
187 LOG.debug("Get info about {}", getMountPointNodeName());
189 int problems = netconfEventListener.removeAllCurrentProblemsOfNode();
190 LOG.debug("Removed all {} problems from database at registration", problems);
192 // Step 2.1: access data broker within this mount point
193 LOG.debug("DBRead start");
195 // Step 2.2: read ne from data store
196 readNetworkElementAndInterfaces();
197 equipment.readNetworkElementEquipment();
199 // Step 2.3: read the existing faults and add to DB
200 List<ProblemNotificationXml> resultList = readAllCurrentProblemsOfNode();
201 equipment.addProblemsofNode(resultList);
203 netconfEventListener.initCurrentProblemStatus(resultList);
205 netconfEventListener.writeEquipment(equipment);
207 LOG.info("Found info at {} for device {} number of problems: {}", getMountPointNodeName(), getUuId(),
212 * Remove all entries from list
215 public int removeAllCurrentProblemsOfNode() {
216 return netconfEventListener.removeAllCurrentProblemsOfNode();
221 public void close() throws Exception {
226 public NetworkElementDeviceType getDeviceType() {
227 return NetworkElementDeviceType.Optical;