Add random number generation for counter value in https-server
Min and Max number passed through configuration and random number generated from it to replace it as counter value
RANDOM_CTR_VALUE is the string which gets replaced with the random number.
Issue-ID: NONRTRIC-1036
Change-Id: I5bc5c2fe6deb9b0ea0dac5bbaf5b0809d837b318
Signed-off-by: aravind.est <aravindhan.a@est.tech>
diff --git a/docker-proj/docker-compose-pm-https.yaml b/docker-proj/docker-compose-pm-https.yaml
index e50da91..505d714 100644
--- a/docker-proj/docker-compose-pm-https.yaml
+++ b/docker-proj/docker-compose-pm-https.yaml
@@ -1,5 +1,6 @@
# ============LICENSE_START===============================================
# Copyright (C) 2023 Nordix Foundation. All rights reserved.
+# Copyright (C) 2023-2024 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.
@@ -30,6 +31,8 @@
ALWAYS_RETURN: /ne-files/pm.xml.gz
GENERATED_FILE_START_TIME: "${START_TIME}"
GENERATED_FILE_TIMEZONE: "+0100"
+ RANDOM_MIN_NUMBER: "2"
+ RANDOM_MAX_NUMBER: "20"
volumes:
- ./ne-files:/ne-files:rw
- ./config/https/template-files:/template-files
diff --git a/https-server/README.md b/https-server/README.md
index e5e6e93..de8982a 100644
--- a/https-server/README.md
+++ b/https-server/README.md
@@ -28,6 +28,10 @@
- GENERATED_FILE_TIMEZONE - Time zone to be used for requested files from the url `/generatedfiles/<file-id>`. Example: "+0100"
+- RANDOM_MIN_NUMBER - Minimum possible random number to generate random number
+
+- RANDOM_MAX_NUMBER - Maximum possible random number to generate random number
+
If generated files shall be used, load the file pm-template.xml.gz to the /template-files dir in the container.
Configure the following for desired behaviour
@@ -59,6 +63,7 @@
## License
Copyright (C) 2023 Nordix Foundation. All rights reserved.
+Copyright (C) 2023-2024 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.
You may obtain a copy of the License at
diff --git a/https-server/main.go b/https-server/main.go
index 406caf8..dbdc7b1 100644
--- a/https-server/main.go
+++ b/https-server/main.go
@@ -1,5 +1,6 @@
// ============LICENSE_START===============================================
// Copyright (C) 2023 Nordix Foundation. All rights reserved.
+// Copyright (C) 2023-2024 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.
@@ -22,6 +23,7 @@
"bytes"
"compress/gzip"
"io"
+ "math/rand"
"net/http"
"os"
"runtime"
@@ -48,6 +50,8 @@
var always_return_file = os.Getenv("ALWAYS_RETURN")
var generated_files_start_time = os.Getenv("GENERATED_FILE_START_TIME")
var generated_files_timezone = os.Getenv("GENERATED_FILE_TIMEZONE")
+var random_min_value, min_value_error = strconv.Atoi(os.Getenv("RANDOM_MIN_NUMBER"))
+var random_max_value, max_value_error = strconv.Atoi(os.Getenv("RANDOM_MAX_NUMBER"))
var unzipped_template = ""
@@ -211,16 +215,21 @@
nodename := id[30:]
nodename = strings.Split(nodename, ".")[0]
+ //Generating random number
+ random_value := rand.Intn(random_max_value-random_min_value+1) + random_min_value
+
template_string := strings.Clone(unzipped_template)
log.Debug("Replacing BEGINTIME with: ", begintime)
log.Debug("Replacing ENDTIME with: ", endtime)
+ log.Debug("Replacing RANDOM_CTR_VALUE with: ", strconv.Itoa(int(random_value)))
log.Debug("Replacing CTR_VALUE with: ", strconv.Itoa(int(file_index)))
log.Debug("Replacing NODE_NAME with: ", nodename)
template_string = strings.Replace(template_string, "BEGINTIME", begintime, -1)
template_string = strings.Replace(template_string, "ENDTIME", endtime, -1)
+ template_string = strings.Replace(template_string, "RANDOM_CTR_VALUE", strconv.Itoa(int(random_value)), -1)
template_string = strings.Replace(template_string, "CTR_VALUE", strconv.Itoa(int(file_index)), -1)
template_string = strings.Replace(template_string, "NODE_NAME", nodename, -1)
@@ -257,6 +266,13 @@
log.Info("Server starting...")
+ if min_value_error != nil {
+ random_min_value = 1
+ }
+ if max_value_error != nil {
+ random_max_value = 10
+ }
+
rtr := mux.NewRouter()
rtr.HandleFunc("/files/{fileid}", files)
rtr.HandleFunc("/generatedfiles/{fileid}", generatedfiles)
diff --git a/install/helm/ran/pm-files/pm-template.xml.gz b/install/helm/ran/pm-files/pm-template.xml.gz
index 517be24..0e3be9c 100644
--- a/install/helm/ran/pm-files/pm-template.xml.gz
+++ b/install/helm/ran/pm-files/pm-template.xml.gz
Binary files differ
diff --git a/install/helm/ran/pm-files/pm-template.xml2 b/install/helm/ran/pm-files/pm-template.xml2
index 3d95954..c8d77af 100644
--- a/install/helm/ran/pm-files/pm-template.xml2
+++ b/install/helm/ran/pm-files/pm-template.xml2
@@ -656,6 +656,7 @@
<measType p="162">pmCounterNumber252Qos</measType>
<measType p="163">pmCounterNumber254</measType>
<measType p="164">pmCounterNumber254Qos</measType>
+ <measType p="165">pmRadioThpVolUl</measType>
<measValue measObjLdn="ManagedElement=NODE_NAME,GNBDUFunction=1,NRCellDU=32">
<r p="1">CTR_VALUE</r>
<r p="2">CTR_VALUE</r>
@@ -821,6 +822,7 @@
<r p="162">CTR_VALUE</r>
<r p="163">CTR_VALUE</r>
<r p="164">CTR_VALUE</r>
+ <r p="165">RANDOM_CTR_VALUE</r>
</measValue>
<measValue measObjLdn="ManagedElement=NODE_NAME,GNBDUFunction=1,NRCellDU=31">
<r p="1">CTR_VALUE</r>
@@ -987,6 +989,7 @@
<r p="162">CTR_VALUE</r>
<r p="163">CTR_VALUE</r>
<r p="164">CTR_VALUE</r>
+ <r p="165">RANDOM_CTR_VALUE</r>
</measValue>
<measValue measObjLdn="ManagedElement=NODE_NAME,GNBDUFunction=1,NRCellDU=2">
<r p="1">CTR_VALUE</r>
@@ -1153,6 +1156,7 @@
<r p="162">CTR_VALUE</r>
<r p="163">CTR_VALUE</r>
<r p="164">CTR_VALUE</r>
+ <r p="165">RANDOM_CTR_VALUE</r>
</measValue>
<measValue measObjLdn="ManagedElement=NODE_NAME,GNBDUFunction=1,NRCellDU=1">
<r p="1">CTR_VALUE</r>
@@ -1319,6 +1323,7 @@
<r p="162">CTR_VALUE</r>
<r p="163">CTR_VALUE</r>
<r p="164">CTR_VALUE</r>
+ <r p="165">RANDOM_CTR_VALUE</r>
</measValue>
</measInfo>
<measInfo measInfoId="PM=1,PmGroup=NRSectorCarrier_GNBDU">
diff --git a/install/helm/ran/pm-files/pm.xml.gz b/install/helm/ran/pm-files/pm.xml.gz
index df90359..ee22685 100644
--- a/install/helm/ran/pm-files/pm.xml.gz
+++ b/install/helm/ran/pm-files/pm.xml.gz
Binary files differ
diff --git a/install/helm/ran/templates/app-deployment.yaml b/install/helm/ran/templates/app-deployment.yaml
index 88e219a..5242a55 100644
--- a/install/helm/ran/templates/app-deployment.yaml
+++ b/install/helm/ran/templates/app-deployment.yaml
@@ -86,6 +86,12 @@
# Shall include +/- sign for the timezone value
- name: GENERATED_FILE_TIMEZONE
value: "+0100"
+ # Minimum random number to get generated
+ - name: RANDOM_MIN_NUMBER
+ value: "2"
+ # Maximum random number to get generated
+ - name: RANDOM_MAX_NUMBER
+ value: "20"
volumeMounts:
- name: cert-vol
mountPath: /certs