[VOL-2778] Introducing Service definition in order to support the TT workflow
Change-Id: Ib171502e8940b5d0b219620a4503f7095d376d7a
diff --git a/cmd/bbr/bbr.go b/cmd/bbr/bbr.go
index 5bbfaf7..1cd33bc 100644
--- a/cmd/bbr/bbr.go
+++ b/cmd/bbr/bbr.go
@@ -34,12 +34,12 @@
// usage
func main() {
- options := common.GetBBROpts()
+ config := common.GetBBROpts()
- common.SetLogLevel(log.StandardLogger(), options.BBR.LogLevel, options.BBR.LogCaller)
+ common.SetLogLevel(log.StandardLogger(), config.BBR.LogLevel, config.BBR.LogCaller)
- if options.LogFile != "" {
- file, err := os.OpenFile(options.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
+ if config.LogFile != "" {
+ file, err := os.OpenFile(config.LogFile, os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil {
log.StandardLogger().Out = file
} else {
@@ -47,10 +47,10 @@
}
}
- if *options.BBSim.CpuProfile != "" {
+ if *config.BBSim.CpuProfile != "" {
// start profiling
- log.Infof("Creating profile file at: %s", *options.BBSim.CpuProfile)
- f, err := os.Create(*options.BBSim.CpuProfile)
+ log.Infof("Creating profile file at: %s", *config.BBSim.CpuProfile)
+ f, err := os.Create(*config.BBSim.CpuProfile)
if err != nil {
log.Fatal(err)
}
@@ -58,31 +58,32 @@
}
log.WithFields(log.Fields{
- "OltID": options.Olt.ID,
- "NumNniPerOlt": options.Olt.NniPorts,
- "NumPonPerOlt": options.Olt.PonPorts,
- "NumOnuPerPon": options.Olt.OnusPonPort,
- "BBSimIp": options.BBSimIp,
- "BBSimPort": options.BBSimPort,
- "LogLevel": options.BBR.LogLevel,
- "TotalOnus": options.Olt.PonPorts * options.Olt.OnusPonPort,
+ "OltID": config.Olt.ID,
+ "NumNniPerOlt": config.Olt.NniPorts,
+ "NumPonPerOlt": config.Olt.PonPorts,
+ "NumOnuPerPon": config.Olt.OnusPonPort,
+ "BBSimIp": config.BBSimIp,
+ "BBSimPort": config.BBSimPort,
+ "LogLevel": config.BBR.LogLevel,
+ "TotalOnus": config.Olt.PonPorts * config.Olt.OnusPonPort,
}).Info("BroadBand Reflector is on")
// create the OLT device
olt := devices.CreateOLT(
- *options.BBSimYamlConfig,
+ *config.GlobalConfig,
+ common.Services,
true,
)
- onuIdMap := make(map[uint32]uint32, options.Olt.PonPorts)
+ onuIdMap := make(map[uint32]uint32, config.Olt.PonPorts)
oltMock := bbrdevices.OltMock{
Olt: olt,
- TargetOnus: int(options.Olt.PonPorts * options.Olt.OnusPonPort),
+ TargetOnus: int(config.Olt.PonPorts * config.Olt.OnusPonPort),
CompletedOnus: 0,
- BBSimIp: options.BBSimIp,
- BBSimPort: options.BBSimPort,
- BBSimApiPort: options.BBSimApiPort,
+ BBSimIp: config.BBSimIp,
+ BBSimPort: config.BBSimPort,
+ BBSimApiPort: config.BBSimApiPort,
LastUsedOnuId: onuIdMap,
}
diff --git a/cmd/bbsim/bbsim.go b/cmd/bbsim/bbsim.go
index e7618f9..75c7263 100644
--- a/cmd/bbsim/bbsim.go
+++ b/cmd/bbsim/bbsim.go
@@ -40,7 +40,7 @@
)
func startApiServer(apiDoneChannel chan bool, group *sync.WaitGroup) {
- address := common.Options.BBSim.ApiAddress
+ address := common.Config.BBSim.ApiAddress
log.Debugf("APIServer listening on %v", address)
lis, err := net.Listen("tcp", address)
if err != nil {
@@ -70,7 +70,7 @@
ctx, cancel := context.WithCancel(ctx)
defer cancel()
- address := common.Options.BBSim.RestApiAddress
+ address := common.Config.BBSim.RestApiAddress
mux := runtime.NewServeMux()
opts := []grpc.DialOption{grpc.WithInsecure()}
@@ -101,8 +101,8 @@
// This server aims to provide compatibility with the previous BBSim version. It is deprecated and will be removed in the future.
func startLegacyApiServer(apiDoneChannel chan bool, group *sync.WaitGroup) {
- grpcAddress := common.Options.BBSim.LegacyApiAddress
- restAddress := common.Options.BBSim.LegacyRestApiAddress
+ grpcAddress := common.Config.BBSim.LegacyApiAddress
+ restAddress := common.Config.BBSim.LegacyRestApiAddress
log.Debugf("Legacy APIServer listening on %v", grpcAddress)
listener, err := net.Listen("tcp", grpcAddress)
@@ -129,15 +129,14 @@
func main() {
- options := common.GetBBSimOpts()
+ common.LoadConfig()
- common.SetLogLevel(log.StandardLogger(), options.BBSim.LogLevel, options.BBSim.LogCaller)
- log.Tracef("BBSim options: %+v", options)
+ common.SetLogLevel(log.StandardLogger(), common.Config.BBSim.LogLevel, common.Config.BBSim.LogCaller)
- if *options.BBSim.CpuProfile != "" {
+ if *common.Config.BBSim.CpuProfile != "" {
// start profiling
- log.Infof("Creating profile file at: %s", *options.BBSim.CpuProfile)
- f, err := os.Create(*options.BBSim.CpuProfile)
+ log.Infof("Creating profile file at: %s", *common.Config.BBSim.CpuProfile)
+ f, err := os.Create(*common.Config.BBSim.CpuProfile)
if err != nil {
log.Fatal(err)
}
@@ -145,37 +144,30 @@
}
log.WithFields(log.Fields{
- "OltID": options.Olt.ID,
- "NumNniPerOlt": options.Olt.NniPorts,
- "NumPonPerOlt": options.Olt.PonPorts,
- "NumOnuPerPon": options.Olt.OnusPonPort,
- "TotalOnus": options.Olt.PonPorts * options.Olt.OnusPonPort,
- "EnableAuth": options.BBSim.EnableAuth,
- "Dhcp": options.BBSim.EnableDhcp,
- "Igmp": options.BBSim.EnableIgmp,
- "Delay": options.BBSim.Delay,
- "Events": options.BBSim.Events,
- "KafkaEventTopic": options.BBSim.KafkaEventTopic,
- "ControlledActivation": options.BBSim.ControlledActivation,
- "EnablePerf": options.BBSim.EnablePerf,
- "CTag": options.BBSim.CTag,
- "CTagAllocation": options.BBSim.CTagAllocation,
- "STag": options.BBSim.STag,
- "STagAllocation": options.BBSim.STagAllocation,
- "SadisFormat": options.BBSim.SadisFormat,
- "DhcpRetry": options.BBSim.DhcpRetry,
- "AuthRetry": options.BBSim.AuthRetry,
+ "OltID": common.Config.Olt.ID,
+ "NumNniPerOlt": common.Config.Olt.NniPorts,
+ "NumPonPerOlt": common.Config.Olt.PonPorts,
+ "NumOnuPerPon": common.Config.Olt.OnusPonPort,
+ "TotalOnus": common.Config.Olt.PonPorts * common.Config.Olt.OnusPonPort,
+ "Delay": common.Config.BBSim.Delay,
+ "Events": common.Config.BBSim.Events,
+ "KafkaEventTopic": common.Config.BBSim.KafkaEventTopic,
+ "ControlledActivation": common.Config.BBSim.ControlledActivation,
+ "EnablePerf": common.Config.BBSim.EnablePerf,
+ "DhcpRetry": common.Config.BBSim.DhcpRetry,
+ "AuthRetry": common.Config.BBSim.AuthRetry,
}).Info("BroadBand Simulator is on")
// control channels, they are only closed when the goroutine needs to be terminated
apiDoneChannel := make(chan bool)
olt := devices.CreateOLT(
- *options,
+ *common.Config,
+ common.Services,
false,
)
- log.Debugf("Created OLT with id: %d", options.Olt.ID)
+ log.Debugf("Created OLT with id: %d", common.Config.Olt.ID)
sigs := make(chan os.Signal, 1)
// stop API servers on SIGTERM
@@ -192,12 +184,12 @@
go startApiServer(apiDoneChannel, &wg)
go startLegacyApiServer(apiDoneChannel, &wg)
log.Debugf("Started APIService")
- if common.Options.BBSim.SadisServer {
+ if common.Config.BBSim.SadisServer {
wg.Add(1)
go sadis.StartRestServer(olt, &wg)
}
- if options.BBSim.Events {
+ if common.Config.BBSim.Events {
// initialize a publisher
if err := common.InitializePublisher(sarama.NewAsyncProducer, olt.ID); err == nil {
// start a go routine which will read from channel and publish on kafka
@@ -211,7 +203,7 @@
defer func() {
log.Info("BroadBand Simulator is off")
- if *options.BBSim.CpuProfile != "" {
+ if *common.Config.BBSim.CpuProfile != "" {
log.Info("Stopping profiler")
pprof.StopCPUProfile()
}
diff --git a/cmd/bbsimctl/bbsimctl.go b/cmd/bbsimctl/bbsimctl.go
index cc05835..08e7b5b 100644
--- a/cmd/bbsimctl/bbsimctl.go
+++ b/cmd/bbsimctl/bbsimctl.go
@@ -38,6 +38,7 @@
commands.RegisterConfigCommands(parser)
commands.RegisterOltCommands(parser)
commands.RegisterONUCommands(parser)
+ commands.RegisterServiceCommands(parser)
commands.RegisterPonCommands(parser)
commands.RegisterCompletionCommands(parser)
commands.RegisterLoggingCommands(parser)
@@ -53,13 +54,6 @@
}
}
- //corderror, ok := err.(corderrors.CordCtlError)
- //if ok {
- // if corderror.ShouldDumpStack() || config.GlobalOptions.Debug {
- // os.Stderr.WriteString("\n" + corderror.Stack())
- // }
- //}
-
fmt.Fprintf(os.Stderr, "%s: %s\n", os.Args[0], err.Error())
os.Exit(1)