diff options
author | 2021-04-19 12:46:16 +0200 | |
---|---|---|
committer | 2021-04-20 08:01:27 +0200 | |
commit | 05fe114a5969727c32cd9f1051cd7b9fde0344d5 (patch) | |
tree | 4cb505cd98ddb5b9c6f188f9febe93b07cf743db /sdnr/wt/devicemanager-openroadm/provider/src/main/java | |
parent | 6ae7e8a1bae83d407b22d8b066dd0bcca730e1bb (diff) |
Reorganization of devicemanager directory structure
Organized into core, onap and o-ran-sc directories
Issue-ID: CCSDK-3242
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Change-Id: I3c23710f990a2d96ba01104c97315fc8c6b1921b
Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-openroadm/provider/src/main/java')
16 files changed, 0 insertions, 1629 deletions
diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java deleted file mode 100644 index e522f4bd7..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/DeviceManagerOpenroadmImpl.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.FactoryRegistration; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Class to initialize the OpenRoadm Device Manager - **/ -public class DeviceManagerOpenroadmImpl implements AutoCloseable { - - // variables - private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOpenroadmImpl.class); - private static final String APPLICATION_NAME = "DeviceManagerOpenRoadm"; - @SuppressWarnings("unused") - private static final String CONFIGURATIONFILE = "etc/devicemanager-opeenroadm.properties"; - private NetconfNetworkElementService netconfNetworkElementService; - private HtDatabaseClient htDatabaseClient; - private Boolean devicemanagerInitializationOk = false; - private FactoryRegistration<OpenroadmNetworkElementFactory> resOpenRoadm; - // end of variables - - // Blueprint begin - // constructors - public DeviceManagerOpenroadmImpl() { - LOG.info("Creating provider for {}", APPLICATION_NAME); - resOpenRoadm = null; - } - // end of constructors - - // public methods - public void setNetconfNetworkElementService(NetconfNetworkElementService netconfNetworkElementService) { - this.netconfNetworkElementService = netconfNetworkElementService; - } - - public void init() throws Exception { - - LOG.info("Session Initiated start {}", APPLICATION_NAME); - - resOpenRoadm = netconfNetworkElementService.registerBindingNetworkElementFactory(new OpenroadmNetworkElementFactory()); - - - netconfNetworkElementService.writeToEventLog(APPLICATION_NAME, "startup", "done"); - this.devicemanagerInitializationOk = true; - - LOG.info("Session Initiated end. Initialization done {}", devicemanagerInitializationOk); - } - // Blueprint end - - @Override - public void close() throws Exception { - LOG.info("closing ..."); - close(htDatabaseClient); - close(resOpenRoadm); - LOG.info("closing done"); - } - // end of public methods - - // private methods - /** - * Used to close all Services, that should support AutoCloseable Pattern - * - * @param toClose - * @throws Exception - */ - private void close(AutoCloseable... toCloseList) { - for (AutoCloseable element : toCloseList) { - if (element != null) { - try { - element.close(); - } catch (Exception e) { - LOG.warn("Fail during close: ", e); - } - } - } - } - // end of private methods -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java deleted file mode 100644 index 6c8837327..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/InitialDeviceAlarmReader.java +++ /dev/null @@ -1,156 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.Collection; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.ActiveAlarmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.Severity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.active.alarm.list.ActiveAlarms; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Faultlog; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Class to read the initial alarms at the time of device registration - * - **/ - -public class InitialDeviceAlarmReader { - // variables - private Integer count = 1; - private static final Logger log = LoggerFactory.getLogger(InitialDeviceAlarmReader.class); - private final NetconfBindingAccessor netConfAccesor; - private final @NonNull FaultService faultEventListener; - private final DataProvider dataProvider; - // end of variables - - // constructors - public InitialDeviceAlarmReader(NetconfBindingAccessor accessor, DeviceManagerServiceProvider serviceProvider) { - this.netConfAccesor = accessor; - this.faultEventListener = serviceProvider.getFaultService(); - this.dataProvider = serviceProvider.getDataProvider(); - } - // end of constructors - - // protected methods - // Mapping the alarm data with the fault data - protected FaultData writeFaultData() { - FaultData faultData = new FaultData(); - if (this.getActiveAlarmList(this.netConfAccesor).getActiveAlarms() != null) { - Collection<ActiveAlarms> activeAlarms = YangHelper.getCollection(this.getActiveAlarmList(this.netConfAccesor).getActiveAlarms()); - if (!activeAlarms.isEmpty()) { - for (ActiveAlarms activeAlarm : activeAlarms) { - faultData.add(this.netConfAccesor.getNodeId(), this.count, activeAlarm.getRaiseTime(), - activeAlarm.getResource().getDevice().getNodeId().getValue(), - activeAlarm.getProbableCause().getCause().getName(), - checkSeverityValue(activeAlarm.getSeverity())); - count = count + 1; - } - return faultData; - } - } - return faultData; - } - - // Write into the FaultLog - protected void writeAlarmLog(FaultData faultData) { - if (faultData != null) { - List<Faultlog> faultLog = faultData.getProblemList(); - for (Faultlog fe : faultLog) { - this.dataProvider.writeFaultLog(fe); - } - } - } - - // Use the FaultService for Alarm notifications - protected void faultService() { - this.faultEventListener.initCurrentProblemStatus(this.netConfAccesor.getNodeId(), writeFaultData()); - writeAlarmLog(writeFaultData()); - } - // Mapping Severity of AlarmNotification to SeverityType of FaultLog - protected static SeverityType checkSeverityValue(Severity severity) { - SeverityType severityType = null; - log.info("Device Severity: {}", severity.getName()); - - switch (severity.getName()) { - case ("warning"): - severityType = SeverityType.Warning; - break; - case ("major"): - severityType = SeverityType.Major; - break; - case ("minor"): - severityType = SeverityType.Minor; - break; - case ("clear"): - severityType = SeverityType.NonAlarmed; - break; - case ("critical"): - severityType = SeverityType.Critical; - break; - case ("indeterminate"): - severityType = SeverityType.Critical; - break; - default: - severityType = SeverityType.Critical; - break; - - } - return severityType; - - } - // end of protected methods - - // private methods - - // Read Alarm Data - private ActiveAlarmList getActiveAlarmList(NetconfBindingAccessor accessor) { - final Class<ActiveAlarmList> classAlarm = ActiveAlarmList.class; - log.info("Get Alarm data for element {}", accessor.getNodeId().getValue()); - InstanceIdentifier<ActiveAlarmList> alarmDataIid = InstanceIdentifier.builder(classAlarm).build(); - - ActiveAlarmList alarmData = accessor.getTransactionUtils().readData(accessor.getDataBroker(), - LogicalDatastoreType.OPERATIONAL, alarmDataIid); - - log.info("AlarmData {}", alarmData); - return alarmData; - } - - - // end of private methods - - - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java deleted file mode 100644 index 3af6d7aca..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmChangeNotificationListener.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.List; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.IetfNetconfNotificationsListener; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfCapabilityChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfigChange; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfConfirmedCommit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionEnd; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.NetconfSessionStart; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.netconf.notifications.rev120206.netconf.config.change.Edit; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -/** - * @author Shabnam Sultana - * - * Listener for change notifications - * - **/ -public class OpenroadmChangeNotificationListener implements IetfNetconfNotificationsListener { - - // variables - private static final Logger log = LoggerFactory.getLogger(OpenroadmChangeNotificationListener.class); - private final NetconfAccessor netconfAccessor; - private final DataProvider databaseService; - private final WebsocketManagerService notificationServiceService; - // end of variables - - // constructors - public OpenroadmChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService, - WebsocketManagerService notificationService) { - this.netconfAccessor = netconfAccessor; - this.databaseService = databaseService; - this.notificationServiceService = notificationService; - } - // end of constructors - - // public methods - @Override - public void onNetconfConfirmedCommit(NetconfConfirmedCommit notification) { - log.info("onNetconfConfirmedCommit {} ", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - NetconfConfirmedCommit.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); - } - - @Override - public void onNetconfSessionStart(NetconfSessionStart notification) { - log.info("onNetconfSessionStart {} ", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - NetconfSessionStart.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); - - } - - @Override - public void onNetconfSessionEnd(NetconfSessionEnd notification) { - log.info("onNetconfSessionEnd {}", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - NetconfSessionEnd.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); - } - - @Override - public void onNetconfCapabilityChange(NetconfCapabilityChange notification) { - log.info("onNetconfCapabilityChange {}", notification); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - NetconfCapabilityChange.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); - } - - @Override - public void onNetconfConfigChange(NetconfConfigChange notification) { - log.info("onNetconfConfigChange (1) {}", notification); - StringBuffer sb = new StringBuffer(); - List<Edit> editList = notification.nonnullEdit(); - for (Edit edit : editList) { - if (sb.length() > 0) { - sb.append(", "); - } - sb.append(edit); - - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - - InstanceIdentifier<?> target = edit.getTarget(); - if (target != null) { - eventlogBuilder.setObjectId(target.toString()); - log.info("TARGET: {} {}", target.getClass(), target.getTargetType()); - for (PathArgument pa : target.getPathArguments()) { - log.info("PathArgument {}", pa); - } - } - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()); - eventlogBuilder.setNewValue(String.valueOf(edit.getOperation())); - databaseService.writeEventLog(eventlogBuilder.build()); - } - log.info("onNetconfConfigChange (2) {}", sb); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - NetconfConfigChange.QNAME, NetconfTimeStampImpl.getConverter().getTimeStamp()); - - } - - // end of public methods - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java deleted file mode 100644 index daea1adb3..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmDeviceChangeNotificationListener.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.ChangeNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.CreateTechInfoNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDeviceListener; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OtdrScanResult; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.change.notification.Edit; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Listener for Open roadm device specific change notifications - **/ - -public class OpenroadmDeviceChangeNotificationListener implements OrgOpenroadmDeviceListener { - // variables - private static final Logger log = LoggerFactory.getLogger(OpenroadmDeviceChangeNotificationListener.class); - private Integer counter = 1; - private final NetconfAccessor netconfAccessor; - private final DataProvider databaseProvider; - private final WebsocketManagerService notificationServiceService; - private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); - // end of variables - - // constructors - public OpenroadmDeviceChangeNotificationListener(NetconfAccessor netconfAccessor, DataProvider databaseService, - WebsocketManagerService faultService) { - this.netconfAccessor = netconfAccessor; - this.databaseProvider = databaseService; - this.notificationServiceService = faultService; - } - // end of constructors - - // public methods - @Override - public void onOtdrScanResult(OtdrScanResult notification) { - // TODO Auto-generated method stub - - } - - @Override - public void onChangeNotification(ChangeNotification notification) { - log.info("onDeviceConfigChange(1){}", notification); - StringBuffer sb = new StringBuffer(); - - @NonNull - List<Edit> editList = notification.nonnullEdit(); - for (Edit edit : editList) { - if (sb.length() > 0) { - sb.append(", "); - } - sb.append(edit); - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - InstanceIdentifier<?> target = edit.getTarget(); - if (target != null) { - eventlogBuilder.setObjectId(target.getPathArguments().toString()); - log.info("TARGET: {} {}", target.getClass(), target.getTargetType()); - for (PathArgument pa : target.getPathArguments()) { - log.info("PathArgument {}", pa); - } - eventlogBuilder.setAttributeName(target.getTargetType().getName()); - } - eventlogBuilder.setNodeId(netconfAccessor.getNodeId().getValue()); - eventlogBuilder.setNewValue(String.valueOf(edit.getOperation())); - eventlogBuilder.setTimestamp(notification.getChangeTime()); - eventlogBuilder.setCounter(counter); - eventlogBuilder.setSourceType(SourceType.Netconf); - databaseProvider.writeEventLog(eventlogBuilder.build()); - log.info("onDeviceConfigChange (2) {}", sb); - counter++; - } - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - ChangeNotification.QNAME, notification.getChangeTime()); - } - - @Override - public void onCreateTechInfoNotification(CreateTechInfoNotification notification) { - - DateAndTime now = NetconfTimeStampImpl.getConverter().getTimeStamp(); - log.info("onCreateTechInfoNotification(1){}", notification); - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setId(notification.getShelfId()).setAttributeName(notification.getShelfId()) - .setObjectId(notification.getShelfId()).setNodeId(this.netconfAccessor.getNodeId().getValue()) - .setCounter(counter).setNewValue(notification.getStatus().getName()).setSourceType(SourceType.Netconf) - .setTimestamp(now); - databaseProvider.writeEventLog(eventlogBuilder.build()); - this.notificationServiceService.sendNotification(notification, this.netconfAccessor.getNodeId().getValue(), - CreateTechInfoNotification.QNAME, now); - log.info("Create-techInfo Notification written "); - counter++; - } - // end of public methods - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java deleted file mode 100644 index 10d0a5640..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmFaultNotificationListener.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - - -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService; -import org.onap.ccsdk.features.sdnr.wt.websocketmanager.model.WebsocketManagerService; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.AlarmNotification; -import org.opendaylight.yang.gen.v1.http.org.openroadm.alarm.rev191129.OrgOpenroadmAlarmListener; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Listener for Open roadm device specific alarm notifications - **/ -public class OpenroadmFaultNotificationListener implements OrgOpenroadmAlarmListener { - private static final Logger log = LoggerFactory.getLogger(OpenroadmFaultNotificationListener.class); - - private final @NonNull FaultService faultEventListener; - private @NonNull WebsocketManagerService notificationService; - private Integer count = 1; - - - public OpenroadmFaultNotificationListener(DeviceManagerServiceProvider serviceProvider) { - this.faultEventListener = serviceProvider.getFaultService(); - this.notificationService = serviceProvider.getWebsocketService(); - - } - - @Override - public void onAlarmNotification(AlarmNotification notification) { - - - log.info("AlarmNotification {} \t {}", notification.getId(), notification.getAdditionalDetail()); - final String nodeId = notification.getResource().getDevice().getNodeId().getValue(); - FaultlogEntity faultAlarm = new FaultlogBuilder().setObjectId(notification.getCircuitId()) - .setProblem(notification.getProbableCause().getCause().getName()).setSourceType(SourceType.Netconf) - .setTimestamp(notification.getRaiseTime()).setId(notification.getId()).setNodeId(nodeId) - .setSeverity(InitialDeviceAlarmReader.checkSeverityValue(notification.getSeverity())).setCounter(count) - .build(); - - this.faultEventListener.faultNotification(faultAlarm); - this.notificationService.sendNotification(notification, nodeId, AlarmNotification.QNAME, - notification.getRaiseTime()); - count++; - log.info("Notification is written into the database {}", faultAlarm.getObjectId()); - - } - - - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java deleted file mode 100644 index abaec72ab..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmInventoryInput.java +++ /dev/null @@ -1,149 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.InventoryBuilder; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Reading the inventory data of an open roadm device - * - **/ -public class OpenroadmInventoryInput { - // variable - private static final Logger log = LoggerFactory.getLogger(OpenroadmInventoryInput.class); - private OrgOpenroadmDevice openRoadmDevice; - private final NetconfAccessor accessor; - // end of variables - - // constructors - public OpenroadmInventoryInput(NetconfAccessor netconfAccessor, OrgOpenroadmDevice roadmDevice) { - this.openRoadmDevice = roadmDevice; - this.accessor = netconfAccessor; - } - // end of constructors - - // public methods - public Inventory getInventoryData(Uint32 treeLevel) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - log.info("Info for device {}", this.openRoadmDevice.getInfo().getNodeId().getValue()); - inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()) - .setUuid(this.openRoadmDevice.getInfo().getNodeId() == null ? "N/A" - : this.openRoadmDevice.getInfo().getNodeId().getValue()) - .setDate(this.openRoadmDevice.getInfo().getCurrentDatetime().getValue()) - .setId(this.openRoadmDevice.getInfo().getNodeId().getValue()) - .setManufacturerIdentifier(this.openRoadmDevice.getInfo().getVendor()) - .setModelIdentifier(this.openRoadmDevice.getInfo().getModel()) - .setSerial(this.openRoadmDevice.getInfo().getSerialId()).setTreeLevel(treeLevel) - .setVersion(this.openRoadmDevice.getInfo().getOpenroadmVersion().getName()) - .setDescription("org-openroadm-device").setParentUuid("None") - .setTypeName(this.openRoadmDevice.getInfo().getNodeType().getName()).setPartTypeId("device"); - log.info("Inventory data written for device {}", this.openRoadmDevice.getInfo().getNodeId().getValue()); - return inventoryBuilder.build(); - } - - public Inventory getShelvesInventory(Shelves shelf, Uint32 treeLevel) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(shelf.getShelfName()) - .setDescription((shelf.getUserDescription() == null) - ? ("Position: " + shelf.getShelfPosition() + "\nState: " + shelf.getOperationalState()) - : (shelf.getUserDescription()) + "\nPosition: " + shelf.getShelfPosition() + "\nState: " - + shelf.getOperationalState()) - .setSerial(shelf.getSerialId()).setUuid(shelf.getShelfName()) - .setParentUuid(this.openRoadmDevice.getInfo().getNodeId().getValue()).setTreeLevel(treeLevel) - .setTypeName(shelf.getShelfType()).setPartTypeId(shelf.getClei()) - .setManufacturerIdentifier(shelf.getVendor()).setModelIdentifier(shelf.getModel()) - .setVersion(shelf.getHardwareVersion()).setDate(shelf.getManufactureDate().getValue()); - log.info("Inventory data written for Shelf {}", shelf.getShelfName()); - return inventoryBuilder.build(); - } - - public Inventory getInterfacesInventory(Interface deviceInterface, Uint32 treeLevel) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(deviceInterface.getName()) - .setDescription((deviceInterface.getDescription() == null) ? "N/A" : deviceInterface.getDescription()) - .setUuid(deviceInterface.getName()).setSerial(deviceInterface.getName()) - .setParentUuid((deviceInterface.getSupportingCircuitPackName() != null) - ? deviceInterface.getSupportingCircuitPackName() - : ((deviceInterface.getSupportingInterface() != null) ? deviceInterface.getSupportingInterface() - : this.openRoadmDevice.getInfo().getNodeId().getValue())) - .setTreeLevel(treeLevel) - .setTypeName((deviceInterface.getType() == null) ? "Interface" - : deviceInterface.getType().getName().substring(69, - deviceInterface.getType().getName().length())) - .setPartTypeId("Interface").setManufacturerIdentifier(this.openRoadmDevice.getInfo().getVendor()) - .setModelIdentifier(this.openRoadmDevice.getInfo().getModel()).setVersion("N/A") - .setDate(this.openRoadmDevice.getInfo().getCurrentDatetime().getValue()); - log.info("Inventory data written for Interface {}", deviceInterface.getName()); - - return inventoryBuilder.build(); - } - - public Inventory getCircuitPackInventory(CircuitPacks circuitPack, Uint32 treeLevel) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setUuid(circuitPack.getCircuitPackName()) - .setDate((circuitPack.getManufactureDate() == null) ? "N/A" - : circuitPack.getManufactureDate().getValue().substring(0, 19)) - .setId(circuitPack.getCircuitPackName()).setManufacturerIdentifier(circuitPack.getVendor()) - .setModelIdentifier(circuitPack.getModel()).setSerial(circuitPack.getSerialId()).setTreeLevel(treeLevel) - .setVersion(circuitPack.getHardwareVersion()) - .setDescription("ProductCode: " + circuitPack.getProductCode() + " " + "Mode: " - + circuitPack.getCircuitPackMode()) - .setTypeName((circuitPack.getType() == null) ? circuitPack.getCircuitPackType() : circuitPack.getType()) - .setPartTypeId((circuitPack.getClei() == null) ? circuitPack.getType() : circuitPack.getClei()) - .setParentUuid((circuitPack.getParentCircuitPack() != null) - ? circuitPack.getParentCircuitPack().getCircuitPackName() - : ((circuitPack.getShelf() != null) ? circuitPack.getShelf() - : this.openRoadmDevice.getInfo().getNodeId().getValue())); - log.info("Inventory data written for CircuitPack {}", circuitPack.getCircuitPackName()); - - return inventoryBuilder.build(); - } - - public Inventory getXponderInventory(Xponder xpdr, Uint32 treeLevel) { - InventoryBuilder inventoryBuilder = new InventoryBuilder(); - inventoryBuilder.setNodeId(this.accessor.getNodeId().getValue()).setId(xpdr.getXpdrNumber().toString()) - .setDescription("Xponder\nLifecycleState: " + xpdr.getLifecycleState().getName()) - .setUuid(xpdr.getXpdrNumber().toString()).setSerial(xpdr.getXpdrNumber().toString()) - .setParentUuid(this.openRoadmDevice.getInfo().getNodeId().getValue()).setTreeLevel(treeLevel) - .setTypeName(xpdr.getXpdrType().getName()).setPartTypeId(xpdr.getXpdrType().getName()) - .setManufacturerIdentifier(this.openRoadmDevice.getInfo().getVendor()) - .setModelIdentifier(this.openRoadmDevice.getInfo().getModel()) - .setVersion(this.openRoadmDevice.getInfo().getOpenroadmVersion().getName()) - .setDate(this.openRoadmDevice.getInfo().getCurrentDatetime().getValue()); - log.info("Inventory data written for Xponder{}", xpdr.getXpdrNumber()); - - return inventoryBuilder.build(); - } - // end of public methods -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java deleted file mode 100644 index 02f8547ae..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElement.java +++ /dev/null @@ -1,323 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Hashtable; -import java.util.List; -import org.eclipse.jdt.annotation.NonNull; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.circuit.packs.CircuitPacks; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.interfaces.grp.Interface; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.org.openroadm.device.Xponder; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelf.Slots; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.shelves.Shelves; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.xponder.XpdrPort; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Inventory; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SourceType; -import org.opendaylight.yangtools.concepts.ListenerRegistration; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.opendaylight.yangtools.yang.binding.NotificationListener; -import org.opendaylight.yangtools.yang.common.Uint32; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Creating the openroadm device as an optical network element and writing inventory, fault, pm data to elastic - * search db - * - **/ -public class OpenroadmNetworkElement extends OpenroadmNetworkElementBase { - - // variables - private final long equipmentLevel = 1; - private static final Logger log = LoggerFactory.getLogger(OpenroadmNetworkElement.class); - private Hashtable<String, Long> circuitPacksRecord; - private Hashtable<String, Long> shelfProvisionedcircuitPacks; - private ListenerRegistration<NotificationListener> openRdmListenerRegistrationResult; - private @NonNull final OpenroadmChangeNotificationListener openRdmListener; - private ListenerRegistration<NotificationListener> opnRdmFaultListenerRegistrationResult; - private @NonNull OpenroadmFaultNotificationListener opnRdmFaultListener; - private ListenerRegistration<NotificationListener> opnRdmDeviceListenerRegistrationResult; - private OpenroadmDeviceChangeNotificationListener opnRdmDeviceListener; - private OpenroadmInventoryInput opnRdmInventoryInput; - private PmDataBuilderOpenRoadm openRoadmPmData; - private InitialDeviceAlarmReader initialAlarmReader; - - private static final NetconfTimeStamp ncTimeConverter = NetconfTimeStampImpl.getConverter(); - private int counter = 1; - // end of variables - - // constructors - public OpenroadmNetworkElement(NetconfBindingAccessor netconfAccess, DeviceManagerServiceProvider serviceProvider) { - - super(netconfAccess, serviceProvider); - - log.info("Create {}", OpenroadmNetworkElement.class.getSimpleName()); - this.openRdmListenerRegistrationResult = null; - this.openRdmListener = new OpenroadmChangeNotificationListener(netconfAccessor, databaseService, - serviceProvider.getWebsocketService()); - this.opnRdmFaultListenerRegistrationResult = null; - this.opnRdmFaultListener = new OpenroadmFaultNotificationListener(serviceProvider); - this.opnRdmDeviceListenerRegistrationResult = null; - this.opnRdmDeviceListener = new OpenroadmDeviceChangeNotificationListener(netconfAccessor, databaseService, - serviceProvider.getWebsocketService()); - this.circuitPacksRecord = new Hashtable<>(); - this.shelfProvisionedcircuitPacks = new Hashtable<>(); - this.openRoadmPmData = new PmDataBuilderOpenRoadm(this.netconfAccessor); - this.initialAlarmReader = new InitialDeviceAlarmReader(this.netconfAccessor, serviceProvider); - log.info("NodeId {}", this.netconfAccessor.getNodeId().getValue()); - - - } - // end of constructors - - // public methods - public void initialReadFromNetworkElement() { - - OrgOpenroadmDevice device = readDevice(this.netconfAccessor); - this.opnRdmInventoryInput = new OpenroadmInventoryInput(this.netconfAccessor, device); - log.info("openroadmMapper details{}", this.opnRdmInventoryInput.getClass().getName()); - List<Inventory> inventoryList = new ArrayList<>(); - inventoryList.add(this.opnRdmInventoryInput.getInventoryData(Uint32.valueOf(equipmentLevel))); - readShelvesData(inventoryList, device); - readXpndrData(inventoryList, device); - readCircuitPacketData(inventoryList, device); - readInterfaceData(inventoryList, device); - this.databaseService.writeInventory(this.netconfAccessor.getNodeId().getValue(), inventoryList); - // Writing initial alarms at the time of device registration - initialAlarmReader.faultService(); - // Writing historical PM data at the time of device registration - List<PmdataEntity> pmDataEntity = new ArrayList<>(); - pmDataEntity = this.openRoadmPmData.buildPmDataEntity(this.openRoadmPmData.getPmData(this.netconfAccessor)); - if (!pmDataEntity.isEmpty()) { - this.databaseService.doWritePerformanceData(pmDataEntity); - log.info("PmDatEntity is written with size {}", pmDataEntity.size()); - for (PmdataEntity ent : pmDataEntity) { - log.info("GetNode: {}, granPeriod: {}", ent.getNodeName(), ent.getGranularityPeriod().getName()); - } - } else { - log.info("PmDatEntity is empty"); - } - } - - - @Override - public void register() { - initialReadFromNetworkElement(); - - this.openRdmListenerRegistrationResult = netconfAccessor.doRegisterNotificationListener(openRdmListener); - this.opnRdmFaultListenerRegistrationResult = - netconfAccessor.doRegisterNotificationListener(opnRdmFaultListener); - this.opnRdmDeviceListenerRegistrationResult = - netconfAccessor.doRegisterNotificationListener(opnRdmDeviceListener); - // Register netconf stream - netconfAccessor.registerNotificationsStream(NetconfAccessor.DefaultNotificationsStream); - } - - @Override - public void deregister() { - if (openRdmListenerRegistrationResult != null) { - this.openRdmListenerRegistrationResult.close(); - } - if (opnRdmFaultListenerRegistrationResult != null) { - this.opnRdmFaultListenerRegistrationResult.close(); - } - if (opnRdmDeviceListenerRegistrationResult != null) { - this.opnRdmDeviceListenerRegistrationResult.close(); - } - } - - // end of public methods - - // private methods - private void readShelvesData(List<Inventory> inventoryList, OrgOpenroadmDevice device) { - Collection<Shelves> shelves = YangHelper.getCollection(device.getShelves()); - if (shelves != null) { - for (Shelves shelf : shelves) { - log.info( - "Shelf Name: {}, \n Serial Id:{}, \n Product Code;{}, \n Position:{}, \n EquipmetState: {}, \n Hardware version: {}" - + "\n ShelfType:{}, \n Vendor: {}, \n LifecycleState: {} ", - shelf.getShelfName(), shelf.getSerialId(), shelf.getProductCode(), shelf.getShelfPosition(), - shelf.getEquipmentState(), shelf.getHardwareVersion(), shelf.getShelfType(), shelf.getVendor(), - shelf.getLifecycleState()); - inventoryList - .add(this.opnRdmInventoryInput.getShelvesInventory(shelf, Uint32.valueOf(equipmentLevel + 1))); - Collection<Slots> slotList = YangHelper.getCollection(shelf.getSlots()); - if (slotList != null) { - for (Slots slot : slotList) { - if (slot.getProvisionedCircuitPack() != null) { - this.shelfProvisionedcircuitPacks.put(slot.getProvisionedCircuitPack(), equipmentLevel + 2); - } - log.info("Slots for the shelf: {}", shelf.getShelfName()); - log.info("\n Slot Name: {}, \n Status: {}, \n Slot label: {} ", slot.getSlotName(), - slot.getSlotStatus(), slot.getLabel()); - } - } - } - log.info("size of shelfProvisionedcircuitPacks: {} ", shelfProvisionedcircuitPacks.size()); - } - - } - - private void readXpndrData(List<Inventory> inventoryList, OrgOpenroadmDevice device) { - Collection<Xponder> xponderList = YangHelper.getCollection(device.getXponder()); - - if (xponderList != null) { - for (Xponder xponder : xponderList) { - - inventoryList.add( - this.opnRdmInventoryInput.getXponderInventory(xponder, Uint32.valueOf(equipmentLevel + 1))); - log.info("Xponders: No.: {} , \n Port: {} ,\n Type: {}", xponder.getXpdrNumber(), xponder.getXpdrPort(), - xponder.getXpdrType()); - Collection<XpdrPort> xpdrportlist = YangHelper.getCollection(xponder.getXpdrPort()); - if (xpdrportlist != null) { - for (XpdrPort xpdrport : xpdrportlist) - if (xpdrport.getCircuitPackName() != null) { - this.shelfProvisionedcircuitPacks.put(xpdrport.getCircuitPackName(), equipmentLevel + 2); - log.info("Size of dict{}", this.shelfProvisionedcircuitPacks.size()); - } - } - - } - } - } - - private void readCircuitPacketData(List<Inventory> inventoryList, OrgOpenroadmDevice device) { - Collection<CircuitPacks> circuitpackCollection = YangHelper.getCollection(device.getCircuitPacks()); - List<String> cpNameList = new ArrayList<>(); - - if (circuitpackCollection != null) { - // collect all circuit pack names. Required to check for invalid parents later on - for (CircuitPacks cp : circuitpackCollection) { - cpNameList.add(cp.getCircuitPackName()); - } - - for (CircuitPacks cp : circuitpackCollection) { - log.info("CP Name:{}", cp.getCircuitPackName()); - - if (cp.getParentCircuitPack() == null - && !this.shelfProvisionedcircuitPacks.containsKey(cp.getCircuitPackName())) { - log.info("cp has no parent and no shelf"); - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 1)); - inventoryList.add( - this.opnRdmInventoryInput.getCircuitPackInventory(cp, Uint32.valueOf(equipmentLevel + 1))); - } else { - // check for missing valid parent circuit name - if (cp.getParentCircuitPack().getCpSlotName() != null - && cp.getParentCircuitPack().getCircuitPackName() == null) { - - log.info("Cp {} has slotname of the parent circuit pack but no parent circuit pack name", - cp.getCircuitPackName()); - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 3)); - inventoryList.add(this.opnRdmInventoryInput.getCircuitPackInventory(cp, - Uint32.valueOf(equipmentLevel + 3))); - databaseService.writeEventLog(writeIncorrectParentLog(cp.getCircuitPackName(), counter) - .setObjectId(device.getInfo().getNodeId().getValue()) - .setId(cp.getParentCircuitPack().getCpSlotName()) - .setNewValue("Missing parent circuit pack name").build()); - } else if (cp.getParentCircuitPack().getCircuitPackName() != null - && this.shelfProvisionedcircuitPacks - .containsKey(cp.getParentCircuitPack().getCircuitPackName())) { - log.info("Cp {} has parent circuit pack and shelf", cp.getCircuitPackName()); - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 3)); - inventoryList.add(this.opnRdmInventoryInput.getCircuitPackInventory(cp, - Uint32.valueOf(equipmentLevel + 3))); - } else { - // check for incorrect hierarchy - if (cp.getParentCircuitPack().getCircuitPackName() != null - && !cpNameList.contains(cp.getParentCircuitPack().getCircuitPackName())) { - databaseService.writeEventLog(writeIncorrectParentLog(cp.getCircuitPackName(), counter) - .setObjectId(device.getInfo().getNodeId().getValue()) - .setId(cp.getParentCircuitPack().getCpSlotName()).build()); - } - - log.info("Cp has parent circuit pack but no shelf or a shelf but no parent circuit pack"); - this.circuitPacksRecord.put(cp.getCircuitPackName(), (equipmentLevel + 2)); - inventoryList.add(this.opnRdmInventoryInput.getCircuitPackInventory(cp, - Uint32.valueOf(equipmentLevel + 2))); - } - - } - } - - } - } - - private void readInterfaceData(List<Inventory> inventoryList, OrgOpenroadmDevice device) { - Collection<Interface> interfaceList = YangHelper.getCollection(device.getInterface()); - if (interfaceList != null) { - for (Interface deviceInterface : interfaceList) { - log.info("\n InterfaceName: {}", deviceInterface.getName()); - log.info("Supporting CP {}", this.circuitPacksRecord.size()); - for (String s : this.circuitPacksRecord.keySet()) { - log.info("{} value {}", s, this.circuitPacksRecord.get(s)); - } - log.info("Interface {} and their supporting CP {}", deviceInterface.getName(), - deviceInterface.getSupportingCircuitPackName()); - if (deviceInterface.getSupportingCircuitPackName() != null) { - if (this.circuitPacksRecord.containsKey(deviceInterface.getSupportingCircuitPackName())) { - inventoryList.add(this.opnRdmInventoryInput.getInterfacesInventory(deviceInterface, - Uint32.valueOf( - this.circuitPacksRecord.get(deviceInterface.getSupportingCircuitPackName()) - + 1))); - } - } else { - inventoryList.add(this.opnRdmInventoryInput.getInterfacesInventory(deviceInterface, - Uint32.valueOf(equipmentLevel + 1))); - } - } - } - } - - private OrgOpenroadmDevice readDevice(NetconfBindingAccessor accessor) { - final Class<OrgOpenroadmDevice> openRoadmDev = OrgOpenroadmDevice.class; - InstanceIdentifier<OrgOpenroadmDevice> deviceId = InstanceIdentifier.builder(openRoadmDev).build(); - return accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - deviceId); - } - - private EventlogBuilder writeIncorrectParentLog(String attributeName, Integer counter) { - EventlogBuilder eventlogBuilder = new EventlogBuilder(); - eventlogBuilder.setAttributeName(attributeName).setCounter(counter) - .setNodeId(this.netconfAccessor.getNodeId().getValue()).setSourceType(SourceType.Netconf) - .setNewValue("Invalid parent circuit-pack name") - .setTimestamp(new DateAndTime(ncTimeConverter.getTimeStamp())); - - return eventlogBuilder; - - } - // end of private methods -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java deleted file mode 100644 index 9949056bb..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementBase.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElementService; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType; -import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId; - -public class OpenroadmNetworkElementBase implements NetworkElement { - - protected final NetconfBindingAccessor netconfAccessor; - protected final DataProvider databaseService; - - public OpenroadmNetworkElementBase(NetconfBindingAccessor netconfAccess, - DeviceManagerServiceProvider serviceProvider) { - - this.netconfAccessor = netconfAccess; - this.databaseService = serviceProvider.getDataProvider(); - } - - @Override - public void register() {} - - @Override - public void deregister() {} - - @Override - public void warmstart() {} - - @Override - public NodeId getNodeId() { - return netconfAccessor.getNodeId(); - } - - @Override - public NetworkElementDeviceType getDeviceType() { - return NetworkElementDeviceType.OROADM; - } - - @Override - public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) { - return Optional.empty(); - } - - @Override - public Optional<NetconfAccessor> getAcessor() { - return Optional.of(netconfAccessor); - } -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java deleted file mode 100644 index cc8eaa68e..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/OpenroadmNetworkElementFactory.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ - -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.util.Optional; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement; -import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.yang.gen.v1.http.org.openroadm.device.rev191129.OrgOpenroadmDevice; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author Shabnam Sultana - * - * Register the openroadm device as an optical network element - * - **/ - -public class OpenroadmNetworkElementFactory implements NetworkElementFactory { - - // variables - private static final Logger log = LoggerFactory.getLogger(OpenroadmNetworkElementFactory.class); - // end of variables - - // public methods - @Override - public Optional<NetworkElement> create(NetconfAccessor accessor, DeviceManagerServiceProvider serviceProvider) { - - if (accessor.getCapabilites().isSupportingNamespaceAndRevision(OrgOpenroadmDevice.QNAME)) { - log.info("Create OpenRoadm device {} ", OpenroadmNetworkElement.class.getName()); - log.info("Node Id read by Acessor {}:", accessor.getNodeId().getValue()); - Optional<NetconfBindingAccessor> bindingAccessor = accessor.getNetconfBindingAccessor(); - if (bindingAccessor.isPresent()) { - return Optional.of(new OpenroadmNetworkElement(bindingAccessor.get(), serviceProvider)); - } - } else if (accessor.getCapabilites().isSupportingNamespaceAndRevision("http://org/openroadm/device","2018-10-19")) { - log.info("Create OpenRoadm base device {} ", OpenroadmNetworkElementBase.class.getName()); - log.info("Node Id read by Acessor {}:", accessor.getNodeId().getValue()); - Optional<NetconfBindingAccessor> bindingAccessor = accessor.getNetconfBindingAccessor(); - if (bindingAccessor.isPresent()) { - return Optional.of(new OpenroadmNetworkElementBase(bindingAccessor.get(), serviceProvider)); - } - } - return Optional.empty(); - } - // end of public methods - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java deleted file mode 100644 index f1fd4471f..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/openroadm/impl/PmDataBuilderOpenRoadm.java +++ /dev/null @@ -1,290 +0,0 @@ -/* - * ============LICENSE_START======================================================= - * ONAP : ccsdk features - * ================================================================================ - * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. - * All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - * - */ -package org.onap.ccsdk.features.sdnr.wt.devicemanager.openroadm.impl; - -import java.net.URL; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import org.onap.ccsdk.features.sdnr.wt.common.YangHelper; -import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfBindingAccessor; -import org.opendaylight.mdsal.common.api.LogicalDatastoreType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.HistoricalPmList; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.group.HistoricalPm; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.list.HistoricalPmEntry; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.rev191129.historical.pm.val.group.Measurement; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmDataType; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmGranularity; -import org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129.PmNamesEnum; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.g836.pm.types.rev200413.ErroredSecond; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.g836.pm.types.rev200413.SeverelyErroredSecond; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413.PerformanceMeasurementTypeId; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntityBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.entity.PerformanceDataBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementBuilder; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.MeasurementKey; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.Celsius; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.DB; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.DBm; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.Fahrenheit; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.KHz; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.MW; -import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.units.rev200413.PerformanceMeasurementUnitId; -import org.opendaylight.yangtools.yang.binding.InstanceIdentifier; -import org.osgi.framework.Bundle; -import org.osgi.framework.BundleContext; -import org.osgi.framework.FrameworkUtil; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * @author shabnam - * - * Reading Openroadm PM data and returning as PmDataEntitiy data - */ -public class PmDataBuilderOpenRoadm { - // variables - private static final Logger log = LoggerFactory.getLogger(PmDataBuilderOpenRoadm.class); - private PmdataEntityBuilder pmDataBuilder; - private Bundle b = FrameworkUtil.getBundle(this.getClass()); - - // end of variables - // constructors - public PmDataBuilderOpenRoadm(NetconfBindingAccessor accessor) { - this.pmDataBuilder = new PmdataEntityBuilder(); - this.pmDataBuilder.setNodeName(accessor.getNodeId().getValue()); - } - - // end of constructors - // public methods - // Read PM data - public HistoricalPmList getPmData(NetconfBindingAccessor accessor) { - final Class<HistoricalPmList> pmDataClass = HistoricalPmList.class; - log.info("Get PM data for element {}", accessor.getNodeId().getValue()); - InstanceIdentifier<HistoricalPmList> pmDataIid = InstanceIdentifier.builder(pmDataClass).build(); - return accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, - pmDataIid); - - } - - // Build PM entity for writing into the database - public List<PmdataEntity> buildPmDataEntity(HistoricalPmList historicalPmEnitityList) { - List<PmdataEntity> pmEntitiyList = new ArrayList<>(); - Collection<HistoricalPmEntry> pmDataEntryList = - YangHelper.getCollection(historicalPmEnitityList.getHistoricalPmEntry()); - for (HistoricalPmEntry pmDataEntry : pmDataEntryList) { - pmDataBuilder.setUuidInterface(pmDataEntry.getPmResourceType().getName()); - Collection<HistoricalPm> historicalPmList = YangHelper.getCollection(pmDataEntry.getHistoricalPm()); - for (HistoricalPm historicalPm : historicalPmList) { - log.info("PmName:{}", historicalPm.getType()); - // pmDataBuilder.setPerformanceData(value) - - try { - writeperformanceData(historicalPm); - } catch (ClassNotFoundException e) { - log.info("No relevant data found"); - } - pmEntitiyList.add(this.pmDataBuilder.build()); - - log.info("PmListSize before db writing: {}", pmEntitiyList.size()); - } - log.info("PmListSize before db writing: {}", pmEntitiyList.size()); - } - return pmEntitiyList; - } - // end of public methods - - // private methods - private void writeperformanceData(HistoricalPm historicalPm) throws ClassNotFoundException { - Collection<Measurement> measurementList = YangHelper.getCollection(historicalPm.getMeasurement()); - Map<MeasurementKey, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement> measurementMap=new HashMap<>(); - // Map Performance data of PmDataEntity with MeasurmentData-HistoricalPm - PerformanceDataBuilder performanceDataBuilder = new PerformanceDataBuilder(); - for (Measurement measurementData : measurementList) { - this.pmDataBuilder.setGranularityPeriod(mapGranularityPeriod(measurementData.getGranularity())) - .setTimeStamp(measurementData.getCompletionTime()); - if (measurementData.getValidity().getName().equals("suspect")) { - this.pmDataBuilder.setSuspectIntervalFlag(true); - } - measurementMap.put(new MeasurementKey(measurementBuilder(historicalPm.getType(), measurementData.getPmParameterUnit(), - measurementData.getPmParameterValue()).getPmKey()), measurementBuilder(historicalPm.getType(), measurementData.getPmParameterUnit(), - measurementData.getPmParameterValue())); - - - } - - pmDataBuilder.setPerformanceData(performanceDataBuilder.setMeasurement(measurementMap).build()); - } - - - - // Mapping Granularity period of PmDataEntity with PmGranularity of MeasurmentData-HistoricalPm - private GranularityPeriodType mapGranularityPeriod(PmGranularity pmGranularity) { - - GranularityPeriodType granPeriod = null; - switch (pmGranularity.getName()) { - case ("notApplicable"): - granPeriod = GranularityPeriodType.Unknown; - break; - case ("15min"): - granPeriod = GranularityPeriodType.Period15Min; - break; - case ("24Hour"): - granPeriod = GranularityPeriodType.Period24Hours; - break; - default: - granPeriod = GranularityPeriodType.Period15Min; - break; - } - return granPeriod; - } - - private List<Class<? extends PerformanceMeasurementTypeId>> setMeasurementTypeId() { - String packageName = - "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.openroadm.pm.types.rev200413"; - String packageName1 = - "/org/opendaylight/yang/gen/v1/urn/opendaylight/params/xml/ns/yang/data/provider/openroadm/pm/types/rev200413/"; - List<Class<? extends PerformanceMeasurementTypeId>> measTypeObjList = - new ArrayList<>(); - URL root = Thread.currentThread().getContextClassLoader().getResource(packageName1); - - log.info("path for type package: {}", root); - - Enumeration<URL> results = getFileURL(b, packageName); - log.info("FOund Packages {}", results); - if(results != null) { - while (results.hasMoreElements()) { - URL path = results.nextElement(); - - Class<?> cls1 = loadClass(b, path.getFile()); - - if (PerformanceMeasurementTypeId.class.isAssignableFrom(cls1)) { - measTypeObjList.add((Class<? extends PerformanceMeasurementTypeId>) cls1); - - - } - if(cls1!=null) { - log.info("Class Added {}", cls1.getSimpleName()); - } - - } - - - } - - return measTypeObjList; - } - - private Class<? extends PerformanceMeasurementUnitId> setMeasurementUnit(String unitName) { - Class<? extends PerformanceMeasurementUnitId> measurementUnitClass = null; - switch (unitName) { - case ("celsius"): - measurementUnitClass = Celsius.class; - break; - case("dB"): - measurementUnitClass = DB.class; - break; - case("dBm"): - measurementUnitClass = DBm.class; - break; - case("fahrenheit"): - measurementUnitClass = Fahrenheit.class; - break; - case("kHz"): - measurementUnitClass = KHz.class; - break; - case("mW"): - measurementUnitClass = MW.class; - break; - default: - break; - } - return measurementUnitClass; - } - - private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.pmdata.grp.Measurement measurementBuilder( - PmNamesEnum pmType, String pmUnit, PmDataType pmDataType) { - - MeasurementBuilder measBuilder = new MeasurementBuilder(); - if (pmType.getName().equals("erroredSeconds") ) { - measBuilder.setPmKey(ErroredSecond.class); - } else if (pmType.getName().equals("severelyErroredSeconds")) { - measBuilder.setPmKey(SeverelyErroredSecond.class); - } else { - for (Class<? extends PerformanceMeasurementTypeId> obj : setMeasurementTypeId()) { - if (obj.toString().contains(pmType.name())) { - measBuilder.setPmKey(obj); - } - } - } - measBuilder.setPmUnit(setMeasurementUnit(pmUnit)); - measBuilder.setPmValue(pmDataType); - return measBuilder.build(); - - } - - private Class<?> loadClass(Bundle bundle, String classFilePath) { - String className = classFilePath.replaceFirst("^/", "").replace('/', '.').replaceFirst(".class$", ""); - try { - return bundle.loadClass(className); - } catch (Exception e) { - log.info(String.format("Class [%s] could not be loaded. Message: [%s].", className, e.getMessage())); - } - return null; - } - - private static Enumeration<URL> getFileURL(Bundle b, String classPath) { - - BundleContext context = b == null ? null : b.getBundleContext(); - if (context == null) { - log.info("no bundle context available"); - return null; - } - Bundle[] bundles = context.getBundles(); - if (bundles == null || bundles.length <= 0) { - log.info("no bundles found"); - return null; - } - log.info("found {} bundles", bundles.length); - Enumeration<URL> resultUrl = null; - - for (Bundle bundle : bundles) { - resultUrl = bundle.findEntries("/" + classPath.replace(".", "/"), "*.class", false); - if (resultUrl != null) { - break; - - } - - } - - return resultUrl; - } - - - // end of private methods -} - diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java deleted file mode 100644 index 249da71fb..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/http/org/openroadm/pm/types/rev191129/PmDataTypeBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.http.org.openroadm.pm.types.rev191129; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class PmDataTypeBuilder { - private PmDataTypeBuilder() { - //Exists only to defeat instantiation. - } - - public static PmDataType getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java deleted file mode 100644 index 30a55a203..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class OperatorStateBuilder { - private OperatorStateBuilder() { - //Exists only to defeat instantiation. - } - - public static OperatorState getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java deleted file mode 100644 index a803bae97..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class ResourceBuilder { - private ResourceBuilder() { - //Exists only to defeat instantiation. - } - - public static Resource getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java deleted file mode 100644 index bbfa37f40..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class ResourceMatchBuilder { - private ResourceMatchBuilder() { - //Exists only to defeat instantiation. - } - - public static ResourceMatch getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java deleted file mode 100644 index 9fb90b438..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class SeverityWithClearBuilder { - private SeverityWithClearBuilder() { - //Exists only to defeat instantiation. - } - - public static SeverityWithClear getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} diff --git a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java b/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java deleted file mode 100644 index 2b8e8af57..000000000 --- a/sdnr/wt/devicemanager-openroadm/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911.alarms; - -/** - * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string - * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 - - * uint16), or (string - uint32). - * - * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be - * finished by the user. This class is generated only once to prevent loss of user code. - * - */ -public class ControlMaxAlarmStatusChangesBuilder { - private ControlMaxAlarmStatusChangesBuilder() { - //Exists only to defeat instantiation. - } - - public static Control.MaxAlarmStatusChanges getDefaultInstance(String defaultValue) { - throw new UnsupportedOperationException("Not yet implemented"); - } - -} |