Skip to content
Snippets Groups Projects

"Overhaul Architecture"

Merged Ghost User requested to merge 67-overhaul-architecture into develop
4 files
+ 43
40
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 8
28
package nucleus
import (
"encoding/gob"
"fmt"
"os"
@@ -33,14 +32,8 @@ func (c *Core) Initialize(IsRunningChannel chan bool) {
if err != nil {
log.Fatal(fmt.Errorf("Fatal error config file: %s \n", err))
}
path := viper.GetString("pnd.path")
gob.Register(&pndImplementation{})
gob.Register(&OpenConfig{})
c.AttachDatabase()
if err := c.loadPNDs(path); err != nil {
log.Info(err)
}
c.CreateSouthboundInterfaces()
c.IsRunning = IsRunningChannel
}
@@ -50,27 +43,14 @@ func (c *Core) AttachDatabase() {
c.database = database.NewDatabaseClient()
}
// TODO: the load and save functions for pnds are just temporary and should be
// moved to the database
// SavePNDs imports the PNDs from last session
func (c *Core) savePNDs(path string) error {
f, err := os.Create(path)
if err != nil {
return err
}
defer f.Close()
return gob.NewEncoder(f).Encode(c.principalNetworkDomains)
}
// loadPNDs imports the PNDs from last session
func (c *Core) loadPNDs(path string) error {
f, err := os.Open(path)
if err != nil {
return err
// CreateSouthboundInterfaces initializes the controller with his SBIs
func (c *Core) CreateSouthboundInterfaces() {
if len(c.southboundInterfaces) == 0 {
sbi := &AristaOC{}
t := &Gnmi{SetNode: sbi.SetNode()}
sbi.SetTransport(t)
c.southboundInterfaces[sbi.SbiIdentifier()] = sbi
}
defer f.Close()
return gob.NewDecoder(f).Decode(&c.principalNetworkDomains)
}
// Shutdown waits for the shutdown signal and gracefully shuts down once it arrived
Loading