Seed code for O-DU slice assurance new repo
[nonrtric/rapp/ransliceassurance.git] / smoversion / internal / structures / measurements.go
1 // -
2 //   ========================LICENSE_START=================================
3 //   O-RAN-SC
4 //   %%
5 //   Copyright (C) 2021: Nordix Foundation
6 //   %%
7 //   Licensed under the Apache License, Version 2.0 (the "License");
8 //   you may not use this file except in compliance with the License.
9 //   You may obtain a copy of the License at
10 //
11 //        http://www.apache.org/licenses/LICENSE-2.0
12 //
13 //   Unless required by applicable law or agreed to in writing, software
14 //   distributed under the License is distributed on an "AS IS" BASIS,
15 //   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 //   See the License for the specific language governing permissions and
17 //   limitations under the License.
18 //   ========================LICENSE_END===================================
19 //
20
21 package structures
22
23 import "oransc.org/usecase/oduclosedloop/messages"
24
25 type SliceMetric struct {
26         DUId             string
27         CellId           string
28         SliceDiff        int
29         SliceServiceType int
30         RRMPolicyRatioId string
31         PM               map[string]int
32 }
33
34 func NewSliceMetric(duid string, cellid string, sd int, sst int) *SliceMetric {
35         sm := SliceMetric{
36                 DUId:             duid,
37                 CellId:           cellid,
38                 SliceDiff:        sd,
39                 SliceServiceType: sst,
40         }
41         sm.PM = make(map[string]int)
42         return &sm
43 }
44
45 type PolicyRatio struct {
46         PolicyRatioId        string
47         PolicyMaxRatio       int
48         PolicyMinRatio       int
49         PolicyDedicatedRatio int
50 }
51
52 func NewPolicyRatio(id string, max_ratio int, min_ratio int, ded_ratio int) *PolicyRatio {
53         pr := PolicyRatio{
54                 PolicyRatioId:        id,
55                 PolicyMaxRatio:       max_ratio,
56                 PolicyMinRatio:       min_ratio,
57                 PolicyDedicatedRatio: ded_ratio,
58         }
59         return &pr
60 }
61
62 func (pr *PolicyRatio) GetUpdateDedicatedRatioMessage(sd int, sst int, dedicatedRatio int) interface{} {
63         message := messages.RRMPolicyRatio{
64                 Id:                      pr.PolicyRatioId,
65                 AdmState:                "unlocked",
66                 UserLabel:               pr.PolicyRatioId,
67                 RRMPolicyMaxRatio:       pr.PolicyMaxRatio,
68                 RRMPolicyMinRatio:       pr.PolicyMinRatio,
69                 RRMPolicyDedicatedRatio: dedicatedRatio,
70                 ResourceType:            "prb",
71                 RRMPolicyMembers: []messages.RRMPolicyMember{
72                         {
73                                 MobileCountryCode:   "046",
74                                 MobileNetworkCode:   "651",
75                                 SliceDifferentiator: sd,
76                                 SliceServiceType:    sst,
77                         },
78                 },
79         }
80         rrmPolicies := []messages.RRMPolicyRatio{message}
81
82         return struct {
83                 RRMPolicies []messages.RRMPolicyRatio `json:"radio-resource-management-policy-ratio"`
84         }{
85                 RRMPolicies: rrmPolicies,
86         }
87
88 }