mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-19 02:37:24 +08:00
Automatic merge from release/2.6.0 -> release/2.7.0
* commit 'f0f6172156f0c693117ee6dc77c9c54bc4f942ba': lbagent: fix corpus versioning mcclient: options: ignore ID when converting to params lbagent: telegraf: add params influx_db_output_unsafe_ssl mcclient: lbagent: allow setting telegraf config template lb: 不记录来自lbagent的GET查询请求 treewide: s/HasSystemAdminPrivelege/HasSystemAdminPrivilege/g
This commit is contained in:
@@ -549,6 +549,12 @@ func (dispatcher *DBModelDispatcher) List(ctx context.Context, query jsonutils.J
|
||||
log.Errorf("Fail to list items: %s", err)
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
if userCred.HasSystemAdminPrivilege() && dispatcher.modelManager.ListSkipLog(ctx, userCred, query) {
|
||||
appParams := appsrv.AppContextGetParams(ctx)
|
||||
if appParams != nil {
|
||||
appParams.SkipLog = true
|
||||
}
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
|
||||
@@ -681,6 +687,12 @@ func (dispatcher *DBModelDispatcher) Get(ctx context.Context, idStr string, quer
|
||||
if !isAllow {
|
||||
return nil, httperrors.NewForbiddenError("Not allow to get details")
|
||||
}
|
||||
if userCred.HasSystemAdminPrivilege() && dispatcher.modelManager.GetSkipLog(ctx, userCred, query) {
|
||||
appParams := appsrv.AppContextGetParams(ctx)
|
||||
if appParams != nil {
|
||||
appParams.SkipLog = true
|
||||
}
|
||||
}
|
||||
return getModelItemDetails(dispatcher.modelManager, model, ctx, userCred, query, isHead)
|
||||
}
|
||||
|
||||
|
||||
@@ -70,6 +70,8 @@ type IModelManager interface {
|
||||
FetchCreateHeaderData(ctx context.Context, header http.Header) (jsonutils.JSONObject, error)
|
||||
FetchUpdateHeaderData(ctx context.Context, header http.Header) (jsonutils.JSONObject, error)
|
||||
IsCustomizedGetDetailsBody() bool
|
||||
ListSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool
|
||||
GetSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool
|
||||
}
|
||||
|
||||
type IModel interface {
|
||||
|
||||
@@ -185,6 +185,14 @@ func (manager *SModelBaseManager) IsCustomizedGetDetailsBody() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) ListSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (manager *SModelBaseManager) GetSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (model *SModelBase) GetId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
@@ -322,7 +322,7 @@ func (manager *SPolicyManager) explainPolicyInternal(userCred mcclient.TokenCred
|
||||
if !consts.IsRbacEnabled() {
|
||||
if !isAdmin {
|
||||
return isAdmin, reqStrs, rbacutils.OwnerAllow, nil
|
||||
} else if isAdmin && userCred.HasSystemAdminPrivelege() {
|
||||
} else if isAdmin && userCred.HasSystemAdminPrivilege() {
|
||||
return isAdmin, reqStrs, rbacutils.AdminAllow, nil
|
||||
} else {
|
||||
return isAdmin, reqStrs, rbacutils.Deny, httperrors.NewForbiddenError("operation not allowed")
|
||||
@@ -361,7 +361,7 @@ func (manager *SPolicyManager) ExplainRpc(userCred mcclient.TokenCredential, par
|
||||
}
|
||||
|
||||
func (manager *SPolicyManager) IsAdminCapable(userCred mcclient.TokenCredential) bool {
|
||||
if !consts.IsRbacEnabled() && userCred.HasSystemAdminPrivelege() {
|
||||
if !consts.IsRbacEnabled() && userCred.HasSystemAdminPrivilege() {
|
||||
return true
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,11 @@ type SPolicyTokenCredential struct {
|
||||
mcclient.TokenCredential
|
||||
}
|
||||
|
||||
func (self *SPolicyTokenCredential) HasSystemAdminPrivelege() bool {
|
||||
func (self *SPolicyTokenCredential) HasSystemAdminPrivilege() bool {
|
||||
if consts.IsRbacEnabled() {
|
||||
return PolicyManager.IsAdminCapable(self.TokenCredential)
|
||||
}
|
||||
return self.TokenCredential.HasSystemAdminPrivelege()
|
||||
return self.TokenCredential.HasSystemAdminPrivilege()
|
||||
}
|
||||
|
||||
func (self *SPolicyTokenCredential) IsAdminAllow(service string, resource string, action string, extra ...string) bool {
|
||||
|
||||
@@ -255,3 +255,8 @@ const (
|
||||
LB_CHARGE_TYPE_BY_BANDWIDTH = "bandwidth"
|
||||
LB_CHARGE_TYPE_BY_HOUR = "hour"
|
||||
)
|
||||
|
||||
const (
|
||||
LBAGENT_QUERY_ORIG_KEY = "_orig"
|
||||
LBAGENT_QUERY_ORIG_VAL = "lbagent"
|
||||
)
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/compute/consts"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -28,3 +29,24 @@ type SLoadbalancerNotifier struct{}
|
||||
func (n *SLoadbalancerNotifier) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerProjId string, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
return
|
||||
}
|
||||
|
||||
type SLoadbalancerLogSkipper struct{}
|
||||
|
||||
func (lls SLoadbalancerLogSkipper) skipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
data, ok := query.(*jsonutils.JSONDict)
|
||||
if !ok {
|
||||
return false
|
||||
}
|
||||
if val, _ := data.GetString(consts.LBAGENT_QUERY_ORIG_KEY); val != consts.LBAGENT_QUERY_ORIG_VAL {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (lls SLoadbalancerLogSkipper) ListSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return lls.skipLog(ctx, userCred, query)
|
||||
}
|
||||
|
||||
func (lls SLoadbalancerLogSkipper) GetSkipLog(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return lls.skipLog(ctx, userCred, query)
|
||||
}
|
||||
|
||||
@@ -83,6 +83,7 @@ func (aclEntries *SLoadbalancerAclEntries) Validate(data *jsonutils.JSONDict) er
|
||||
}
|
||||
|
||||
type SLoadbalancerAclManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SSharableVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerAgentManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SStandaloneResourceBaseManager
|
||||
}
|
||||
|
||||
@@ -78,9 +79,10 @@ type SLoadbalancerAgentParamsHaproxy struct {
|
||||
}
|
||||
|
||||
type SLoadbalancerAgentParamsTelegraf struct {
|
||||
InfluxDbOutputUrl string
|
||||
InfluxDbOutputName string
|
||||
HaproxyInputInterval int
|
||||
InfluxDbOutputUrl string
|
||||
InfluxDbOutputName string
|
||||
InfluxDbOutputUnsafeSsl bool
|
||||
HaproxyInputInterval int
|
||||
}
|
||||
|
||||
type SLoadbalancerAgentParams struct {
|
||||
@@ -525,6 +527,7 @@ listen stats
|
||||
[[outputs.influxdb]]
|
||||
urls = ["{{ .telegraf.influx_db_output_url }}"]
|
||||
database = "{{ .telegraf.influx_db_output_name }}"
|
||||
insecure_skip_verify = {{ .telegraf.influx_db_output_unsafe_ssl }}
|
||||
|
||||
[[inputs.haproxy]]
|
||||
interval = "{{ .telegraf.haproxy_input_interval }}s"
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerBackendGroupManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerBackendManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerCertificateManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerListenerRuleManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerListenerManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
)
|
||||
|
||||
type SLoadbalancerManager struct {
|
||||
SLoadbalancerLogSkipper
|
||||
db.SVirtualResourceBaseManager
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,7 @@ func getSnapshotPath(diskId, snapshotId string) string {
|
||||
|
||||
func inputCheck(ctx context.Context) (string, error) {
|
||||
var userCred = auth.FetchUserCredential(ctx, nil)
|
||||
if !userCred.HasSystemAdminPrivelege() {
|
||||
if !userCred.HasSystemAdminPrivilege() {
|
||||
return "", httperrors.NewForbiddenError("System admin only")
|
||||
}
|
||||
|
||||
|
||||
+5
-1
@@ -6,8 +6,10 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/compute/consts"
|
||||
agentmodels "yunion.io/x/onecloud/pkg/lbagent/models"
|
||||
agentutils "yunion.io/x/onecloud/pkg/lbagent/utils"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
@@ -71,7 +73,9 @@ func (h *ApiHelper) adminClientSession(ctx context.Context) *mcclient.ClientSess
|
||||
|
||||
func (h *ApiHelper) agentPeekOnce(ctx context.Context) (*models.LoadbalancerAgent, error) {
|
||||
s := h.adminClientSession(ctx)
|
||||
data, err := modules.LoadbalancerAgents.Get(s, h.opts.ApiLbagentId, nil)
|
||||
params := jsonutils.NewDict()
|
||||
params.Set(consts.LBAGENT_QUERY_ORIG_KEY, jsonutils.NewString(consts.LBAGENT_QUERY_ORIG_VAL))
|
||||
data, err := modules.LoadbalancerAgents.Get(s, h.opts.ApiLbagentId, params)
|
||||
if err != nil {
|
||||
err := fmt.Errorf("agent get error: %s", err)
|
||||
return nil, err
|
||||
|
||||
@@ -55,9 +55,10 @@ func NewAgentParams(agent *models.LoadbalancerAgent) (*AgentParams, error) {
|
||||
"log_normal": agent.Params.Haproxy.LogNormal,
|
||||
}
|
||||
dataTelegraf := map[string]interface{}{
|
||||
"influx_db_output_url": agent.Params.Telegraf.InfluxDbOutputUrl,
|
||||
"influx_db_output_name": agent.Params.Telegraf.InfluxDbOutputName,
|
||||
"haproxy_input_interval": agent.Params.Telegraf.HaproxyInputInterval,
|
||||
"influx_db_output_url": agent.Params.Telegraf.InfluxDbOutputUrl,
|
||||
"influx_db_output_name": agent.Params.Telegraf.InfluxDbOutputName,
|
||||
"influx_db_output_unsafe_ssl": agent.Params.Telegraf.InfluxDbOutputUnsafeSsl,
|
||||
"haproxy_input_interval": agent.Params.Telegraf.HaproxyInputInterval,
|
||||
}
|
||||
data := map[string]map[string]interface{}{
|
||||
"agent": dataAgent,
|
||||
|
||||
@@ -24,6 +24,7 @@ type LoadbalancerCorpus struct {
|
||||
|
||||
func NewEmptyLoadbalancerCorpus() *LoadbalancerCorpus {
|
||||
return &LoadbalancerCorpus{
|
||||
CorpusVersion: CORPUS_VERSION,
|
||||
ModelSets: NewModelSets(),
|
||||
ModelSetsMaxUpdatedAt: NewModelSetsMaxUpdatedAt(),
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"yunion.io/x/pkg/util/timeutils"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/compute/consts"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/models"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
@@ -105,6 +106,7 @@ func GetModels(opts *GetModelsOptions) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("%s: making list params: %s", manKeyPlural, err)
|
||||
}
|
||||
params.Set(consts.LBAGENT_QUERY_ORIG_KEY, jsonutils.NewString(consts.LBAGENT_QUERY_ORIG_VAL))
|
||||
|
||||
entriesJson := []jsonutils.JSONObject{}
|
||||
for {
|
||||
|
||||
@@ -195,9 +195,10 @@ type LoadbalancerAgentParamsHaproxy struct {
|
||||
}
|
||||
|
||||
type LoadbalancerAgentParamsTelegraf struct {
|
||||
InfluxDbOutputUrl string
|
||||
InfluxDbOutputName string
|
||||
HaproxyInputInterval int
|
||||
InfluxDbOutputUrl string
|
||||
InfluxDbOutputName string
|
||||
InfluxDbOutputUnsafeSsl bool
|
||||
HaproxyInputInterval int
|
||||
}
|
||||
|
||||
type LoadbalancerAgentParams struct {
|
||||
|
||||
@@ -34,7 +34,7 @@ func NewBaseManager(serviceType, endpointType, version string, columns, adminCol
|
||||
|
||||
func (this *BaseManager) GetColumns(session *mcclient.ClientSession) []string {
|
||||
cols := this.columns
|
||||
if session.HasSystemAdminPrivelege() && len(this.adminColumns) > 0 {
|
||||
if session.HasSystemAdminPrivilege() && len(this.adminColumns) > 0 {
|
||||
cols = append(cols, this.adminColumns...)
|
||||
}
|
||||
return cols
|
||||
|
||||
@@ -63,7 +63,7 @@ type LoadbalancerAclCreateOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerAclGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerAclListOptions struct {
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
type LoadbalancerAgentParamsOptions struct {
|
||||
KeepalivedConfTmpl string
|
||||
HaproxyConfTmpl string
|
||||
TelegrafConfTmpl string
|
||||
|
||||
VrrpPriority *int // required
|
||||
VrrpVirtualRouterId *int // required
|
||||
@@ -25,9 +26,10 @@ type LoadbalancerAgentParamsOptions struct {
|
||||
HaproxyLogTcp string `choices:"true|false"`
|
||||
HaproxyLogNormal string `choices:"true|false"`
|
||||
|
||||
TelegrafInfluxDbOutputUrl string
|
||||
TelegrafInfluxDbOutputName string
|
||||
TelegrafHaproxyInputInterval int
|
||||
TelegrafInfluxDbOutputUrl string
|
||||
TelegrafInfluxDbOutputName string
|
||||
TelegrafInfluxDbOutputUnsafeSsl *bool
|
||||
TelegrafHaproxyInputInterval int
|
||||
}
|
||||
|
||||
func (opts *LoadbalancerAgentParamsOptions) setPrefixedParams(params *jsonutils.JSONDict, pref string) {
|
||||
@@ -82,11 +84,11 @@ type LoadbalancerAgentListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerAgentGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerAgentUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
HbTimeout *int
|
||||
@@ -101,15 +103,15 @@ type LoadbalancerAgentUpdateOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerAgentDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerAgentActionHbOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerAgentActionPatchParamsOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
|
||||
LoadbalancerAgentParamsOptions
|
||||
}
|
||||
|
||||
@@ -94,16 +94,16 @@ func (opts *LoadbalancerBackendGroupCreateOptions) Params() (*jsonutils.JSONDict
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGroupGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGroupUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGroupDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGroupListOptions struct {
|
||||
|
||||
@@ -19,7 +19,7 @@ type LoadbalancerBackendListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerBackendUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
Weight *int
|
||||
@@ -27,9 +27,9 @@ type LoadbalancerBackendUpdateOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerBackendGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerBackendDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
@@ -56,11 +56,11 @@ func (opts *LoadbalancerCertificateCreateOptions) Params() (*jsonutils.JSONDict,
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateListOptions struct {
|
||||
@@ -72,7 +72,7 @@ type LoadbalancerCertificateListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
Cert string `json:"-" help:"path to certificate file"`
|
||||
|
||||
@@ -18,21 +18,21 @@ type LoadbalancerListenerRuleListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
BackendGroup string
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerRuleActionStatusOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Status string `choices:"enabled|disabled"`
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ type LoadbalancerListenerListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerListenerUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
BackendGroup string
|
||||
@@ -150,18 +150,18 @@ type LoadbalancerListenerUpdateOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerListenerGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerActionStatusOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Status string `choices:"enabled|disabled"`
|
||||
}
|
||||
|
||||
type LoadbalancerListenerActionSyncStatusOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
@@ -12,22 +12,22 @@ type LoadbalancerCreateOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerGetOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerUpdateOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Name string
|
||||
|
||||
BackendGroup string
|
||||
}
|
||||
|
||||
type LoadbalancerDeleteOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerPurgeOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
type LoadbalancerListOptions struct {
|
||||
@@ -41,10 +41,10 @@ type LoadbalancerListOptions struct {
|
||||
}
|
||||
|
||||
type LoadbalancerActionStatusOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
Status string `choices:"enabled|disabled"`
|
||||
}
|
||||
|
||||
type LoadbalancerActionSyncStatusOptions struct {
|
||||
ID string
|
||||
ID string `json:-`
|
||||
}
|
||||
|
||||
@@ -218,8 +218,8 @@ func (this *ClientSession) ParseJSONResponse(resp *http.Response, err error) (ht
|
||||
return httputils.ParseJSONResponse(resp, err, this.client.debug)
|
||||
}
|
||||
|
||||
func (this *ClientSession) HasSystemAdminPrivelege() bool {
|
||||
return this.token.HasSystemAdminPrivelege()
|
||||
func (this *ClientSession) HasSystemAdminPrivilege() bool {
|
||||
return this.token.HasSystemAdminPrivilege()
|
||||
}
|
||||
|
||||
func (this *ClientSession) GetRegion() string {
|
||||
|
||||
@@ -45,7 +45,7 @@ type TokenCredential interface {
|
||||
IsValid() bool
|
||||
ValidDuration() time.Duration
|
||||
// IsAdmin() bool
|
||||
HasSystemAdminPrivelege() bool
|
||||
HasSystemAdminPrivilege() bool
|
||||
IsAdminAllow(service string, resource string, action string, extra ...string) bool
|
||||
GetRegions() []string
|
||||
|
||||
|
||||
@@ -130,12 +130,12 @@ func (this *TokenCredentialV2) GetRegions() []string {
|
||||
return this.ServiceCatalog.getRegions()
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV2) HasSystemAdminPrivelege() bool {
|
||||
func (this *TokenCredentialV2) HasSystemAdminPrivilege() bool {
|
||||
return this.IsAdmin() && this.GetTenantName() == "system"
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV2) IsAdminAllow(service string, resource string, action string, extra ...string) bool {
|
||||
return this.HasSystemAdminPrivelege()
|
||||
return this.HasSystemAdminPrivilege()
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV2) GetServiceURL(service, region, zone, endpointType string) (string, error) {
|
||||
|
||||
@@ -135,12 +135,12 @@ func (this *TokenCredentialV3) IsAdmin() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV3) HasSystemAdminPrivelege() bool {
|
||||
func (this *TokenCredentialV3) HasSystemAdminPrivilege() bool {
|
||||
return this.IsAdmin() && this.GetTenantName() == "system"
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV3) IsAdminAllow(service string, resource string, action string, extra ...string) bool {
|
||||
return this.HasSystemAdminPrivelege()
|
||||
return this.HasSystemAdminPrivilege()
|
||||
}
|
||||
|
||||
func (this *TokenCredentialV3) GetRegions() []string {
|
||||
|
||||
@@ -84,12 +84,12 @@ func (self *SSimpleToken) IsAdmin() bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (self *SSimpleToken) HasSystemAdminPrivelege() bool {
|
||||
func (self *SSimpleToken) HasSystemAdminPrivilege() bool {
|
||||
return self.IsAdmin() && self.Project == "system"
|
||||
}
|
||||
|
||||
func (this *SSimpleToken) IsAdminAllow(service string, resource string, action string, extra ...string) bool {
|
||||
return this.HasSystemAdminPrivelege()
|
||||
return this.HasSystemAdminPrivilege()
|
||||
}
|
||||
|
||||
func (self *SSimpleToken) GetRegions() []string {
|
||||
|
||||
Reference in New Issue
Block a user