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.dataprovider.model.DataProvider;
 
  22 import org.onap.ccsdk.features.sdnr.wt.devicemanager.onf.impl.DeviceManagerOnfConfiguration;
 
  23 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.AaiService;
 
  24 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
 
  25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
 
  26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
 
  27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
 
  28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.MaintenanceService;
 
  29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.PerformanceManager;
 
  30 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
 
  31 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.Capabilities;
 
  32 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor;
 
  33 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
 
  34 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionBuilder;
 
  35 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
 
  36 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
 
  37 import org.opendaylight.yangtools.yang.common.QName;
 
  38 import org.slf4j.Logger;
 
  39 import org.slf4j.LoggerFactory;
 
  42  * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
 
  44  * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
 
  45  * MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
 
  46  * MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
 
  47  * ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
 
  48  * ,MicrowaveModel-ObjectClasses-PureEthernetStructure
 
  53 public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
 
  55     private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Basic.class);
 
  57     /*-----------------------------------------------------------------------------
 
  60     private final @NonNull FaultService faultService;
 
  61     private final @NonNull EquipmentService equipmentService;
 
  62     private final @NonNull MaintenanceService maintenanceService;
 
  63     private final @NonNull AaiService aaiProviderClient;
 
  64     private final @NonNull PerformanceManager performanceManager;
 
  65     private final @NonNull EventHandlingService eventListenerHandler;
 
  66     private final @NonNull DataProvider dataProvider;
 
  69     private final @NonNull NodeId mountPointNodeId;
 
  70     private final @NonNull NetconfBindingAccessor acessor;
 
  71     private final @NonNull DeviceManagerOnfConfiguration pollAlarmConfig;
 
  73     /*-----------------------------------------------------------------------------
 
  78      * Basic element for netconf device with ONF Core model V1.2
 
  80      * @param acessor to manage device connection
 
  81      * @param serviceProvider to get devicemanager services
 
  83     public ONFCoreNetworkElement12Basic(@NonNull NetconfBindingAccessor acessor,
 
  84             @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration) {
 
  86         super(acessor, serviceProvider);
 
  87         this.mountPointNodeId = acessor.getNodeId();
 
  88         this.acessor = acessor;
 
  89         this.pollAlarmConfig = configuration;
 
  91         this.faultService = serviceProvider.getFaultService();
 
  92         this.equipmentService = serviceProvider.getEquipmentService();
 
  93         this.maintenanceService = serviceProvider.getMaintenanceService();
 
  94         this.aaiProviderClient = serviceProvider.getAaiService();
 
  95         this.performanceManager = serviceProvider.getPerformanceManagerService();
 
  96         this.eventListenerHandler = serviceProvider.getEventHandlingService();
 
  97         this.dataProvider = serviceProvider.getDataProvider();
 
 100     /*-----------------------------------------------------------------------------
 
 105      * DeviceMonitor Prepare check by updating NE state and reading all interfaces.
 
 108     public void prepareCheck() {
 
 109         synchronized (dmLock) {
 
 110             boolean change = readNetworkElementAndInterfaces();
 
 111             if (change || pollAlarmConfig.isPollAlarmsEnabled()) {
 
 112                 int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
 
 113                 FaultData resultList = readAllCurrentProblemsOfNode();
 
 114                 faultService.initCurrentProblemStatus(nodeId, resultList);
 
 115                 LOG.info("Resync mountpoint {} for device {}. Removed {}. Current problems: {}", getMountpoint(),
 
 116                         getUuId(), problems, resultList.size());
 
 121     // public boolean checkIfConnectionToMediatorIsOk() -> Shifted to super class
 
 122     // public boolean checkIfConnectionToNeIsOk() -> Shifted to super class
 
 124     /*-----------------------------------------------------------------------------
 
 128     // public void initSynchronizationExtension() -> Shifted to super class
 
 129     // private InstanceList readPTPClockInstances() -> Shifted to super class
 
 132     /*-----------------------------------------------------------------------------
 
 133      * Problem/Fault related functions
 
 137      * Read during startup all relevant structure and status parameters from device
 
 140     public void initialReadFromNetworkElement() {
 
 142         LOG.debug("Get info about {}", getMountpoint());
 
 144         int problems = faultService.removeAllCurrentProblemsOfNode(nodeId);
 
 145         LOG.debug("Removed all {} problems from database at registration", problems);
 
 147         // Step 2.1: access data broker within this mount point
 
 148         LOG.debug("DBRead start");
 
 150         // Step 2.2: read ne from data store
 
 151         readNetworkElementAndInterfaces();
 
 152         LOG.debug("NETCONF read network element and interfaces completed");
 
 153         equipment.readNetworkElementEquipment();
 
 154         LOG.debug("NETCONF read equipment completed");
 
 156         // Step 2.3: read the existing faults and add to DB
 
 157         FaultData resultList = readAllCurrentProblemsOfNode();
 
 158         LOG.debug("NETCONF read current problems completed");
 
 159         equipment.addProblemsofNode(resultList);
 
 161         faultService.initCurrentProblemStatus(nodeId, resultList);
 
 162         LOG.debug("DB write current problems completed");
 
 164         equipmentService.writeEquipment(nodeId, equipment.getEquipmentData());
 
 166         LOG.info("Found info at {} for device {} number of problems: {}", getMountpoint(), getUuId(),
 
 172      * set core-model-capability
 
 174     public void setCoreModel(@NonNull NetconfNode nNode) {
 
 175         NetworkElementConnectionBuilder eb = new NetworkElementConnectionBuilder();
 
 177         String namespaceRevision;
 
 178         QName QNAME_COREMODEL = QName.create("urn:onf:params:xml:ns:yang:core-model", "2017-03-20", "core-model").intern();
 
 180         Capabilities availableCapabilities = Capabilities.getAvailableCapabilities(nNode);
 
 181         namespaceRevision = availableCapabilities.getRevisionForNamespace(QNAME_COREMODEL);
 
 182         if (Capabilities.isNamespaceSupported(namespaceRevision)) {
 
 183             eb.setCoreModelCapability(namespaceRevision);
 
 185             eb.setCoreModelCapability("Unsupported");
 
 187         dataProvider.updateNetworkConnection22(eb.build(), acessor.getNodeId().getValue());
 
 190      * Remove all entries from list
 
 193     public int removeAllCurrentProblemsOfNode() {
 
 194         return faultService.removeAllCurrentProblemsOfNode(nodeId);
 
 198     public void register() {
 
 200         // Setup microwaveEventListener for notification service
 
 201         doRegisterEventListener(acessor.getMountpoint());
 
 203                 if (acessor.isNotificationsRFC5277Supported()) {
 
 204                         // Register default (NETCONF) stream
 
 205                         acessor.registerNotificationsStream();
 
 208         // Set core-model revision value in "core-model-capability" field
 
 209         setCoreModel(acessor.getNetconfNode());
 
 211         // -- Read data from NE
 
 212         initialReadFromNetworkElement();
 
 214         // create automatic empty maintenance entry into db before reading and listening
 
 216         maintenanceService.createIfNotExists(mountPointNodeId);
 
 218         aaiProviderClient.onDeviceRegistered(mountPointNodeId);
 
 219         // -- Register NE to performance manager
 
 220         performanceManager.registration(mountPointNodeId, this);
 
 222         //events will be already pushed by base devmgr (needs more clarification SDNC-1123)
 
 223         //eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
 
 224         //LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
 
 225         //eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
 
 226         LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeId,
 
 233     public void deregister() {
 
 234         maintenanceService.deleteIfNotRequired(mountPointNodeId);
 
 235         performanceManager.deRegistration(mountPointNodeId);
 
 236         aaiProviderClient.onDeviceUnregistered(mountPointNodeId);
 
 237         faultService.removeAllCurrentProblemsOfNode(acessor.getNodeId());
 
 238         dataProvider.clearGuiCutThroughEntriesOfNode(acessor.getNodeId().getValue());
 
 242     public void close() throws Exception {
 
 243         // Close to be implemented
 
 248     public NetworkElementDeviceType getDeviceType() {
 
 249         return NetworkElementDeviceType.Optical;