From 35ef9f44df9d643391ba9139aa31aafa5d29a09d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Sun, 7 Jul 2024 09:46:43 +0800 Subject: [PATCH] fix(climc): auto enable storage when switch s3 on (#20727) --- cmd/climc/shell/misc/feature.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/cmd/climc/shell/misc/feature.go b/cmd/climc/shell/misc/feature.go index f563eb5e7d..ee71477f97 100644 --- a/cmd/climc/shell/misc/feature.go +++ b/cmd/climc/shell/misc/feature.go @@ -20,6 +20,7 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" "yunion.io/x/pkg/util/sets" + "yunion.io/x/pkg/utils" "yunion.io/x/onecloud/pkg/mcclient" "yunion.io/x/onecloud/pkg/mcclient/modules/yunionconf" @@ -59,6 +60,9 @@ func (g *GlobalSettingsValue) Switch(featureKey string, on bool) { } func init() { + var storageFeatures = []string{ + "s3", "xsky", "ceph", + } var features = []string{ "onestack", "baremetal", @@ -81,9 +85,6 @@ func init() { "cloudpods", "hcso", "nutanix", - "s3", - "ceph", - "xsky", "bill", "auth", "onecloud", @@ -104,6 +105,8 @@ func init() { "sangfor", } + features = append(features, storageFeatures...) + const ( GlobalSettings = "global-settings" SystemScope = "system" @@ -130,10 +133,14 @@ func init() { if len(items.Data) == 0 { // create it if enabled if enable { + value := []string{name} + if utils.IsInStringArray(name, storageFeatures) { + value = append(value, "storage") + } input := map[string]interface{}{ "name": GlobalSettings, "service_id": YunionAgent, - "value": NewGlobalSettingsValue([]string{name}, true), + "value": NewGlobalSettingsValue(value, true), } params := jsonutils.Marshal(input) if _, err := yunionconf.Parameters.Create(s, params); err != nil { @@ -163,6 +170,9 @@ func init() { curConf.Switch(name, false) } else { curConf.Switch(name, true) + if utils.IsInStringArray(name, storageFeatures) { + curConf.Switch("storage", true) + } } id, err := ss.GetString("id") if err != nil {