Skip to content

Commit

Permalink
Merge pull request #88 from irappa-pattar/odim-5349
Browse files Browse the repository at this point in the history
ODIM-62 update aci plugin message bus config
  • Loading branch information
shivacharanms authored Nov 29, 2021
2 parents e39afbf + 6e7f3ae commit 2544ada
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 9 deletions.
31 changes: 24 additions & 7 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
Expand Down Expand Up @@ -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
}

Expand Down
3 changes: 3 additions & 0 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@
},
"MessageBusConf": {
"MessageQueueConfigFilePath": "",
"MessageBusAddress": "localhost",
"MessageBusPort": "6379",
"HASet": "redisSentinel",
"MessageBusType": "Kafka",
"MessageBusQueue": ["REDFISH-EVENTS-TOPIC"]
},
Expand Down
6 changes: 6 additions & 0 deletions config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
1 change: 1 addition & 0 deletions install/Kubernetes/helmcharts/aciplugin-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ aciplugin:
odimURL:
odimUserName:
odimPassword:
messageBusType: Kafka
12 changes: 10 additions & 2 deletions install/Kubernetes/helmcharts/aciplugin/templates/configmaps.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
1 change: 1 addition & 0 deletions install/Kubernetes/helmcharts/aciplugin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ aciplugin:
odimURL:
odimUserName:
odimPassword:
messageBusType: Kafka

0 comments on commit 2544ada

Please sign in to comment.