Newer
Older
"code.fbi.h-da.de/cocsn/gosdn/database"
CliSocket string
DatabaseSocket string
DatabaseUser string
DatabasePassword string
DatabaseCrypto bool
ConfigPath string
// Core is the representation of the controllers core
southboundInterfaces map[string]SouthboundInterface
prinipalNetworkDomains map[uuid.UUID]PrincipalNetworkDomain
database database.Database
config controllerConfig
IsRunning chan bool
//Init does start-up housekeeping like reading controller config files
func (c *Core) Init(socket, configFileController, configFileClient string, IsRunningChannel chan bool) {
if err := c.readControllerConfig(configFileController); err != nil {
if socket != "localhost:55055" {
c.config.CliSocket = socket
c.IsRunning = IsRunningChannel
// AttachDatabase connects to the database and passes the connectio to the controller core
c.database = database.NewDatabaseClient(c.config.DatabaseSocket, c.config.DatabaseUser, c.config.DatabasePassword, c.config.DatabaseCrypto)
// Shutdown waits for the shutdown signal and gracefully shuts down once it arrived
log.Info("Received shutdown signal. Shutting down")
enc := toml.NewEncoder(f)
if err := enc.Encode(c.config); err != nil {
log.Info("Shutdown complete")
os.Exit(0)
func (c *Core) readControllerConfig(configFileController string) error {
if configFileController == "" {
}
if _, err := os.Stat(configFileController); err != nil {
return err
}
c.config = controllerConfig{}
if _, err := toml.DecodeFile(configFileController, &c.config); err != nil {
return err
}
if c.config.ConfigPath == "" {
c.config.ConfigPath = configFileController
}
return nil
}