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

Resolve "Running the controller via VSCode uses different paths for...

Resolve "Running the controller via VSCode uses different paths for configs/stores/etc. which leads to some problems"

See merge request !360
parent 5f445a11
No related branches found
No related tags found
2 merge requests!360Resolve "Running the controller via VSCode uses different paths for configs/stores/etc. which leads to some problems",!333WIP: Develop
Pipeline #110750 passed
...@@ -21,6 +21,7 @@ const ( ...@@ -21,6 +21,7 @@ const (
jwtDurationKey = "defaultJWTDuration" jwtDurationKey = "defaultJWTDuration"
defaultJWTDuration = time.Hour * 24 defaultJWTDuration = time.Hour * 24
jwtSecretKey = "jwtSecret" jwtSecretKey = "jwtSecret"
gNMISubscriptionsFilePathKey = "gNMISubscriptionsPath"
// RabbitMQ Broker // RabbitMQ Broker
amqpPrefixKey = "amqpPrefix" amqpPrefixKey = "amqpPrefix"
...@@ -72,6 +73,9 @@ var AMQPHost string ...@@ -72,6 +73,9 @@ var AMQPHost string
// AMQPPort is the amqp port // AMQPPort is the amqp port
var AMQPPort string var AMQPPort string
// GNMISubscriptionsFilePath is the path to the file used for automated subscriptions
var GNMISubscriptionsFilePath string
// Init gets called on module import // Init gets called on module import
func Init() { func Init() {
err := InitializeConfig() err := InitializeConfig()
...@@ -125,6 +129,8 @@ func InitializeConfig() error { ...@@ -125,6 +129,8 @@ func InitializeConfig() error {
JWTSecret = viper.GetString(jwtSecretKey) JWTSecret = viper.GetString(jwtSecretKey)
GNMISubscriptionsFilePath = getStringFromViper(gNMISubscriptionsFilePathKey)
loadAMQPConfig() loadAMQPConfig()
if err := viper.WriteConfig(); err != nil { if err := viper.WriteConfig(); err != nil {
......
...@@ -16,12 +16,18 @@ var gnmiSubscriptionPaths [][]string ...@@ -16,12 +16,18 @@ var gnmiSubscriptionPaths [][]string
// ReadGnmiSubscriptionPaths reads the paths the watcher should subscribe to provided in a file. // ReadGnmiSubscriptionPaths reads the paths the watcher should subscribe to provided in a file.
func ReadGnmiSubscriptionPaths() error { func ReadGnmiSubscriptionPaths() error {
currentDir, err := os.Getwd() var filePath string
if err != nil {
return err
}
filePath := filepath.Join(currentDir, defaultGnmiSubscriptionFilePath) if GNMISubscriptionsFilePath != "" {
filePath = GNMISubscriptionsFilePath
} else {
currentDir, err := os.Getwd()
if err != nil {
return err
}
filePath = filepath.Join(currentDir, defaultGnmiSubscriptionFilePath)
}
f, err := os.Open(filePath) f, err := os.Open(filePath)
if err != nil { if err != nil {
......
...@@ -11,6 +11,8 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec" ...@@ -11,6 +11,8 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
socket = ":55055" socket = ":55055"
databaseConnection = "mongodb://root:example@clab-gosdn_csbi_arista_base-mongodb:27017" databaseConnection = "mongodb://root:example@clab-gosdn_csbi_arista_base-mongodb:27017"
filesystemPathToStores = "stores" filesystemPathToStores = "stores"
gNMISubscriptionsPath = "controller/configs/gNMISubscriptions.txt"
amqpPrefix = "amqp://" amqpPrefix = "amqp://"
amqpUser = "guest" amqpUser = "guest"
......
...@@ -11,7 +11,7 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec" ...@@ -11,7 +11,7 @@ pnduuid = "bf8160d4-4659-4a1b-98fd-f409a04111ec"
socket = ":55055" socket = ":55055"
databaseConnection = "mongodb://root:example@localhost:27017" databaseConnection = "mongodb://root:example@localhost:27017"
filesystemPathToStores = "stores" filesystemPathToStores = "stores"
gNMISubscriptionsPath = "controller/configs/gNMISubscriptions.txt"
amqpPrefix = "amqp://" amqpPrefix = "amqp://"
amqpUser = "guest" amqpUser = "guest"
......
...@@ -112,8 +112,6 @@ func initialize() error { ...@@ -112,8 +112,6 @@ func initialize() error {
} }
c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore) c.deviceWatcher = nucleus.NewDeviceWatcher(c.pndStore)
// TODO: udpate with actual paths to subscribe when using template/config
fmt.Println(config.GetGnmiSubscriptionPaths())
c.deviceWatcher.SubToDevices(config.GetGnmiSubscriptionPaths(), nil) c.deviceWatcher.SubToDevices(config.GetGnmiSubscriptionPaths(), nil)
err = ensureDefaultRoleExists() err = ensureDefaultRoleExists()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment