From: aravind.est Date: Mon, 10 Mar 2025 16:39:13 +0000 (+0000) Subject: NONRTRIC-1048 Add support for TS28532 format X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F35%2F14235%2F3;p=nonrtric%2Fplt%2Franpm.git NONRTRIC-1048 Add support for TS28532 format Pm-file-converter modified to support existing format and TS28532 format. This can be controlled over an environment variable 'DATA_TYPE_FORMAT' Issue-ID: NONRTRIC-1048 Change-Id: Ib4b30df3c6535448049bec8e6fb04d9fc872b7ec Signed-off-by: aravind.est --- diff --git a/pm-file-converter/Dockerfile b/pm-file-converter/Dockerfile index 6248698..edbe27b 100644 --- a/pm-file-converter/Dockerfile +++ b/pm-file-converter/Dockerfile @@ -1,5 +1,6 @@ # ============LICENSE_START=============================================== # Copyright (C) 2023 Nordix Foundation. All rights reserved. +# Copyright (C) 2023-2025 OpenInfra Foundation Europe. 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. @@ -23,6 +24,8 @@ COPY main.go . ADD common common ADD components components RUN go mod init main +COPY go.mod . +COPY go.sum . RUN go mod tidy RUN go build -o /pm-file-converter diff --git a/pm-file-converter/common/dataTypes/dataTypes.go b/pm-file-converter/common/dataTypes/dataTypes.go index 66b462c..26f6571 100644 --- a/pm-file-converter/common/dataTypes/dataTypes.go +++ b/pm-file-converter/common/dataTypes/dataTypes.go @@ -4,6 +4,7 @@ // O-RAN-SC // %% // Copyright (C) 2023: Nordix Foundation +// Copyright (C) 2023-2025 OpenInfra Foundation Europe. 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. @@ -21,7 +22,8 @@ package dataTypes import ( - "encoding/xml" + "encoding/xml" + "github.com/confluentinc/confluent-kafka-go/kafka" ) @@ -112,6 +114,66 @@ type MeasCollecFile struct { } `xml:"fileFooter"` } +// Data type for the new input XML file +type MeasDataFile struct { + XMLName xml.Name `xml:"measDataFile"` + Text string `xml:",chardata"` + Xmlns string `xml:"xmlns,attr"` + Xsi string `xml:"xsi,attr"` + SchemaLocation string `xml:"schemaLocation,attr"` + FileHeader struct { + Text string `xml:",chardata"` + FileFormatVersion string `xml:"fileFormatVersion,attr"` + VendorName string `xml:"vendorName,attr"` + FileSender struct { + Text string `xml:",chardata"` + SenderName string `xml:"senderName,attr"` + ElementType string `xml:"elementType,attr"` + } `xml:"fileSender"` + MeasDataCollection struct { + Text string `xml:",chardata"` + BeginTime string `xml:"beginTime,attr"` + } `xml:"measDataCollection"` + } `xml:"fileHeader"` + MeasData struct { + Text string `xml:",chardata"` + MeasEntity struct { + Text string `xml:",chardata"` + LocalDn string `xml:"localDn,attr"` + SwVersion string `xml:"swVersion,attr"` + } `xml:"measEntity"` + MeasInfo []struct { + Text string `xml:",chardata"` + MeasInfoId string `xml:"measInfoId,attr"` + GranPeriod struct { + Text string `xml:",chardata"` + Duration string `xml:"duration,attr"` + EndTime string `xml:"endTime,attr"` + } `xml:"granPeriod"` + MeasType []struct { + Text string `xml:",chardata"` + P string `xml:"p,attr"` + } `xml:"measType"` + MeasValue []struct { + Text string `xml:",chardata"` + MeasObjLdn string `xml:"measObjLdn,attr"` + R []struct { + Text string `xml:",chardata"` + P string `xml:"p,attr"` + } `xml:"r"` + Suspect string `xml:"suspect"` + } `xml:"measValue"` + } `xml:"measInfo"` + } `xml:"measData"` + FileFooter struct { + Text string `xml:",chardata"` + MeasDataClosure struct { + Text string `xml:",chardata"` + EndTime string `xml:"endTime,attr"` + } `xml:"measDataClosure"` + } `xml:"fileFooter"` +} + // Splitted in sevreal part to allow add/remove in lists type MeasResults struct { P int `json:"p"` diff --git a/pm-file-converter/components/xmltransform/D20241211.0934+0000-0936+0000_-0_DC=Keysight.com,SubNetwork=Morrisville,ManagedElement=GNB-1_-_1.xml b/pm-file-converter/components/xmltransform/D20241211.0934+0000-0936+0000_-0_DC=Keysight.com,SubNetwork=Morrisville,ManagedElement=GNB-1_-_1.xml new file mode 100644 index 0000000..a4007ce --- /dev/null +++ b/pm-file-converter/components/xmltransform/D20241211.0934+0000-0936+0000_-0_DC=Keysight.com,SubNetwork=Morrisville,ManagedElement=GNB-1_-_1.xml @@ -0,0 +1,1478 @@ + + + + + + + + + + + + + + DRB.AirIfDelayDl + DRB.AirIfDelayDl.01 + DRB.AirIfDelayDl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.AirIfDelayUl + DRB.AirIfDelayUl.01 + DRB.AirIfDelayUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.EstabAtt + + 0.000000 + false + + + + + + + DRB.EstabSucc + + 0.000000 + false + + + + + + + DRB.MaxActiveUeDl + DRB.MaxActiveUeDl.01 + DRB.MaxActiveUeDl.010003e8 + DRB.MaxActiveUeDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MaxActiveUeUl + DRB.MaxActiveUeUl.01 + DRB.MaxActiveUeUl.010003e8 + DRB.MaxActiveUeUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MeanActiveUeDl + DRB.MeanActiveUeDl.01 + DRB.MeanActiveUeDl.010003e8 + DRB.MeanActiveUeDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MeanActiveUeUl + DRB.MeanActiveUeUl.01 + DRB.MeanActiveUeUl.010003e8 + DRB.MeanActiveUeUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.PdcpSduVolumeDL + DRB.PdcpSduVolumeDL.01 + DRB.PdcpSduVolumeDL.010003e8 + DRB.PdcpSduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.PdcpSduVolumeUL + DRB.PdcpSduVolumeUL.01 + DRB.PdcpSduVolumeUL.010003e8 + DRB.PdcpSduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.RelActNbr + + 0.000000 + false + + + + + + + DRB.RlcDelayUl + DRB.RlcDelayUl.01 + DRB.RlcDelayUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.RlcSduDelayDl.01 + DRB.RlcSduDelayDl.010003e8 + + 1198.000000 + 1198.000000 + false + + + + + + + DRB.SessionTime + DRB.SessionTime.01 + DRB.SessionTime.010003e8 + + 11084.000000 + 11084.000000 + 11084.000000 + false + + + + + + + DRB.UEThpDl + DRB.UEThpDl.01 + DRB.UEThpDl.010003e8 + DRB.UEThpDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.UEThpUl + DRB.UEThpUl.01 + DRB.UEThpUl.010003e8 + DRB.UEThpUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + MM.HoExeInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeIntraReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeIntraSucc + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoPrepInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoPrepInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoResAlloInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoResAlloInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + PEE.AvgPower + + 25.000000 + false + + + + + + + PEE.Energy + + 21780 + false + + + + + + + PEE.MaxPower + + 25.000000 + false + + + + + + + PEE.MinPower + + 25.000000 + false + + + + + + + QosFlow.PdcpPduVolumeDL + QosFlow.PdcpPduVolumeDL.01 + QosFlow.PdcpPduVolumeDL.010003e8 + QosFlow.PdcpPduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpPduVolumeUL + QosFlow.PdcpPduVolumeUL.01 + QosFlow.PdcpPduVolumeUL.010003e8 + QosFlow.PdcpPduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpSduVolumeDL + QosFlow.PdcpSduVolumeDL.01 + QosFlow.PdcpSduVolumeDL.010003e8 + QosFlow.PdcpSduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpSduVolumeUL + QosFlow.PdcpSduVolumeUL.01 + QosFlow.PdcpSduVolumeUL.010003e8 + QosFlow.PdcpSduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRC.ConnMax + RRC.ConnMax.226F04 + + 0.000000 + 0.000000 + false + + + + + + + RRC.ConnMean + RRC.ConnMean.226F04 + + 0.000000 + 0.000000 + false + + + + + + + RRC.ReEstabAtt + + 0.000000 + false + + + + + + + RRC.ReEstabSuccWithUeContext + + 0.000000 + false + + + + + + + RRC.ReEstabSuccWithoutUeContext + + 0.000000 + false + + + + + + + RRU.MaxPrbUsedDl + RRU.MaxPrbUsedDl.01 + RRU.MaxPrbUsedDl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.MaxPrbUsedUl + RRU.MaxPrbUsedUl.01 + RRU.MaxPrbUsedUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.PrbAvailDl + + 14.000000 + false + + + + + + + RRU.PrbAvailUl + + 14.000000 + false + + + + + + + RRU.PrbTotDl + + 0.000000 + false + + + + + + + RRU.PrbTotUl + + 0.000000 + false + + + + + + + RRU.PrbUsedDl + RRU.PrbUsedDl.01 + RRU.PrbUsedDl.010003e8 + RRU.PrbUsedDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.PrbUsedUl + RRU.PrbUsedUl.01 + RRU.PrbUsedUl.010003e8 + RRU.PrbUsedUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + SM.PDUSessionSetupReq + SM.PDUSessionSetupReq.010003e8 + + 0.000000 + 0.000000 + false + + + + + + + SM.PDUSessionSetupSucc + SM.PDUSessionSetupSucc.010003e8 + + 0.000000 + 0.000000 + false + + + + + + + DRB.AirIfDelayDl + DRB.AirIfDelayDl.01 + DRB.AirIfDelayDl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.AirIfDelayUl + DRB.AirIfDelayUl.01 + DRB.AirIfDelayUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.EstabAtt + + 0.000000 + false + + + + + + + DRB.EstabSucc + + 0.000000 + false + + + + + + + DRB.MaxActiveUeDl + DRB.MaxActiveUeDl.01 + DRB.MaxActiveUeDl.010003e8 + DRB.MaxActiveUeDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MaxActiveUeUl + DRB.MaxActiveUeUl.01 + DRB.MaxActiveUeUl.010003e8 + DRB.MaxActiveUeUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MeanActiveUeDl + DRB.MeanActiveUeDl.01 + DRB.MeanActiveUeDl.010003e8 + DRB.MeanActiveUeDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.MeanActiveUeUl + DRB.MeanActiveUeUl.01 + DRB.MeanActiveUeUl.010003e8 + DRB.MeanActiveUeUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.PdcpSduVolumeDL + DRB.PdcpSduVolumeDL.01 + DRB.PdcpSduVolumeDL.010003e8 + DRB.PdcpSduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.PdcpSduVolumeUL + DRB.PdcpSduVolumeUL.01 + DRB.PdcpSduVolumeUL.010003e8 + DRB.PdcpSduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.RelActNbr + + 0.000000 + false + + + + + + + DRB.RlcDelayUl + DRB.RlcDelayUl.01 + DRB.RlcDelayUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.RlcSduDelayDl.01 + DRB.RlcSduDelayDl.010003e8 + + 1198.000000 + 1198.000000 + false + + + + + + + DRB.SessionTime + DRB.SessionTime.01 + DRB.SessionTime.010003e8 + + 12650.000000 + 12650.000000 + 12650.000000 + false + + + + + + + DRB.UEThpDl + DRB.UEThpDl.01 + DRB.UEThpDl.010003e8 + DRB.UEThpDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + DRB.UEThpUl + DRB.UEThpUl.01 + DRB.UEThpUl.010003e8 + DRB.UEThpUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + MM.HoExeInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeIntraReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoExeIntraSucc + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoPrepInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoPrepInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoResAlloInterReq + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + MM.HoResAlloInterSucc + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + 0.000000 + false + + + + + + + PEE.AvgPower + + 25.000000 + false + + + + + + + PEE.Energy + + 20856 + false + + + + + + + PEE.MaxPower + + 25.000000 + false + + + + + + + PEE.MinPower + + 25.000000 + false + + + + + + + QosFlow.PdcpPduVolumeDL + QosFlow.PdcpPduVolumeDL.01 + QosFlow.PdcpPduVolumeDL.010003e8 + QosFlow.PdcpPduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpPduVolumeUL + QosFlow.PdcpPduVolumeUL.01 + QosFlow.PdcpPduVolumeUL.010003e8 + QosFlow.PdcpPduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpSduVolumeDL + QosFlow.PdcpSduVolumeDL.01 + QosFlow.PdcpSduVolumeDL.010003e8 + QosFlow.PdcpSduVolumeDL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + QosFlow.PdcpSduVolumeUL + QosFlow.PdcpSduVolumeUL.01 + QosFlow.PdcpSduVolumeUL.010003e8 + QosFlow.PdcpSduVolumeUL.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRC.ConnMax + RRC.ConnMax.226F04 + + 0.000000 + 0.000000 + false + + + + + + + RRC.ConnMean + RRC.ConnMean.226F04 + + 0.000000 + 0.000000 + false + + + + + + + RRC.ReEstabAtt + + 0.000000 + false + + + + + + + RRC.ReEstabSuccWithUeContext + + 0.000000 + false + + + + + + + RRC.ReEstabSuccWithoutUeContext + + 0.000000 + false + + + + + + + RRU.MaxPrbUsedDl + RRU.MaxPrbUsedDl.01 + RRU.MaxPrbUsedDl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.MaxPrbUsedUl + RRU.MaxPrbUsedUl.01 + RRU.MaxPrbUsedUl.010003e8 + + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.PrbAvailDl + + 14.000000 + false + + + + + + + RRU.PrbAvailUl + + 14.000000 + false + + + + + + + RRU.PrbTotDl + + 0.000000 + false + + + + + + + RRU.PrbTotUl + + 0.000000 + false + + + + + + + RRU.PrbUsedDl + RRU.PrbUsedDl.01 + RRU.PrbUsedDl.010003e8 + RRU.PrbUsedDl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + RRU.PrbUsedUl + RRU.PrbUsedUl.01 + RRU.PrbUsedUl.010003e8 + RRU.PrbUsedUl.226F04 + + 0.000000 + 0.000000 + 0.000000 + 0.000000 + false + + + + + + + SM.PDUSessionSetupReq + SM.PDUSessionSetupReq.010003e8 + + 0.000000 + 0.000000 + false + + + + + + + SM.PDUSessionSetupSucc + SM.PDUSessionSetupSucc.010003e8 + + 0.000000 + 0.000000 + false + + + + + + + diff --git a/pm-file-converter/components/xmltransform/xmltransform.go b/pm-file-converter/components/xmltransform/xmltransform.go index 6e70022..046882a 100644 --- a/pm-file-converter/components/xmltransform/xmltransform.go +++ b/pm-file-converter/components/xmltransform/xmltransform.go @@ -4,6 +4,7 @@ // O-RAN-SC // %% // Copyright (C) 2023: Nordix Foundation +// Copyright (C) 2023-2025 OpenInfra Foundation Europe. 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. @@ -26,18 +27,28 @@ import ( "encoding/xml" "errors" "fmt" - jsoniter "github.com/json-iterator/go" - log "github.com/sirupsen/logrus" "io" "main/common/dataTypes" "net/http" + "os" "strconv" "time" + + jsoniter "github.com/json-iterator/go" + log "github.com/sirupsen/logrus" ) //lint:ignore S117 func xmlToJsonConv(fBytevalue *[]byte, xfeh *dataTypes.XmlFileEventHeader) ([]byte, error) { - var f dataTypes.MeasCollecFile + var datatypeformat = os.Getenv("DATA_TYPE_FORMAT") + + var f interface{} + if datatypeformat == "" { + f = &dataTypes.MeasCollecFile{} + } else { + f = &dataTypes.MeasDataFile{} + } + start := time.Now() err := xml.Unmarshal(*fBytevalue, &f) if err != nil { @@ -51,32 +62,64 @@ func xmlToJsonConv(fBytevalue *[]byte, xfeh *dataTypes.XmlFileEventHeader) ([]by pmfile.Event.Perf3GppFields.Perf3GppFieldsVersion = "1.0" pmfile.Event.Perf3GppFields.MeasDataCollection.GranularityPeriod = 900 pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntityUserName = "" - pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntityDn = f.FileHeader.FileSender.LocalDn - pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntitySoftwareVersion = f.MeasData.ManagedElement.SwVersion - - for _, it := range f.MeasData.MeasInfo { - var mili dataTypes.MeasInfoList - mili.MeasInfoID.SMeasInfoID = it.MeasInfoId - for _, jt := range it.MeasType { - mili.MeasTypes.SMeasTypesList = append(mili.MeasTypes.SMeasTypesList, jt.Text) - } - for _, jt := range it.MeasValue { - var mv dataTypes.MeasValues - mv.MeasObjInstID = jt.MeasObjLdn - mv.SuspectFlag = jt.Suspect - if jt.Suspect == "" { - mv.SuspectFlag = "false" + + switch v := f.(type) { + case *dataTypes.MeasCollecFile: + pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntityDn = v.FileHeader.FileSender.LocalDn + pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntitySoftwareVersion = v.MeasData.ManagedElement.SwVersion + for _, it := range v.MeasData.MeasInfo { + var mili dataTypes.MeasInfoList + mili.MeasInfoID.SMeasInfoID = it.MeasInfoId + for _, jt := range it.MeasType { + mili.MeasTypes.SMeasTypesList = append(mili.MeasTypes.SMeasTypesList, jt.Text) } - for _, kt := range jt.R { - ni, _ := strconv.Atoi(kt.P) - nv := kt.Text - mr := dataTypes.MeasResults{ni, nv} - mv.MeasResultsList = append(mv.MeasResultsList, mr) + for _, jt := range it.MeasValue { + var mv dataTypes.MeasValues + mv.MeasObjInstID = jt.MeasObjLdn + mv.SuspectFlag = jt.Suspect + if jt.Suspect == "" { + mv.SuspectFlag = "false" + } + for _, kt := range jt.R { + ni, _ := strconv.Atoi(kt.P) + nv := kt.Text + mr := dataTypes.MeasResults{ni, nv} + mv.MeasResultsList = append(mv.MeasResultsList, mr) + } + mili.MeasValuesList = append(mili.MeasValuesList, mv) } - mili.MeasValuesList = append(mili.MeasValuesList, mv) + + pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList = append(pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList, mili) } + case *dataTypes.MeasDataFile: + pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntityDn = v.FileHeader.FileSender.SenderName + pmfile.Event.Perf3GppFields.MeasDataCollection.MeasuredEntitySoftwareVersion = "N/A" + for _, it := range v.MeasData.MeasInfo { + var mili dataTypes.MeasInfoList + mili.MeasInfoID.SMeasInfoID = it.MeasInfoId + for _, jt := range it.MeasType { + mili.MeasTypes.SMeasTypesList = append(mili.MeasTypes.SMeasTypesList, jt.Text) + } + for _, jt := range it.MeasValue { + var mv dataTypes.MeasValues + mv.MeasObjInstID = jt.MeasObjLdn + mv.SuspectFlag = jt.Suspect + if jt.Suspect == "" { + mv.SuspectFlag = "false" + } + for _, kt := range jt.R { + ni, _ := strconv.Atoi(kt.P) + nv := kt.Text + mr := dataTypes.MeasResults{ni, nv} + mv.MeasResultsList = append(mv.MeasResultsList, mr) + } + mili.MeasValuesList = append(mili.MeasValuesList, mv) + } - pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList = append(pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList, mili) + pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList = append(pmfile.Event.Perf3GppFields.MeasDataCollection.SMeasInfoList, mili) + } + default: + return nil, errors.New("Unexpected file type") } pmfile.Event.Perf3GppFields.MeasDataCollection.GranularityPeriod = 900 diff --git a/pm-file-converter/components/xmltransform/xmltransform_test.go b/pm-file-converter/components/xmltransform/xmltransform_test.go index 5f6e89d..e8465cd 100644 --- a/pm-file-converter/components/xmltransform/xmltransform_test.go +++ b/pm-file-converter/components/xmltransform/xmltransform_test.go @@ -3,7 +3,8 @@ // ========================LICENSE_START================================= // O-RAN-SC // %% -// Copyright (C) 2022: Nordix Foundation +// Copyright (C) 2022-2023: Nordix Foundation +// Copyright (C) 2023-2025 OpenInfra Foundation Europe. 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. @@ -90,3 +91,68 @@ func TestXMLToJSONConv_Success(t *testing.T) { } defer fi.Close() } + +func TestXMLToJSONConv_Newformat_Success(t *testing.T) { + // Prepare the input data + var evt_data dataTypes.XmlFileEventHeader = dataTypes.XmlFileEventHeader{ + ProductName: "O-RAN SC", + VendorName: "Ericsson AB", + Location: "Ireland", + Compression: "gzip", + SourceName: "GNODEB-0", + FileFormatType: "xml", + FileFormatVersion: "1.0", + Name: "Sample Event", + ChangeIdentifier: "Sample Change ID", + InternalLocation: "Sample Internal Location", + TimeZoneOffset: "+05:00", + ObjectStoreBucket: "Sample Bucket", + } + + os.Setenv("DATA_TYPE_FORMAT", "TS28532") + + filename := "D20241211.0934+0000-0936+0000_-0_DC=Keysight.com,SubNetwork=Morrisville,ManagedElement=GNB-1_-_1.xml" + fi, err := os.Open(filename) + + if err != nil { + t.Fatalf("File %s - cannot be opened - discarding message, error details: %s", filename, err.Error()) + } + defer fi.Close() + + reader := fi + + var buf3 bytes.Buffer + _, err2 := io.Copy(&buf3, reader) + if err2 != nil { + t.Fatalf("File %s - cannot be read, discarding message, %s", filename, err.Error()) + return + } + file_bytes := buf3.Bytes() + b, err := xmlToJsonConv(&file_bytes, &evt_data) + + json_filename := "D20241211.0934+0000-0936+0000_-0_DC=Keysight.com,SubNetwork=Morrisville,ManagedElement=GNB-1_-_1.json" + + err3 := os.WriteFile(json_filename, b, 0644) + + if err3 != nil { + t.Fatalf("Error writing %s to JSON :, %s ", json_filename, err3.Error()) + } + + if err != nil { + t.Fatalf("Cannot convert file %s - discarding message, %s", filename, err.Error()) + } + + if len(b) <= 1000 { + t.Fatalf("Conversion of %s returned %d bytes", filename, len(b)) + } + + fi, err = os.Open(json_filename) + + if err != nil { + t.Fatalf("File %s - cannot be opened - discarding message, error details: %s", json_filename, err.Error()) + } else { + fmt.Println("XML file Converted to JSON") + } + os.Unsetenv("DATA_TYPE_FORMAT") + defer fi.Close() +}