RIC:1060: Change in PTL
[ric-plt/nodeb-rnib.git] / common / utils.go
index 608130e..0067038 100644 (file)
@@ -1,6 +1,7 @@
 //
 // Copyright 2019 AT&T Intellectual Property
 // Copyright 2019 Nokia
+// Copyright 2023 Capgemini
 //
 // 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,9 @@ import (
        "fmt"
 )
 
+//SDL namespace used by the RNIB
+const rnibNamespace = "e2Manager"
+
 /*
 ValidateAndBuildCellIdKey builds key according to the specified format returns the resulting string
 */
@@ -56,7 +60,7 @@ func ValidateAndBuildNodeBNameKey(inventoryName string) (string, error) {
 /*
 ValidateAndBuildNodeBIdKey builds key according to the specified format returns the resulting string
 */
-func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (string, error) {
+func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string, cuupId string, duId string) (string, error) {
        if nodeType == "" {
                return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty node type received")
        }
@@ -66,8 +70,22 @@ func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (st
        if nbId == "" {
                return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty nbId received")
        }
+        /*Note: Deployment where CU-UP and DU are combined
+         (but do not include the CP-CP) and have a single E2 connection
+          is not supported. The combination of CU-CP, CU-UP, and DU will be
+          treated as a single gNB and expect it to have only the
+          global gNB ID in its E2 Setup ID*/
+
+       if cuupId != "" && duId != ""{
+               return fmt.Sprintf("%s:%s:%s", nodeType, plmnId, nbId), nil
+       }else if cuupId != "" {
+               return fmt.Sprintf("%s:%s:%s:%s", nodeType, plmnId, nbId, cuupId), nil
+       }else if duId != "" {
+               return fmt.Sprintf("%s:%s:%s:%s", nodeType, plmnId, nbId, duId ), nil
+       }else {
        return fmt.Sprintf("%s:%s:%s", nodeType, plmnId, nbId), nil
 }
+}
 
 /*
 ValidateAndBuildCellNamePciKey builds key according to the specified format returns the resulting string
@@ -91,8 +109,29 @@ func ValidateAndBuildRanLoadInformationKey(inventoryName string) (string, error)
 func ValidateAndBuildE2TInstanceKey(address string) (string, error) {
 
        if address == "" {
-               return "", NewValidationError("#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received")
+               return "", NewValidationError("#utils.ValidateAndBuildE2TInstanceKey - an empty E2T address received")
        }
 
        return fmt.Sprintf("E2TInstance:%s", address), nil
-}
\ No newline at end of file
+}
+
+func BuildGeneralConfigurationKey() string {
+       return "GENERAL"
+}
+
+func MapE2TAddressesToKeys(addresses []string) []string {
+
+       keys := []string{}
+       for _, v := range addresses {
+               if len(v) != 0 {
+                       keys = append(keys, fmt.Sprintf("E2TInstance:%s", v))
+               }
+       }
+
+       return keys
+}
+
+//GetRNibNamespace returns namespace used by the RNIB in SDL.
+func GetRNibNamespace() string {
+       return rnibNamespace
+}