From fbbf841494567bd1130ca304577c66e6dbc88e4b Mon Sep 17 00:00:00 2001 From: Zexi Li Date: Tue, 11 Dec 2018 11:44:35 +0800 Subject: [PATCH 01/16] region: network details show routes --- pkg/compute/models/networks.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/compute/models/networks.go b/pkg/compute/models/networks.go index 0fa55fee27..5e405c9c79 100644 --- a/pkg/compute/models/networks.go +++ b/pkg/compute/models/networks.go @@ -856,6 +856,10 @@ func (self *SNetwork) getMoreDetails(extra *jsonutils.JSONDict) *jsonutils.JSOND extra.Add(jsonutils.NewString(vpc.GetExternalId()), "vpc_external_id") } } + routes := self.GetRoutes() + if len(routes) > 0 { + extra.Add(jsonutils.Marshal(routes), "routes") + } return extra } From beec785040390b88bdb79c49fec4c9888629fbcb Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Tue, 11 Dec 2018 16:29:50 +0800 Subject: [PATCH 02/16] add bill-detail file --- cmd/climc/shell/bill_details.go | 47 ++++++++++++++++++++++++ pkg/mcclient/modules/mod_bill_details.go | 14 +++++++ 2 files changed, 61 insertions(+) create mode 100644 cmd/climc/shell/bill_details.go create mode 100644 pkg/mcclient/modules/mod_bill_details.go diff --git a/cmd/climc/shell/bill_details.go b/cmd/climc/shell/bill_details.go new file mode 100644 index 0000000000..60cdc11ae8 --- /dev/null +++ b/cmd/climc/shell/bill_details.go @@ -0,0 +1,47 @@ +package shell + +import ( + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" +) + +func init() { + + type BillDetailListOptions struct { + options.BaseListOptions + STARTDATE string `"help":"start date of the bill_detail"` + ENDDATE string `"help":"end date of the bill_detail"` + ProjectId string `"help":"project id of the bill_detail"` + } + R(&BillDetailListOptions{}, "billdetail-list", "List all bill details", func(s *mcclient.ClientSession, args *BillDetailListOptions) error { + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } + if len(args.STARTDATE) > 0 { + params.Add(jsonutils.NewString(args.STARTDATE), "start_date") + } + if len(args.ENDDATE) > 0 { + params.Add(jsonutils.NewString(args.ENDDATE), "end_date") + } + + if len(args.ProjectId) > 0 { + params.Add(jsonutils.NewString(args.ProjectId), "project_id") + } + + result, err := modules.BillDetails.List(s, params) + if err != nil { + return err + } + + printList(result, modules.BillDetails.GetColumns(s)) + return nil + }) +} diff --git a/pkg/mcclient/modules/mod_bill_details.go b/pkg/mcclient/modules/mod_bill_details.go new file mode 100644 index 0000000000..4f588feb4b --- /dev/null +++ b/pkg/mcclient/modules/mod_bill_details.go @@ -0,0 +1,14 @@ +package modules + +var ( + BillDetails ResourceManager +) + +func init() { + BillDetails = NewMeterManager("bill_detail", "bill_details", + []string{"bill_id", "account", "platform", "region", "sub_account_project", "res_id", + "res_type", "res_name", "start_time", "end_time", "charge_type", "item_rate", "item_fee"}, + []string{}, + ) + register(&BillDetails) +} From 34ade66e93ee95aa62e776923d1e464966236f4b Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Tue, 11 Dec 2018 17:03:00 +0800 Subject: [PATCH 03/16] modify ad fmt file --- cmd/climc/shell/bill_details.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/climc/shell/bill_details.go b/cmd/climc/shell/bill_details.go index 60cdc11ae8..f5d17510d0 100644 --- a/cmd/climc/shell/bill_details.go +++ b/cmd/climc/shell/bill_details.go @@ -11,9 +11,9 @@ func init() { type BillDetailListOptions struct { options.BaseListOptions - STARTDATE string `"help":"start date of the bill_detail"` - ENDDATE string `"help":"end date of the bill_detail"` - ProjectId string `"help":"project id of the bill_detail"` + STARTDATE string `help:"start date of the bill_detail"` + ENDDATE string `help:"end date of the bill_detail"` + ProjectId string `help:"project id of the bill_detail"` } R(&BillDetailListOptions{}, "billdetail-list", "List all bill details", func(s *mcclient.ClientSession, args *BillDetailListOptions) error { var params *jsonutils.JSONDict From cea2fcb6f38532c37d7ddadcd936b4b70b06b81c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=B1=88=E8=BD=A9?= Date: Tue, 11 Dec 2018 19:43:33 +0800 Subject: [PATCH 04/16] =?UTF-8?q?=E9=98=BF=E9=87=8C=E4=BA=91=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/util/aliyun/aliyun.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/pkg/util/aliyun/aliyun.go b/pkg/util/aliyun/aliyun.go index 5a3d0586f5..dacf605b59 100644 --- a/pkg/util/aliyun/aliyun.go +++ b/pkg/util/aliyun/aliyun.go @@ -12,6 +12,7 @@ import ( "yunion.io/x/log" "yunion.io/x/onecloud/pkg/cloudprovider" "yunion.io/x/onecloud/pkg/compute/models" + "yunion.io/x/pkg/utils" ) const ( @@ -72,8 +73,12 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str return nil, err } //{"Code":"InvalidInstanceType.ValueNotSupported","HostId":"ecs.aliyuncs.com","Message":"The specified instanceType beyond the permitted range.","RequestId":"0042EE30-0EDF-48A7-A414-56229D4AD532"} + //{"Code":"200","Message":"successful","PageNumber":1,"PageSize":50,"RequestId":"BB4C970C-0E23-48DC-A3B0-EB21FFC70A29","RouterTableList":{"RouterTableListType":[{"CreationTime":"2017-03-19T13:37:40Z","Description":"","ResourceGroupId":"rg-acfmwie3cqoobmi","RouteTableId":"vtb-j6c60lectdi80rk5xz43g","RouteTableName":"","RouteTableType":"System","RouterId":"vrt-j6c00qrol733dg36iq4qj","RouterType":"VRouter","VSwitchIds":{"VSwitchId":["vsw-j6c3gig5ub4fmi2veyrus"]},"VpcId":"vpc-j6c86z3sh8ufhgsxwme0q"}]},"Success":true,"TotalCount":1} if body.Contains("Code") { - return nil, fmt.Errorf(body.String()) + code, _ := body.GetString("Code") + if len(code) > 0 && !utils.IsInStringArray(code, []string{"200"}) { + return nil, fmt.Errorf(body.String()) + } } return body, nil } From b3644003a84d191be9c3d70730252a46db073851 Mon Sep 17 00:00:00 2001 From: TangBin Date: Tue, 11 Dec 2018 19:47:16 +0800 Subject: [PATCH 05/16] delete project bugfix --- pkg/mcclient/modules/mod_projects.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/mcclient/modules/mod_projects.go b/pkg/mcclient/modules/mod_projects.go index d920951482..4e89b08009 100644 --- a/pkg/mcclient/modules/mod_projects.go +++ b/pkg/mcclient/modules/mod_projects.go @@ -241,6 +241,7 @@ func (this *ProjectManagerV3) Delete(session *mcclient.ClientSession, id string, func (this *ProjectManagerV3) DeleteInContexts(session *mcclient.ClientSession, id string, body jsonutils.JSONObject, ctxs []ManagerContext) (jsonutils.JSONObject, error) { if ctxs == nil { p := jsonutils.NewDict() + p.Add(jsonutils.JSONTrue, "admin") p.Add(jsonutils.NewString(id), "tenant") ret, e := Servers.List(session, p) if e != nil { From 58aca9ea9ebaccb24c09c11b193443c7c600711f Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 10 Dec 2018 07:09:55 +0000 Subject: [PATCH 06/16] =?UTF-8?q?loadbalancers:=20=E7=A7=BB=E9=99=A4Bandwi?= =?UTF-8?q?dth=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 未在使用,且名称太泛,不便于日后扩展维护 --- pkg/compute/models/loadbalancerlisteners.go | 1 - pkg/mcclient/models/loadbalancers.go | 1 - pkg/mcclient/options/loadbalancerlisteners.go | 3 --- 3 files changed, 5 deletions(-) diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index ea16d3e9a4..7445c0ed75 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -69,7 +69,6 @@ type SLoadbalancerListener struct { ListenerPort int `nullable:"false" list:"user" create:"required"` BackendGroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional" update:"user"` - Bandwidth int `nullable:"false" list:"user" create:"optional" update:"user"` Scheduler string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required" update:"user"` ClientRequestTimeout int `nullable:"false" list:"user" create:"optional" update:"user"` diff --git a/pkg/mcclient/models/loadbalancers.go b/pkg/mcclient/models/loadbalancers.go index e2ec149582..0ae4a5128f 100644 --- a/pkg/mcclient/models/loadbalancers.go +++ b/pkg/mcclient/models/loadbalancers.go @@ -42,7 +42,6 @@ type LoadbalancerListener struct { VirtualResource LoadbalancerId string - Bandwidth int ListenerType string ListenerPort int diff --git a/pkg/mcclient/options/loadbalancerlisteners.go b/pkg/mcclient/options/loadbalancerlisteners.go index 7b232ae365..11b6c093a2 100644 --- a/pkg/mcclient/options/loadbalancerlisteners.go +++ b/pkg/mcclient/options/loadbalancerlisteners.go @@ -9,7 +9,6 @@ type LoadbalancerListenerCreateOptions struct { BackendGroup string Scheduler string `required:"true" choices:"rr|wrr|wlc|sch|tch"` - Bandwidth *int ClientRequestTimeout *int ClientIdleTimeout *int @@ -57,7 +56,6 @@ type LoadbalancerListenerListOptions struct { BackendGroup string Scheduler string `choices:"rr|wrr|wlc|sch|tch"` - Bandwidth *int ClientRequestTimeout *int ClientIdleTimeout *int @@ -103,7 +101,6 @@ type LoadbalancerListenerUpdateOptions struct { BackendGroup string Scheduler string `choices:"rr|wrr|wlc|sch|tch"` - Bandwidth *int ClientRequestTimeout *int ClientIdleTimeout *int From 93e1e7799edace52d48ee9d00e64f3e63b76a60d Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 10 Dec 2018 07:33:57 +0000 Subject: [PATCH 07/16] =?UTF-8?q?loadbalancers:=20=E6=B8=85=E7=90=86?= =?UTF-8?q?=E7=9B=91=E5=90=AC=E9=80=89=E9=A1=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/loadbalancerlisteners.go | 2 -- pkg/mcclient/models/loadbalancers.go | 9 ++------- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 7445c0ed75..143a782ca7 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -43,8 +43,6 @@ type SLoadbalancerHTTPListener struct { StickySessionCookie string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"optional" update:"user"` StickySessionCookieTimeout int `nullable:"false" list:"user" create:"optional" update:"user"` - //XForwardedForSLBIP bool `nullable:"false" list:"user" create:"optional"` - //XForwardedForSLBID bool `nullable:"false" list:"user" create:"optional"` XForwardedFor bool `nullable:"false" list:"user" create:"optional" update:"user"` Gzip bool `nullable:"false" list:"user" create:"optional" update:"user"` } diff --git a/pkg/mcclient/models/loadbalancers.go b/pkg/mcclient/models/loadbalancers.go index 0ae4a5128f..667fdbe8d2 100644 --- a/pkg/mcclient/models/loadbalancers.go +++ b/pkg/mcclient/models/loadbalancers.go @@ -25,10 +25,8 @@ type LoadbalancerHTTPListener struct { StickySessionCookie string StickySessionCookieTimeout int - XForwardedFor bool - XForwardedForSLBIP bool - XForwardedForSLBID bool - Gzip bool + XForwardedFor bool + Gzip bool } // CACertificate string @@ -77,9 +75,6 @@ type LoadbalancerListener struct { LoadbalancerUDPListener LoadbalancerHTTPListener LoadbalancerHTTPSListener - - XForwardedFor bool - Gzip bool } type LoadbalancerListenerRule struct { From 5564929e349985f4c0ddbd07f13ebf7aa23f9dbc Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Mon, 10 Dec 2018 08:05:55 +0000 Subject: [PATCH 08/16] =?UTF-8?q?loadbalancers:=20=E5=A2=9E=E5=8A=A0rps?= =?UTF-8?q?=E9=99=90=E9=80=9F=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cmd/lbagent/main.go | 3 + .../models/loadbalancerlistenerrules.go | 19 ++++-- pkg/compute/models/loadbalancerlisteners.go | 13 ++++ pkg/lbagent/models/haproxy.go | 59 +++++++++++++++++-- pkg/mcclient/models/loadbalancers.go | 9 +++ pkg/mcclient/options/loadbalancerlisteners.go | 9 +++ 6 files changed, 104 insertions(+), 8 deletions(-) diff --git a/cmd/lbagent/main.go b/cmd/lbagent/main.go index 1943948512..9215a1ece1 100644 --- a/cmd/lbagent/main.go +++ b/cmd/lbagent/main.go @@ -9,10 +9,13 @@ import ( "yunion.io/x/log" "yunion.io/x/onecloud/pkg/cloudcommon" + "yunion.io/x/onecloud/pkg/cloudcommon/consts" "yunion.io/x/onecloud/pkg/lbagent" ) func main() { + consts.SetServiceType("lbagent") + opts := &lbagent.Options{} commonOpts := &opts.CommonOpts { diff --git a/pkg/compute/models/loadbalancerlistenerrules.go b/pkg/compute/models/loadbalancerlistenerrules.go index 3e3d3bccc8..26f6540822 100644 --- a/pkg/compute/models/loadbalancerlistenerrules.go +++ b/pkg/compute/models/loadbalancerlistenerrules.go @@ -39,6 +39,8 @@ type SLoadbalancerListenerRule struct { Domain string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"optional"` Path string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"optional"` + + SLoadbalancerHTTPRateLimiter } func loadbalancerListenerRuleCheckUniqueness(ctx context.Context, lbls *SLoadbalancerListener, domain, path string) error { @@ -101,6 +103,9 @@ func (man *SLoadbalancerListenerRuleManager) ValidateCreateData(ctx context.Cont "backend_group": backendGroupV, "domain": domainV.AllowEmpty(true).Default(""), "path": pathV.Default(""), + + "http_request_rate": validators.NewNonNegativeValidator("http_request_rate").Default(0), + "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src").Default(0), } for _, v := range keyV { if err := v.Validate(data); err != nil { @@ -131,10 +136,16 @@ func (lbr *SLoadbalancerListenerRule) AllowPerformStatus(ctx context.Context, us func (lbr *SLoadbalancerListenerRule) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) { backendGroupV := validators.NewModelIdOrNameValidator("backend_group", "loadbalancerbackendgroup", lbr.GetOwnerProjectId()) - backendGroupV.Optional(true) - err := backendGroupV.Validate(data) - if err != nil { - return nil, err + keyV := map[string]validators.IValidator{ + "backend_group": backendGroupV, + "http_request_rate": validators.NewNonNegativeValidator("http_request_rate"), + "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src"), + } + for _, v := range keyV { + v.Optional(true) + if err := v.Validate(data); err != nil { + return nil, err + } } if backendGroup, ok := backendGroupV.Model.(*SLoadbalancerBackendGroup); ok && backendGroup.Id != lbr.BackendGroupId { listenerM, err := LoadbalancerListenerManager.FetchById(lbr.ListenerId) diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 143a782ca7..458502672c 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -33,6 +33,11 @@ func init() { } } +type SLoadbalancerHTTPRateLimiter struct { + HTTPRequestRate int `nullable:"false" list:"user" create:"optional" update:"user"` + HTTPRequestRatePerSrc int `nullable:"false" list:"user" create:"optional" update:"user"` +} + type SLoadbalancerTCPListener struct{} type SLoadbalancerUDPListener struct{} @@ -97,6 +102,8 @@ type SLoadbalancerListener struct { SLoadbalancerUDPListener SLoadbalancerHTTPListener SLoadbalancerHTTPSListener + + SLoadbalancerHTTPRateLimiter } func (man *SLoadbalancerListenerManager) checkListenerUniqueness(ctx context.Context, lb *SLoadbalancer, listenerType string, listenerPort int64) error { @@ -198,6 +205,9 @@ func (man *SLoadbalancerListenerManager) ValidateCreateData(ctx context.Context, "x_forwarded_for": validators.NewBoolValidator("x_forwarded_for").Default(true), "gzip": validators.NewBoolValidator("gzip").Default(false), + + "http_request_rate": validators.NewNonNegativeValidator("http_request_rate").Default(0), + "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src").Default(0), } for _, v := range keyV { if err := v.Validate(data); err != nil { @@ -342,6 +352,9 @@ func (lblis *SLoadbalancerListener) ValidateUpdateData(ctx context.Context, user "x_forwarded_for": validators.NewBoolValidator("x_forwarded_for"), "gzip": validators.NewBoolValidator("gzip"), + "http_request_rate": validators.NewNonNegativeValidator("http_request_rate").Default(0), + "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src").Default(0), + "certificate": certV, "tls_cipher_policy": tlsCipherPolicyV, "enable_http2": validators.NewBoolValidator("enable_http2").Default(true), diff --git a/pkg/lbagent/models/haproxy.go b/pkg/lbagent/models/haproxy.go index 59830b036d..d19f172ff7 100644 --- a/pkg/lbagent/models/haproxy.go +++ b/pkg/lbagent/models/haproxy.go @@ -318,6 +318,43 @@ func (b *LoadbalancerCorpus) genHaproxyConfigBackend(data map[string]interface{} return nil } +func (b *LoadbalancerCorpus) genHaproxyConfigHttpRate(data map[string]interface{}, requestRate, requestRatePerSrc int) error { + periodSecond := 10 + id := data["id"].(string) + dummyBackends := []map[string]string{} + rateRules := []string{} + + // order matters here: every src uses up his own quota before touching + // the shared one + if requestRatePerSrc > 0 { + idPerSrc := id + "_persrc" + dummyBackends = append(dummyBackends, map[string]string{ + "id": idPerSrc, + "stick_table": fmt.Sprintf("stick-table type ip size 1m expire 1m store http_req_rate(%ds)", periodSecond), + }) + rateRules = append(rateRules, + fmt.Sprintf("http-request deny deny_status 429 if { src_http_req_rate(%s) gt %d }", + idPerSrc, requestRatePerSrc*periodSecond), + fmt.Sprintf("http-request track-sc0 src table %s", + idPerSrc)) + } + if requestRate > 0 { + idTotal := id + "_total" + dummyBackends = append(dummyBackends, map[string]string{ + "id": idTotal, + "stick_table": fmt.Sprintf("stick-table type integer size 1 expire 1m store http_req_rate(%ds)", periodSecond), + }) + rateRules = append(rateRules, + fmt.Sprintf("http-request deny deny_status 429 if { int(1),table_http_req_rate(%s) gt %d }", + idTotal, requestRate*periodSecond), + fmt.Sprintf("http-request track-sc1 int(1) table %s", + idTotal)) + } + data["rate_rules"] = rateRules + data["dummy_backends"] = dummyBackends + return nil +} + func (b *LoadbalancerCorpus) genHaproxyConfigHttp(buf *bytes.Buffer, listener *LoadbalancerListener, opts *AgentParams) error { lb := listener.loadbalancer rules := listener.rules.OrderedEnabledList() @@ -366,8 +403,10 @@ func (b *LoadbalancerCorpus) genHaproxyConfigHttp(buf *bytes.Buffer, listener *L backendGroup.Name, backendGroup.Id), "id": ruleBackendIdGen(rule.Id), } - err := b.genHaproxyConfigBackend(backendData, lb, listener, backendGroup) - if err != nil { + if err := b.genHaproxyConfigBackend(backendData, lb, listener, backendGroup); err != nil { + return err + } + if err := b.genHaproxyConfigHttpRate(backendData, rule.HTTPRequestRate, rule.HTTPRequestRatePerSrc); err != nil { return err } backends = append(backends, backendData) @@ -381,8 +420,10 @@ func (b *LoadbalancerCorpus) genHaproxyConfigHttp(buf *bytes.Buffer, listener *L backendGroup.Name, backendGroup.Id), "id": fmt.Sprintf("backends_listener_default-%s", listener.Id), } - err := b.genHaproxyConfigBackend(backendData, lb, listener, backendGroup) - if err != nil { + if err := b.genHaproxyConfigBackend(backendData, lb, listener, backendGroup); err != nil { + return err + } + if err := b.genHaproxyConfigHttpRate(backendData, listener.HTTPRequestRate, listener.HTTPRequestRatePerSrc); err != nil { return err } backends = append(backends, backendData) @@ -436,12 +477,17 @@ listen {{ .id }} {{ define "httpListen" -}} # {{ .listener_type }} listener: {{ .comment }} +{{- range .dummy_backends }} +backend {{ .id }} + {{ println .stick_table }} +{{- end }} frontend {{ .id }} bind {{ .bind }} mode http {{- println }} {{- if .log }} {{ println "option httplog clf" }} {{- end }} {{- if .acl }} {{ println .acl }} {{- end}} + {{- range .rate_rules }} {{ println . }} {{- end }} {{- if .client_request_timeout }} timeout http-request {{ println .client_request_timeout }} {{- end}} {{- if .client_idle_timeout }} timeout http-keep-alive {{ println .client_idle_timeout }} {{- end}} {{- if .xforwardedfor }} {{ println "option forwardfor" }} {{- end}} @@ -455,10 +501,15 @@ frontend {{ .id }} {{ define "backend" -}} # {{ .comment }} +{{- range .dummy_backends }} +backend {{ .id }} + {{ println .stick_table }} +{{- end }} backend {{ .id }} mode {{ .mode }} balance {{ .balanceAlgorithm }} {{- println }} + {{- range .rate_rules }} {{ println . }} {{- end }} {{- if .backend_connect_timeout }} timeout connect {{ println .backend_connect_timeout }} {{- end}} {{- if .backend_idle_timeout }} timeout server {{ println .backend_idle_timeout }} {{- end}} {{- if .timeout_check }} {{ println .timeout_check }} {{- end }} diff --git a/pkg/mcclient/models/loadbalancers.go b/pkg/mcclient/models/loadbalancers.go index 667fdbe8d2..7f7358f4fa 100644 --- a/pkg/mcclient/models/loadbalancers.go +++ b/pkg/mcclient/models/loadbalancers.go @@ -36,6 +36,11 @@ type LoadbalancerHTTPSListener struct { EnableHttp2 bool } +type LoadbalancerHTTPRateLimiter struct { + HTTPRequestRate int + HTTPRequestRatePerSrc int +} + type LoadbalancerListener struct { VirtualResource @@ -75,6 +80,8 @@ type LoadbalancerListener struct { LoadbalancerUDPListener LoadbalancerHTTPListener LoadbalancerHTTPSListener + + LoadbalancerHTTPRateLimiter } type LoadbalancerListenerRule struct { @@ -85,6 +92,8 @@ type LoadbalancerListenerRule struct { Domain string Path string + + LoadbalancerHTTPRateLimiter } type LoadbalancerBackendGroup struct { diff --git a/pkg/mcclient/options/loadbalancerlisteners.go b/pkg/mcclient/options/loadbalancerlisteners.go index 11b6c093a2..7f2ddd087e 100644 --- a/pkg/mcclient/options/loadbalancerlisteners.go +++ b/pkg/mcclient/options/loadbalancerlisteners.go @@ -45,6 +45,9 @@ type LoadbalancerListenerCreateOptions struct { Certificate string TLSCipherPolicy string EnableHttp2 string `choices:"true|false"` + + HTTPRequestRate *int + HTTPRequestRatePerSrc *int } type LoadbalancerListenerListOptions struct { @@ -92,6 +95,9 @@ type LoadbalancerListenerListOptions struct { Certificate string TLSCipherPolicy string EnableHttp2 string `choices:"true|false"` + + HTTPRequestRate *int + HTTPRequestRatePerSrc *int } type LoadbalancerListenerUpdateOptions struct { @@ -137,6 +143,9 @@ type LoadbalancerListenerUpdateOptions struct { Certificate string TLSCipherPolicy string EnableHttp2 string `choices:"true|false"` + + HTTPRequestRate *int + HTTPRequestRatePerSrc *int } type LoadbalancerListenerGetOptions struct { From 31cb423a2f8442a1385a6f0c87e4a0bec4062e74 Mon Sep 17 00:00:00 2001 From: zhengjiajie Date: Wed, 12 Dec 2018 11:53:45 +0800 Subject: [PATCH 09/16] zhengjj add files --- cmd/climc/shell/bill_resources.go | 47 ++++++++++++++++++++++ pkg/mcclient/modules/mod_bill_details.go | 2 +- pkg/mcclient/modules/mod_bill_resources.go | 14 +++++++ 3 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 cmd/climc/shell/bill_resources.go create mode 100644 pkg/mcclient/modules/mod_bill_resources.go diff --git a/cmd/climc/shell/bill_resources.go b/cmd/climc/shell/bill_resources.go new file mode 100644 index 0000000000..61a3c1ad4b --- /dev/null +++ b/cmd/climc/shell/bill_resources.go @@ -0,0 +1,47 @@ +package shell + +import ( + "yunion.io/x/jsonutils" + "yunion.io/x/onecloud/pkg/mcclient" + "yunion.io/x/onecloud/pkg/mcclient/modules" + "yunion.io/x/onecloud/pkg/mcclient/options" +) + +func init() { + + type BillResourceListOptions struct { + options.BaseListOptions + STARTDATE string `help:"start date of the bill_resource"` + ENDDATE string `help:"end date of the bill_resource"` + ProjectId string `help:"project id of the bill_resource"` + } + R(&BillResourceListOptions{}, "billresource-list", "List all bill resources", func(s *mcclient.ClientSession, args *BillResourceListOptions) error { + var params *jsonutils.JSONDict + { + var err error + params, err = args.BaseListOptions.Params() + if err != nil { + return err + + } + } + if len(args.STARTDATE) > 0 { + params.Add(jsonutils.NewString(args.STARTDATE), "start_date") + } + if len(args.ENDDATE) > 0 { + params.Add(jsonutils.NewString(args.ENDDATE), "end_date") + } + + if len(args.ProjectId) > 0 { + params.Add(jsonutils.NewString(args.ProjectId), "project_id") + } + + result, err := modules.BillResources.List(s, params) + if err != nil { + return err + } + + printList(result, modules.BillResources.GetColumns(s)) + return nil + }) +} diff --git a/pkg/mcclient/modules/mod_bill_details.go b/pkg/mcclient/modules/mod_bill_details.go index 4f588feb4b..b389ca1f59 100644 --- a/pkg/mcclient/modules/mod_bill_details.go +++ b/pkg/mcclient/modules/mod_bill_details.go @@ -6,7 +6,7 @@ var ( func init() { BillDetails = NewMeterManager("bill_detail", "bill_details", - []string{"bill_id", "account", "platform", "region", "sub_account_project", "res_id", + []string{"bill_id", "account", "platform", "region", "manager_project", "res_id", "res_type", "res_name", "start_time", "end_time", "charge_type", "item_rate", "item_fee"}, []string{}, ) diff --git a/pkg/mcclient/modules/mod_bill_resources.go b/pkg/mcclient/modules/mod_bill_resources.go new file mode 100644 index 0000000000..284d716768 --- /dev/null +++ b/pkg/mcclient/modules/mod_bill_resources.go @@ -0,0 +1,14 @@ +package modules + +var ( + BillResources ResourceManager +) + +func init() { + BillResources = NewMeterManager("bill_resource", "bill_resources", + []string{"account", "platform", "region", "manager_project", "res_id", + "res_type", "res_name", "charge_type", "res_fee"}, + []string{}, + ) + register(&BillResources) +} From a5dfe342a1462a2dcb9d108ba53cf5fb62a9ab4e Mon Sep 17 00:00:00 2001 From: Qiu Jian Date: Wed, 12 Dec 2018 11:59:31 +0800 Subject: [PATCH 10/16] =?UTF-8?q?=E5=B0=86host=20resource=20type=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BAcreate=5Foptional=EF=BC=8C=E4=B8=94default?= =?UTF-8?q?=E4=B8=BAshared?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/appsrv/handlerinfo.go | 2 +- pkg/compute/models/hosts.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/appsrv/handlerinfo.go b/pkg/appsrv/handlerinfo.go index 6a7234ca65..048a4124cd 100644 --- a/pkg/appsrv/handlerinfo.go +++ b/pkg/appsrv/handlerinfo.go @@ -110,4 +110,4 @@ func (hi *SHandlerInfo) GetAppParams(params map[string]string, path []string) *S appParams.Params = params appParams.Path = path return &appParams -} \ No newline at end of file +} diff --git a/pkg/compute/models/hosts.go b/pkg/compute/models/hosts.go index 9fa926df40..a1df23d231 100644 --- a/pkg/compute/models/hosts.go +++ b/pkg/compute/models/hosts.go @@ -23,6 +23,7 @@ import ( "yunion.io/x/pkg/utils" "yunion.io/x/sqlchemy" + "yunion.io/x/onecloud/pkg/appsrv" "yunion.io/x/onecloud/pkg/cloudcommon/db" "yunion.io/x/onecloud/pkg/cloudcommon/db/lockman" "yunion.io/x/onecloud/pkg/cloudcommon/db/taskman" @@ -35,7 +36,6 @@ import ( "yunion.io/x/onecloud/pkg/mcclient/modules" "yunion.io/x/onecloud/pkg/util/httputils" "yunion.io/x/onecloud/pkg/util/logclient" - "yunion.io/x/onecloud/pkg/appsrv" ) const ( @@ -166,7 +166,7 @@ type SHost struct { LastPingAt time.Time `` - ResourceType string `width:"36" charset:"ascii" nullable:"false" list:"admin" update:"admin" create:"admin_required"` // Column(VARCHAR(36, charset='ascii'), nullable=False) + ResourceType string `width:"36" charset:"ascii" nullable:"false" list:"admin" update:"admin" create:"admin_optional" default:"shared"` // Column(VARCHAR(36, charset='ascii'), nullable=False) RealExternalId string `width:"256" charset:"utf8" get:"admin"` } From 8f10bed30addb3cf00811380b91bdbade97ac85e Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 12 Dec 2018 06:24:54 +0000 Subject: [PATCH 11/16] vendor: run "dep ensure" --- vendor/yunion.io/x/pkg/trace/trace.go | 2 ++ .../x/pkg/util/osprofile/osprofile.go | 2 +- .../yunion.io/x/pkg/util/secrules/secrules.go | 19 ++++-------- vendor/yunion.io/x/sqlchemy/conditions.go | 15 +--------- vendor/yunion.io/x/sqlchemy/filter.go | 5 ---- vendor/yunion.io/x/sqlchemy/functions.go | 10 ++----- vendor/yunion.io/x/sqlchemy/insert.go | 2 +- vendor/yunion.io/x/sqlchemy/query.go | 1 - vendor/yunion.io/x/sqlchemy/update.go | 30 ++++++++----------- 9 files changed, 24 insertions(+), 62 deletions(-) diff --git a/vendor/yunion.io/x/pkg/trace/trace.go b/vendor/yunion.io/x/pkg/trace/trace.go index 8d6e4564bc..dd60bd143a 100644 --- a/vendor/yunion.io/x/pkg/trace/trace.go +++ b/vendor/yunion.io/x/pkg/trace/trace.go @@ -6,6 +6,7 @@ import ( "strings" "time" + "yunion.io/x/log" "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" ) @@ -235,4 +236,5 @@ func (tr *STrace) AddClientRequestHeader(header http.Header) { } func SubmitTrace(trace *STrace) { + log.Infof("%s", trace) } diff --git a/vendor/yunion.io/x/pkg/util/osprofile/osprofile.go b/vendor/yunion.io/x/pkg/util/osprofile/osprofile.go index 09cb355365..7d7c92d87f 100644 --- a/vendor/yunion.io/x/pkg/util/osprofile/osprofile.go +++ b/vendor/yunion.io/x/pkg/util/osprofile/osprofile.go @@ -106,7 +106,7 @@ func GetOSProfileFromImageProperties(imgProp map[string]string, hypervisor strin } var imgHypers []string imgHyperStr, ok := imgProp["hypervisor"] - if ok && len(imgHyperStr) > 0 { + if ok { imgHypers = strings.Split(imgHyperStr, ",") } else { imgHypers = []string{} diff --git a/vendor/yunion.io/x/pkg/util/secrules/secrules.go b/vendor/yunion.io/x/pkg/util/secrules/secrules.go index 037bb62d45..6437ff1ae9 100644 --- a/vendor/yunion.io/x/pkg/util/secrules/secrules.go +++ b/vendor/yunion.io/x/pkg/util/secrules/secrules.go @@ -127,21 +127,12 @@ func ParseSecurityRule(pattern string) (*SecurityRule, error) { return nil, ErrInvalidAction } } else if status == SEG_IP { - // NOTE regutils.MatchCIDR actually also matches IP address without prefix length if regutils.MatchCIDR(seg) { - if idx := strings.Index(seg, "/"); idx > -1 { - if _, ipnet, err := net.ParseCIDR(seg); err != nil { - return nil, ErrInvalidNet - } else { - rule.IPNet = ipnet - } - } else if ip := net.ParseIP(seg); ip != nil { - rule.IPNet = &net.IPNet{ - IP: ip, - Mask: net.CIDRMask(32, 32), - } - } else { - return nil, ErrInvalidIPAddr + _, rule.IPNet, _ = net.ParseCIDR(seg) + } else if regutils.MatchIPAddr(seg) { + rule.IPNet = &net.IPNet{ + IP: net.ParseIP(seg), + Mask: net.CIDRMask(32, 32), } } else { rule.IPNet = &net.IPNet{ diff --git a/vendor/yunion.io/x/sqlchemy/conditions.go b/vendor/yunion.io/x/sqlchemy/conditions.go index 59fd7ed8fb..064d60c437 100644 --- a/vendor/yunion.io/x/sqlchemy/conditions.go +++ b/vendor/yunion.io/x/sqlchemy/conditions.go @@ -159,25 +159,12 @@ func IsEmpty(f IQueryField) ICondition { return &c } -type SIsNullOrEmptyCondition struct { - SSingleCondition -} - -func (c *SIsNullOrEmptyCondition) WhereClause() string { - return fmt.Sprintf("%s IS NULL OR LENGTH(%s) = 0", c.field.Reference(), c.field.Reference()) -} - -func IsNullOrEmpty(f IQueryField) ICondition { - c := SIsNullOrEmptyCondition{NewSingleCondition(f)} - return &c -} - type SIsNotEmptyCondition struct { SSingleCondition } func (c *SIsNotEmptyCondition) WhereClause() string { - return fmt.Sprintf("%s IS NOT NULL AND LENGTH(%s) > 0", c.field.Reference(), c.field.Reference()) + return fmt.Sprintf("LENGTH(%s) > 0", c.field.Reference()) } func IsNotEmpty(f IQueryField) ICondition { diff --git a/vendor/yunion.io/x/sqlchemy/filter.go b/vendor/yunion.io/x/sqlchemy/filter.go index 9689d83492..855fcba11f 100644 --- a/vendor/yunion.io/x/sqlchemy/filter.go +++ b/vendor/yunion.io/x/sqlchemy/filter.go @@ -107,11 +107,6 @@ func (q *SQuery) IsEmpty(f string) *SQuery { return q.Filter(cond) } -func (q *SQuery) IsNullOrEmpty(f string) *SQuery { - cond := IsNullOrEmpty(q.Field(f)) - return q.Filter(cond) -} - func (q *SQuery) IsNotEmpty(f string) *SQuery { cond := IsNotEmpty(q.Field(f)) return q.Filter(cond) diff --git a/vendor/yunion.io/x/sqlchemy/functions.go b/vendor/yunion.io/x/sqlchemy/functions.go index 237cdb31f5..c55920f836 100644 --- a/vendor/yunion.io/x/sqlchemy/functions.go +++ b/vendor/yunion.io/x/sqlchemy/functions.go @@ -38,14 +38,8 @@ func NewFunctionField(name string, funcexp string, fields ...IQueryField) SFunct return ff } -func COUNT(name string, field ...IQueryField) IQueryField { - var expr string - if len(field) == 0 { - expr = "COUNT(*)" - } else { - expr = "COUNT(%s)" - } - ff := NewFunctionField(name, expr, field...) +func COUNT(name string) IQueryField { + ff := NewFunctionField(name, "COUNT(*)") return &ff } diff --git a/vendor/yunion.io/x/sqlchemy/insert.go b/vendor/yunion.io/x/sqlchemy/insert.go index 65b8100248..c7442588f0 100644 --- a/vendor/yunion.io/x/sqlchemy/insert.go +++ b/vendor/yunion.io/x/sqlchemy/insert.go @@ -37,7 +37,7 @@ func (t *STableSpec) insertSqlPrep(dataFields map[string]interface{}) (string, [ createdAtFields = append(createdAtFields, k) names = append(names, fmt.Sprintf("`%s`", k)) format = append(format, "UTC_TIMESTAMP()") - } else if ov != nil && (!c.IsZero(ov) || !c.IsText()) && !isAutoInc { + } else if ov != nil && !c.IsZero(ov) && !isAutoInc { v := c.ConvertFromValue(ov) values = append(values, v) names = append(names, fmt.Sprintf("`%s`", k)) diff --git a/vendor/yunion.io/x/sqlchemy/query.go b/vendor/yunion.io/x/sqlchemy/query.go index 60b2cd7cd5..b72b412856 100644 --- a/vendor/yunion.io/x/sqlchemy/query.go +++ b/vendor/yunion.io/x/sqlchemy/query.go @@ -450,7 +450,6 @@ func (q *SQuery) AllStringMap() ([]map[string]string, error) { if err != nil { return nil, err } - defer rows.Close() results := make([]map[string]string, 0) for rows.Next() { result, err := q.rowScan2StringMap(rows) diff --git a/vendor/yunion.io/x/sqlchemy/update.go b/vendor/yunion.io/x/sqlchemy/update.go index 3a6512d2fb..f88e1a6bde 100644 --- a/vendor/yunion.io/x/sqlchemy/update.go +++ b/vendor/yunion.io/x/sqlchemy/update.go @@ -83,16 +83,17 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er setters := make(map[string]SUpdateDiff) for _, c := range us.tableSpec.columns { k := c.Name() - of := ofields[k] + of, ok := ofields[k] + if !ok { + continue + } nf := fields[k] - if !gotypes.IsNil(of) { - if c.IsPrimary() && !c.IsZero(of) { // skip update primary key - primaries[k] = of - continue - } else if c.IsKeyIndex() && !c.IsZero(of) { - keyIndexes[k] = of - continue - } + if c.IsPrimary() && !c.IsZero(of) { // skip update primary key + primaries[k] = of + continue + } else if c.IsKeyIndex() && !c.IsZero(of) { + keyIndexes[k] = of + continue } nc, ok := c.(*SIntegerColumn) if ok && nc.IsAutoVersion { @@ -107,9 +108,6 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er if reflect.DeepEqual(of, nf) { continue } - if c.IsZero(nf) && c.IsText() { - nf = nil - } setters[k] = SUpdateDiff{old: of, new: nf, col: c} } @@ -127,12 +125,8 @@ func (us *SUpdateSession) saveUpdate(dt interface{}) (map[string]SUpdateDiff, er } else { buf.WriteString(", ") } - if gotypes.IsNil(v.new) { - buf.WriteString(fmt.Sprintf("`%s` = NULL", k)) - } else { - buf.WriteString(fmt.Sprintf("`%s` = ?", k)) - vars = append(vars, v.col.ConvertFromValue(v.new)) - } + buf.WriteString(fmt.Sprintf("`%s` = ?", k)) + vars = append(vars, v.col.ConvertFromValue(v.new)) } for _, versionField := range versionFields { buf.WriteString(fmt.Sprintf(", `%s` = `%s` + 1", versionField, versionField)) From 8f8c1a1f1593be121b45778c00318a9399734d0e Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 12 Dec 2018 06:36:52 +0000 Subject: [PATCH 12/16] vendor: run "dep ensure -v -update yunion.io/x/jsonutils" --- Gopkg.lock | 4 +- vendor/yunion.io/x/jsonutils/marshal.go | 77 ++++++++++++------------- vendor/yunion.io/x/jsonutils/utils.go | 14 +++++ 3 files changed, 53 insertions(+), 42 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index 97e5f4c360..4975c42bc7 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -1310,11 +1310,11 @@ [[projects]] branch = "master" - digest = "1:a2346cf0c965791c281a428a3e9bf522913941028e4c814a774af7f3cc2360b0" + digest = "1:30c2a461ac89edba03106741bfd399b5b19354f5a1c8879816e459775e762ae7" name = "yunion.io/x/jsonutils" packages = ["."] pruneopts = "UT" - revision = "814e036849815935e5957ebd03bd0f4fc992fe83" + revision = "3dc94f21b85b0975a07c9cbe6854acf6fd63b77d" [[projects]] branch = "master" diff --git a/vendor/yunion.io/x/jsonutils/marshal.go b/vendor/yunion.io/x/jsonutils/marshal.go index 97630bb987..f1e60f0388 100644 --- a/vendor/yunion.io/x/jsonutils/marshal.go +++ b/vendor/yunion.io/x/jsonutils/marshal.go @@ -130,51 +130,48 @@ func struct2JSONPairs(val reflect.Value) []JSONPair { structType := val.Type() objPairs := make([]JSONPair, 0) for i := 0; i < structType.NumField(); i += 1 { - fieldType := structType.Field(i) - if !gotypes.IsFieldExportable(fieldType.Name) { // unexportable field, ignore + sf := structType.Field(i) + + // ignore unexported field altogether + if !gotypes.IsFieldExportable(sf.Name) { continue } - if fieldType.Anonymous { - nextVal := val.Field(i) - switch fieldType.Type.Kind() { - case reflect.Struct: // embbed struct - nextVal = val.Field(i) - case reflect.Interface: // embbed interface - CHECKINTERFACE: - for { - switch nextVal.Type().Kind() { - case reflect.Interface: - nextVal = nextVal.Elem() - case reflect.Ptr: - nextVal = reflect.Indirect(nextVal) - case reflect.Struct: - break CHECKINTERFACE - default: - log.Warningf("embeded interface point to a non struct data %s", nextVal.Type()) - break CHECKINTERFACE - } - } - default: - log.Warningf("unsupport anonymous embeded type %s", fieldType.Type.Name()) - continue - } - newPairs := struct2JSONPairs(nextVal) - objPairs = append(objPairs, newPairs...) - } else { - jsonInfo := parseJsonMarshalInfo(fieldType.Tag) - if jsonInfo.ignore { + if sf.Anonymous { + fv := val.Field(i) + + // T, *T + switch fv.Kind() { + case reflect.Ptr, reflect.Interface: + // ignore nil values completely + if !fv.IsValid() || fv.IsNil() { + continue + } + fv = fv.Elem() + } + // note that we regard anonymous interface field the + // same as with anonymous struct field. This is + // different from how encoding/json handles struct + // field of interface type. + if fv.Kind() == reflect.Struct { + newPairs := struct2JSONPairs(fv) + objPairs = append(objPairs, newPairs...) continue } - key := jsonInfo.name - if len(key) == 0 { - key = utils.CamelSplit(fieldType.Name, "_") - } - val := marshalValue(val.Field(i), &jsonInfo) - if val != nil && val != JSONNull { - objPair := JSONPair{key: key, val: val} - objPairs = append(objPairs, objPair) - } + } + + jsonInfo := parseJsonMarshalInfo(sf.Tag) + if jsonInfo.ignore { + continue + } + key := jsonInfo.name + if len(key) == 0 { + key = utils.CamelSplit(sf.Name, "_") + } + val := marshalValue(val.Field(i), &jsonInfo) + if val != nil && val != JSONNull { + objPair := JSONPair{key: key, val: val} + objPairs = append(objPairs, objPair) } } return objPairs diff --git a/vendor/yunion.io/x/jsonutils/utils.go b/vendor/yunion.io/x/jsonutils/utils.go index 5c80a2c90b..cfd77eee04 100644 --- a/vendor/yunion.io/x/jsonutils/utils.go +++ b/vendor/yunion.io/x/jsonutils/utils.go @@ -93,3 +93,17 @@ func GetAnyString(json JSONObject, keys []string) string { } return "" } + +func GetArrayOfPrefix(json JSONObject, prefix string) []JSONObject { + retArray := make([]JSONObject, 0) + idx := 0 + for { + obj, _ := json.Get(fmt.Sprintf("%s.%d", prefix, idx)) + if obj == nil || obj == JSONNull { + break + } + retArray = append(retArray, obj) + idx += 1 + } + return retArray +} From 953da6e348be9d2e1bd9ffc4382d8193e3dbad1c Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 12 Dec 2018 14:41:55 +0800 Subject: [PATCH 13/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcapabilities=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3hypervisors=E4=B8=BA=E7=A9=BA=E5=BC=95=E5=8F=91?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/capabilities.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/capabilities.go b/pkg/compute/models/capabilities.go index c85fe238ba..d384e59edb 100644 --- a/pkg/compute/models/capabilities.go +++ b/pkg/compute/models/capabilities.go @@ -11,8 +11,8 @@ import ( ) type SCapabilities struct { - Hypervisors []string - StorageTypes []string + Hypervisors []string `json:",allowempty"` + StorageTypes []string `json:",allowempty"` GPUModels []string MinNicCount int MaxNicCount int From 68249b00d74fd1e801fe639cf1959272c16711a9 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 12 Dec 2018 15:06:09 +0800 Subject: [PATCH 14/16] =?UTF-8?q?project=E5=88=A0=E9=99=A4bufix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/mcclient/modules/mod_projects.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/mcclient/modules/mod_projects.go b/pkg/mcclient/modules/mod_projects.go index 4e89b08009..513c5c8883 100644 --- a/pkg/mcclient/modules/mod_projects.go +++ b/pkg/mcclient/modules/mod_projects.go @@ -242,6 +242,7 @@ func (this *ProjectManagerV3) DeleteInContexts(session *mcclient.ClientSession, if ctxs == nil { p := jsonutils.NewDict() p.Add(jsonutils.JSONTrue, "admin") + p.Add(jsonutils.JSONTrue, "system") p.Add(jsonutils.NewString(id), "tenant") ret, e := Servers.List(session, p) if e != nil { From c3a5afd88ea1056a1f05f16fa3460a3e06a59581 Mon Sep 17 00:00:00 2001 From: TangBin Date: Wed, 12 Dec 2018 15:09:03 +0800 Subject: [PATCH 15/16] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dcapabilities=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3hypervisors=E4=B8=BA=E7=A9=BA=E5=BC=95=E5=8F=91?= =?UTF-8?q?=E7=9A=84=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/capabilities.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/compute/models/capabilities.go b/pkg/compute/models/capabilities.go index d384e59edb..f0bdff951f 100644 --- a/pkg/compute/models/capabilities.go +++ b/pkg/compute/models/capabilities.go @@ -13,7 +13,7 @@ import ( type SCapabilities struct { Hypervisors []string `json:",allowempty"` StorageTypes []string `json:",allowempty"` - GPUModels []string + GPUModels []string `json:",allowempty"` MinNicCount int MaxNicCount int MinDataDiskCount int From 432bab6fa5051f640b214b7fdfc26f544534d1b8 Mon Sep 17 00:00:00 2001 From: Yousong Zhou Date: Wed, 12 Dec 2018 07:35:40 +0000 Subject: [PATCH 16/16] =?UTF-8?q?loadbalancerlisteners:=20=E6=94=B9?= =?UTF-8?q?=E6=AD=A3rps=20update?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/compute/models/loadbalancerlisteners.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/compute/models/loadbalancerlisteners.go b/pkg/compute/models/loadbalancerlisteners.go index 458502672c..4828b3ecea 100644 --- a/pkg/compute/models/loadbalancerlisteners.go +++ b/pkg/compute/models/loadbalancerlisteners.go @@ -352,8 +352,8 @@ func (lblis *SLoadbalancerListener) ValidateUpdateData(ctx context.Context, user "x_forwarded_for": validators.NewBoolValidator("x_forwarded_for"), "gzip": validators.NewBoolValidator("gzip"), - "http_request_rate": validators.NewNonNegativeValidator("http_request_rate").Default(0), - "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src").Default(0), + "http_request_rate": validators.NewNonNegativeValidator("http_request_rate"), + "http_request_rate_per_src": validators.NewNonNegativeValidator("http_request_rate_per_src"), "certificate": certV, "tls_cipher_policy": tlsCipherPolicyV,