mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
add rpc-global-settings-dictionary
This commit is contained in:
@@ -14,6 +14,15 @@
|
||||
|
||||
package modules
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
)
|
||||
|
||||
type ParametersManager struct {
|
||||
ResourceManager
|
||||
}
|
||||
@@ -29,3 +38,20 @@ func init() {
|
||||
)}
|
||||
register(&Parameters)
|
||||
}
|
||||
|
||||
func (this *ParametersManager) GetGlobalSettings(s *mcclient.ClientSession, params jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
adminSession := auth.GetAdminSession(context.Background(), "", "")
|
||||
p := jsonutils.NewDict()
|
||||
p.Add(jsonutils.NewString("system"), "scope")
|
||||
p.Add(jsonutils.NewString("name"), "global-settings")
|
||||
parameters, err := this.ListInContext(adminSession, p, &ServicesV3, "yunionagent")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if parameters.Total == 0 {
|
||||
return nil, httperrors.NewNotFoundError("global-settings not found")
|
||||
}
|
||||
|
||||
return parameters.Data[0], nil
|
||||
}
|
||||
Reference in New Issue
Block a user