/
nssf_configmap.go
119 lines (107 loc) · 4.54 KB
/
nssf_configmap.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/*
Copyright 2021 IBM.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package v13
import (
"bytes"
v1alpha1 "github.com/5GZORRO/issm-mec-cnmp-5g-operator/api/v1alpha1"
"text/template"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)
const NssfConfig = `info:
version: 1.0.1
description: NSSF initial local configuration
configuration:
nssfName: NSSF # the name of this NSSF
sbi: # Service-based interface information
scheme: http # the protocol for sbi (http or https)
registerIPv4: {{ .Name }}-sbi # IP used to register to NRF
bindingIPv4: {{ .Name }}-sbi # IP used to bind the service
port: 8000 # Port used to bind the service
tls: # the local path of TLS key
pem: ./config/TLS/nssf.pem # NSSF TLS Certificate
key: ./config/TLS/nssf.key # NSSF TLS Private key
serviceNameList: # the SBI services provided by this SMF, refer to TS 29.531
- nnssf-nsselection # Nnssf_NSSelection service
- nnssf-nssaiavailability # Nnssf_NSSAIAvailability service
nrfUri: http://{{ .NrfIPAddress }}:{{ .NrfPort }} # a valid URI of NRF
supportedPlmnList: # the PLMNs (Public land mobile network) list supported by this NSSF
- mcc: {{ .Mcc }} # Mobile Country Code (3 digits string, digit: 0~9)
mnc: {{ .Mnc }} # Mobile Network Code (2 or 3 digits string, digit: 0~9)
supportedNssaiInPlmnList: # Supported S-NSSAI List for each PLMN
- plmnId: # Public Land Mobile Network ID, <PLMN ID> = <MCC><MNC>
mcc: {{ .Mcc }} # Mobile Country Code (3 digits string, digit: 0~9)
mnc: {{ .Mnc }} # Mobile Network Code (2 or 3 digits string, digit: 0~9)
supportedSnssaiList: # Supported S-NSSAIs of the PLMN
- sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
- sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
nsiList: # List of available Network Slice Instance (NSI)
- snssai: # S-NSSAI of this NSI
sst: 1 # Slice/Service Type (uinteger, range: 0~255)
nsiInformationList: # Information list of this NSI
# the NRF to be used to select the NFs/services within the selected NSI, and an optonal ID
- nrfId: http://{{ .NrfIPAddress }}:{{ .NrfPort }}/nnrf-nfm/v1/nf-instances
nsiId: 10
- snssai: # S-NSSAI of this NSI
sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: 010203 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
nsiInformationList: # Information list of this NSI
# the NRF to be used to select the NFs/services within the selected NSI, and an optonal ID
- nrfId: http://{{ .NrfIPAddress }}:{{ .NrfPort }}/nnrf-nfm/v1/nf-instances
nsiId: 22
- snssai: # S-NSSAI of this NSI
sst: 1 # Slice/Service Type (uinteger, range: 0~255)
sd: 112233 # Slice Differentiator (3 bytes hex string, range: 000000~FFFFFF)
nsiInformationList: # Information list of this NSI
# the NRF to be used to select the NFs/services within the selected NSI, and an optonal ID
- nrfId: http://{{ .NrfIPAddress }}:{{ .NrfPort }}/nnrf-nfm/v1/nf-instances
nsiId: 23
# the kind of log output
# debugLevel: how detailed to output, value: trace, debug, info, warn, error, fatal, panic
# ReportCaller: enable the caller report or not, value: true or false
logger:
NSSF:
debugLevel: info
ReportCaller: false
PathUtil:
debugLevel: info
ReportCaller: false
OpenApi:
debugLevel: info
ReportCaller: false
`
func NssfConfigMap(cr *v1alpha1.Nssf) (*corev1.ConfigMap, error) {
t, err := template.New("nssf").Parse(NssfConfig)
if err != nil {
return nil, err
}
var b bytes.Buffer
err = t.Execute(&b, cr.Spec.Config)
if err != nil {
return nil, err
}
return &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name,
Namespace: cr.Namespace,
Labels: map[string]string{
"app": "nssf",
},
},
Data: map[string]string{
"nssf.yaml": b.String(),
},
}, nil
}