From 07f98779ad0714337e195440b70589671891e1ae Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 11 Mar 2019 12:30:57 +0000 Subject: [PATCH 1/6] treewide: s/HasSystemAdminPrivelege/HasSystemAdminPrivilege/g --- pkg/cloudcommon/policy/policy.go | 4 ++-- pkg/cloudcommon/policy/token.go | 4 ++-- pkg/hostimage/host_image_service.go | 2 +- pkg/mcclient/modules/base.go | 2 +- pkg/mcclient/session.go | 4 ++-- pkg/mcclient/token.go | 2 +- pkg/mcclient/token2.go | 4 ++-- pkg/mcclient/token3.go | 4 ++-- pkg/mcclient/tokensimple.go | 4 ++-- 9 files changed, 15 insertions(+), 15 deletions(-) diff --git a/pkg/cloudcommon/policy/policy.go b/pkg/cloudcommon/policy/policy.go index 13c5aa4c7d..86bb0dcef2 100644 --- a/pkg/cloudcommon/policy/policy.go +++ b/pkg/cloudcommon/policy/policy.go @@ -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 } diff --git a/pkg/cloudcommon/policy/token.go b/pkg/cloudcommon/policy/token.go index 47fde62233..feba5052a8 100644 --- a/pkg/cloudcommon/policy/token.go +++ b/pkg/cloudcommon/policy/token.go @@ -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 { diff --git a/pkg/hostimage/host_image_service.go b/pkg/hostimage/host_image_service.go index 1dd1855af3..4b6d1b4e62 100644 --- a/pkg/hostimage/host_image_service.go +++ b/pkg/hostimage/host_image_service.go @@ -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") } diff --git a/pkg/mcclient/modules/base.go b/pkg/mcclient/modules/base.go index c082c42eb2..d3c2ff35b1 100644 --- a/pkg/mcclient/modules/base.go +++ b/pkg/mcclient/modules/base.go @@ -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 diff --git a/pkg/mcclient/session.go b/pkg/mcclient/session.go index 4f09e8b03d..46b5c0e42d 100644 --- a/pkg/mcclient/session.go +++ b/pkg/mcclient/session.go @@ -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 { diff --git a/pkg/mcclient/token.go b/pkg/mcclient/token.go index a2a0ab7ad8..df26bea4a8 100644 --- a/pkg/mcclient/token.go +++ b/pkg/mcclient/token.go @@ -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 diff --git a/pkg/mcclient/token2.go b/pkg/mcclient/token2.go index d5188353ad..97b85b56d3 100644 --- a/pkg/mcclient/token2.go +++ b/pkg/mcclient/token2.go @@ -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) { diff --git a/pkg/mcclient/token3.go b/pkg/mcclient/token3.go index c7d063fede..26c46dbc70 100644 --- a/pkg/mcclient/token3.go +++ b/pkg/mcclient/token3.go @@ -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 { diff --git a/pkg/mcclient/tokensimple.go b/pkg/mcclient/tokensimple.go index 15a8badbfb..26d761b181 100644 --- a/pkg/mcclient/tokensimple.go +++ b/pkg/mcclient/tokensimple.go @@ -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 { From c6e4fff0d09f9054f5c835e34a6f7c5e6d952bf2 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 11 Mar 2019 12:07:47 +0000 Subject: [PATCH 2/6] =?UTF-8?q?lb:=20=E4=B8=8D=E8=AE=B0=E5=BD=95=E6=9D=A5?= =?UTF-8?q?=E8=87=AAlbagent=E7=9A=84GET=E6=9F=A5=E8=AF=A2=E8=AF=B7?= =?UTF-8?q?=E6=B1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 要求 - _orig=lbagent - userCred.HasSystemAdminPrivilege() --- pkg/cloudcommon/db/db_dispatcher.go | 12 ++++++++++ pkg/cloudcommon/db/interface.go | 2 ++ pkg/cloudcommon/db/modelbase.go | 8 +++++++ pkg/compute/consts/loadbalancer_const.go | 5 +++++ pkg/compute/models/loadbalancer_common.go | 22 +++++++++++++++++++ pkg/compute/models/loadbalanceracls.go | 1 + pkg/compute/models/loadbalanceragents.go | 1 + .../models/loadbalancerbackendgroups.go | 1 + pkg/compute/models/loadbalancerbackends.go | 1 + .../models/loadbalancercertificates.go | 1 + .../models/loadbalancerlistenerrules.go | 1 + pkg/compute/models/loadbalancerlisteners.go | 1 + pkg/compute/models/loadbalancers.go | 1 + pkg/lbagent/api.go | 6 ++++- pkg/lbagent/models/reflect.go | 2 ++ 15 files changed, 64 insertions(+), 1 deletion(-) diff --git a/pkg/cloudcommon/db/db_dispatcher.go b/pkg/cloudcommon/db/db_dispatcher.go index 78f20c69ef..534808e8fc 100644 --- a/pkg/cloudcommon/db/db_dispatcher.go +++ b/pkg/cloudcommon/db/db_dispatcher.go @@ -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) } diff --git a/pkg/cloudcommon/db/interface.go b/pkg/cloudcommon/db/interface.go index 2d526dc079..57f4cf7959 100644 --- a/pkg/cloudcommon/db/interface.go +++ b/pkg/cloudcommon/db/interface.go @@ -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 { diff --git a/pkg/cloudcommon/db/modelbase.go b/pkg/cloudcommon/db/modelbase.go index c48df26c5d..67d57a789e 100644 --- a/pkg/cloudcommon/db/modelbase.go +++ b/pkg/cloudcommon/db/modelbase.go @@ -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 "" } diff --git a/pkg/compute/consts/loadbalancer_const.go b/pkg/compute/consts/loadbalancer_const.go index a35bd28b6a..2fc734aa83 100644 --- a/pkg/compute/consts/loadbalancer_const.go +++ b/pkg/compute/consts/loadbalancer_const.go @@ -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" +) diff --git a/pkg/compute/models/loadbalancer_common.go b/pkg/compute/models/loadbalancer_common.go index 1c9bf411a9..5e6ff57abb 100644 --- a/pkg/compute/models/loadbalancer_common.go +++ b/pkg/compute/models/loadbalancer_common.go @@ -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) +} diff --git a/pkg/compute/models/loadbalanceracls.go b/pkg/compute/models/loadbalanceracls.go index f4d727f63b..70a167ccf6 100644 --- a/pkg/compute/models/loadbalanceracls.go +++ b/pkg/compute/models/loadbalanceracls.go @@ -82,6 +82,7 @@ func (aclEntries *SLoadbalancerAclEntries) Validate(data *jsonutils.JSONDict) er } type SLoadbalancerAclManager struct { + SLoadbalancerLogSkipper db.SSharableVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalanceragents.go b/pkg/compute/models/loadbalanceragents.go index 756e74abda..32b512ebfb 100644 --- a/pkg/compute/models/loadbalanceragents.go +++ b/pkg/compute/models/loadbalanceragents.go @@ -19,6 +19,7 @@ import ( ) type SLoadbalancerAgentManager struct { + SLoadbalancerLogSkipper db.SStandaloneResourceBaseManager } diff --git a/pkg/compute/models/loadbalancerbackendgroups.go b/pkg/compute/models/loadbalancerbackendgroups.go index 5e89ab27d6..526c76569e 100644 --- a/pkg/compute/models/loadbalancerbackendgroups.go +++ b/pkg/compute/models/loadbalancerbackendgroups.go @@ -21,6 +21,7 @@ import ( ) type SLoadbalancerBackendGroupManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalancerbackends.go b/pkg/compute/models/loadbalancerbackends.go index 1d19680af7..8116ee4fd8 100644 --- a/pkg/compute/models/loadbalancerbackends.go +++ b/pkg/compute/models/loadbalancerbackends.go @@ -19,6 +19,7 @@ import ( ) type SLoadbalancerBackendManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalancercertificates.go b/pkg/compute/models/loadbalancercertificates.go index 1d908a4ccc..fe8fe83cf3 100644 --- a/pkg/compute/models/loadbalancercertificates.go +++ b/pkg/compute/models/loadbalancercertificates.go @@ -25,6 +25,7 @@ import ( ) type SLoadbalancerCertificateManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalancerlistenerrules.go b/pkg/compute/models/loadbalancerlistenerrules.go index 277e8bfd21..398c564efc 100644 --- a/pkg/compute/models/loadbalancerlistenerrules.go +++ b/pkg/compute/models/loadbalancerlistenerrules.go @@ -19,6 +19,7 @@ import ( ) type SLoadbalancerListenerRuleManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 4a68f7ceaa..3f29f2251b 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -22,6 +22,7 @@ import ( ) type SLoadbalancerListenerManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/compute/models/loadbalancers.go b/pkg/compute/models/loadbalancers.go index 9522a32c24..528f5c100b 100644 --- a/pkg/compute/models/loadbalancers.go +++ b/pkg/compute/models/loadbalancers.go @@ -21,6 +21,7 @@ import ( ) type SLoadbalancerManager struct { + SLoadbalancerLogSkipper db.SVirtualResourceBaseManager } diff --git a/pkg/lbagent/api.go b/pkg/lbagent/api.go index d55468c429..1d77ecb439 100644 --- a/pkg/lbagent/api.go +++ b/pkg/lbagent/api.go @@ -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 diff --git a/pkg/lbagent/models/reflect.go b/pkg/lbagent/models/reflect.go index 0d129638ea..6060aacb66 100644 --- a/pkg/lbagent/models/reflect.go +++ b/pkg/lbagent/models/reflect.go @@ -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 { From c6648ed0da733c8cb167241666fc180572a11cb1 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 25 Feb 2019 13:03:51 +0000 Subject: [PATCH 3/6] mcclient: lbagent: allow setting telegraf config template --- pkg/mcclient/options/loadbalanceragents.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/mcclient/options/loadbalanceragents.go b/pkg/mcclient/options/loadbalanceragents.go index ab3b230818..9cd5499e16 100644 --- a/pkg/mcclient/options/loadbalanceragents.go +++ b/pkg/mcclient/options/loadbalanceragents.go @@ -10,6 +10,7 @@ import ( type LoadbalancerAgentParamsOptions struct { KeepalivedConfTmpl string HaproxyConfTmpl string + TelegrafConfTmpl string VrrpPriority *int // required VrrpVirtualRouterId *int // required From 8016a27abfeb799ff921d2b837a2b5c36014daac Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 25 Feb 2019 13:04:17 +0000 Subject: [PATCH 4/6] lbagent: telegraf: add params influx_db_output_unsafe_ssl --- pkg/compute/models/loadbalanceragents.go | 8 +++++--- pkg/lbagent/models/agentparams.go | 7 ++++--- pkg/mcclient/models/loadbalancers.go | 7 ++++--- pkg/mcclient/options/loadbalanceragents.go | 7 ++++--- 4 files changed, 17 insertions(+), 12 deletions(-) diff --git a/pkg/compute/models/loadbalanceragents.go b/pkg/compute/models/loadbalanceragents.go index 32b512ebfb..8c376e155c 100644 --- a/pkg/compute/models/loadbalanceragents.go +++ b/pkg/compute/models/loadbalanceragents.go @@ -79,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 { @@ -524,6 +525,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" diff --git a/pkg/lbagent/models/agentparams.go b/pkg/lbagent/models/agentparams.go index 6f8d51ea18..91032e1060 100644 --- a/pkg/lbagent/models/agentparams.go +++ b/pkg/lbagent/models/agentparams.go @@ -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, diff --git a/pkg/mcclient/models/loadbalancers.go b/pkg/mcclient/models/loadbalancers.go index 2c1b2cc6be..603f0799c8 100644 --- a/pkg/mcclient/models/loadbalancers.go +++ b/pkg/mcclient/models/loadbalancers.go @@ -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 { diff --git a/pkg/mcclient/options/loadbalanceragents.go b/pkg/mcclient/options/loadbalanceragents.go index 9cd5499e16..4ff66a18fb 100644 --- a/pkg/mcclient/options/loadbalanceragents.go +++ b/pkg/mcclient/options/loadbalanceragents.go @@ -26,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) { From fef63230ac083a0a394b8c9ed176e256fd8507bc Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 7 Mar 2019 10:31:47 +0000 Subject: [PATCH 5/6] mcclient: options: ignore ID when converting to params --- pkg/mcclient/options/loadbalanceracls.go | 2 +- pkg/mcclient/options/loadbalanceragents.go | 10 +++++----- pkg/mcclient/options/loadbalancerbackendgroups.go | 6 +++--- pkg/mcclient/options/loadbalancerbackends.go | 6 +++--- pkg/mcclient/options/loadbalancercertificates.go | 6 +++--- pkg/mcclient/options/loadbalancerlistenerrules.go | 8 ++++---- pkg/mcclient/options/loadbalancerlisteners.go | 10 +++++----- pkg/mcclient/options/loadbalancers.go | 12 ++++++------ 8 files changed, 30 insertions(+), 30 deletions(-) diff --git a/pkg/mcclient/options/loadbalanceracls.go b/pkg/mcclient/options/loadbalanceracls.go index 3064116497..4f1bbcbb6d 100644 --- a/pkg/mcclient/options/loadbalanceracls.go +++ b/pkg/mcclient/options/loadbalanceracls.go @@ -63,7 +63,7 @@ type LoadbalancerAclCreateOptions struct { } type LoadbalancerAclGetOptions struct { - ID string + ID string `json:-` } type LoadbalancerAclListOptions struct { diff --git a/pkg/mcclient/options/loadbalanceragents.go b/pkg/mcclient/options/loadbalanceragents.go index 4ff66a18fb..a35b48651a 100644 --- a/pkg/mcclient/options/loadbalanceragents.go +++ b/pkg/mcclient/options/loadbalanceragents.go @@ -84,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 @@ -103,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 } diff --git a/pkg/mcclient/options/loadbalancerbackendgroups.go b/pkg/mcclient/options/loadbalancerbackendgroups.go index 1c33e15ff8..0553ab46da 100644 --- a/pkg/mcclient/options/loadbalancerbackendgroups.go +++ b/pkg/mcclient/options/loadbalancerbackendgroups.go @@ -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 { diff --git a/pkg/mcclient/options/loadbalancerbackends.go b/pkg/mcclient/options/loadbalancerbackends.go index 7e9f66527a..b87fe04c45 100644 --- a/pkg/mcclient/options/loadbalancerbackends.go +++ b/pkg/mcclient/options/loadbalancerbackends.go @@ -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:-` } diff --git a/pkg/mcclient/options/loadbalancercertificates.go b/pkg/mcclient/options/loadbalancercertificates.go index a88a441952..d943452521 100644 --- a/pkg/mcclient/options/loadbalancercertificates.go +++ b/pkg/mcclient/options/loadbalancercertificates.go @@ -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"` diff --git a/pkg/mcclient/options/loadbalancerlistenerrules.go b/pkg/mcclient/options/loadbalancerlistenerrules.go index 352450dfd5..b1d8899669 100644 --- a/pkg/mcclient/options/loadbalancerlistenerrules.go +++ b/pkg/mcclient/options/loadbalancerlistenerrules.go @@ -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"` } diff --git a/pkg/mcclient/options/loadbalancerlisteners.go b/pkg/mcclient/options/loadbalancerlisteners.go index 567409e549..ee1daa932d 100644 --- a/pkg/mcclient/options/loadbalancerlisteners.go +++ b/pkg/mcclient/options/loadbalancerlisteners.go @@ -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:-` } diff --git a/pkg/mcclient/options/loadbalancers.go b/pkg/mcclient/options/loadbalancers.go index 0e27c8cfb6..9aa01b3db1 100644 --- a/pkg/mcclient/options/loadbalancers.go +++ b/pkg/mcclient/options/loadbalancers.go @@ -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:-` } From 4b4c86b88304cfaf978082646567ba7aff569a1f Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Thu, 7 Mar 2019 15:38:20 +0000 Subject: [PATCH 6/6] lbagent: fix corpus versioning --- pkg/lbagent/models/corpus.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/lbagent/models/corpus.go b/pkg/lbagent/models/corpus.go index 04f539ab03..799d06400a 100644 --- a/pkg/lbagent/models/corpus.go +++ b/pkg/lbagent/models/corpus.go @@ -24,6 +24,7 @@ type LoadbalancerCorpus struct { func NewEmptyLoadbalancerCorpus() *LoadbalancerCorpus { return &LoadbalancerCorpus{ + CorpusVersion: CORPUS_VERSION, ModelSets: NewModelSets(), ModelSetsMaxUpdatedAt: NewModelSetsMaxUpdatedAt(), }