diff --git a/config/config.go b/config/config.go index eaefb75..e35a277 100644 --- a/config/config.go +++ b/config/config.go @@ -82,6 +82,9 @@ type EventConf struct { // MessageBusConf will have configuration data of MessageBusConf type MessageBusConf struct { MessageQueueConfigFilePath string `json:"MessageQueueConfigFilePath"` // Message Queue Config File Path + MessageBusAddress string `json:"MessageBusAddress"` + MessageBusPort string `json:"MessageBusPort"` + HASet string `json:"HASet"` EmbType string `json:"MessageBusType"` EmbQueue []string `json:"MessageBusQueue"` } @@ -265,17 +268,31 @@ func checkMessageBusConf() error { if Data.MessageBusConf == nil { return fmt.Errorf("no value found for MessageBusConf") } - if _, err := os.Stat(Data.MessageBusConf.MessageQueueConfigFilePath); err != nil { - return fmt.Errorf("value check failed for MessageQueueConfigFilePath:%s with %v", Data.MessageBusConf.MessageQueueConfigFilePath, err) - } if Data.MessageBusConf.EmbType == "" { - log.Info("no value set for MessageBusType, setting default value") + log.Warn("No value set for MessageBusType, setting default value") Data.MessageBusConf.EmbType = "Kafka" } - if len(Data.MessageBusConf.EmbQueue) <= 0 { - log.Info("no value set for MessageBusQueue, setting default value") - Data.MessageBusConf.EmbQueue = []string{"REDFISH-EVENTS-TOPIC"} + if Data.MessageBusConf.EmbType == "Kafka" { + if _, err := os.Stat(Data.MessageBusConf.MessageQueueConfigFilePath); err != nil { + return fmt.Errorf("Value check failed for MessageQueueConfigFilePath:%s with %v", Data.MessageBusConf.MessageQueueConfigFilePath, err) + } + if len(Data.MessageBusConf.EmbQueue) <= 0 { + log.Warn("No value set for MessageBusQueue, setting default value") + Data.MessageBusConf.EmbQueue = []string{"REDFISH-EVENTS-TOPIC"} + } + } + if Data.MessageBusConf.EmbType == "RedisStream" { + if Data.MessageBusConf.MessageBusAddress == "" { + return fmt.Errorf("error: no value configured for MessageBusAddress") + } + if Data.MessageBusConf.MessageBusPort == "" { + return fmt.Errorf("error: no value configured for MessageBusPort") + } } + if !AllowedMessageBusTypes[Data.MessageBusConf.EmbType] { + return fmt.Errorf("error: invalid value configured for MessageBusType") + } + return nil } diff --git a/config/config.json b/config/config.json index df2f226..7c57fbc 100644 --- a/config/config.json +++ b/config/config.json @@ -48,6 +48,9 @@ }, "MessageBusConf": { "MessageQueueConfigFilePath": "", + "MessageBusAddress": "localhost", + "MessageBusPort": "6379", + "HASet": "redisSentinel", "MessageBusType": "Kafka", "MessageBusQueue": ["REDFISH-EVENTS-TOPIC"] }, diff --git a/config/constants.go b/config/constants.go index 83d72a4..5adfb7e 100644 --- a/config/constants.go +++ b/config/constants.go @@ -22,3 +22,9 @@ const ( // DefaultDBMinIdleConns - default MinIdleConns value DefaultDBMinIdleConns = 10 ) + +// AllowedMessageBusTypes is for checking for message types are allowed +var AllowedMessageBusTypes = map[string]bool{ + "Kafka": true, + "RedisStream": true, +} diff --git a/install/Kubernetes/helmcharts/aciplugin-config.yaml b/install/Kubernetes/helmcharts/aciplugin-config.yaml index 6f18352..a0df425 100755 --- a/install/Kubernetes/helmcharts/aciplugin-config.yaml +++ b/install/Kubernetes/helmcharts/aciplugin-config.yaml @@ -12,3 +12,4 @@ aciplugin: odimURL: odimUserName: odimPassword: + messageBusType: Kafka diff --git a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml index 6cd7fa7..386883c 100755 --- a/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml +++ b/install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml @@ -60,8 +60,16 @@ data: }, "MessageBusConf": { "MessageQueueConfigFilePath": "/etc/aciplugin_config/platformconfig.toml", - "MessageBusType": "Kafka", - "MessageBusQueue": ["ACI-EVENTS-TOPIC"] + {{ if eq .Values.odimra.haDeploymentEnabled false }} + "MessageBusAddress": "redis-inmemory", + "HASet": "", + {{ else }} + "MessageBusAddress": "redis-ha-inmemory", + "HASet": "redisSentinel", + {{ end }} + "MessageBusPort": "6379", + "MessageBusType": {{ .Values.aciplugin.messageBusType | quote }}, + "MessageBusQueue": ["ACI-EVENTS-TOPIC"] }, "URLTranslation": { "NorthBoundURL": { diff --git a/install/Kubernetes/helmcharts/aciplugin/values.yaml b/install/Kubernetes/helmcharts/aciplugin/values.yaml index a7779b8..0144dfe 100755 --- a/install/Kubernetes/helmcharts/aciplugin/values.yaml +++ b/install/Kubernetes/helmcharts/aciplugin/values.yaml @@ -20,3 +20,4 @@ aciplugin: odimURL: odimUserName: odimPassword: + messageBusType: Kafka