X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=pkg%2Fxapp%2Fconfig.go;h=56986d31caf0a2282a12a630ef7517adfb18c605;hb=8e5efa4f44f646b5389db3ccb5588d41a185e598;hp=8ab79418ce09d1988755d90049362b5c97d73e4e;hpb=827a6410631045b503ce098de6683c6916c09842;p=ric-plt%2Fxapp-frame.git diff --git a/pkg/xapp/config.go b/pkg/xapp/config.go index 8ab7941..56986d3 100755 --- a/pkg/xapp/config.go +++ b/pkg/xapp/config.go @@ -65,7 +65,7 @@ func LoadConfig() (l *Log) { updateMTypes := func() { var mtypes []mtype - viper.UnmarshalKey("rmr.mtypes", &mtypes) + viper.UnmarshalKey("messaging.mtypes", &mtypes) if len(mtypes) > 0 { l.Info("Config mtypes before RICMessageTypes:%d RicMessageTypeToName:%d", len(RICMessageTypes), len(RicMessageTypeToName)) @@ -124,13 +124,17 @@ func AddConfigChangeListener(f ConfigChangeCB) { func PublishConfigChange(appName, eventJson string) error { channel := fmt.Sprintf("CM_UPDATE:%s", appName) - if err := Sdl.StoreAndPublish(channel, eventJson, appName, eventJson); err != nil { + if err := SdlStorage.StoreAndPublish(getCmSdlNs(), channel, eventJson, appName, eventJson); err != nil { Logger.Error("Sdl.Store failed: %v", err) return err } return nil } +func ReadConfig(appName string) (map[string]interface{}, error) { + return SdlStorage.Read(getCmSdlNs(), appName) +} + func GetPortData(pname string) (d PortData) { var getPolicies = func(policies []interface{}) (plist []int) { for _, p := range policies { @@ -139,6 +143,16 @@ func GetPortData(pname string) (d PortData) { return plist } + if viper.IsSet("messaging") == false { + if pname == "http" { + d.Port = 8080 + } + if pname == "rmrdata" { + d.Port = 4560 + } + return + } + for _, v := range viper.GetStringMap("messaging")["ports"].([]interface{}) { if n, ok := v.(map[string]interface{})["name"].(string); ok && n == pname { d.Name = n @@ -168,8 +182,12 @@ func GetPortData(pname string) (d PortData) { return } +func getCmSdlNs() string { + return fmt.Sprintf("cm/%s", viper.GetString("name")) +} + func (*Configurator) SetSDLNotificationCB(appName string, sdlNotificationCb SDLNotificationCB) error { - return Sdl.Subscribe(sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName)) + return SdlStorage.Subscribe(getCmSdlNs(), sdlNotificationCb, fmt.Sprintf("CM_UPDATE:%s", appName)) } func (*Configurator) GetString(key string) string { @@ -199,3 +217,7 @@ func (*Configurator) GetStringSlice(key string) []string { func (*Configurator) GetStringMap(key string) map[string]interface{} { return viper.GetStringMap(key) } + +func (*Configurator) IsSet(key string) bool { + return viper.IsSet(key) +}