From 5ca05eef843548b7ce0b7b97ddd758080ab998d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Fri, 6 Sep 2024 00:38:37 +0800 Subject: [PATCH] fix: support apigateway for cloudpods (#21164) --- pkg/mcclient/cloudpods/cloudpods.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/pkg/mcclient/cloudpods/cloudpods.go b/pkg/mcclient/cloudpods/cloudpods.go index 77073281c9..89e571d994 100644 --- a/pkg/mcclient/cloudpods/cloudpods.go +++ b/pkg/mcclient/cloudpods/cloudpods.go @@ -50,6 +50,7 @@ type ModelManager interface { List(session *mcclient.ClientSession, params jsonutils.JSONObject) (*printutils.ListResult, error) Create(session *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) Delete(session *mcclient.ClientSession, id string, param jsonutils.JSONObject) (jsonutils.JSONObject, error) + DeleteWithParam(session *mcclient.ClientSession, id string, query jsonutils.JSONObject, body jsonutils.JSONObject) (jsonutils.JSONObject, error) PerformAction(session *mcclient.ClientSession, id string, action string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) Get(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) Update(session *mcclient.ClientSession, id string, params jsonutils.JSONObject) (jsonutils.JSONObject, error) @@ -123,7 +124,11 @@ func (self *SCloudpodsClient) auth() error { serviceRegion = region } } - self.s = client.NewSession(context.Background(), serviceRegion, "", "publicURL", token) + endpoint := "publicURL" + if strings.Contains(self.authURL, "api/s/identity/v3") { + endpoint = "apigateway" + } + self.s = client.NewSession(context.Background(), serviceRegion, "", endpoint, token) if !self.s.GetToken().HasSystemAdminPrivilege() { return fmt.Errorf("no system admin privilege") } @@ -176,7 +181,7 @@ func (self *SCloudpodsClient) delete(manager ModelManager, id string) error { return nil } params := map[string]interface{}{"override_pending_delete": true} - _, err := manager.Delete(self.s, id, jsonutils.Marshal(params)) + _, err := manager.DeleteWithParam(self.s, id, jsonutils.Marshal(params), nil) return err }