X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;ds=inline;f=common%2Futils.go;h=00670381906e6c591922d23d29e4b36ae9138906;hb=refs%2Ftags%2Freader%2Fv1.2.9;hp=f7a84ad1541528c6924a4fa8443da7b971496318;hpb=286ce41c7d5049e688a40f68e4c6681a645add3d;p=ric-plt%2Fnodeb-rnib.git diff --git a/common/utils.go b/common/utils.go index f7a84ad..0067038 100644 --- a/common/utils.go +++ b/common/utils.go @@ -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. @@ -14,67 +15,123 @@ // See the License for the specific language governing permissions and // limitations under the License. +// This source code is part of the near-RT RIC (RAN Intelligent Controller) +// platform project (RICP). + package common import ( - "errors" "fmt" ) + +//SDL namespace used by the RNIB +const rnibNamespace = "e2Manager" + /* ValidateAndBuildCellIdKey builds key according to the specified format returns the resulting string - */ -func ValidateAndBuildCellIdKey(cellId string) (string, IRNibError) { +*/ +func ValidateAndBuildCellIdKey(cellId string) (string, error) { if cellId == "" { - e := errors.New("#utils.ValidateAndBuildCellIdKey - an empty cell id received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildCellIdKey - an empty cell id received") } return fmt.Sprintf("CELL:%s", cellId), nil } + /* ValidateAndBuildNrCellIdKey builds key according to the specified format returns the resulting string - */ -func ValidateAndBuildNrCellIdKey(cellId string) (string, IRNibError) { +*/ +func ValidateAndBuildNrCellIdKey(cellId string) (string, error) { if cellId == "" { - e := errors.New("#utils.ValidateAndBuildNrCellIdKey - an empty cell id received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildNrCellIdKey - an empty cell id received") } return fmt.Sprintf("NRCELL:%s", cellId), nil } + /* ValidateAndBuildNodeBNameKey builds key according to the specified format returns the resulting string - */ -func ValidateAndBuildNodeBNameKey(inventoryName string) (string, IRNibError) { +*/ +func ValidateAndBuildNodeBNameKey(inventoryName string) (string, error) { if inventoryName == "" { - e := errors.New("#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received") } return fmt.Sprintf("RAN:%s", inventoryName), nil } + /* ValidateAndBuildNodeBIdKey builds key according to the specified format returns the resulting string - */ -func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (string, IRNibError) { +*/ +func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string, cuupId string, duId string) (string, error) { if nodeType == "" { - e := errors.New("#utils.ValidateAndBuildNodeBIdKey - an empty node type received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty node type received") } if plmnId == "" { - e := errors.New("#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received") } if nbId == "" { - e := errors.New("#utils.ValidateAndBuildNodeBIdKey - an empty nbId received") - return "", NewValidationError(e) + 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 - */ -func ValidateAndBuildCellNamePciKey(inventoryName string, pci uint32) (string, IRNibError) { +*/ +func ValidateAndBuildCellNamePciKey(inventoryName string, pci uint32) (string, error) { if inventoryName == "" { - e := errors.New("#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received") - return "", NewValidationError(e) + return "", NewValidationError("#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received") } return fmt.Sprintf("PCI:%s:%02x", inventoryName, pci), nil -} \ No newline at end of file +} + +func ValidateAndBuildRanLoadInformationKey(inventoryName string) (string, error) { + + if inventoryName == "" { + return "", NewValidationError("#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received") + } + + return fmt.Sprintf("LOAD:%s", inventoryName), nil +} + +func ValidateAndBuildE2TInstanceKey(address string) (string, error) { + + if address == "" { + return "", NewValidationError("#utils.ValidateAndBuildE2TInstanceKey - an empty E2T address received") + } + + return fmt.Sprintf("E2TInstance:%s", address), nil +} + +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 +}