2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
22 package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.binding;
24 import java.time.Instant;
25 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.ORanDMDOMUtility;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.dom.ORanDeviceManagerQNames;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO;
29 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO;
30 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
31 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
32 import org.slf4j.Logger;
33 import org.slf4j.LoggerFactory;
35 public class ORanRegistrationToVESpnfRegistrationMapper {
37 @SuppressWarnings("unused")
38 private static final Logger LOG = LoggerFactory.getLogger(ORanFaultToVESFaultMapper.class);
39 //CommonEventHeader fields
40 private static final String VES_EVENT_DOMAIN = "pnfRegistration";
41 private static final String VES_EVENTTYPE = "NetConf Callhome Registration";
42 private static final String VES_EVENT_PRIORITY = "Normal";
44 private final VESCollectorService vesProvider;
45 private final NetconfAccessor netconfAccessor;
47 private Integer sequenceNo;
50 public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor,
51 VESCollectorService vesCollectorService) {
52 this.netconfAccessor = netconfAccessor;
53 this.vesProvider = vesCollectorService;
58 public VESCommonEventHeaderPOJO mapCommonEventHeader(MapEntryNode component) {
59 VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO();
60 vesCEH.setDomain(VES_EVENT_DOMAIN);
61 vesCEH.setEventId(netconfAccessor.getNodeId().getValue());
62 vesCEH.setEventName(netconfAccessor.getNodeId().getValue());
63 vesCEH.setEventType(VES_EVENTTYPE);
64 vesCEH.setPriority(VES_EVENT_PRIORITY);
66 vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000);
67 vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000);
68 vesCEH.setNfVendorName(
69 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
70 vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName());
71 vesCEH.setSequence(sequenceNo++);
73 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null
74 ? ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID)
75 : netconfAccessor.getNodeId().getValue());
76 vesCEH.setSourceName(netconfAccessor.getNodeId().getValue());
81 public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields(MapEntryNode component) {
82 VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO();
83 vesPnfFields.setModelNumber(
84 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
86 .setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address() != null
87 ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address().getValue()
90 .setOamV6IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address() != null
91 ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address().getValue()
93 vesPnfFields.setSerialNumber(
94 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM));
95 vesPnfFields.setVendorName(
96 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
97 vesPnfFields.setSoftwareVersion(
98 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SW_REV));
99 vesPnfFields.setUnitType(
100 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_ALIAS));
101 vesPnfFields.setUnitFamily(
102 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS));
105 ORanDMDOMUtility.getLeafValue(component,
106 ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) != null
107 ? ORanDMDOMUtility.getLeafValue(component,
108 ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE)
110 //vesPnfFields.setLastServiceDate(component.getLastChange());