Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/interfaces/southbound"
"github.com/google/uuid"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
"google.golang.org/grpc"
pb "code.fbi.h-da.de/cocsn/api/go/gosdn/core"
ppb "code.fbi.h-da.de/cocsn/api/go/gosdn/pnd"
spb "code.fbi.h-da.de/cocsn/api/go/gosdn/southbound"
nbi "code.fbi.h-da.de/cocsn/gosdn/northbound/server"
var coreLock sync.RWMutex
var coreOnce sync.Once
// Core is the representation of the controller's core
// deprecated
database database.Database
grpcServer *grpc.Server
nbi *nbi.NorthboundInterface
// Setting up signal capturing
signal.Notify(c.stopChan, os.Interrupt)
}
// initialize does start-up housekeeping like reading controller config files
func initialize() error {
}
func startGrpcServer() error {
sock := viper.GetString("socket")
lis, err := net.Listen("tcp", sock)
if err != nil {
return err
}
c.grpcServer = grpc.NewServer()
c.nbi = nbi.NewNBI(c.pndc)
pb.RegisterCoreServer(c.grpcServer, c.nbi.Core)
ppb.RegisterPndServer(c.grpcServer, c.nbi.Pnd)
go func() {
if err := c.grpcServer.Serve(lis); err != nil {
log.Fatal(err)
}
}()
// createSouthboundInterfaces initializes the controller with its supported SBIs
return createPrincipalNetworkDomain(sbi)
}
// createPrincipalNetworkDomain initializes the controller with an initial PND
func createPrincipalNetworkDomain(s southbound.SouthboundInterface) error {
pnd, err := nucleus.NewPND("base", "gosdn base pnd", uuid.New(), s)
return err
}
return nil
// Run calls initialize to start the controller
initError = initialize()
})
if initError != nil {
log.WithFields(log.Fields{}).Error(initError)
return initError
}
log.WithFields(log.Fields{}).Info("initialisation finished")
for {
select {
case <-c.stopChan:
return shutdown()
case <-time.Tick(time.Minute):
log.Debug("up and running")
}