Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/database"
var coreLock sync.RWMutex
var coreOnce sync.Once
// Core is the representation of the controllers core
// deprecated
database database.Database
pndc pndStore
sbic sbiStore
httpServer *http.Server
stopChan chan os.Signal
database: database.Database{},
pndc: pndStore{store{}},
sbic: sbiStore{store{}},
stopChan: make(chan os.Signal, 1),
// Setting up signal capturing
signal.Notify(c.stopChan, os.Interrupt)
}
// initialize does start-up housekeeping like reading controller config files
func initialize() error {
if err := createSouthboundInterfaces(); err != nil {
if err := httpAPI(); err != nil {
// attachDatabase connects to the database and passes the connection to the controller core
// createSouthboundInterfaces initializes the controller with its supported SBIs
sbi := &OpenConfig{id: uuid.New()}
if err := c.sbic.add(sbi); err != nil {
return err
}
return createPrincipalNetworkDomain(sbi)
}
// createPrincipalNetworkDomain initializes the controller with an initial PND
func createPrincipalNetworkDomain(sbi SouthboundInterface) error {
pnd, err := NewPND("base", "gosdn base pnd", uuid.New(), sbi)
if err != nil {
return err
}
err = c.pndc.add(pnd)
if err != nil {
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")
}
log.Info("shutting down controller")
return stopHttpServer()