Newer
Older
"os"
"code.fbi.h-da.de/cocsn/gosdn/database"
// Core is the representation of the controllers core
// deprecated
database database.Database
IsRunning chan bool
//Initialize does start-up housekeeping like reading controller config files
func (c *Core) Initialize(IsRunningChannel chan bool) error {
c.sbic = sbiStore{
store{},
}
c.pndc = pndStore{
store{},
}
// Set config path and read config
viper.SetConfigName("gosdn")
viper.SetConfigType("toml")
viper.AddConfigPath("/usr/local/etc/gosdn/")
viper.AddConfigPath("./configs/")
err := viper.ReadInConfig()
if err != nil {
if err := c.CreateSouthboundInterfaces(); err != nil {
return err
}
c.IsRunning = IsRunningChannel
// AttachDatabase connects to the database and passes the connection to the controller core
// CreateSouthboundInterfaces initializes the controller with its supported SBIs
func (c *Core) CreateSouthboundInterfaces() error {
if err := c.sbic.add(&OpenConfig{id: uuid.New()}); err != nil {
if err := c.sbic.add(&OpenConfig{id: uuid.New()}); err != nil {
return err
}
return nil
// Shutdown waits for the shutdown signal and gracefully shuts down once it arrived
log.Info("Received shutdown signal. Shutting down")
log.Info("Shutdown complete")
os.Exit(0)