Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/database"
// Core is the representation of the controllers core
// deprecated
database database.Database
pndc pndStore
sbic sbiStore
httpServer *http.Server
stopChan chan os.Signal
pndc: pndStore{store{}},
sbic: sbiStore{store{}},
// 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
return err
}
log.WithFields(log.Fields{}).Info("initialisation finished")
for {
select {
case <-time.Tick(time.Minute):
log.Debug("up and running")
}
func shutdown()error{
log.Info("shutting down controller")
return stopHttpServer()
}