blob: 0919de8eb4c7f48a5cf75d3cd43f9b4c8f0ba996 [file] [log] [blame]
Matteo Scandolo40e067f2019-10-16 16:59:41 -07001/*
2 * Copyright 2018-present Open Networking Foundation
3
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7
8 * http://www.apache.org/licenses/LICENSE-2.0
9
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package common
18
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +010019import (
20 "flag"
21 "fmt"
22 "io/ioutil"
23 "net"
Matteo Scandolof65e6872020-04-15 15:18:43 -070024 "strings"
Shrey Baid64cda472020-04-24 18:58:18 +053025
Matteo Scandolo4a036262020-08-17 15:56:13 -070026 "github.com/imdario/mergo"
Shrey Baid64cda472020-04-24 18:58:18 +053027 log "github.com/sirupsen/logrus"
Matteo Scandolo4a036262020-08-17 15:56:13 -070028 "gopkg.in/yaml.v2"
Matteo Scandolof65e6872020-04-15 15:18:43 -070029)
Matteo Scandolo40e067f2019-10-16 16:59:41 -070030
Matteo Scandolof65e6872020-04-15 15:18:43 -070031var tagAllocationValues = []string{
32 "unknown",
33 "shared",
34 "unique",
35}
36
Matteo Scandolo94967142021-05-28 11:37:06 -070037const (
38 BP_FORMAT_MEF = "mef"
39 BP_FORMAT_IETF = "ietf"
40)
41
Matteo Scandolof65e6872020-04-15 15:18:43 -070042type TagAllocation int
43
44func (t TagAllocation) String() string {
45 return tagAllocationValues[t]
46}
47
48func tagAllocationFromString(s string) (TagAllocation, error) {
49 for i, v := range tagAllocationValues {
Matteo Scandolo4a036262020-08-17 15:56:13 -070050 if v == strings.TrimSpace(s) {
Matteo Scandolof65e6872020-04-15 15:18:43 -070051 return TagAllocation(i), nil
52 }
53 }
54 log.WithFields(log.Fields{
55 "ValidValues": strings.Join(tagAllocationValues[1:], ", "),
56 }).Errorf("%s-is-not-a-valid-tag-allocation", s)
Shrey Baid688b4242020-07-10 20:40:10 +053057 return TagAllocation(0), fmt.Errorf("%s-is-not-a-valid-tag-allocation", s)
Matteo Scandolof65e6872020-04-15 15:18:43 -070058}
59
60const (
61 _ TagAllocation = iota
62 TagAllocationShared
63 TagAllocationUnique
64)
65
Matteo Scandolo40e067f2019-10-16 16:59:41 -070066type BBRCliOptions struct {
Matteo Scandolo4a036262020-08-17 15:56:13 -070067 *GlobalConfig
Matteo Scandolo40e067f2019-10-16 16:59:41 -070068 BBSimIp string
69 BBSimPort string
70 BBSimApiPort string
Matteo Scandolof5c537e2019-10-28 16:45:57 -070071 LogFile string
Matteo Scandolo40e067f2019-10-16 16:59:41 -070072}
73
Matteo Scandolo4a036262020-08-17 15:56:13 -070074type GlobalConfig struct {
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +010075 BBSim BBSimConfig
76 Olt OltConfig
77 BBR BBRConfig
78}
Matteo Scandolo40e067f2019-10-16 16:59:41 -070079
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +010080type OltConfig struct {
81 Model string `yaml:"model"`
82 Vendor string `yaml:"vendor"`
83 HardwareVersion string `yaml:"hardware_version"`
84 FirmwareVersion string `yaml:"firmware_version"`
85 DeviceId string `yaml:"device_id"`
86 DeviceSerialNumber string `yaml:"device_serial_number"`
87 PonPorts uint32 `yaml:"pon_ports"`
88 NniPorts uint32 `yaml:"nni_ports"`
Elia Battiston420c9092022-02-02 12:17:54 +010089 NniSpeed uint32 `yaml:"nni_speed"`
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +010090 OnusPonPort uint32 `yaml:"onus_per_port"`
91 Technology string `yaml:"technology"`
92 ID int `yaml:"id"`
93 OltRebootDelay int `yaml:"reboot_delay"`
Shrey Baid688b4242020-07-10 20:40:10 +053094 PortStatsInterval int `yaml:"port_stats_interval"`
Holger Hildebrandtc10bab12021-04-27 09:23:48 +000095 OmciResponseRate uint8 `yaml:"omci_response_rate"`
Mahir Gunyela1753ae2021-06-23 00:24:56 -070096 UniPorts uint32 `yaml:"uni_ports"`
Elia Battistonac63b112022-01-12 18:40:49 +010097 PotsPorts uint32 `yaml:"pots_ports"`
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +010098}
Matteo Scandolo40e067f2019-10-16 16:59:41 -070099
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100100type BBSimConfig struct {
Matteo Scandolo94967142021-05-28 11:37:06 -0700101 ConfigFile string
102 ServiceConfigFile string
103 DhcpRetry bool `yaml:"dhcp_retry"`
104 AuthRetry bool `yaml:"auth_retry"`
105 LogLevel string `yaml:"log_level"`
106 LogCaller bool `yaml:"log_caller"`
107 Delay int `yaml:"delay"`
108 CpuProfile *string `yaml:"cpu_profile"`
109 OpenOltAddress string `yaml:"openolt_address"`
110 ApiAddress string `yaml:"api_address"`
111 RestApiAddress string `yaml:"rest_api_address"`
112 LegacyApiAddress string `yaml:"legacy_api_address"`
113 LegacyRestApiAddress string `yaml:"legacy_rest_api_address"`
114 SadisRestAddress string `yaml:"sadis_rest_address"`
115 SadisServer bool `yaml:"sadis_server"`
116 KafkaAddress string `yaml:"kafka_address"`
117 Events bool `yaml:"enable_events"`
118 ControlledActivation string `yaml:"controlled_activation"`
119 EnablePerf bool `yaml:"enable_perf"`
120 KafkaEventTopic string `yaml:"kafka_event_topic"`
121 DmiServerAddress string `yaml:"dmi_server_address"`
122 BandwidthProfileFormat string `yaml:"bp_format"`
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100123}
Matteo Scandoloc1147092019-10-29 09:38:33 -0700124
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100125type BBRConfig struct {
126 Log string `yaml:"log"`
127 LogLevel string `yaml:"log_level"`
128 LogCaller bool `yaml:"log_caller"`
129}
130
Matteo Scandolo4a036262020-08-17 15:56:13 -0700131type ServiceYaml struct {
132 Name string
133 CTag int `yaml:"c_tag"`
134 STag int `yaml:"s_tag"`
135 NeedsEapol bool `yaml:"needs_eapol"`
Matteo Scandolo8a574812021-05-20 15:18:53 -0700136 NeedsDhcp bool `yaml:"needs_dhcp"`
Matteo Scandolo4a036262020-08-17 15:56:13 -0700137 NeedsIgmp bool `yaml:"needs_igmp"`
138 CTagAllocation string `yaml:"c_tag_allocation"`
139 STagAllocation string `yaml:"s_tag_allocation"`
140 TechnologyProfileID int `yaml:"tp_id"`
141 UniTagMatch int `yaml:"uni_tag_match"`
142 ConfigureMacAddress bool `yaml:"configure_mac_address"`
Matteo Scandolo8d281372020-09-03 16:23:37 -0700143 UsPonCTagPriority uint8 `yaml:"us_pon_c_tag_priority"`
144 UsPonSTagPriority uint8 `yaml:"us_pon_s_tag_priority"`
145 DsPonCTagPriority uint8 `yaml:"ds_pon_c_tag_priority"`
146 DsPonSTagPriority uint8 `yaml:"ds_pon_s_tag_priority"`
Matteo Scandolo4a036262020-08-17 15:56:13 -0700147}
148type YamlServiceConfig struct {
149 Workflow string
150 Services []ServiceYaml `yaml:"services,flow"`
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100151}
152
Matteo Scandolo4a036262020-08-17 15:56:13 -0700153func (cfg *YamlServiceConfig) String() string {
154 str := fmt.Sprintf("[workflow: %s, Services: ", cfg.Workflow)
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100155
Matteo Scandolo4a036262020-08-17 15:56:13 -0700156 for _, s := range cfg.Services {
157 str = fmt.Sprintf("%s[", str)
158 str = fmt.Sprintf("%sname=%s, c_tag=%d, s_tag=%d, ",
159 str, s.Name, s.CTag, s.STag)
160 str = fmt.Sprintf("%sc_tag_allocation=%s, s_tag_allocation=%s, ",
161 str, s.CTagAllocation, s.STagAllocation)
162 str = fmt.Sprintf("%sneeds_eapol=%t, needs_dhcp=%t, needs_igmp=%t",
Matteo Scandolo8a574812021-05-20 15:18:53 -0700163 str, s.NeedsEapol, s.NeedsDhcp, s.NeedsIgmp)
Matteo Scandolo4a036262020-08-17 15:56:13 -0700164 str = fmt.Sprintf("%stp_id=%d, uni_tag_match=%d",
165 str, s.TechnologyProfileID, s.UniTagMatch)
166 str = fmt.Sprintf("%s]", str)
167 }
168 str = fmt.Sprintf("%s]", str)
169 return str
170}
171
172var (
173 Config *GlobalConfig
174 Services []ServiceYaml
175)
176
177// Load the BBSim configuration. This is a combination of CLI parameters and YAML files
178// We proceed in this order:
179// - Read CLI parameters
180// - Using those we read the yaml files (config and services)
181// - we merge the configuration (CLI has priority over yaml files)
182func LoadConfig() {
183
184 Config = getDefaultOps()
185
186 cliConf := readCliParams()
187
188 yamlConf, err := loadBBSimConf(cliConf.BBSim.ConfigFile)
189
190 if err != nil {
191 log.WithFields(log.Fields{
192 "file": cliConf.BBSim.ConfigFile,
193 "err": err,
194 }).Fatal("Can't read config file")
195 }
196
197 // merging Yaml and Default Values
198 if err := mergo.Merge(Config, yamlConf, mergo.WithOverride); err != nil {
199 log.WithFields(log.Fields{
200 "err": err,
201 }).Fatal("Can't merge YAML and Config")
202 }
203
204 // merging CLI values on top of the yaml ones
205 if err := mergo.Merge(Config, cliConf, mergo.WithOverride); err != nil {
206 log.WithFields(log.Fields{
207 "err": err,
208 }).Fatal("Can't merge CLI and Config")
209 }
210
211 services, err := loadBBSimServices(Config.BBSim.ServiceConfigFile)
212
213 if err != nil {
214 log.WithFields(log.Fields{
215 "file": Config.BBSim.ServiceConfigFile,
216 "err": err,
217 }).Fatal("Can't read services file")
218 }
219
220 Services = services
221
222}
223
224func readCliParams() *GlobalConfig {
225
Matteo Scandoloc11074d2020-09-14 14:59:24 -0700226 conf := getDefaultOps()
Matteo Scandolo4a036262020-08-17 15:56:13 -0700227
228 configFile := flag.String("config", conf.BBSim.ConfigFile, "Configuration file path")
229 servicesFile := flag.String("services", conf.BBSim.ServiceConfigFile, "Service Configuration file path")
Matteo Scandolo94967142021-05-28 11:37:06 -0700230 sadisBpFormat := flag.String("bp_format", conf.BBSim.BandwidthProfileFormat, "Bandwidth profile format, 'mef' or 'ietf'")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700231
232 olt_id := flag.Int("olt_id", conf.Olt.ID, "OLT device ID")
233 nni := flag.Int("nni", int(conf.Olt.NniPorts), "Number of NNI ports per OLT device to be emulated")
Elia Battiston420c9092022-02-02 12:17:54 +0100234 nni_speed := flag.Uint("nni_speed", uint(conf.Olt.NniSpeed), "Reported speed of the NNI ports in Mbps")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700235 pon := flag.Int("pon", int(conf.Olt.PonPorts), "Number of PON ports per OLT device to be emulated")
236 onu := flag.Int("onu", int(conf.Olt.OnusPonPort), "Number of ONU devices per PON port to be emulated")
Elia Battistonac63b112022-01-12 18:40:49 +0100237 uni := flag.Int("uni", int(conf.Olt.UniPorts), "Number of Ethernet UNI Ports per ONU device to be emulated")
238 pots := flag.Int("pots", int(conf.Olt.PotsPorts), "Number of POTS UNI Ports per ONU device to be emulated")
Mahir Gunyela1753ae2021-06-23 00:24:56 -0700239
Matteo Scandolo93566702020-09-30 15:19:27 -0700240 oltRebootDelay := flag.Int("oltRebootDelay", conf.Olt.OltRebootDelay, "Time that BBSim should before restarting after a reboot")
Holger Hildebrandtc10bab12021-04-27 09:23:48 +0000241 omci_response_rate := flag.Int("omci_response_rate", int(conf.Olt.OmciResponseRate), "Amount of OMCI messages to respond to")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700242
243 openolt_address := flag.String("openolt_address", conf.BBSim.OpenOltAddress, "IP address:port")
244 api_address := flag.String("api_address", conf.BBSim.ApiAddress, "IP address:port")
245 rest_api_address := flag.String("rest_api_address", conf.BBSim.RestApiAddress, "IP address:port")
amit.ghosh258d14c2020-10-02 15:13:38 +0200246 dmi_server_address := flag.String("dmi_server_address", conf.BBSim.DmiServerAddress, "IP address:port")
Matteo Scandolo4a036262020-08-17 15:56:13 -0700247
248 profileCpu := flag.String("cpuprofile", "", "write cpu profile to file")
249
250 logLevel := flag.String("logLevel", conf.BBSim.LogLevel, "Set the log level (trace, debug, info, warn, error)")
251 logCaller := flag.Bool("logCaller", conf.BBSim.LogCaller, "Whether to print the caller filename or not")
252
253 delay := flag.Int("delay", conf.BBSim.Delay, "The delay between ONU DISCOVERY batches in milliseconds (1 ONU per each PON PORT at a time")
254
255 controlledActivation := flag.String("ca", conf.BBSim.ControlledActivation, "Set the mode for controlled activation of PON ports and ONUs")
256 enablePerf := flag.Bool("enableperf", conf.BBSim.EnablePerf, "Setting this flag will cause BBSim to not store data like traffic schedulers, flows of ONUs etc..")
257 enableEvents := flag.Bool("enableEvents", conf.BBSim.Events, "Enable sending BBSim events on configured kafka server")
258 kafkaAddress := flag.String("kafkaAddress", conf.BBSim.KafkaAddress, "IP:Port for kafka")
259 kafkaEventTopic := flag.String("kafkaEventTopic", conf.BBSim.KafkaEventTopic, "Ability to configure the topic on which BBSim publishes events on Kafka")
260 dhcpRetry := flag.Bool("dhcpRetry", conf.BBSim.DhcpRetry, "Set this flag if BBSim should retry DHCP upon failure until success")
261 authRetry := flag.Bool("authRetry", conf.BBSim.AuthRetry, "Set this flag if BBSim should retry EAPOL (Authentication) upon failure until success")
Matteo Scandolo93566702020-09-30 15:19:27 -0700262
Matteo Scandolo4a036262020-08-17 15:56:13 -0700263 flag.Parse()
264
265 conf.Olt.ID = int(*olt_id)
266 conf.Olt.NniPorts = uint32(*nni)
Elia Battiston420c9092022-02-02 12:17:54 +0100267 conf.Olt.NniSpeed = uint32(*nni_speed)
Matteo Scandolo4a036262020-08-17 15:56:13 -0700268 conf.Olt.PonPorts = uint32(*pon)
Mahir Gunyela1753ae2021-06-23 00:24:56 -0700269 conf.Olt.UniPorts = uint32(*uni)
Elia Battistonac63b112022-01-12 18:40:49 +0100270 conf.Olt.PotsPorts = uint32(*pots)
Matteo Scandolo4a036262020-08-17 15:56:13 -0700271 conf.Olt.OnusPonPort = uint32(*onu)
Matteo Scandolo93566702020-09-30 15:19:27 -0700272 conf.Olt.OltRebootDelay = *oltRebootDelay
Holger Hildebrandtc10bab12021-04-27 09:23:48 +0000273 conf.Olt.OmciResponseRate = uint8(*omci_response_rate)
Matteo Scandolo4a036262020-08-17 15:56:13 -0700274 conf.BBSim.ConfigFile = *configFile
275 conf.BBSim.ServiceConfigFile = *servicesFile
276 conf.BBSim.CpuProfile = profileCpu
277 conf.BBSim.LogLevel = *logLevel
278 conf.BBSim.LogCaller = *logCaller
279 conf.BBSim.Delay = *delay
280 conf.BBSim.ControlledActivation = *controlledActivation
281 conf.BBSim.EnablePerf = *enablePerf
282 conf.BBSim.Events = *enableEvents
283 conf.BBSim.KafkaAddress = *kafkaAddress
284 conf.BBSim.OpenOltAddress = *openolt_address
285 conf.BBSim.ApiAddress = *api_address
286 conf.BBSim.RestApiAddress = *rest_api_address
287 conf.BBSim.KafkaEventTopic = *kafkaEventTopic
288 conf.BBSim.AuthRetry = *authRetry
289 conf.BBSim.DhcpRetry = *dhcpRetry
amit.ghosh258d14c2020-10-02 15:13:38 +0200290 conf.BBSim.DmiServerAddress = *dmi_server_address
Matteo Scandolo4a036262020-08-17 15:56:13 -0700291
292 // update device id if not set
293 if conf.Olt.DeviceId == "" {
294 conf.Olt.DeviceId = net.HardwareAddr{0xA, 0xA, 0xA, 0xA, 0xA, byte(conf.Olt.ID)}.String()
295 }
296
Matteo Scandolo94967142021-05-28 11:37:06 -0700297 // check that the BP format is valid
298 if (*sadisBpFormat != BP_FORMAT_MEF) && (*sadisBpFormat != BP_FORMAT_IETF) {
299 log.Fatalf("Invalid parameter 'bp_format', supported values are %s and %s, you provided %s", BP_FORMAT_MEF, BP_FORMAT_IETF, *sadisBpFormat)
300 }
301 conf.BBSim.BandwidthProfileFormat = *sadisBpFormat
302
Matteo Scandoloc11074d2020-09-14 14:59:24 -0700303 return conf
Matteo Scandolo4a036262020-08-17 15:56:13 -0700304}
305
306func getDefaultOps() *GlobalConfig {
307
308 c := &GlobalConfig{
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100309 BBSimConfig{
Matteo Scandolo94967142021-05-28 11:37:06 -0700310 ConfigFile: "configs/bbsim.yaml",
311 ServiceConfigFile: "configs/att-services.yaml",
312 LogLevel: "debug",
313 LogCaller: false,
314 Delay: 200,
315 OpenOltAddress: ":50060",
316 ApiAddress: ":50070",
317 RestApiAddress: ":50071",
318 LegacyApiAddress: ":50072",
319 LegacyRestApiAddress: ":50073",
320 SadisRestAddress: ":50074",
321 SadisServer: true,
322 KafkaAddress: ":9092",
323 Events: false,
324 ControlledActivation: "default",
325 EnablePerf: false,
326 KafkaEventTopic: "",
327 DhcpRetry: false,
328 AuthRetry: false,
329 DmiServerAddress: ":50075",
330 BandwidthProfileFormat: BP_FORMAT_MEF,
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100331 },
332 OltConfig{
333 Vendor: "BBSim",
334 Model: "asfvolt16",
335 HardwareVersion: "emulated",
336 FirmwareVersion: "",
337 DeviceSerialNumber: "BBSM00000001",
338 PonPorts: 1,
339 NniPorts: 1,
Elia Battiston420c9092022-02-02 12:17:54 +0100340 NniSpeed: 10000, //Mbps
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100341 OnusPonPort: 1,
342 Technology: "XGS-PON",
343 ID: 0,
Matteo Scandolo93566702020-09-30 15:19:27 -0700344 OltRebootDelay: 60,
Pragya Arya996a0892020-03-09 21:47:52 +0530345 PortStatsInterval: 20,
Holger Hildebrandtc10bab12021-04-27 09:23:48 +0000346 OmciResponseRate: 10,
Mahir Gunyela1753ae2021-06-23 00:24:56 -0700347 UniPorts: 4,
Elia Battistonac63b112022-01-12 18:40:49 +0100348 PotsPorts: 0,
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100349 },
350 BBRConfig{
351 LogLevel: "debug",
352 LogCaller: false,
353 },
354 }
355 return c
356}
357
358// LoadBBSimConf loads the BBSim configuration from a YAML file
Matteo Scandolo4a036262020-08-17 15:56:13 -0700359func loadBBSimConf(filename string) (*GlobalConfig, error) {
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100360 yamlConfig := getDefaultOps()
361
362 yamlFile, err := ioutil.ReadFile(filename)
363 if err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700364 log.WithFields(log.Fields{
365 "err": err,
366 "filename": filename,
367 }).Error("Cannot load BBSim configuration file. Using defaults.")
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100368 return yamlConfig, nil
369 }
370
371 err = yaml.Unmarshal(yamlFile, yamlConfig)
372 if err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700373 return nil, err
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100374 }
375
376 return yamlConfig, nil
377}
378
Matteo Scandolo4a036262020-08-17 15:56:13 -0700379// LoadBBSimServices parses a file describing the services that need to be created for each UNI
380func loadBBSimServices(filename string) ([]ServiceYaml, error) {
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100381
Matteo Scandolo4a036262020-08-17 15:56:13 -0700382 yamlServiceCfg := YamlServiceConfig{}
Zdravko Bozakov3ddb2452019-11-29 14:33:41 +0100383
Matteo Scandolo4a036262020-08-17 15:56:13 -0700384 yamlFile, err := ioutil.ReadFile(filename)
Matteo Scandolof65e6872020-04-15 15:18:43 -0700385 if err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700386 return nil, err
Matteo Scandolof65e6872020-04-15 15:18:43 -0700387 }
388
Matteo Scandolo4a036262020-08-17 15:56:13 -0700389 err = yaml.Unmarshal([]byte(yamlFile), &yamlServiceCfg)
Matteo Scandolof65e6872020-04-15 15:18:43 -0700390 if err != nil {
Matteo Scandolo4a036262020-08-17 15:56:13 -0700391 return nil, err
Matteo Scandolof65e6872020-04-15 15:18:43 -0700392 }
393
Matteo Scandolo4a036262020-08-17 15:56:13 -0700394 for _, service := range yamlServiceCfg.Services {
395
396 if service.CTagAllocation == "" || service.STagAllocation == "" {
397 log.Fatal("c_tag_allocation and s_tag_allocation are mandatory fields")
398 }
399
400 if _, err := tagAllocationFromString(string(service.CTagAllocation)); err != nil {
401 log.WithFields(log.Fields{
402 "err": err,
403 }).Fatal("c_tag_allocation is not valid")
404 }
Matteo Scandolof65e6872020-04-15 15:18:43 -0700405 }
406
Matteo Scandolo4a036262020-08-17 15:56:13 -0700407 log.WithFields(log.Fields{
408 "services": yamlServiceCfg.String(),
409 }).Debug("BBSim services description correctly loaded")
410 return yamlServiceCfg.Services, nil
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700411}
412
Matteo Scandolo4a036262020-08-17 15:56:13 -0700413// This is only used by BBR
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700414func GetBBROpts() BBRCliOptions {
415
416 bbsimIp := flag.String("bbsimIp", "127.0.0.1", "BBSim IP")
417 bbsimPort := flag.String("bbsimPort", "50060", "BBSim Port")
418 bbsimApiPort := flag.String("bbsimApiPort", "50070", "BBSim API Port")
Matteo Scandolof5c537e2019-10-28 16:45:57 -0700419 logFile := flag.String("logfile", "", "Log to a file")
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700420
Matteo Scandoloc11074d2020-09-14 14:59:24 -0700421 LoadConfig()
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700422
423 bbrOptions := BBRCliOptions{
Matteo Scandolo4a036262020-08-17 15:56:13 -0700424 Config,
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700425 *bbsimIp,
426 *bbsimPort,
427 *bbsimApiPort,
Matteo Scandolof5c537e2019-10-28 16:45:57 -0700428 *logFile,
Matteo Scandolo40e067f2019-10-16 16:59:41 -0700429 }
430
431 return bbrOptions
432}