2 // Copyright 2019 AT&T Intellectual Property
3 // Copyright 2019 Nokia
5 // Licensed under the Apache License, Version 2.0 (the "License");
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
17 // This source code is part of the near-RT RIC (RAN Intelligent Controller)
18 // platform project (RICP).
27 ValidateAndBuildCellIdKey builds key according to the specified format returns the resulting string
29 func ValidateAndBuildCellIdKey(cellId string) (string, error) {
31 return "", NewValidationError("#utils.ValidateAndBuildCellIdKey - an empty cell id received")
33 return fmt.Sprintf("CELL:%s", cellId), nil
37 ValidateAndBuildNrCellIdKey builds key according to the specified format returns the resulting string
39 func ValidateAndBuildNrCellIdKey(cellId string) (string, error) {
41 return "", NewValidationError("#utils.ValidateAndBuildNrCellIdKey - an empty cell id received")
43 return fmt.Sprintf("NRCELL:%s", cellId), nil
47 ValidateAndBuildNodeBNameKey builds key according to the specified format returns the resulting string
49 func ValidateAndBuildNodeBNameKey(inventoryName string) (string, error) {
50 if inventoryName == "" {
51 return "", NewValidationError("#utils.ValidateAndBuildNodeBNameKey - an empty inventory name received")
53 return fmt.Sprintf("RAN:%s", inventoryName), nil
57 ValidateAndBuildNodeBIdKey builds key according to the specified format returns the resulting string
59 func ValidateAndBuildNodeBIdKey(nodeType string, plmnId string, nbId string) (string, error) {
61 return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty node type received")
64 return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty plmnId received")
67 return "", NewValidationError("#utils.ValidateAndBuildNodeBIdKey - an empty nbId received")
69 return fmt.Sprintf("%s:%s:%s", nodeType, plmnId, nbId), nil
73 ValidateAndBuildCellNamePciKey builds key according to the specified format returns the resulting string
75 func ValidateAndBuildCellNamePciKey(inventoryName string, pci uint32) (string, error) {
76 if inventoryName == "" {
77 return "", NewValidationError("#utils.ValidateAndBuildCellNamePciKey - an empty inventory name received")
79 return fmt.Sprintf("PCI:%s:%02x", inventoryName, pci), nil
82 func ValidateAndBuildRanLoadInformationKey(inventoryName string) (string, error) {
84 if inventoryName == "" {
85 return "", NewValidationError("#utils.ValidateAndBuildRanLoadInformationKey - an empty inventory name received")
88 return fmt.Sprintf("LOAD:%s", inventoryName), nil
91 func ValidateAndBuildE2TInstanceKey(address string) (string, error) {
94 return "", NewValidationError("#utils.ValidateAndBuildE2TInstanceKey - an empty E2T address received")
97 return fmt.Sprintf("E2TInstance:%s", address), nil
100 func MapE2TAddressesToKeys(addresses []string) []string {
103 for _, v := range addresses {
105 keys = append(keys, fmt.Sprintf("E2TInstance:%s", v))