summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager-oran/provider/src/main
diff options
context:
space:
mode:
authorRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-05 11:04:55 +0200
committerRavi Pendurty <ravi.pendurty@highstreet-technologies.com>2021-04-06 07:16:24 +0200
commit6188c03a3fd1b73da7184c26fdb81f02c8aa8825 (patch)
tree6e5c8c71a0d57ac0f2ec60cf7a60acfab7e83bb4 /sdnr/wt/devicemanager-oran/provider/src/main
parent9fb395380431345b7da7a765651185815a9ac91d (diff)
Callhome to VES PNF Registration
Callhome to VES PNF Registration Issue-ID: CCSDK-3160 Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com> Change-Id: Ic5503ff7bb5bb77af3d5b4ad3ba6b09ccd10d87e Signed-off-by: Ravi Pendurty <ravi.pendurty@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager-oran/provider/src/main')
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java66
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java87
2 files changed, 151 insertions, 2 deletions
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
index 47ea3eadd..df81f60bf 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
@@ -41,6 +41,9 @@ import org.opendaylight.yang.gen.v1.urn.onap.system.rev201026.System1;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Guicutthrough;
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.NetworkElementDeviceType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.NetconfCallhomeServer;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.AllowedDevices;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconf.callhome.server.rev161109.netconf.callhome.server.allowed.devices.Device;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.opendaylight.yangtools.concepts.ListenerRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@@ -64,7 +67,9 @@ public class ORanNetworkElement implements NetworkElement {
private ListenerRegistration<NotificationListener> oRanFaultListenerRegistrationResult;
private @NonNull final ORanFaultNotificationListener oRanFaultListener;
private final NotificationProxyParser notificationProxyParser;
+ private @NonNull ORanRegistrationToVESpnfRegistrationMapper mapper;
private Collection<Component> componentList;
+ private static int sequenceNo = 0;
ORanNetworkElement(NetconfBindingAccessor netconfAccess, DataProvider databaseService,
VESCollectorService vesCollectorService) {
@@ -89,7 +94,7 @@ public class ORanNetworkElement implements NetworkElement {
componentList = YangHelper.getCollection(hardware.nonnullComponent());
List<Inventory> inventoryList =
ORanToInternalDataModel.getInventoryList(netconfAccessor.getNodeId(), componentList);
- inventoryList.forEach(databaseService::writeInventory);
+ inventoryList.forEach(databaseService::writeInventory);
}
Optional<Guicutthrough> oGuicutthrough = ORanToInternalDataModel.getGuicutthrough(getOnapSystemData());
@@ -106,6 +111,8 @@ public class ORanNetworkElement implements NetworkElement {
@Override
public void register() {
initialReadFromNetworkElement();
+ // Publish the mountpoint to VES if enabled
+ publishMountpointToVES();
// Register call back class for receiving notifications
Optional<NetconfNotifications> oNotifications = netconfAccessor.getNotificationAccessor();
if (oNotifications.isPresent()) {
@@ -176,5 +183,60 @@ public class ORanNetworkElement implements NetworkElement {
log.debug("Result of Hardware = {}", res);
return res;
}
-
+
+ private void publishMountpointToVES() {
+ log.debug("In publishMountpointToVES()");
+
+ /**
+ * 1. Check if this device is in the list of allowed-devices.
+ * 2. If device exists in allowed-devices, then create VES pnfRegistration event and publish to VES
+ */
+ if (inAllowedDevices(netconfAccessor.getNodeId().getValue())) {
+ if (vesCollectorService.getConfig().isVESCollectorEnabled()) {
+
+ for (Component component : ORanToInternalDataModel.getRootComponents(componentList)) {
+ //Just get one component. At the moment we don't care which one. Also since there is only one management address, we assume there will be only one chassis.
+ //If the device supports subtended configuration then it is assumed that the Chassis containing the management interface will be the root component and there will be only one root.
+ this.mapper = new ORanRegistrationToVESpnfRegistrationMapper(netconfAccessor,
+ vesCollectorService, component);
+ VESCommonEventHeaderPOJO header =
+ mapper.mapCommonEventHeader(sequenceNo++);
+ VESPNFRegistrationFieldsPOJO body = mapper.mapPNFRegistrationFields();
+ try {
+ vesCollectorService.publishVESMessage(vesCollectorService.generateVESEvent(header, body));
+ } catch (JsonProcessingException e) {
+ log.warn("Error while serializing VES Event to String ", e);
+ e.printStackTrace();
+ }
+
+ }
+ }
+
+ }
+
+ }
+
+ private boolean inAllowedDevices(String mountpointName) {
+ final InstanceIdentifier<AllowedDevices> ALL_DEVICES =
+ InstanceIdentifier.create(NetconfCallhomeServer.class).child(AllowedDevices.class);
+
+ AllowedDevices allowedDevices;
+ allowedDevices = netconfAccessor.getTransactionUtils().readData(
+ netconfAccessor.getControllerBindingDataBroker(), LogicalDatastoreType.CONFIGURATION, ALL_DEVICES);
+
+ if (allowedDevices != null) {
+ Collection<Device> deviceList = YangHelper.getCollection(allowedDevices.nonnullDevice());
+ for (Device device : deviceList) {
+ log.info("Device in allowed-devices is - {}", device.getUniqueId());
+ if (device.getUniqueId().equals(netconfAccessor.getNodeId().getValue())) {
+ log.info("Mountpoint is part of allowed-devices list");
+ return true;
+ }
+ }
+ }
+
+ log.info("Mountpoint {} is not part of allowed-devices list", mountpointName);
+ return false;
+ }
+
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java
new file mode 100644
index 000000000..81605e450
--- /dev/null
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanRegistrationToVESpnfRegistrationMapper.java
@@ -0,0 +1,87 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2021 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.oran.impl;
+
+import java.time.Instant;
+import org.eclipse.jdt.annotation.NonNull;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.hardware.rev180313.hardware.Component;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class ORanRegistrationToVESpnfRegistrationMapper {
+
+ private static final Logger LOG = LoggerFactory.getLogger(ORanFaultToVESFaultMapper.class);
+ //CommonEventHeader fields
+ private static final String VES_EVENT_DOMAIN = "pnfRegistration";
+ private static final String VES_EVENTTYPE = "NetConf Callhome Registration";
+ private static final String VES_EVENT_PRIORITY = "Normal";
+
+ private final VESCollectorService vesProvider;
+ private final @NonNull Component component;
+ private final NetconfAccessor netconfAccessor;
+
+ public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor,
+ VESCollectorService vesCollectorService, Component component) {
+ this.netconfAccessor = netconfAccessor;
+ this.vesProvider = vesCollectorService;
+ this.component = component;
+ }
+
+ public VESCommonEventHeaderPOJO mapCommonEventHeader(int sequenceNo) {
+ VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO();
+ vesCEH.setDomain(VES_EVENT_DOMAIN);
+ vesCEH.setEventId(netconfAccessor.getNodeId().getValue());
+ vesCEH.setEventName(netconfAccessor.getNodeId().getValue());
+ vesCEH.setEventType(VES_EVENTTYPE);
+ vesCEH.setPriority(VES_EVENT_PRIORITY);
+
+ vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000);
+ vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000);
+ vesCEH.setNfVendorName(component.getMfgName());
+ vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName());
+ vesCEH.setSequence(sequenceNo);
+ vesCEH.setSourceId(component.getUuid().toString());
+ vesCEH.setSourceName(netconfAccessor.getNodeId().getValue());
+
+ return vesCEH;
+ }
+
+ public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields() {
+ VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO();
+ vesPnfFields.setModelNumber(component.getModelName());
+ vesPnfFields.setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().toString());
+ //vesPnfFields.setOamV6IpAddress(oamV6IpAddress); // Check if IP address in V6 format and then include it. Same with v4 address also
+ vesPnfFields.setSerialNumber(component.getSerialNum());
+ vesPnfFields.setVendorName(component.getMfgName());
+ vesPnfFields.setSoftwareVersion(component.getSoftwareRev());
+ vesPnfFields.setUnitType(component.getAlias());
+ vesPnfFields.setUnitFamily(component.getXmlClass().toString());
+ vesPnfFields.setManufactureDate(component.getMfgDate().toString());
+ //vesPnfFields.setLastServiceDate(component.getLastChange());
+
+ return vesPnfFields;
+ }
+}