Starting BBSim API Server
Adding SerialNumber to GetDeviceInfo response (it's now required by
VOLTHA)
Change-Id: If726b5c313b6a424f54682aef68c001f6de51b57
diff --git a/internal/bbsim/bbsim.go b/internal/bbsim/bbsim.go
index d0acc14..589d557 100644
--- a/internal/bbsim/bbsim.go
+++ b/internal/bbsim/bbsim.go
@@ -2,8 +2,12 @@
import (
"flag"
+ "gerrit.opencord.org/bbsim/api/bbsim"
"gerrit.opencord.org/bbsim/internal/bbsim/devices"
log "github.com/sirupsen/logrus"
+ "google.golang.org/grpc"
+ "google.golang.org/grpc/reflection"
+ "net"
"sync"
)
@@ -25,6 +29,22 @@
return o
}
+func startApiServer() {
+ // TODO make configurable
+ address := "0.0.0.0:50070"
+ log.Debugf("APIServer Listening on: %v", address)
+ lis, err := net.Listen("tcp", address)
+ if err != nil {
+ log.Fatalf("APIServer failed to listen: %v", err)
+ }
+ grpcServer := grpc.NewServer()
+ bbsim.RegisterBBSimServer(grpcServer, BBSimServer{})
+
+ reflection.Register(grpcServer)
+
+ go grpcServer.Serve(lis)
+}
+
func init() {
log.SetLevel(log.DebugLevel)
//log.SetReportCaller(true)
@@ -42,11 +62,13 @@
}).Info("BroadBand Simulator is on")
wg := sync.WaitGroup{}
- wg.Add(1)
+ wg.Add(2)
go devices.CreateOLT(options.OltID, options.NumNniPerOlt, options.NumPonPerOlt, options.NumOnuPerPon)
log.Debugf("Created OLT with id: %d", options.OltID)
+ go startApiServer()
+ log.Debugf("Started APIService")
wg.Wait()