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.dom;
24 import java.time.Instant;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.VESCollectorService;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESCommonEventHeaderPOJO;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.VESPNFRegistrationFieldsPOJO;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
30 import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
31 import org.slf4j.Logger;
32 import org.slf4j.LoggerFactory;
34 public class ORanRegistrationToVESpnfRegistrationMapper {
36 @SuppressWarnings("unused")
37 private static final Logger LOG = LoggerFactory.getLogger(ORanRegistrationToVESpnfRegistrationMapper.class);
38 //CommonEventHeader fields
39 private static final String VES_EVENT_DOMAIN = "pnfRegistration";
40 private static final String VES_EVENTTYPE = "NetConf Callhome Registration";
41 private static final String VES_EVENT_PRIORITY = "Normal";
43 private final VESCollectorService vesProvider;
44 private final NetconfAccessor netconfAccessor;
46 private Integer sequenceNo;
49 public ORanRegistrationToVESpnfRegistrationMapper(NetconfAccessor netconfAccessor,
50 VESCollectorService vesCollectorService) {
51 this.netconfAccessor = netconfAccessor;
52 this.vesProvider = vesCollectorService;
57 public VESCommonEventHeaderPOJO mapCommonEventHeader(MapEntryNode component) {
58 VESCommonEventHeaderPOJO vesCEH = new VESCommonEventHeaderPOJO();
59 vesCEH.setDomain(VES_EVENT_DOMAIN);
60 vesCEH.setEventId(netconfAccessor.getNodeId().getValue());
61 vesCEH.setEventName(netconfAccessor.getNodeId().getValue());
62 vesCEH.setEventType(VES_EVENTTYPE);
63 vesCEH.setPriority(VES_EVENT_PRIORITY);
65 vesCEH.setStartEpochMicrosec(Instant.now().toEpochMilli() * 1000);
66 vesCEH.setLastEpochMicrosec(Instant.now().toEpochMilli() * 1000);
67 vesCEH.setNfVendorName(
68 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
69 vesCEH.setReportingEntityName(vesProvider.getConfig().getReportingEntityName());
70 vesCEH.setSequence(sequenceNo++);
72 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID) != null
73 ? ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_UUID)
74 : netconfAccessor.getNodeId().getValue());
75 vesCEH.setSourceName(netconfAccessor.getNodeId().getValue());
80 public VESPNFRegistrationFieldsPOJO mapPNFRegistrationFields(MapEntryNode component) {
81 VESPNFRegistrationFieldsPOJO vesPnfFields = new VESPNFRegistrationFieldsPOJO();
82 vesPnfFields.setModelNumber(
83 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
85 .setOamV4IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address() != null
86 ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv4Address().getValue()
89 .setOamV6IpAddress(netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address() != null
90 ? netconfAccessor.getNetconfNode().getHost().getIpAddress().getIpv6Address().getValue()
92 vesPnfFields.setSerialNumber(
93 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SER_NUM));
94 vesPnfFields.setVendorName(
95 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_NAME));
96 vesPnfFields.setSoftwareVersion(
97 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_SW_REV));
98 vesPnfFields.setUnitType(
99 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_ALIAS));
100 vesPnfFields.setUnitFamily(
101 ORanDMDOMUtility.getLeafValue(component, ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_CLASS));
104 ORanDMDOMUtility.getLeafValue(component,
105 ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE) != null
106 ? ORanDMDOMUtility.getLeafValue(component,
107 ORanDeviceManagerQNames.IETF_HW_COMPONENT_LIST_MFG_DATE)
109 //vesPnfFields.setLastServiceDate(component.getLastChange());