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