naman.gupta | 6d6fe01 | 2022-11-30 15:21:16 +0530 | [diff] [blame^] | 1 | /* |
| 2 | ================================================================================== |
| 3 | Copyright (c) 2022 Samsung |
| 4 | |
| 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 |
| 8 | |
| 9 | http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | |
| 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. |
| 16 | |
| 17 | This source code is part of the near-RT RIC (RAN Intelligent Controller) |
| 18 | platform project (RICP). |
| 19 | ================================================================================== |
| 20 | */ |
| 21 | |
| 22 | package policy |
| 23 | |
| 24 | import ( |
| 25 | "strconv" |
| 26 | |
| 27 | "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/a1" |
| 28 | "gerrit.o-ran-sc.org/r/ric-plt/sdlgo" |
| 29 | ) |
| 30 | |
| 31 | const ( |
| 32 | a1HandlerPrefix = "a1.policy_handler." |
| 33 | a1MediatorNs = "A1m_ns" |
| 34 | ) |
| 35 | |
| 36 | func NewPolicyManager(sdl *sdlgo.SyncStorage) *PolicyManager { |
| 37 | return createPolicyManager(sdl) |
| 38 | } |
| 39 | |
| 40 | func createPolicyManager(sdlInst iSdl) *PolicyManager { |
| 41 | pm := &PolicyManager{ |
| 42 | db: sdlInst, |
| 43 | } |
| 44 | return pm |
| 45 | } |
| 46 | func (pm *PolicyManager) SetPolicyInstanceStatus(policyTypeId int, policyInstanceID int, status string) error { |
| 47 | a1.Logger.Debug("message recieved for %d and %d", policyTypeId, policyInstanceID) |
| 48 | instancehandlerKey := a1HandlerPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + strconv.FormatInt((int64(policyInstanceID)), 10) |
| 49 | err := pm.db.Set(a1MediatorNs, instancehandlerKey, status) |
| 50 | if err != nil { |
| 51 | a1.Logger.Error("error1 :%+v", err) |
| 52 | return err |
| 53 | } |
| 54 | return nil |
| 55 | } |