Skip to content
Snippets Groups Projects
Commit 6e040b72 authored by Fabian Seidl's avatar Fabian Seidl
Browse files

Resolve "Implement management component with automatic subscriptions to NEs"

See merge request !358
parent 07b29e33
No related branches found
No related tags found
2 merge requests!358Resolve "Implement management component with automatic subscriptions to NEs",!333WIP: Develop
Pipeline #110531 passed
...@@ -23,12 +23,13 @@ cli/gosdnc ...@@ -23,12 +23,13 @@ cli/gosdnc
csbi/resources/csbi csbi/resources/csbi
# controller # controller
controller/config/*_test.toml
controller/configs/testing-gosdn.toml controller/configs/testing-gosdn.toml
controller/configs/gosdn.toml controller/configs/gosdn.toml
controller/configs/development-gosdn.toml controller/configs/development-gosdn.toml
controller/configs/containerlab-gosdn.toml controller/configs/containerlab-gosdn.toml
controller/config/*_test.toml
controller/configs/ci-testing-gosdn.toml controller/configs/ci-testing-gosdn.toml
controller/configs/gNMISubscriptions.txt
controller/stores_testing controller/stores_testing
controller/stores/** controller/stores/**
controller/cmd/gosdn/stores/ controller/cmd/gosdn/stores/
......
package config
import (
"bufio"
"fmt"
"os"
"path/filepath"
"strings"
)
const (
defaultGnmiSubscriptionFilePath = "controller/configs/gNMISubscriptions.txt"
)
var gnmiSubscriptionPaths [][]string
// ReadGnmiSubscriptionPaths reads the paths the watcher should subscribe to provided in a file.
func ReadGnmiSubscriptionPaths() error {
currentDir, err := os.Getwd()
if err != nil {
return err
}
filePath := filepath.Join(currentDir, defaultGnmiSubscriptionFilePath)
f, err := os.Open(filePath)
if err != nil {
return err
}
defer f.Close()
scanner := bufio.NewScanner(f)
for scanner.Scan() {
path := strings.Split(scanner.Text(), "/")
gnmiSubscriptionPaths = append(gnmiSubscriptionPaths, path)
}
fmt.Println(gnmiSubscriptionPaths)
return nil
}
// GetGnmiSubscriptionPaths returns the paths the watcher should subscribe to.
func GetGnmiSubscriptionPaths() [][]string {
return gnmiSubscriptionPaths
}
system/config/hostname
system/config/domain-name
...@@ -74,6 +74,11 @@ func initialize() error { ...@@ -74,6 +74,11 @@ func initialize() error {
return err return err
} }
err = config.ReadGnmiSubscriptionPaths()
if err != nil {
log.Error("Error reading in gNMI subscription paths, can not watch devices automatically: ", err)
}
eventService, err := eventservice.NewEventService() eventService, err := eventservice.NewEventService()
if err != nil { if err != nil {
return err return err
...@@ -107,8 +112,9 @@ func initialize() error { ...@@ -107,8 +112,9 @@ func initialize() error {
} }
c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore) c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore)
// TODO: udpate with actual paths to subscribe to using template/config // TODO: udpate with actual paths to subscribe when using template/config
c.deviceWatcher.SubToDevices([][]string{{"system", "config", "hostname"}}, nil) fmt.Println(config.GetGnmiSubscriptionPaths())
c.deviceWatcher.SubToDevices(config.GetGnmiSubscriptionPaths(), nil)
err = ensureDefaultRoleExists() err = ensureDefaultRoleExists()
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment