mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 16:13:56 +08:00
Compare commits
270 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
caa530bd60 | ||
|
|
559d30afa8 | ||
|
|
b8c10b8e7c | ||
|
|
b3285aebce | ||
|
|
ad01c895cf | ||
|
|
b2aa6dd321 | ||
|
|
a4dcc91d0d | ||
|
|
18a751548c | ||
|
|
b53b09ebb5 | ||
|
|
c6941536b7 | ||
|
|
edba3c3dfc | ||
|
|
a66c1aa1ba | ||
|
|
c5dd4389d3 | ||
|
|
0e4ea782e1 | ||
|
|
9b993f1a99 | ||
|
|
8a62c46a92 | ||
|
|
d3ad4967a9 | ||
|
|
37897cadc7 | ||
|
|
9a8111de6c | ||
|
|
9cdd7dd2da | ||
|
|
8549df1a00 | ||
|
|
cd9b632d08 | ||
|
|
ac8ba1e86d | ||
|
|
2add6fc1f5 | ||
|
|
45eda7c703 | ||
|
|
85008a7b0c | ||
|
|
2f9cfae375 | ||
|
|
410782cffc | ||
|
|
9342ccf9c3 | ||
|
|
29c96f2d2b | ||
|
|
df7d68e404 | ||
|
|
869744d1bb | ||
|
|
b01a477cb2 | ||
|
|
1ec3d6ddf0 | ||
|
|
984006ea31 | ||
|
|
1bc2c75e06 | ||
|
|
cf8b548392 | ||
|
|
a898d76094 | ||
|
|
30ee4056e1 | ||
|
|
7d64b9fffc | ||
|
|
3da4dd1953 | ||
|
|
014170e74a | ||
|
|
db60e37c4d | ||
|
|
4ac56f7fc3 | ||
|
|
9494c0939a | ||
|
|
1e1941cd7b | ||
|
|
70d2e5c84d | ||
|
|
4e864a7a86 | ||
|
|
5bce2bd959 | ||
|
|
8089afa122 | ||
|
|
da66f26503 | ||
|
|
8450fe9ea0 | ||
|
|
b0163b6a70 | ||
|
|
b19762e1a9 | ||
|
|
c3fd4937d3 | ||
|
|
77e19e79a0 | ||
|
|
c069179adc | ||
|
|
fdf51560a3 | ||
|
|
9561c0c8d4 | ||
|
|
b0d7d2f912 | ||
|
|
35c0e52de9 | ||
|
|
ec5995da4b | ||
|
|
21567833fd | ||
|
|
159fba33b6 | ||
|
|
5b0247a35f | ||
|
|
62c39c62cd | ||
|
|
995b24c319 | ||
|
|
82e1234ed4 | ||
|
|
208a49e3d4 | ||
|
|
c8388cab1a | ||
|
|
45b538bd2a | ||
|
|
f2e3766bee | ||
|
|
2154e7c18b | ||
|
|
27dc7b6296 | ||
|
|
ae64d437f2 | ||
|
|
8d842b0d2f | ||
|
|
34d0478af1 | ||
|
|
b1bec7337f | ||
|
|
de77edc357 | ||
|
|
2ce7f7b9fe | ||
|
|
e6206944dd | ||
|
|
02bac8b9ae | ||
|
|
78c10c78cc | ||
|
|
433807432a | ||
|
|
0f973234b8 | ||
|
|
58810cde95 | ||
|
|
36a9314427 | ||
|
|
2864b15ecc | ||
|
|
0ee2cbcf60 | ||
|
|
44252983e9 | ||
|
|
532ada4bf9 | ||
|
|
df4a02ac49 | ||
|
|
6d5941eaad | ||
|
|
f77c4d078a | ||
|
|
5364ba5641 | ||
|
|
f4d8225a10 | ||
|
|
9122c7e10d | ||
|
|
3e3d356ffc | ||
|
|
1c86c0d73a | ||
|
|
aa937e6966 | ||
|
|
706980e233 | ||
|
|
47fdfc78c9 | ||
|
|
96d199724e | ||
|
|
50a36e3906 | ||
|
|
3817b9e6ad | ||
|
|
e4c07c0304 | ||
|
|
2ff318a5b8 | ||
|
|
e8605a1758 | ||
|
|
ee391ed98a | ||
|
|
d2702b67f9 | ||
|
|
deae194d43 | ||
|
|
aad036a822 | ||
|
|
16f59a2f2c | ||
|
|
4aec6e7e36 | ||
|
|
c553099588 | ||
|
|
5863e4a73d | ||
|
|
bc3aa5432f | ||
|
|
bd666ee815 | ||
|
|
2ad30a0872 | ||
|
|
c5655ed2ba | ||
|
|
3d99fe914d | ||
|
|
d357f03757 | ||
|
|
28e5b39fff | ||
|
|
2d248612e0 | ||
|
|
0ebde53d20 | ||
|
|
8ac922480e | ||
|
|
212bdc0907 | ||
|
|
31436641cc | ||
|
|
5e3861b28b | ||
|
|
475842e818 | ||
|
|
f3fee11711 | ||
|
|
d1d62de884 | ||
|
|
20f2ed2b1f | ||
|
|
529da18451 | ||
|
|
ee5351b536 | ||
|
|
f82e51af65 | ||
|
|
91680e5fca | ||
|
|
c74b89332d | ||
|
|
b8e6b5db7b | ||
|
|
8471421b87 | ||
|
|
ab6d57afea | ||
|
|
5920af6aee | ||
|
|
df6d774d69 | ||
|
|
5d69ae9a02 | ||
|
|
c3be526988 | ||
|
|
9d1267b0f7 | ||
|
|
e762b2e2e0 | ||
|
|
cfefa015fd | ||
|
|
986fa9881f | ||
|
|
ffe1c9050b | ||
|
|
07bcf6a7a7 | ||
|
|
0e01df9200 | ||
|
|
9e5667c50a | ||
|
|
fd7fe62930 | ||
|
|
eba5bd84df | ||
|
|
9080fdbde3 | ||
|
|
ec76d129f6 | ||
|
|
ee9e59df88 | ||
|
|
c2765f5fda | ||
|
|
8cd9d39155 | ||
|
|
e77ca84876 | ||
|
|
76ca993e8a | ||
|
|
aa96758354 | ||
|
|
8a35ef6bcc | ||
|
|
e2ab5190c6 | ||
|
|
af006498f8 | ||
|
|
b54ebf45f3 | ||
|
|
639e1f045c | ||
|
|
1c68b97c86 | ||
|
|
ec47e47734 | ||
|
|
76fd4945bd | ||
|
|
60ca1f7266 | ||
|
|
220fb5bca5 | ||
|
|
0ea12ffcc6 | ||
|
|
f80c6a214a | ||
|
|
29343a6828 | ||
|
|
b9d08c74a3 | ||
|
|
4b06ee94d0 | ||
|
|
bf625de12d | ||
|
|
60dbb28022 | ||
|
|
43407d3d77 | ||
|
|
9e5018b147 | ||
|
|
43f5c84955 | ||
|
|
91dd66b5a8 | ||
|
|
1615426f29 | ||
|
|
3df0be2fd4 | ||
|
|
7d9a3c04b1 | ||
|
|
1a2204d146 | ||
|
|
ed6c42ae37 | ||
|
|
372c9a393f | ||
|
|
37f648bfb8 | ||
|
|
1818d4853a | ||
|
|
ff5396b909 | ||
|
|
b2854aff23 | ||
|
|
da30ae5efd | ||
|
|
17face8f52 | ||
|
|
9a8277ff20 | ||
|
|
61eaea8099 | ||
|
|
6f0d6cbeac | ||
|
|
09ed698ae8 | ||
|
|
7bf1bef04a | ||
|
|
024a17de83 | ||
|
|
0f5a8b6407 | ||
|
|
cd4ce681b0 | ||
|
|
fc16c37eab | ||
|
|
3dfd086a27 | ||
|
|
8e2cd5112d | ||
|
|
a5d82922bd | ||
|
|
9d19bf34b0 | ||
|
|
e4bf0fa8dc | ||
|
|
6bd82d216d | ||
|
|
60138f6401 | ||
|
|
a43f747bdc | ||
|
|
2560198943 | ||
|
|
6e0d4cb35c | ||
|
|
71535f670e | ||
|
|
5e47566b42 | ||
|
|
c325d8355c | ||
|
|
206dc2a62d | ||
|
|
55a7de9ba6 | ||
|
|
3b2938380a | ||
|
|
3774549979 | ||
|
|
9c2cc664f6 | ||
|
|
42582043ee | ||
|
|
690aef8f4e | ||
|
|
eb7173085e | ||
|
|
b6917c5604 | ||
|
|
47349e71b9 | ||
|
|
3d2b24a351 | ||
|
|
b9565f288a | ||
|
|
6b0ae74acb | ||
|
|
438a0cb0b7 | ||
|
|
3fb97c99b6 | ||
|
|
ad8459053f | ||
|
|
491a9ece55 | ||
|
|
ba2a188f0d | ||
|
|
ea793d9902 | ||
|
|
4b4964e58e | ||
|
|
4a06b38da8 | ||
|
|
96400124ba | ||
|
|
aee0299d71 | ||
|
|
cbea17b4c4 | ||
|
|
4acb237f70 | ||
|
|
3a8e998718 | ||
|
|
bef9af4c3b | ||
|
|
3e17ee7519 | ||
|
|
d3aba7285a | ||
|
|
43f4f5f946 | ||
|
|
4d3c7f3059 | ||
|
|
fd26fc1947 | ||
|
|
b74f61fe1d | ||
|
|
dc19e7b035 | ||
|
|
37272588fa | ||
|
|
029530ac34 | ||
|
|
c047d69a53 | ||
|
|
6f76c5d670 | ||
|
|
71ddac232d | ||
|
|
ca9859f126 | ||
|
|
7db6ad9a01 | ||
|
|
b545066e05 | ||
|
|
befef016dc | ||
|
|
c32ad0ac5b | ||
|
|
ecc75aa231 | ||
|
|
202e0bf266 | ||
|
|
c4d4700d26 | ||
|
|
1fce2ec30c | ||
|
|
dfe7661c61 | ||
|
|
5a28b3c13e | ||
|
|
27c8861b64 | ||
|
|
e9459b4a7d |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -31,6 +31,7 @@ _output
|
||||
/structargtest
|
||||
.idea
|
||||
.vscode
|
||||
intellij.yaml
|
||||
GPATH
|
||||
GRTAGS
|
||||
GTAGS
|
||||
|
||||
2
Makefile
2
Makefile
@@ -9,7 +9,7 @@ BUILD_SCRIPT := $(ROOT_DIR)/build/build.sh
|
||||
|
||||
ifeq ($(ONECLOUD_CI_BUILD),)
|
||||
GIT_COMMIT := $(shell git rev-parse --short HEAD)
|
||||
GIT_BRANCH := $(shell git name-rev --name-only HEAD)
|
||||
GIT_BRANCH := $(shell git branch -r --contains | head -1 | sed -E -e "s%(HEAD ->|origin|upstream)/?%%g" | xargs)
|
||||
GIT_VERSION := $(shell git describe --always --tags --abbrev=14 $(GIT_COMMIT)^{commit})
|
||||
GIT_TREE_STATE := $(shell s=`git status --porcelain 2>/dev/null`; if [ -z "$$s" ]; then echo "clean"; else echo "dirty"; fi)
|
||||
BUILD_DATE := $(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
## {{.title}}
|
||||
- 时间: {{.start_time}}
|
||||
- 级别: {{.level}}
|
||||
- 详情地址: {{.web_url}}/commonalerts
|
||||
|
||||
{{ range .matches}}
|
||||
- 指标: {{.metric}}
|
||||
- 触发值: {{html .value_str}}
|
||||
|
||||
### 触发条件:
|
||||
- {{html $.description}}
|
||||
|
||||
### 标签
|
||||
> 名称: {{ index .tags "name" }}
|
||||
> ip: {{ index .tags "ip" }}
|
||||
> 平台: {{ index .tags "brand" }}
|
||||
------
|
||||
{{- end}}
|
||||
@@ -1,18 +0,0 @@
|
||||
## {{.title}}
|
||||
- Time: {{.start_time}}
|
||||
- Level: {{.level}}
|
||||
- WebUrl: {{.web_url}}/commonalerts
|
||||
|
||||
{{ range .matches}}
|
||||
- Metric: {{.metric}}
|
||||
- Trigger value: {{html .value_str}}
|
||||
|
||||
### Trigger condition:
|
||||
- {{html $.description }}
|
||||
|
||||
### Label
|
||||
> Name: {{ index .tags "name" }}
|
||||
> IP: {{ index .tags "ip" }}
|
||||
> Brand: {{ index .tags "brand" }}
|
||||
------
|
||||
{{- end}}
|
||||
@@ -0,0 +1,9 @@
|
||||
{{.title}}
|
||||
策略名称: {{.name}}
|
||||
触发时间: {{.start_time}}
|
||||
报警级别: {{.level}}
|
||||
触发条件: {{.description | unescaped}}
|
||||
资源数量:{{len .matches}}
|
||||
资源名称:{{.resource_name}}
|
||||
|
||||
详情地址: {{.web_url}}/commonalerts
|
||||
@@ -0,0 +1,9 @@
|
||||
{{.title}}
|
||||
AlertName: {{.name}}
|
||||
Time: {{.start_time}}
|
||||
Level: {{.level}}
|
||||
TriggerCondition: {{.description | unescaped}}
|
||||
ResourceCount: {{len .matches}}
|
||||
ResourceName: {{.resource_name}}
|
||||
|
||||
WebUrl: {{.web_url}}/commonalerts
|
||||
@@ -19,6 +19,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
@@ -26,6 +27,23 @@ import (
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.Cloudregions).WithKeyword("cloud-region")
|
||||
cmd.PerformClass("sync-skus", &options.CloudregionSkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "cloud-region-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.Cloudregions.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type CloudregionListOptions struct {
|
||||
options.BaseListOptions
|
||||
|
||||
|
||||
@@ -15,12 +15,30 @@
|
||||
package compute
|
||||
|
||||
import (
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.DBInstanceSkus).WithKeyword("dbinstance-sku")
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "dbinstance-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.DBInstanceSkus.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type DBInstanceSkuListOption struct {
|
||||
options.BaseListOptions
|
||||
Engine string
|
||||
@@ -54,5 +72,4 @@ func init() {
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -19,12 +19,30 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.ElasticcacheSkus).WithKeyword("elastic-cache-sku")
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "elastic-cache-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticcacheSkus.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.BaseListOptions{}, "elastic-cache-list", "List elastisc cache instance", func(s *mcclient.ClientSession, opts *options.BaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
|
||||
@@ -50,7 +50,7 @@ func init() {
|
||||
Manager string `help:"cloud provider"`
|
||||
Region string `help:"cloud region in which EIP is allocated"`
|
||||
Bandwidth int `help:"Bandwidth in Mbps"`
|
||||
Ip string `help:"IP address of the EIP"`
|
||||
IpAddr string `help:"IP address of the EIP" json:"ip_addr"`
|
||||
Network string `help:"Network of the EIP"`
|
||||
ChargeType string `help:"bandwidth charge type" choices:"traffic|bandwidth"`
|
||||
}
|
||||
@@ -75,8 +75,8 @@ func init() {
|
||||
params.Add(jsonutils.NewString(args.Network), "network")
|
||||
}
|
||||
|
||||
if len(args.Ip) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Ip), "ip")
|
||||
if len(args.IpAddr) > 0 {
|
||||
params.Add(jsonutils.NewString(args.IpAddr), "ip_addr")
|
||||
}
|
||||
|
||||
result, err := modules.Elasticips.Create(s, params)
|
||||
|
||||
@@ -407,12 +407,14 @@ func init() {
|
||||
})
|
||||
|
||||
type HostAddNetIfOptions struct {
|
||||
ID string `help:"ID or Name of host"`
|
||||
WIRE string `help:"ID or Name of wire to attach"`
|
||||
MAC string `help:"Mac address of NIC"`
|
||||
INDEX int64 `help:"nic index"`
|
||||
Type string `help:"Nic type" choices:"admin|ipmi"`
|
||||
IpAddr string `help:"IP address"`
|
||||
ID string `help:"ID or Name of host"`
|
||||
WIRE string `help:"ID or Name of wire to attach"`
|
||||
MAC string `help:"Mac address of NIC"`
|
||||
INDEX int64 `help:"nic index"`
|
||||
Type string `help:"Nic type" choices:"admin|ipmi"`
|
||||
IpAddr string `help:"IP address"`
|
||||
Bridge string `help:"Bridge of hostwire"`
|
||||
Interface string `help:"Interface name, eg:eth0, en0"`
|
||||
}
|
||||
R(&HostAddNetIfOptions{}, "host-add-netif", "Host add a NIC", func(s *mcclient.ClientSession, args *HostAddNetIfOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
@@ -426,6 +428,12 @@ func init() {
|
||||
if len(args.IpAddr) > 0 {
|
||||
params.Add(jsonutils.NewString(args.IpAddr), "ip_addr")
|
||||
}
|
||||
if len(args.Bridge) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Bridge), "bridge")
|
||||
}
|
||||
if len(args.Interface) > 0 {
|
||||
params.Add(jsonutils.NewString(args.Interface), "interface")
|
||||
}
|
||||
result, err := modules.Hosts.PerformAction(s, args.ID, "add-netif", params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -316,7 +316,7 @@ func init() {
|
||||
QuotaSetBaseOptions
|
||||
IdentityQuotaOptions
|
||||
}
|
||||
R(&IdentityQuotaSetOptions{}, "identity-quota-set", "Set identity quota for domain", func(s *mcclient.ClientSession, args *InfrasQuotaSetOptions) error {
|
||||
R(&IdentityQuotaSetOptions{}, "identity-quota-set", "Set identity quota for domain", func(s *mcclient.ClientSession, args *IdentityQuotaSetOptions) error {
|
||||
params := jsonutils.Marshal(args)
|
||||
quotas, e := modules.IdentityQuotas.DoQuotaSet(s, params)
|
||||
if e != nil {
|
||||
|
||||
@@ -123,9 +123,10 @@ func init() {
|
||||
})
|
||||
|
||||
type SchedulerHistoryListOptions struct {
|
||||
Limit int `default:"50" help:"Page limit"`
|
||||
Offset int `default:"0" help:"Page offset"`
|
||||
All bool `help:"Show all histories, including scheduler-test"`
|
||||
Limit int `default:"50" help:"Page limit"`
|
||||
Offset int `default:"0" help:"Page offset"`
|
||||
All bool `help:"Show all histories, including scheduler-test"`
|
||||
IsSuggestion bool `help:"Only show forcast suggestion history"`
|
||||
}
|
||||
R(&SchedulerHistoryListOptions{}, "scheduler-history-list", "Show scheduler history list",
|
||||
func(s *mcclient.ClientSession, args *SchedulerHistoryListOptions) error {
|
||||
@@ -138,17 +139,14 @@ func init() {
|
||||
if args.Offset > 0 {
|
||||
params.Add(jsonutils.NewInt(int64(args.Offset)), "offset")
|
||||
}
|
||||
if args.All {
|
||||
params.Add(jsonutils.JSONTrue, "all")
|
||||
} else {
|
||||
params.Add(jsonutils.JSONFalse, "all")
|
||||
}
|
||||
params.Add(jsonutils.NewBool(args.All), "all")
|
||||
params.Add(jsonutils.NewBool(args.IsSuggestion), "is_suggestion")
|
||||
result, err := modules.SchedManager.HistoryList(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printList(modulebase.JSON2ListResult(result), []string{
|
||||
"session_id", "time", "status", "consuming",
|
||||
"session_id", "time", "status", "consuming", "is_suggestion",
|
||||
})
|
||||
return nil
|
||||
})
|
||||
|
||||
@@ -17,12 +17,30 @@ package compute
|
||||
import (
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/cmd/climc/shell"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
cmd := shell.NewResourceCmd(&modules.ServerSkus).WithKeyword("server-sku")
|
||||
cmd.PerformClass("sync-skus", &options.SkuSyncOptions{})
|
||||
|
||||
R(&options.SkuTaskQueryOptions{}, "server-sku-sync-task-show", "Show details of skus sync tasks", func(s *mcclient.ClientSession, args *options.SkuTaskQueryOptions) error {
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ServerSkus.Get(s, "sync-tasks", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ServerSkusListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudregion string `help:"region Id or name"`
|
||||
|
||||
@@ -61,13 +61,14 @@ func init() {
|
||||
ID string `help:"ID or Name of storage to update"`
|
||||
Name string `help:"New Name of storage"`
|
||||
Desc string `help:"Description"`
|
||||
CommitBound float64 `help:"Upper bound of storage overcommit rate"`
|
||||
CommitBound float64 `help:"Upper bound of storage overcommit rate" json:"cmtbound"`
|
||||
MediumType string `help:"Medium type" choices:"ssd|rotate"`
|
||||
RbdRadosMonOpTimeout int64 `help:"ceph rados_mon_op_timeout"`
|
||||
RbdRadosOsdOpTimeout int64 `help:"ceph rados_osd_op_timeout"`
|
||||
RbdClientMountTimeout int64 `help:"ceph client_mount_timeout"`
|
||||
RbdKey string `help:"ceph rbd key"`
|
||||
Reserved string `help:"Reserved storage space"`
|
||||
Capacity int `help:"Capacity for storage"`
|
||||
}
|
||||
R(&StorageUpdateOptions{}, "storage-update", "Update a storage", func(s *mcclient.ClientSession, args *StorageUpdateOptions) error {
|
||||
params, err := options.StructToParams(args)
|
||||
|
||||
@@ -42,34 +42,24 @@ func init() {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
connParams, err := obj.GetString("connect_params")
|
||||
if err != nil {
|
||||
|
||||
resp := &webconsole_api.ServerRemoteConsoleResponse{}
|
||||
if err := obj.Unmarshal(resp); err != nil {
|
||||
return err
|
||||
}
|
||||
if decodeStr, err := base64.StdEncoding.DecodeString(connParams); err == nil {
|
||||
connParams = string(decodeStr)
|
||||
}
|
||||
var query url.Values
|
||||
connUrl, err := url.ParseRequestURI(connParams)
|
||||
if err == nil {
|
||||
query = connUrl.Query()
|
||||
} else {
|
||||
query, err = url.ParseQuery(connParams)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
protocol := query.Get("protocol")
|
||||
if !utils.IsInStringArray(protocol, []string{
|
||||
connectParams := resp.GetConnectParams()
|
||||
if protocol, err := resp.GetConnectProtocol(); err != nil {
|
||||
return err
|
||||
} else if !utils.IsInStringArray(protocol, []string{
|
||||
command.PROTOCOL_TTY, webconsole_api.VNC,
|
||||
webconsole_api.SPICE, webconsole_api.WMKS,
|
||||
}) {
|
||||
fmt.Println(connParams)
|
||||
fmt.Println(connectParams)
|
||||
return nil
|
||||
}
|
||||
|
||||
newQuery := url.Values(make(map[string][]string))
|
||||
newQuery.Set("data", base64.StdEncoding.EncodeToString([]byte(connParams)))
|
||||
newQuery := url.Values{}
|
||||
newQuery.Set("data", base64.StdEncoding.EncodeToString([]byte(connectParams)))
|
||||
u.RawQuery = newQuery.Encode()
|
||||
fmt.Println(u.String())
|
||||
return nil
|
||||
|
||||
@@ -284,7 +284,10 @@ type IPerformOpt interface {
|
||||
func (cmd ResourceCmd) Perform(action string, args IPerformOpt) {
|
||||
man := cmd.manager
|
||||
callback := func(s *mcclient.ClientSession, args IPerformOpt) error {
|
||||
params := jsonutils.Marshal(args) // .Params()
|
||||
params, err := args.Params()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ret, err := man.(modulebase.Manager).PerformAction(s, args.GetId(), action, params)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
"yunion.io/x/onecloud/pkg/util/fileutils2"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
"yunion.io/x/onecloud/pkg/util/shellutils"
|
||||
)
|
||||
@@ -183,6 +184,7 @@ func init() {
|
||||
type PolicyShowOptions struct {
|
||||
ID string `help:"ID of policy"`
|
||||
Format string `help:"policy format, default yaml" default:"yaml" choices:"yaml|json"`
|
||||
Save string `help:"save policy data into a file"`
|
||||
}
|
||||
R(&PolicyShowOptions{}, "policy-show", "Show policy", func(s *mcclient.ClientSession, args *PolicyShowOptions) error {
|
||||
query := jsonutils.NewDict()
|
||||
@@ -192,6 +194,15 @@ func init() {
|
||||
return err
|
||||
}
|
||||
printObject(result)
|
||||
if len(args.Save) > 0 {
|
||||
if args.Format == "yaml" {
|
||||
yaml, _ := result.GetString("policy")
|
||||
fileutils2.FilePutContents(args.Save, yaml, false)
|
||||
} else {
|
||||
p, _ := result.Get("policy")
|
||||
fileutils2.FilePutContents(args.Save, p.PrettyString(), false)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
})
|
||||
|
||||
|
||||
2
go.mod
2
go.mod
@@ -141,7 +141,7 @@ require (
|
||||
k8s.io/cluster-bootstrap v0.17.3
|
||||
k8s.io/kubernetes v1.16.0
|
||||
yunion.io/x/executor v0.0.0-20200227030256-a18417815e74
|
||||
yunion.io/x/jsonutils v0.0.0-20201105032201-9d0fba742954
|
||||
yunion.io/x/jsonutils v0.0.0-20201110084044-3e4e1cb49769
|
||||
yunion.io/x/log v0.0.0-20200313080802-57a4ce5966b3
|
||||
yunion.io/x/ovsdb v0.0.0-20200526071744-27bf0940cbc7
|
||||
yunion.io/x/pkg v0.0.0-20201028134817-3ed15ee169bc
|
||||
|
||||
2
go.sum
2
go.sum
@@ -1126,6 +1126,8 @@ yunion.io/x/executor v0.0.0-20200227030256-a18417815e74/go.mod h1:Uxuou9WQIeJXNp
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
yunion.io/x/jsonutils v0.0.0-20201105032201-9d0fba742954 h1:gGU3uGxw82voqh3tVrTY4q43lLLooqgF662PqOeEpKY=
|
||||
yunion.io/x/jsonutils v0.0.0-20201105032201-9d0fba742954/go.mod h1:p0nyMqGA/apTxxyLIU/o1k4V7Vujl2O6ey30L594sYE=
|
||||
yunion.io/x/jsonutils v0.0.0-20201110084044-3e4e1cb49769 h1:LIQ4hhLGQuQK+XxlV+8JrKBuL37WUT+5ZTVxBwHOTD4=
|
||||
yunion.io/x/jsonutils v0.0.0-20201110084044-3e4e1cb49769/go.mod h1:p0nyMqGA/apTxxyLIU/o1k4V7Vujl2O6ey30L594sYE=
|
||||
yunion.io/x/log v0.0.0-20190514041436-04ce53b17c6b/go.mod h1:+gauLs73omeJAPlsXcevLsJLKixV+sR/E7WSYTSx1fE=
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d h1:59zrDL7Ft+hDukguJRmLr/Gdu/9V75x+yX99ovZwfaA=
|
||||
yunion.io/x/log v0.0.0-20190629062853-9f6483a7103d/go.mod h1:LC6f/4FozL0iaAbnFt2eDX9jlsyo3WiOUPm03d7+U4U=
|
||||
|
||||
5661
locales/locales.go
5661
locales/locales.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -24,12 +24,13 @@ type DBInstanceCreateInput struct {
|
||||
apis.VirtualResourceCreateInput
|
||||
DeletePreventableCreateInput
|
||||
|
||||
// Ip子网名称或Id,建议使用Id
|
||||
// Ip子网Id
|
||||
// 谷歌云并不实际使用Ip子网,仅仅通过Ip子网确定Vpc
|
||||
// required: true
|
||||
Network string `json:"network"`
|
||||
NetworkId string `json:"network_id"`
|
||||
|
||||
// swagger:ignore
|
||||
NetworkId string
|
||||
Network string `json:"network" yunion-deprecated-by:"network_id"`
|
||||
|
||||
// Ip子网内的地址,不填则按照ip子网的地址分配策略分配一个ip
|
||||
// required: false
|
||||
@@ -66,8 +67,10 @@ type DBInstanceCreateInput struct {
|
||||
// swagger:ignore
|
||||
CloudregionId string
|
||||
|
||||
VpcId string `json:"vpc_id"`
|
||||
|
||||
// swagger:ignore
|
||||
VpcId string
|
||||
Vpc string `json:"vpc" yunion-deprecated-by:"vpc_id"`
|
||||
|
||||
// swagger:ignore
|
||||
ManagerId string
|
||||
@@ -142,6 +145,9 @@ type DBInstanceCreateInput struct {
|
||||
// required: true
|
||||
DiskSizeGB int `json:"disk_size_gb"`
|
||||
|
||||
// 指定连接端口
|
||||
Port int `json:"port"`
|
||||
|
||||
// rds初始化密码
|
||||
// 阿里云不需要此参数
|
||||
// 华为云会默认创建一个用户,若不传此参数, 则为随机密码
|
||||
@@ -163,6 +169,9 @@ type DBInstanceCreateInput struct {
|
||||
|
||||
// swagger:ignore
|
||||
Provider string
|
||||
|
||||
// 从备份中创建新实例
|
||||
DBInstancebackupId string `json:"dbinstancebackup_id"`
|
||||
}
|
||||
|
||||
type SDBInstanceChangeConfigInput struct {
|
||||
|
||||
@@ -67,6 +67,8 @@ type SElasticipCreateInput struct {
|
||||
// 子网Id
|
||||
// 私有云创建此参数必传,例如Openstack, ZStack
|
||||
NetworkId string `json:"network_id"`
|
||||
// 指定新建EIP的地址
|
||||
IpAddr string `json:"ip_addr"`
|
||||
}
|
||||
|
||||
type ElasticipDetails struct {
|
||||
|
||||
@@ -42,7 +42,6 @@ const (
|
||||
|
||||
EIP_CHARGE_TYPE_BY_TRAFFIC = "traffic"
|
||||
EIP_CHARGE_TYPE_BY_BANDWIDTH = "bandwidth"
|
||||
EIP_CHARGE_TYPE_DEFAULT = EIP_CHARGE_TYPE_BY_TRAFFIC
|
||||
)
|
||||
|
||||
var (
|
||||
|
||||
@@ -249,6 +249,8 @@ var HOSTTYPE_HYPERVISOR = map[string]string{
|
||||
}
|
||||
|
||||
const (
|
||||
VM_DEFAULT_WINDOWS_LOGIN_USER = "Administrator"
|
||||
VM_DEFAULT_LINUX_LOGIN_USER = "root"
|
||||
VM_AWS_DEFAULT_LOGIN_USER = "ec2user"
|
||||
VM_AWS_DEFAULT_WINDOWS_LOGIN_USER = "Administrator"
|
||||
VM_AZURE_DEFAULT_LOGIN_USER = "toor"
|
||||
|
||||
@@ -41,6 +41,11 @@ type ServerListInput struct {
|
||||
Baremetal *bool `json:"baremetal"`
|
||||
// 只列出GPU主机
|
||||
Gpu *bool `json:"gpu"`
|
||||
// 只列出还有备份机的主机
|
||||
Backup *bool `json:"bakcup"`
|
||||
// 列出指定类型的主机
|
||||
// enum: normal,gpu,backup
|
||||
ServerType string `json:"server_type"`
|
||||
// 列出管理安全组为指定安全组的主机
|
||||
AdminSecgroup string `json:"admin_security"`
|
||||
// 列出Hypervisor为指定值的主机
|
||||
@@ -209,6 +214,8 @@ type ServerDetails struct {
|
||||
Vpc string `json:"vpc"`
|
||||
// 归属VPC ID
|
||||
VpcId string `json:"vpc_id"`
|
||||
// Vpc外网访问模式
|
||||
VpcExternalAccessMode string `json:"vpc_external_access_mode"`
|
||||
|
||||
// 关联安全组列表
|
||||
Secgroups []apis.StandaloneShortDesc `json:"secgroups"`
|
||||
|
||||
@@ -62,6 +62,7 @@ var (
|
||||
CLOUD_PROVIDER_CTYUN,
|
||||
CLOUD_PROVIDER_UCLOUD,
|
||||
CLOUD_PROVIDER_GOOGLE,
|
||||
CLOUD_PROVIDER_OPENSTACK,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -155,3 +155,25 @@ type DBInstanceSkuListInput struct {
|
||||
Zone2 []string `json:"zone2"`
|
||||
Zone3 []string `json:"zone3"`
|
||||
}
|
||||
|
||||
type SkuSyncInput struct {
|
||||
// 云平台名称
|
||||
// example: Google
|
||||
Provider string `json:"provider,omitempty"`
|
||||
|
||||
// 区域ID
|
||||
CloudregionIds []string `json:"cloudregion_ids"`
|
||||
}
|
||||
|
||||
type SkuTaskQueryInput struct {
|
||||
// 异步任务ID
|
||||
TaskIds []string `json:"task_ids"`
|
||||
}
|
||||
|
||||
type CloudregionSkuSyncInput struct {
|
||||
SkuSyncInput
|
||||
|
||||
// 同步资源类型
|
||||
// choices: serversku|elasticcachesku|dbinstance_sku
|
||||
Resource string `json:"resource"`
|
||||
}
|
||||
|
||||
@@ -59,9 +59,10 @@ const (
|
||||
STORAGE_CLOUD_HSSD = "cloud_hssd" //增强型SSD云硬盘
|
||||
|
||||
// huawei storage type
|
||||
STORAGE_HUAWEI_SSD = "SSD" // 超高IO云硬盘
|
||||
STORAGE_HUAWEI_SAS = "SAS" // 高IO云硬盘
|
||||
STORAGE_HUAWEI_SATA = "SATA" // 普通IO云硬盘
|
||||
STORAGE_HUAWEI_SSD = "SSD" // 超高IO云硬盘
|
||||
STORAGE_HUAWEI_SAS = "SAS" // 高IO云硬盘
|
||||
STORAGE_HUAWEI_SATA = "SATA" // 普通IO云硬盘
|
||||
STORAGE_HUAWEI_GPSSD = "GPSSD" // 通用型SSD
|
||||
|
||||
// openstack
|
||||
STORAGE_OPENSTACK_ISCSI = "iscsi"
|
||||
|
||||
@@ -18,10 +18,13 @@ import (
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
)
|
||||
|
||||
const VPC_OVN_ENCAP_COST = 58
|
||||
|
||||
const (
|
||||
VPC_EXTERNAL_ACCESS_MODE_DISTGW = "distgw" // distgw only
|
||||
VPC_EXTERNAL_ACCESS_MODE_EIP_DISTGW = "eip-distgw" // eip when available, distgw otherwise
|
||||
VPC_EXTERNAL_ACCESS_MODE_EIP = "eip" // eip only
|
||||
VPC_EXTERNAL_ACCESS_MODE_NONE = "none" // no external access
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -29,6 +32,7 @@ var (
|
||||
VPC_EXTERNAL_ACCESS_MODE_DISTGW,
|
||||
VPC_EXTERNAL_ACCESS_MODE_EIP_DISTGW,
|
||||
VPC_EXTERNAL_ACCESS_MODE_EIP,
|
||||
VPC_EXTERNAL_ACCESS_MODE_NONE,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -99,6 +99,7 @@ var (
|
||||
|
||||
CommonWhitelistOptionMap = map[string][]string{
|
||||
"default": []string{
|
||||
"enable_quota_check",
|
||||
"default_quota_value",
|
||||
"enable_rbac",
|
||||
"non_default_domain_projects",
|
||||
|
||||
@@ -201,6 +201,8 @@ type PerformStatusInput struct {
|
||||
// 更改的目标状态值
|
||||
// required:true
|
||||
Status string `json:"status"`
|
||||
// swagger:ignore
|
||||
BlockJobsCount int `json:"block_jobs_count"`
|
||||
|
||||
// 更改状态的原因描述
|
||||
// required:false
|
||||
|
||||
@@ -117,6 +117,7 @@ type AlertCreateInput struct {
|
||||
NoDataState string `json:"no_data_state"`
|
||||
// 报警执行错误将当前报警状态设置为对应的状态
|
||||
ExecutionErrorState string `json:"execution_error_state"`
|
||||
UsedBy string `json:"used_by"`
|
||||
}
|
||||
|
||||
type AlertUpdateInput struct {
|
||||
|
||||
@@ -34,7 +34,9 @@ type AlertRecordCreateInput struct {
|
||||
|
||||
type AlertRecordRule struct {
|
||||
Metric string `json:"metric"`
|
||||
Measurement string `json:"measurement"`
|
||||
MeasurementDesc string `json:"measurement_desc"`
|
||||
Field string `json:"field"`
|
||||
FieldDesc string `json:"field_desc"`
|
||||
// 比较运算符, 比如: >, <, >=, <=
|
||||
Comparator string `json:"comparator"`
|
||||
|
||||
@@ -23,6 +23,11 @@ import (
|
||||
const (
|
||||
METRIC_TAG = "TAG"
|
||||
METRIC_FIELD = "FIELD"
|
||||
|
||||
METRIC_VM_ID = "vm_id"
|
||||
METRIC_OSS_ID = "oss_id"
|
||||
METRIC_RDS_ID = "rds_id"
|
||||
METRIC_REDIS_ID = "redis_id"
|
||||
)
|
||||
|
||||
var PROPERTY_TYPE = []string{"databases", "measurements", "metric-measurement"}
|
||||
|
||||
@@ -19,9 +19,10 @@ type NotificationTemplateCreateInput struct {
|
||||
}
|
||||
|
||||
type NotificationTemplateConfig struct {
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
Matches []EvalMatch `json:"matches"`
|
||||
Title string `json:"title"`
|
||||
Name string `json:"name"`
|
||||
ResourceName string `json:"resource_name"`
|
||||
Matches []EvalMatch `json:"matches"`
|
||||
// PrevAlertState AlertStateType `json:"prev_alert_state"`
|
||||
// State AlertStateType `json:"state"`
|
||||
NoDataFound bool `json:"no_data"`
|
||||
|
||||
@@ -81,6 +81,10 @@ type ScheduleInput struct {
|
||||
CpuMicrocode string `json:"cpu_microcode"`
|
||||
CpuMode string `json:"cpu_mode"`
|
||||
|
||||
// In the migrate and create backup cases
|
||||
// we don't need reallocate network
|
||||
ReuseNetwork bool `json:"reuse_network"`
|
||||
|
||||
PendingUsages []jsonutils.JSONObject
|
||||
}
|
||||
|
||||
|
||||
53
pkg/apis/webconsole/types.go
Normal file
53
pkg/apis/webconsole/types.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Copyright 2019 Yunion
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
package webconsole
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"net/url"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
)
|
||||
|
||||
type ServerRemoteConsoleResponse struct {
|
||||
ConnectParams string `json:"connect_params"`
|
||||
Session string `json:"session,omitempty"`
|
||||
|
||||
apis.Meta
|
||||
}
|
||||
|
||||
func (resp *ServerRemoteConsoleResponse) GetConnectParams() string {
|
||||
params := resp.ConnectParams
|
||||
if data, err := base64.StdEncoding.DecodeString(params); err == nil {
|
||||
params = string(data)
|
||||
}
|
||||
return params
|
||||
}
|
||||
|
||||
func (resp *ServerRemoteConsoleResponse) GetConnectProtocol() (string, error) {
|
||||
var (
|
||||
params = resp.GetConnectParams()
|
||||
query url.Values
|
||||
)
|
||||
if uri, err := url.ParseRequestURI(params); err == nil {
|
||||
query = uri.Query()
|
||||
} else if q, err := url.ParseQuery(params); err == nil {
|
||||
query = q
|
||||
} else {
|
||||
return "", err
|
||||
}
|
||||
protocol := query.Get("protocol")
|
||||
return protocol, nil
|
||||
}
|
||||
@@ -368,7 +368,7 @@ func (req *dhcpRequest) createBaremetal(session *mcclient.ClientSession) (jsonut
|
||||
params := jsonutils.NewDict()
|
||||
mac := req.ClientMac.String()
|
||||
zoneId := req.baremetalManager.GetZoneId()
|
||||
name := fmt.Sprintf("BM%s", strings.Replace(mac, ":", "", -1))
|
||||
name := strings.ToLower(fmt.Sprintf("BM%s", strings.Replace(mac, ":", "", -1)))
|
||||
params.Add(jsonutils.NewString(name), "name")
|
||||
params.Add(jsonutils.NewString(mac), "access_mac")
|
||||
params.Add(jsonutils.NewString("baremetal"), "host_type")
|
||||
|
||||
@@ -756,7 +756,7 @@ func (adapter *MegaRaidAdaptor) storcliBuildNoRaid(devs []*baremetal.BaremetalSt
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
log.Errorf("Try build JBOD fail: %v", err)
|
||||
log.Errorf("Try storcli build JBOD fail: %v", err)
|
||||
labels := []string{}
|
||||
for _, dev := range devs {
|
||||
labels = append(labels, GetSpecString(dev))
|
||||
@@ -779,7 +779,7 @@ func (adapter *MegaRaidAdaptor) megacliBuildNoRaid(devs []*baremetal.BaremetalSt
|
||||
if err == nil {
|
||||
return nil
|
||||
}
|
||||
log.Errorf("Try build jbod fail: %v", err)
|
||||
log.Errorf("Try megacli build jbod fail: %v", err)
|
||||
cmds := []string{}
|
||||
for _, dev := range devs {
|
||||
cmd := GetCommand("-CfgLdAdd", "-r0", fmt.Sprintf("[%s]", GetSpecString(dev)),
|
||||
@@ -862,29 +862,42 @@ func (adapter *MegaRaidAdaptor) RemoveLogicVolumes() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
/*
|
||||
def _storcli_clear_jbod_disks(self):
|
||||
cmds = []
|
||||
for dev in self.devs:
|
||||
cmd = self.raid.get_command2(
|
||||
'/c%d/e%d/s%d' % (self.index, dev.enclosure, dev.slot),
|
||||
'set', 'good', 'force')
|
||||
cmds.append(cmd)
|
||||
logging.info('%s', cmds)
|
||||
self.raid.term.exec_remote_commands(cmds)
|
||||
*/
|
||||
func (adapter *MegaRaidAdaptor) storcliClearJBODDisks() error {
|
||||
errs := make([]error, 0)
|
||||
for _, dev := range adapter.devs {
|
||||
cmd := GetCommand2(fmt.Sprintf("/c%d/e%d/s%d", adapter.index, dev.enclosure, dev.slot), "set", "good", "force")
|
||||
if _, err := adapter.remoteRun(cmd); err != nil {
|
||||
err = errors.Wrapf(err, "Set PD good storcli cmd %v", cmd)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func (adapter *MegaRaidAdaptor) megacliClearJBODDisks() error {
|
||||
devIds := []string{}
|
||||
for idx, dev := range adapter.devs {
|
||||
devIds = append(devIds, GetSpecString(dev.ToBaremetalStorage(idx)))
|
||||
}
|
||||
cmd := GetCommand("-PDMakeGood", fmt.Sprintf("-PhysDrv[%s]", strings.Join(devIds, ",")), "-Force", fmt.Sprintf("-a%d", adapter.index))
|
||||
_, err := adapter.remoteRun(cmd)
|
||||
return err
|
||||
errs := make([]error, 0)
|
||||
for _, devId := range devIds {
|
||||
cmd := GetCommand("-PDMakeGood", "-PhysDrv", fmt.Sprintf("'[%s]'", devId), "-Force", fmt.Sprintf("-a%d", adapter.index))
|
||||
if _, err := adapter.remoteRun(cmd); err != nil {
|
||||
err = errors.Wrapf(err, "PDMakeGood megacli cmd %v", cmd)
|
||||
errs = append(errs, err)
|
||||
}
|
||||
}
|
||||
return errors.NewAggregate(errs)
|
||||
}
|
||||
|
||||
func (adapter *MegaRaidAdaptor) clearJBODDisks() {
|
||||
if err := adapter.megacliClearJBODDisks(); err != nil {
|
||||
log.Errorf("megacliClearJBODDisks error: %v", err)
|
||||
log.Infof("try storcliClearJBODDisks")
|
||||
if err := adapter.storcliClearJBODDisks(); err != nil {
|
||||
log.Errorf("storcliClearJBODDisks error: %v", err)
|
||||
}
|
||||
}
|
||||
adapter.megacliEnableJBOD(true)
|
||||
adapter.megacliEnableJBOD(false)
|
||||
adapter.megacliEnableJBOD(true)
|
||||
|
||||
@@ -35,6 +35,8 @@ var (
|
||||
maxPagingLimit int64 = 2048
|
||||
|
||||
domainizedNamespace = true
|
||||
|
||||
enableQuotaCheck = false
|
||||
)
|
||||
|
||||
func SetRegion(region string) {
|
||||
@@ -85,3 +87,11 @@ func SetDomainizedNamespace(domainNS bool) {
|
||||
func IsDomainizedNamespace() bool {
|
||||
return nonDefaultDomainProjects && domainizedNamespace
|
||||
}
|
||||
|
||||
func SetEnableQuotaCheck(val bool) {
|
||||
enableQuotaCheck = val
|
||||
}
|
||||
|
||||
func EnableQuotaCheck() bool {
|
||||
return enableQuotaCheck
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import (
|
||||
type SJointResourceBase struct {
|
||||
SResourceBase
|
||||
|
||||
RowId int64 `primary:"true" auto_increment:"true"`
|
||||
RowId int64 `primary:"true" auto_increment:"true" list:"user"`
|
||||
}
|
||||
|
||||
type SJointResourceBaseManager struct {
|
||||
|
||||
@@ -47,8 +47,9 @@ const (
|
||||
ACT_BACKUP_START = "backup_start"
|
||||
ACT_BACKUP_START_FAILED = "backup_start_fail"
|
||||
|
||||
ACT_FREEZE = "freeze"
|
||||
ACT_UNFREEZE = "unfreeze"
|
||||
ACT_FREEZE = "freeze"
|
||||
ACT_FREEZE_FAIL = "freeze_fail"
|
||||
ACT_UNFREEZE = "unfreeze"
|
||||
|
||||
ACT_RESTARING = "restarting"
|
||||
ACT_RESTART_FAIL = "restart_fail"
|
||||
@@ -260,4 +261,6 @@ const (
|
||||
|
||||
ACT_SYNC_VPCS = "sync_vpcs"
|
||||
ACT_SYNC_RECORD_SETS = "sync_record_sets"
|
||||
|
||||
ACT_UPDATE_RULE = "update_config"
|
||||
)
|
||||
|
||||
@@ -19,9 +19,11 @@ import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type SOutOfQuotaError struct {
|
||||
scope rbacutils.TRbacScope
|
||||
name string
|
||||
limit int
|
||||
used int
|
||||
@@ -37,7 +39,7 @@ func (e *SOutOfQuotaError) Cause() error {
|
||||
}
|
||||
|
||||
func (e *SOutOfQuotaError) Error() string {
|
||||
return fmt.Sprintf("%s limit %d used %d request %d", e.name, e.limit, e.used, e.request)
|
||||
return fmt.Sprintf("[%s.%s] limit %d used %d request %d", e.scope, e.name, e.limit, e.used, e.request)
|
||||
}
|
||||
|
||||
func (es *SOutOfQuotaErrors) Error() string {
|
||||
@@ -63,8 +65,10 @@ func NewOutOfQuotaError() *SOutOfQuotaErrors {
|
||||
}
|
||||
}
|
||||
|
||||
func (es *SOutOfQuotaErrors) Add(name string, limit int, used int, request int) {
|
||||
func (es *SOutOfQuotaErrors) Add(quota IQuota, name string, limit int, used int, request int) {
|
||||
scope := quota.GetKeys().Scope()
|
||||
e := SOutOfQuotaError{
|
||||
scope: scope,
|
||||
name: name,
|
||||
limit: limit,
|
||||
used: used,
|
||||
|
||||
@@ -132,6 +132,12 @@ func (manager *SQuotaBaseManager) queryQuota(ctx context.Context, quota IQuota,
|
||||
ret := jsonutils.NewDict()
|
||||
|
||||
keys := quota.GetKeys()
|
||||
ret.Update(jsonutils.Marshal(keys))
|
||||
ret.Update(quota.ToJSON(""))
|
||||
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
usage := manager.newQuota()
|
||||
err := manager.usageStore.GetQuota(ctx, keys, usage)
|
||||
@@ -150,8 +156,6 @@ func (manager *SQuotaBaseManager) queryQuota(ctx context.Context, quota IQuota,
|
||||
return nil, errors.Wrap(err, "manager.GetPendingUsages")
|
||||
}
|
||||
|
||||
ret.Update(jsonutils.Marshal(keys))
|
||||
ret.Update(quota.ToJSON(""))
|
||||
if usage != nil {
|
||||
ret.Update(usage.ToJSON("usage"))
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/object"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
type IQuotaKeys interface {
|
||||
@@ -30,6 +31,8 @@ type IQuotaKeys interface {
|
||||
Compare(IQuotaKeys) int
|
||||
|
||||
OwnerId() mcclient.IIdentityProvider
|
||||
|
||||
Scope() rbacutils.TRbacScope
|
||||
}
|
||||
|
||||
type IQuota interface {
|
||||
|
||||
@@ -22,6 +22,7 @@ import (
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
@@ -57,6 +58,10 @@ func getQuotaManager(quota IQuota) IQuotaManager {
|
||||
}
|
||||
|
||||
func CancelPendingUsage(ctx context.Context, userCred mcclient.TokenCredential, localUsage IQuota, cancelUsage IQuota, save bool) error {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return nil
|
||||
}
|
||||
|
||||
if localUsage == nil {
|
||||
return nil
|
||||
}
|
||||
@@ -65,6 +70,10 @@ func CancelPendingUsage(ctx context.Context, userCred mcclient.TokenCredential,
|
||||
}
|
||||
|
||||
func CheckSetPendingQuota(ctx context.Context, userCred mcclient.TokenCredential, quota IQuota) error {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return nil
|
||||
}
|
||||
|
||||
manager := getQuotaManager(quota)
|
||||
err := manager.checkSetPendingQuota(ctx, userCred, quota)
|
||||
if err != nil {
|
||||
@@ -75,6 +84,9 @@ func CheckSetPendingQuota(ctx context.Context, userCred mcclient.TokenCredential
|
||||
}
|
||||
|
||||
func CancelUsages(ctx context.Context, userCred mcclient.TokenCredential, usages []db.IUsage) {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return
|
||||
}
|
||||
for _, usage := range usages {
|
||||
cancelUsage(ctx, userCred, usage.(IQuota))
|
||||
}
|
||||
@@ -89,6 +101,9 @@ func cancelUsage(ctx context.Context, userCred mcclient.TokenCredential, usage I
|
||||
}
|
||||
|
||||
func AddUsages(ctx context.Context, userCred mcclient.TokenCredential, usages []db.IUsage) {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return
|
||||
}
|
||||
for _, usage := range usages {
|
||||
addUsage(ctx, userCred, usage.(IQuota))
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/appsrv"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/consts"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -61,6 +62,12 @@ func isDirty(key string) bool {
|
||||
}
|
||||
|
||||
func (manager *SQuotaBaseManager) PostUsageJob(keys IQuotaKeys, usageChan chan IQuota, realTime bool) {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
go func() {
|
||||
usageChan <- nil
|
||||
}()
|
||||
return
|
||||
}
|
||||
key := QuotaKeyString(keys)
|
||||
setDirty(key)
|
||||
|
||||
@@ -105,6 +112,10 @@ func (manager *SQuotaBaseManager) PostUsageJob(keys IQuotaKeys, usageChan chan I
|
||||
}
|
||||
|
||||
func (manager *SQuotaBaseManager) CalculateQuotaUsages(ctx context.Context, userCred mcclient.TokenCredential, isStart bool) {
|
||||
if !consts.EnableQuotaCheck() {
|
||||
return
|
||||
}
|
||||
|
||||
log.Infof("CalculateQuotaUsages")
|
||||
quota := manager.newQuota()
|
||||
keys := quota.GetKeys()
|
||||
|
||||
@@ -51,6 +51,8 @@ func isObjectRbacAllowed(model IModel, userCred mcclient.TokenCredential, action
|
||||
case rbacutils.ScopeUser:
|
||||
if ownerId != nil && objOwnerId != nil && (ownerId.GetUserId() == objOwnerId.GetUserId() || objOwnerId.GetUserId() == "" || (model.IsSharable(ownerId) && action == policy.PolicyActionGet)) {
|
||||
requireScope = rbacutils.ScopeUser
|
||||
} else if ownerId != nil && objOwnerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() {
|
||||
requireScope = rbacutils.ScopeDomain
|
||||
} else {
|
||||
requireScope = rbacutils.ScopeSystem
|
||||
}
|
||||
@@ -103,6 +105,8 @@ func isClassRbacAllowed(manager IModelManager, userCred mcclient.TokenCredential
|
||||
case rbacutils.ScopeUser:
|
||||
if ownerId != nil && ownerId.GetUserId() == objOwnerId.GetUserId() {
|
||||
requireScope = rbacutils.ScopeUser
|
||||
} else if ownerId != nil && ownerId.GetProjectDomainId() == objOwnerId.GetProjectDomainId() {
|
||||
requireScope = rbacutils.ScopeDomain
|
||||
} else {
|
||||
requireScope = rbacutils.ScopeSystem
|
||||
}
|
||||
|
||||
@@ -472,6 +472,10 @@ func SharablePerformPublic(model ISharableBaseModel, ctx context.Context, userCr
|
||||
if targetScope.HigherThan(allowScope) {
|
||||
return errors.Wrapf(httperrors.ErrNotSufficientPrivilege, "require %s allow %s", targetScope, allowScope)
|
||||
}
|
||||
requireScope := model.GetPublicScope()
|
||||
if requireScope.HigherThan(allowScope) {
|
||||
return errors.Wrapf(httperrors.ErrNotSufficientPrivilege, "require %s allow %s", requireScope, allowScope)
|
||||
}
|
||||
|
||||
_, err = Update(model, func() error {
|
||||
model.SetShare(targetScope)
|
||||
|
||||
@@ -41,6 +41,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/auth"
|
||||
"yunion.io/x/onecloud/pkg/util/httputils"
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
@@ -280,8 +281,9 @@ func (manager *STaskManager) NewTask(
|
||||
}
|
||||
parentTask := task.GetParentTask()
|
||||
if parentTask != nil {
|
||||
st := SSubTask{TaskId: parentTask.Id, Stage: parentTask.Stage, SubtaskId: task.Id}
|
||||
err := SubTaskManager.TableSpec().Insert(ctx, &st)
|
||||
st := &SSubTask{TaskId: parentTask.Id, Stage: parentTask.Stage, SubtaskId: task.Id}
|
||||
st.SetModelManager(SubTaskManager, st)
|
||||
err := SubTaskManager.TableSpec().Insert(ctx, st)
|
||||
if err != nil {
|
||||
log.Errorf("Subtask insert error %s", err)
|
||||
return nil, err
|
||||
@@ -814,7 +816,11 @@ func (self *STask) GetObjects() []db.IStandaloneModel {
|
||||
}
|
||||
|
||||
func (task *STask) GetTaskRequestHeader() http.Header {
|
||||
header := mcclient.GetTokenHeaders(task.GetUserCred())
|
||||
userCred := task.GetUserCred()
|
||||
if !userCred.IsValid() {
|
||||
userCred = auth.AdminCredential()
|
||||
}
|
||||
header := mcclient.GetTokenHeaders(userCred)
|
||||
header.Set(mcclient.TASK_ID, task.GetTaskId())
|
||||
return header
|
||||
}
|
||||
|
||||
@@ -143,6 +143,10 @@ func (cli *SEtcdClient) GetClient() *clientv3.Client {
|
||||
return cli.client
|
||||
}
|
||||
|
||||
func (cli *SEtcdClient) SessionLiving() bool {
|
||||
return cli.leaseLiving
|
||||
}
|
||||
|
||||
func (cli *SEtcdClient) startSession() error {
|
||||
ctx := context.TODO()
|
||||
|
||||
|
||||
@@ -91,7 +91,9 @@ func getTemplate(ctx context.Context, topic string, contType string, channel npk
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
tmp, err := template.New(key).Parse(string(cont))
|
||||
tmp := template.New(key)
|
||||
tmp.Funcs(template.FuncMap{"unescaped": unescaped})
|
||||
tmp, err = tmp.Parse(string(cont))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -100,6 +102,10 @@ func getTemplate(ctx context.Context, topic string, contType string, channel npk
|
||||
return templatesTable[key], nil
|
||||
}
|
||||
|
||||
func unescaped(str string) template.HTML {
|
||||
return template.HTML(str)
|
||||
}
|
||||
|
||||
func getContent(ctx context.Context, topic string, contType string, channel npk.TNotifyChannel, data jsonutils.JSONObject) (string, error) {
|
||||
if channel == npk.NotifyByWebhook {
|
||||
return "", nil
|
||||
@@ -332,7 +338,13 @@ func notifyRobot(ctx context.Context, robot string, recipientId []string, isGrou
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
jarray, _ := result.Get("types")
|
||||
if result == nil {
|
||||
return nil
|
||||
}
|
||||
jarray, err := result.Get("types")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
cTypes := jarray.(*jsonutils.JSONArray).GetStringArray()
|
||||
for _, ct := range cTypes {
|
||||
RawNotifyWithCtx(ctx, recipientId, isGroup, npk.TNotifyChannel(ct), priority, event, data)
|
||||
|
||||
@@ -40,6 +40,9 @@ func OnBaseOptionsChange(oOpts, nOpts interface{}) bool {
|
||||
consts.SetDomainizedNamespace(newOpts.DomainizedNamespace)
|
||||
changed = true
|
||||
}
|
||||
if oldOpts.EnableQuotaCheck != newOpts.EnableQuotaCheck {
|
||||
consts.SetEnableQuotaCheck(newOpts.EnableQuotaCheck)
|
||||
}
|
||||
return changed
|
||||
}
|
||||
|
||||
|
||||
@@ -124,10 +124,10 @@ func (manager *SOptionManager) DoSync(first bool) (time.Duration, error) {
|
||||
appsrv.SetExitFlag()
|
||||
}
|
||||
copyOptions(manager.options, newOpts)
|
||||
if first {
|
||||
// upload config for the first time ONLY
|
||||
manager.session.Upload()
|
||||
}
|
||||
// if first {
|
||||
// upload config
|
||||
manager.session.Upload()
|
||||
// }
|
||||
}
|
||||
return manager.refreshInterval, nil
|
||||
}
|
||||
|
||||
@@ -66,6 +66,8 @@ type mcclientServiceConfigSession struct {
|
||||
session *mcclient.ClientSession
|
||||
serviceId string
|
||||
config *jsonutils.JSONDict
|
||||
|
||||
commonServiceId string
|
||||
}
|
||||
|
||||
func newServiceConfigSession() IServiceConfigSession {
|
||||
@@ -88,12 +90,12 @@ func (s *mcclientServiceConfigSession) Merge(opts interface{}, serviceType strin
|
||||
merged = true
|
||||
} else {
|
||||
// not initialized
|
||||
s.Upload()
|
||||
// s.Upload()
|
||||
}
|
||||
}
|
||||
commonServiceId, _ := getServiceIdByType(s.session, consts.COMMON_SERVICE, "")
|
||||
if len(commonServiceId) > 0 {
|
||||
commonConf, err := getServiceConfig(s.session, commonServiceId)
|
||||
s.commonServiceId, _ = getServiceIdByType(s.session, consts.COMMON_SERVICE, "")
|
||||
if len(s.commonServiceId) > 0 {
|
||||
commonConf, err := getServiceConfig(s.session, s.commonServiceId)
|
||||
if err != nil {
|
||||
log.Errorf("getServiceConfig for %s failed: %s", consts.COMMON_SERVICE, err)
|
||||
} else if commonConf != nil {
|
||||
@@ -123,6 +125,11 @@ func (s *mcclientServiceConfigSession) Upload() {
|
||||
// ignore the error
|
||||
log.Errorf("fail to save config: %s", err)
|
||||
}
|
||||
_, err = modules.ServicesV3.PerformAction(s.session, s.commonServiceId, "config", nconf)
|
||||
if err != nil {
|
||||
// ignore the error
|
||||
log.Errorf("fail to save common config: %s", err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -78,6 +78,7 @@ type BaseOptions struct {
|
||||
IsSlaveNode bool `help:"Slave mode"`
|
||||
CronJobWorkerCount int `help:"Cron job worker count" default:"4"`
|
||||
|
||||
EnableQuotaCheck bool `help:"enable quota check" default:"true"`
|
||||
DefaultQuotaValue string `help:"default quota value" choices:"unlimit|zero|default" default:"default"`
|
||||
|
||||
CalculateQuotaUsageIntervalSeconds int `help:"interval to calculate quota usages, default 30 minutes" default:"900"`
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/gotypes"
|
||||
"yunion.io/x/pkg/util/netutils"
|
||||
"yunion.io/x/pkg/util/regutils"
|
||||
@@ -821,3 +822,15 @@ func NewIPv4AddrValidator(key string) *ValidatorIPv4Addr {
|
||||
v.SetParent(v)
|
||||
return v
|
||||
}
|
||||
|
||||
var ValidateModel = func(userCred mcclient.TokenCredential, manager db.IStandaloneModelManager, id *string) (db.IModel, error) {
|
||||
model, err := manager.FetchByIdOrName(userCred, *id)
|
||||
if err != nil {
|
||||
if errors.Cause(err) == sql.ErrNoRows {
|
||||
return nil, httperrors.NewResourceNotFoundError2(manager.Keyword(), *id)
|
||||
}
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
*id = model.GetId()
|
||||
return model, nil
|
||||
}
|
||||
|
||||
@@ -55,6 +55,8 @@ func InitHandlers(app *appsrv.Application) {
|
||||
|
||||
for _, manager := range []db.IModelManager{
|
||||
db.OpsLog,
|
||||
db.Metadata,
|
||||
|
||||
proxy.ProxySettingManager,
|
||||
models.CloudeventManager,
|
||||
} {
|
||||
|
||||
@@ -168,6 +168,7 @@ func (manager *SCloudaccountManager) syncCloudaccounts(ctx context.Context, user
|
||||
continue
|
||||
}
|
||||
account.StartSyncCloudIdResourcesTask(ctx, userCred, "")
|
||||
account.StartSystemCloudpolicySyncTask(ctx, userCred, false, "") // 避免新加账号未能及时同步策略
|
||||
localAccounts = append(localAccounts, *account)
|
||||
result.Add()
|
||||
}
|
||||
@@ -676,7 +677,16 @@ func (self *SCloudaccount) GetCloudaccountByProvider(provider string) ([]SClouda
|
||||
return accounts, nil
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) SyncSystemCloudpoliciesFromCloud(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
func (self *SCloudaccount) SyncSystemCloudpoliciesFromCloud(ctx context.Context, userCred mcclient.TokenCredential, refresh bool) error {
|
||||
dbPolicies, err := self.GetSystemCloudpolicies()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetSystemCloudpolicies")
|
||||
}
|
||||
|
||||
if len(dbPolicies) > 0 && !refresh {
|
||||
return nil
|
||||
}
|
||||
|
||||
factory, err := self.GetProviderFactory()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetProviderFactory")
|
||||
@@ -716,22 +726,18 @@ func (self *SCloudaccount) SyncSystemCloudpoliciesFromCloud(ctx context.Context,
|
||||
return errors.Wrapf(err, "GetISystemCloudpolicies for account %s(%s)", self.Name, self.Provider)
|
||||
}
|
||||
}
|
||||
return self.syncSystemCloudpoliciesFromCloud(ctx, userCred, iPolicies)
|
||||
return self.syncSystemCloudpoliciesFromCloud(ctx, userCred, iPolicies, dbPolicies)
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) syncSystemCloudpoliciesFromCloud(ctx context.Context, userCred mcclient.TokenCredential, iPolicies []cloudprovider.ICloudpolicy) error {
|
||||
func (self *SCloudaccount) syncSystemCloudpoliciesFromCloud(ctx context.Context, userCred mcclient.TokenCredential, iPolicies []cloudprovider.ICloudpolicy, dbPolicies []SCloudpolicy) error {
|
||||
result := compare.SyncResult{}
|
||||
dbPolicies, err := self.GetSystemCloudpolicies()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetSystemCloudpolicies")
|
||||
}
|
||||
|
||||
removed := make([]SCloudpolicy, 0)
|
||||
commondb := make([]SCloudpolicy, 0)
|
||||
commonext := make([]cloudprovider.ICloudpolicy, 0)
|
||||
added := make([]cloudprovider.ICloudpolicy, 0)
|
||||
|
||||
err = compare.CompareSets(dbPolicies, iPolicies, &removed, &commondb, &commonext, &added)
|
||||
err := compare.CompareSets(dbPolicies, iPolicies, &removed, &commondb, &commonext, &added)
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "compare.CompareSets")
|
||||
}
|
||||
@@ -832,6 +838,9 @@ func (self *SCloudaccount) GetICloudprovider() ([]SCloudprovider, error) {
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) syncCloudprovider(ctx context.Context, userCred mcclient.TokenCredential) compare.SyncResult {
|
||||
lockman.LockRawObject(ctx, "cloudproviders", self.Id)
|
||||
defer lockman.ReleaseRawObject(ctx, "cloudproviders", self.Id)
|
||||
|
||||
result := compare.SyncResult{}
|
||||
|
||||
providers, err := self.GetICloudprovider()
|
||||
@@ -932,22 +941,28 @@ func (manager *SCloudaccountManager) SyncCloudidSystemPolicies(ctx context.Conte
|
||||
log.Errorf("GetSupportCloudIdAccounts error: %v", err)
|
||||
return
|
||||
}
|
||||
providers := []string{}
|
||||
for i := range accounts {
|
||||
_, err := accounts[i].GetProvider() // 检查账号是否可以正常连接
|
||||
if err != nil {
|
||||
log.Errorf("GetProvider for account %s(%s) error: %v", accounts[i].Name, accounts[i].Provider, err)
|
||||
continue
|
||||
}
|
||||
err = accounts[i].StartSystemCloudpolicySyncTask(ctx, userCred, "")
|
||||
if utils.IsInStringArray(accounts[i].Provider, providers) {
|
||||
continue
|
||||
}
|
||||
err = accounts[i].StartSystemCloudpolicySyncTask(ctx, userCred, true, "")
|
||||
if err != nil {
|
||||
log.Errorf("StartSystemCloudpolicySyncTask for account %s(%s) error: %v", accounts[i].Name, accounts[i].Provider, err)
|
||||
continue
|
||||
}
|
||||
providers = append(providers, accounts[i].Provider)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) StartSystemCloudpolicySyncTask(ctx context.Context, userCred mcclient.TokenCredential, parentTaskId string) error {
|
||||
func (self *SCloudaccount) StartSystemCloudpolicySyncTask(ctx context.Context, userCred mcclient.TokenCredential, refresh bool, parentTaskId string) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Add(jsonutils.NewBool(refresh), "refresh")
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "SystemCloudpolicySyncTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "NewTask")
|
||||
|
||||
@@ -21,6 +21,7 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudid/models"
|
||||
)
|
||||
@@ -39,7 +40,12 @@ func (self *SystemCloudpolicySyncTask) taskFailed(ctx context.Context, cloudacco
|
||||
|
||||
func (self *SystemCloudpolicySyncTask) OnInit(ctx context.Context, obj db.IStandaloneModel, body jsonutils.JSONObject) {
|
||||
account := obj.(*models.SCloudaccount)
|
||||
err := account.SyncSystemCloudpoliciesFromCloud(ctx, self.GetUserCred())
|
||||
|
||||
lockman.LockRawObject(ctx, "system policies", account.Provider)
|
||||
defer lockman.ReleaseRawObject(ctx, "system policies", account.Provider)
|
||||
|
||||
refresh := jsonutils.QueryBoolean(self.GetParams(), "refresh", false)
|
||||
err := account.SyncSystemCloudpoliciesFromCloud(ctx, self.GetUserCred(), refresh)
|
||||
if err != nil {
|
||||
self.taskFailed(ctx, account, errors.Wrapf(err, "SyncSystemCloudpoliciesFromCloud"))
|
||||
return
|
||||
|
||||
@@ -16,6 +16,14 @@ package cloudprovider
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/util/billing"
|
||||
|
||||
type TBackupMethod string
|
||||
|
||||
const (
|
||||
BackupMethodLogical = TBackupMethod("Logical")
|
||||
BackupMethodPhysical = TBackupMethod("Physical")
|
||||
BackupMethodUnknown = TBackupMethod("")
|
||||
)
|
||||
|
||||
type SDBInstanceNetwork struct {
|
||||
IP string
|
||||
NetworkId string
|
||||
@@ -55,6 +63,9 @@ type SManagedDBInstanceCreateConfig struct {
|
||||
ProjectId string
|
||||
|
||||
BillingCycle *billing.SBillingCycle
|
||||
|
||||
// 仅从备份恢复到新实例用到
|
||||
RdsId string
|
||||
}
|
||||
|
||||
type SManagedDBInstanceChangeConfig struct {
|
||||
|
||||
@@ -26,6 +26,52 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
|
||||
type SDistDefaultAccount struct {
|
||||
// 操作系统发行版
|
||||
OsDistribution string
|
||||
// 默认用户名
|
||||
DefaultAccount string
|
||||
// 是否可更改
|
||||
Changeable bool
|
||||
}
|
||||
|
||||
type SOsDefaultAccount struct {
|
||||
// 默认用户名
|
||||
DefaultAccount string
|
||||
// 是否可更改用户名
|
||||
Changeable bool
|
||||
// 禁止使用的账号
|
||||
DisabledAccounts []string
|
||||
// 各操作系统发行版的默认用户名信息
|
||||
DistAccounts []SDistDefaultAccount
|
||||
}
|
||||
|
||||
type SDefaultAccount struct {
|
||||
Linux SOsDefaultAccount
|
||||
Windows SOsDefaultAccount
|
||||
}
|
||||
|
||||
type StorageInfo struct {
|
||||
StorageType string
|
||||
MaxSizeGb int
|
||||
MinSizeGb int
|
||||
Resizable bool
|
||||
StepSizeGb int
|
||||
}
|
||||
|
||||
type Storage struct {
|
||||
DataDisk []StorageInfo
|
||||
SysDisk []StorageInfo
|
||||
}
|
||||
|
||||
type SInstanceCapability struct {
|
||||
Provider string
|
||||
Hypervisor string
|
||||
Storages Storage
|
||||
|
||||
DefaultAccount SDefaultAccount
|
||||
}
|
||||
|
||||
type SDiskInfo struct {
|
||||
StorageExternalId string
|
||||
StorageType string
|
||||
|
||||
@@ -75,6 +75,7 @@ type ICloudRegion interface {
|
||||
CreateISecurityGroup(conf *SecurityGroupCreateInput) (ICloudSecurityGroup, error)
|
||||
|
||||
CreateIVpc(name string, desc string, cidr string) (ICloudVpc, error)
|
||||
CreateInternetGateway() (ICloudInternetGateway, error)
|
||||
CreateEIP(eip *SEip) (ICloudEIP, error)
|
||||
|
||||
GetISnapshots() ([]ICloudSnapshot, error)
|
||||
@@ -437,6 +438,10 @@ type ICloudVpc interface {
|
||||
// GetGlobalId() // 若vpc属于globalvpc,此函数返回格式必须是 'region.GetGlobalId()/vpc.GetGlobalId()'
|
||||
ICloudResource
|
||||
|
||||
IsSupportSetExternalAccess() bool // 是否支持Attach互联网网关.
|
||||
GetExternalAccessMode() string
|
||||
AttachInternetGateway(igwId string) error
|
||||
|
||||
GetRegion() ICloudRegion
|
||||
GetIsDefault() bool
|
||||
GetCidrBlock() string
|
||||
@@ -451,6 +456,10 @@ type ICloudVpc interface {
|
||||
GetINatGateways() ([]ICloudNatGateway, error)
|
||||
}
|
||||
|
||||
type ICloudInternetGateway interface {
|
||||
ICloudResource
|
||||
}
|
||||
|
||||
type ICloudWire interface {
|
||||
ICloudResource
|
||||
GetIVpc() ICloudVpc
|
||||
@@ -816,6 +825,9 @@ type ICloudDBInstanceBackup interface {
|
||||
GetBackupSizeMb() int
|
||||
GetDBNames() string
|
||||
GetBackupMode() string
|
||||
GetBackupMethod() TBackupMethod
|
||||
|
||||
CreateICloudDBInstance(opts *SManagedDBInstanceCreateConfig) (ICloudDBInstance, error)
|
||||
|
||||
Delete() error
|
||||
}
|
||||
|
||||
@@ -164,6 +164,39 @@ func (self *SAliyunGuestDriver) GetGuestInitialStateAfterRebuild() string {
|
||||
return api.VM_READY
|
||||
}
|
||||
|
||||
func (self *SAliyunGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 32768, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD_PL2, MaxSizeGb: 32768, MinSizeGb: 461, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD_PL3, MaxSizeGb: 32768, MinSizeGb: 1261, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_PUBLIC_CLOUD, MaxSizeGb: 2000, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_EPHEMERAL_SSD, MaxSizeGb: 800, MinSizeGb: 5, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_EFFICIENCY, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_ESSD, MaxSizeGb: 500, MinSizeGb: 20, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAliyunGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
userName := "root"
|
||||
if desc.OsType == "Windows" {
|
||||
|
||||
@@ -86,6 +86,39 @@ func (self *SAwsGuestDriver) GetWindowsUserDataType() string {
|
||||
return cloudprovider.CLOUD_EC2
|
||||
}
|
||||
|
||||
func (self *SAwsGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GP2_SSD, MaxSizeGb: 16384, MinSizeGb: 1, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_IO1_SSD, MaxSizeGb: 16384, MinSizeGb: 4, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_ST1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_SC1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARD_HDD, MaxSizeGb: 1024, MinSizeGb: 1, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GP2_SSD, MaxSizeGb: 16384, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_IO1_SSD, MaxSizeGb: 16384, MinSizeGb: 4, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_ST1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_SC1_HDD, MaxSizeGb: 16384, MinSizeGb: 500, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARD_HDD, MaxSizeGb: 1024, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAwsGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
// return fetchAwsUserName(desc)
|
||||
if desc.OsType == "Windows" {
|
||||
|
||||
@@ -222,6 +222,35 @@ func (self *SAzureGuestDriver) GetGuestInitialStateAfterRebuild() string {
|
||||
return api.VM_READY
|
||||
}
|
||||
|
||||
func (self *SAzureGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_AZURE_DEFAULT_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARDSSD_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARD_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_PREMIUM_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARDSSD_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_STANDARD_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_PREMIUM_LRS, MaxSizeGb: 32767, MinSizeGb: 1, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SAzureGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
return api.VM_AZURE_DEFAULT_LOGIN_USER
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/baremetal"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
@@ -56,6 +57,13 @@ func (self *SBaremetalGuestDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_ONECLOUD
|
||||
}
|
||||
|
||||
func (self *SBaremetalGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SBaremetalGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
|
||||
keys := models.SComputeResourceKeys{}
|
||||
keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
|
||||
|
||||
@@ -398,3 +398,7 @@ func (self *SBaseGuestDriver) RequestRemoteUpdate(ctx context.Context, guest *mo
|
||||
// nil ops
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SBaseGuestDriver) ValidateDetachNetwork(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
@@ -57,6 +58,13 @@ func (self *SContainerDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_ONECLOUD
|
||||
}
|
||||
|
||||
func (self *SContainerDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
}
|
||||
}
|
||||
|
||||
// for backward compatibility, deprecated driver
|
||||
func (self *SContainerDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
|
||||
keys := models.SComputeResourceKeys{}
|
||||
|
||||
@@ -39,6 +39,23 @@ func (self *SCtyunGuestDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_CTYUN
|
||||
}
|
||||
|
||||
func (self *SCtyunGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SCtyunGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
|
||||
keys := models.SComputeResourceKeys{}
|
||||
keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
|
||||
|
||||
@@ -65,6 +65,23 @@ func (self *SESXiGuestDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_VMWARE
|
||||
}
|
||||
|
||||
func (self *SESXiGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: true,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SESXiGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
|
||||
keys := models.SComputeResourceKeys{}
|
||||
keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
|
||||
|
||||
@@ -65,6 +65,33 @@ func (self *SGoogleGuestDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_GOOGLE
|
||||
}
|
||||
|
||||
func (self *SGoogleGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_SSD, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_STANDARD, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_BALANCED, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_SSD, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_STANDARD, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_GOOGLE_PD_BALANCED, MaxSizeGb: 65536, MinSizeGb: 10, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SGoogleGuestDriver) GetDefaultSysDiskBackend() string {
|
||||
return api.STORAGE_GOOGLE_PD_STANDARD
|
||||
}
|
||||
|
||||
@@ -110,6 +110,35 @@ func (self *SHuaweiGuestDriver) GetGuestInitialStateAfterRebuild() string {
|
||||
return api.VM_RUNNING
|
||||
}
|
||||
|
||||
func (self *SHuaweiGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SSD, MaxSizeGb: 32768, MinSizeGb: 10, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SATA, MaxSizeGb: 32768, MinSizeGb: 10, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SAS, MaxSizeGb: 32768, MinSizeGb: 10, StepSizeGb: 1, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_GPSSD, MaxSizeGb: 32768, MinSizeGb: 10, StepSizeGb: 1, Resizable: true},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SSD, MaxSizeGb: 1024, MinSizeGb: 40, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SATA, MaxSizeGb: 1024, MinSizeGb: 40, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_SAS, MaxSizeGb: 1024, MinSizeGb: 40, StepSizeGb: 1, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_HUAWEI_GPSSD, MaxSizeGb: 1024, MinSizeGb: 40, StepSizeGb: 1, Resizable: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SHuaweiGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
userName := "root"
|
||||
if desc.OsType == "Windows" {
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
"yunion.io/x/onecloud/pkg/compute/options"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
@@ -68,6 +69,22 @@ func (self *SKVMGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, own
|
||||
return keys
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: true,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) GetDefaultSysDiskBackend() string {
|
||||
return api.STORAGE_LOCAL
|
||||
}
|
||||
@@ -629,3 +646,10 @@ func (self *SKVMGuestDriver) CheckLiveMigrate(guest *models.SGuest, userCred mcc
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SKVMGuestDriver) ValidateDetachNetwork(ctx context.Context, userCred mcclient.TokenCredential, guest *models.SGuest) error {
|
||||
if guest.Status == api.VM_RUNNING && guest.GetMetadata("hot_remove_nic", nil) != "enable" {
|
||||
return httperrors.NewBadRequestError("Guest %s can't hot remove nic", guest.GetName())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -649,8 +649,7 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
log.Errorf("host.GetIHost fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "host.GetIHost")
|
||||
}
|
||||
|
||||
// 创建失败时external id为空。此时直接返回即可。不需要再调用公有云api
|
||||
@@ -663,14 +662,11 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Errorf("ihost.GetIVMById fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "ihost.GetIVMById(%s)", guest.ExternalId)
|
||||
}
|
||||
err = ivm.DeleteVM(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("ivm.DeleteVM fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "ivm.DeleteVM")
|
||||
}
|
||||
|
||||
for _, guestdisk := range guest.GetDisks() {
|
||||
@@ -682,16 +678,14 @@ func (self *SManagedVirtualizedGuestDriver) RequestUndeployGuestOnHost(ctx conte
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
continue
|
||||
}
|
||||
log.Errorf("disk.GetIDisk fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "disk.GetIDisk")
|
||||
}
|
||||
if idisk.GetStatus() == api.DISK_DEALLOC {
|
||||
continue
|
||||
}
|
||||
err = idisk.Delete(ctx)
|
||||
if err != nil {
|
||||
log.Errorf("idisk.Delete fail %s", err)
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "idisk.Delete")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,6 +64,23 @@ func (self *SOpenStackGuestDriver) GetProvider() string {
|
||||
return api.CLOUD_PROVIDER_OPENSTACK
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SOpenStackGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
|
||||
keys := models.SComputeResourceKeys{}
|
||||
keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
|
||||
|
||||
@@ -136,7 +136,7 @@ func (self *SQcloudGuestDriver) ValidateCreateData(ctx context.Context, userCred
|
||||
if sysDisk.SizeMb > 1024*1024 {
|
||||
return nil, fmt.Errorf("The %s system disk size must be less than 1024GB", sysDisk.Backend)
|
||||
}
|
||||
case api.STORAGE_LOCAL_PRO:
|
||||
case api.STORAGE_LOCAL_PRO, api.STORAGE_CLOUD_HSSD: //https://cloud.tencent.com/document/product/362/2353
|
||||
return nil, fmt.Errorf("storage %s can not be system disk", sysDisk.Backend)
|
||||
}
|
||||
|
||||
@@ -243,6 +243,43 @@ func (self *SQcloudGuestDriver) GetUserDataType() string {
|
||||
return cloudprovider.CLOUD_SHELL
|
||||
}
|
||||
|
||||
func (self *SQcloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
Changeable: false,
|
||||
DistAccounts: []cloudprovider.SDistDefaultAccount{
|
||||
{
|
||||
OsDistribution: "Ubuntu",
|
||||
DefaultAccount: "ubuntu",
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
Changeable: false,
|
||||
},
|
||||
},
|
||||
Storages: cloudprovider.Storage{
|
||||
DataDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BASIC, MaxSizeGb: 16000, MinSizeGb: 10, StepSizeGb: 10, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_PREMIUM, MaxSizeGb: 16000, MinSizeGb: 50, StepSizeGb: 10, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 16000, MinSizeGb: 100, StepSizeGb: 10, Resizable: true},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_HSSD, MaxSizeGb: 32000, MinSizeGb: 20, StepSizeGb: 10, Resizable: true},
|
||||
},
|
||||
SysDisk: []cloudprovider.StorageInfo{
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_BASIC, MaxSizeGb: 500, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_PREMIUM, MaxSizeGb: 1024, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
|
||||
cloudprovider.StorageInfo{StorageType: api.STORAGE_CLOUD_SSD, MaxSizeGb: 500, MinSizeGb: 50, StepSizeGb: 10, Resizable: false},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SQcloudGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
userName := "root"
|
||||
if desc.ImageType == "system" {
|
||||
|
||||
@@ -96,6 +96,21 @@ func (self *SUCloudGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *m
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SUCloudGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SUCloudGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
if desc.OsType == "Windows" {
|
||||
return "Administrator"
|
||||
|
||||
@@ -158,6 +158,21 @@ func (self *SZStackGuestDriver) IsWindowsUserDataTypeNeedEncode() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SZStackGuestDriver) GetInstanceCapability() cloudprovider.SInstanceCapability {
|
||||
return cloudprovider.SInstanceCapability{
|
||||
Hypervisor: self.GetHypervisor(),
|
||||
Provider: self.GetProvider(),
|
||||
DefaultAccount: cloudprovider.SDefaultAccount{
|
||||
Linux: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_LINUX_LOGIN_USER,
|
||||
},
|
||||
Windows: cloudprovider.SOsDefaultAccount{
|
||||
DefaultAccount: api.VM_DEFAULT_WINDOWS_LOGIN_USER,
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SZStackGuestDriver) GetLinuxDefaultAccount(desc cloudprovider.SManagedVMCreateConfig) string {
|
||||
userName := "root"
|
||||
if desc.OsType == "Windows" {
|
||||
|
||||
@@ -153,6 +153,7 @@ func (self *SBaseHostDriver) FinishConvert(userCred mcclient.TokenCredential, ho
|
||||
bs := host.GetBaremetalstorage().GetStorage()
|
||||
bs.SetStatus(userCred, api.STORAGE_OFFLINE, "")
|
||||
db.Update(host, func() error {
|
||||
host.Name = guest.GetName()
|
||||
host.CpuReserved = 0
|
||||
host.MemReserved = 0
|
||||
host.AccessIp = guest.GetRealIPs()[0]
|
||||
|
||||
@@ -59,7 +59,15 @@ func (self *SHuaweiHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb
|
||||
|
||||
func (self *SHuaweiHostDriver) ValidateResetDisk(ctx context.Context, userCred mcclient.TokenCredential, disk *models.SDisk, snapshot *models.SSnapshot, guests []models.SGuest, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
if len(guests) >= 1 {
|
||||
return nil, httperrors.NewBadRequestError("Disk must be dettached")
|
||||
if disk.DiskType == api.DISK_TYPE_SYS {
|
||||
for _, g := range guests {
|
||||
if g.Status != api.VM_READY {
|
||||
return nil, httperrors.NewBadRequestError("Server %s must in status ready", g.GetName())
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return nil, httperrors.NewBadRequestError("Disk must be detached")
|
||||
}
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
@@ -49,20 +49,21 @@ func (self *SQcloudHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb
|
||||
if sizeGb%10 != 0 {
|
||||
return fmt.Errorf("The disk size must be a multiple of 10Gb")
|
||||
}
|
||||
if storage.StorageType == api.STORAGE_CLOUD_BASIC {
|
||||
if sizeGb < 10 || sizeGb > 16000 {
|
||||
return fmt.Errorf("The %s disk size must be in the range of 10 ~ 16000GB", storage.StorageType)
|
||||
}
|
||||
} else if storage.StorageType == api.STORAGE_CLOUD_PREMIUM {
|
||||
if sizeGb < 50 || sizeGb > 16000 {
|
||||
return fmt.Errorf("The %s disk size must be in the range of 50 ~ 16000GB", storage.StorageType)
|
||||
}
|
||||
} else if storage.StorageType == api.STORAGE_CLOUD_SSD {
|
||||
if sizeGb < 100 || sizeGb > 16000 {
|
||||
return fmt.Errorf("The %s disk size must be in the range of 100 ~ 16000GB", storage.StorageType)
|
||||
}
|
||||
} else {
|
||||
return fmt.Errorf("Not support create %s disk", storage.StorageType)
|
||||
min, max := 0, 0
|
||||
switch storage.StorageType {
|
||||
case api.STORAGE_CLOUD_BASIC:
|
||||
min, max = 10, 16000
|
||||
case api.STORAGE_CLOUD_PREMIUM:
|
||||
min, max = 50, 16000
|
||||
case api.STORAGE_CLOUD_SSD:
|
||||
min, max = 100, 16000
|
||||
case api.STORAGE_CLOUD_HSSD:
|
||||
min, max = 20, 320000
|
||||
default:
|
||||
return fmt.Errorf("Not support create or resize %s disk", storage.StorageType)
|
||||
}
|
||||
if sizeGb < min || sizeGb > max {
|
||||
return fmt.Errorf("The %s disk size must be in the range of %d ~ %dGB", storage.StorageType, min, max)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -72,6 +72,8 @@ type SCapabilities struct {
|
||||
StorageTypes3 map[string]map[string]*SimpleStorageInfo `json:",allowempty"`
|
||||
DataStorageTypes2 map[string][]string `json:",allowempty"`
|
||||
DataStorageTypes3 map[string]map[string]*SimpleStorageInfo `json:",allowempty"`
|
||||
|
||||
InstanceCapabilities []cloudprovider.SInstanceCapability
|
||||
}
|
||||
|
||||
func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, region *SCloudregion, zone *SZone) (SCapabilities, error) {
|
||||
@@ -104,6 +106,13 @@ func GetCapabilities(ctx context.Context, userCred mcclient.TokenCredential, que
|
||||
domainId = ""
|
||||
}
|
||||
capa.Hypervisors = getHypervisors(region, zone, domainId)
|
||||
capa.InstanceCapabilities = []cloudprovider.SInstanceCapability{}
|
||||
for _, hypervisor := range capa.Hypervisors {
|
||||
driver := GetDriver(hypervisor)
|
||||
if driver != nil {
|
||||
capa.InstanceCapabilities = append(capa.InstanceCapabilities, driver.GetInstanceCapability())
|
||||
}
|
||||
}
|
||||
getBrands(region, zone, domainId, &capa)
|
||||
// capa.Brands, capa.ComputeEngineBrands, capa.NetworkManageBrands, capa.ObjectStorageBrands = a, c, n, o
|
||||
capa.ResourceTypes = getResourceTypes(region, zone, domainId)
|
||||
|
||||
@@ -519,20 +519,13 @@ func (scm *SCloudaccountManager) PerformPrepareNets(ctx context.Context, userCre
|
||||
output.HostSuggestedNetworks = confs
|
||||
}
|
||||
|
||||
// Find the suitable network containing the VM IP in Project 'input.Project', and if not, give the corresponding suggested network configuration in this project.
|
||||
project := input.ProjectId
|
||||
excludeNets := []*SNetwork{}
|
||||
// Find the suitable network containing the VM IP, and if not, give the corresponding suggested network configuration in this project.
|
||||
var allNets []SNetwork
|
||||
if suitableWire != nil {
|
||||
allNets, err = suitableWire.getNetworks(userCred, rbacutils.ScopeSystem)
|
||||
if err != nil {
|
||||
return output, err
|
||||
}
|
||||
for i := range allNets {
|
||||
if allNets[i].ProjectId == project {
|
||||
excludeNets = append(excludeNets, &allNets[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
type vm struct {
|
||||
@@ -572,18 +565,32 @@ func (scm *SCloudaccountManager) PerformPrepareNets(ctx context.Context, userCre
|
||||
return vms[i].IP < vms[j].IP
|
||||
})
|
||||
|
||||
excludeNets = make([]*SNetwork, 0, len(allNets)+len(output.HostSuggestedNetworks))
|
||||
type sExcludeNet struct {
|
||||
StartIp netutils.IPV4Addr
|
||||
EndIp netutils.IPV4Addr
|
||||
Id string
|
||||
}
|
||||
excludeNets := make([]sExcludeNet, 0, len(allNets)+len(output.HostSuggestedNetworks))
|
||||
for i := range allNets {
|
||||
excludeNets = append(excludeNets, &allNets[i])
|
||||
startIp, _ := netutils.NewIPV4Addr(allNets[i].GuestIpStart)
|
||||
endIp, _ := netutils.NewIPV4Addr(allNets[i].GuestIpEnd)
|
||||
excludeNets = append(excludeNets, sExcludeNet{
|
||||
StartIp: startIp,
|
||||
EndIp: endIp,
|
||||
Id: allNets[i].GetId(),
|
||||
})
|
||||
}
|
||||
for i := range output.HostSuggestedNetworks {
|
||||
startipStr := output.HostSuggestedNetworks[i].GuestIpStart
|
||||
endipStr := output.HostSuggestedNetworks[i].GuestIpEnd
|
||||
excludeNets = append(excludeNets, &SNetwork{GuestIpEnd: endipStr, GuestIpStart: startipStr})
|
||||
startIp, _ := netutils.NewIPV4Addr(output.HostSuggestedNetworks[i].GuestIpStart)
|
||||
endIp, _ := netutils.NewIPV4Addr(output.HostSuggestedNetworks[i].GuestIpEnd)
|
||||
excludeNets = append(excludeNets, sExcludeNet{
|
||||
StartIp: startIp,
|
||||
EndIp: endIp,
|
||||
})
|
||||
}
|
||||
// sort excludeNets via their GuestIpStart
|
||||
sort.Slice(excludeNets, func(i, j int) bool {
|
||||
return excludeNets[i].GuestIpStart < excludeNets[j].GuestIpStart
|
||||
return excludeNets[i].StartIp < excludeNets[j].StartIp
|
||||
})
|
||||
|
||||
svNets := make([]api.CASimpleNetConf, 0, 5)
|
||||
@@ -594,8 +601,8 @@ Loop:
|
||||
if vmi >= len(vms) {
|
||||
break
|
||||
}
|
||||
startIp, _ := netutils.NewIPV4Addr(excludeNets[neti].GuestIpStart)
|
||||
endIp, _ := netutils.NewIPV4Addr(excludeNets[neti].GuestIpEnd)
|
||||
startIp := excludeNets[neti].StartIp
|
||||
endIp := excludeNets[neti].EndIp
|
||||
switch {
|
||||
case vms[vmi].IP > endIp:
|
||||
neti++
|
||||
@@ -2544,6 +2551,7 @@ func (account *SCloudaccount) SubmitSyncAccountTask(ctx context.Context, userCre
|
||||
if err == nil && autoSync && account.GetEnabled() && account.EnableAutoSync {
|
||||
syncRange := SSyncRange{FullSync: true}
|
||||
account.markAutoSync(userCred)
|
||||
account.SyncAccountResources(ctx, userCred)
|
||||
providers := account.GetEnabledCloudproviders()
|
||||
for i := range providers {
|
||||
provider := &providers[i]
|
||||
@@ -3050,8 +3058,8 @@ func (self *SCloudaccount) GetAvailableExternalProject(local *db.STenant, projec
|
||||
// 若本地项目没有映射云上任何项目,则在云上新建一个同名项目
|
||||
// 若本地项目a映射云上项目b,但b项目不可用,则看云上是否有a项目,有则直接使用,若没有则在云上创建a-1, a-2类似项目
|
||||
func (self *SCloudaccount) SyncProject(ctx context.Context, userCred mcclient.TokenCredential, projectId string) (string, error) {
|
||||
lockman.LockRawObject(ctx, self.Id, projectId)
|
||||
defer lockman.ReleaseRawObject(ctx, self.Id, projectId)
|
||||
lockman.LockRawObject(ctx, "projects", self.Id)
|
||||
defer lockman.ReleaseRawObject(ctx, "projects", self.Id)
|
||||
|
||||
provider, err := self.GetProvider()
|
||||
if err != nil {
|
||||
@@ -3239,3 +3247,54 @@ func (self *SCloudaccount) SyncDnsZones(ctx context.Context, userCred mcclient.T
|
||||
|
||||
return localZones, remoteZones, result
|
||||
}
|
||||
|
||||
func (self *SCloudaccount) SyncAccountResources(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
provider, err := self.GetProvider()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetProvider")
|
||||
}
|
||||
if cloudprovider.IsSupportProject(provider) {
|
||||
return func() error {
|
||||
lockman.LockRawObject(ctx, "projects", self.Id)
|
||||
defer lockman.ReleaseRawObject(ctx, "projects", self.Id)
|
||||
|
||||
projects, err := provider.GetIProjects()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "provider.GetIProjects")
|
||||
}
|
||||
result := ExternalProjectManager.SyncProjects(ctx, userCred, self, projects)
|
||||
log.Infof("Sync project for cloudaccount %s result: %s", self.Name, result.Result())
|
||||
return nil
|
||||
}()
|
||||
}
|
||||
|
||||
if cloudprovider.IsSupportDnsZone(provider) {
|
||||
return func() error {
|
||||
lockman.LockRawObject(ctx, "dns_zones", self.Id)
|
||||
defer lockman.ReleaseRawObject(ctx, "dns_zones", self.Id)
|
||||
|
||||
dnsZones, err := provider.GetICloudDnsZones()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "GetICloudDnsZones")
|
||||
}
|
||||
localZones, remoteZones, result := self.SyncDnsZones(ctx, userCred, dnsZones)
|
||||
log.Infof("Sync dns zones for cloudaccount %s result: %s", self.Name, result.Result())
|
||||
for i := 0; i < len(localZones); i++ {
|
||||
func() {
|
||||
lockman.LockObject(ctx, &localZones[i])
|
||||
defer lockman.ReleaseObject(ctx, &localZones[i])
|
||||
|
||||
if localZones[i].Deleted {
|
||||
return
|
||||
}
|
||||
|
||||
result := localZones[i].SyncDnsRecordSets(ctx, userCred, self.Provider, remoteZones[i])
|
||||
log.Infof("Sync dns records for dns zone %s result: %s", localZones[i].GetName(), result.Result())
|
||||
}()
|
||||
}
|
||||
return nil
|
||||
}()
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -937,3 +937,19 @@ func (manager *SCloudregionManager) FetchDefaultRegion() *SCloudregion {
|
||||
func (self *SCloudregion) GetCloudEnv() string {
|
||||
return cloudprovider.GetProviderCloudEnv(self.Provider)
|
||||
}
|
||||
|
||||
func (manager *SCloudregionManager) AllowSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowPerform(userCred, manager, "sync-skus")
|
||||
}
|
||||
|
||||
func (manager *SCloudregionManager) PerformSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.CloudregionSkuSyncInput) (jsonutils.JSONObject, error) {
|
||||
return PerformActionSyncSkus(ctx, userCred, input.Resource, input.SkuSyncInput)
|
||||
}
|
||||
|
||||
func (manager *SCloudregionManager) AllowGetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowGetSpec(userCred, manager, "sync-tasks")
|
||||
}
|
||||
|
||||
func (manager *SCloudregionManager) GetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query api.SkuTaskQueryInput) (jsonutils.JSONObject, error) {
|
||||
return GetPropertySkusSyncTasks(ctx, userCred, query)
|
||||
}
|
||||
|
||||
@@ -145,8 +145,8 @@ func syncRegionSkus(ctx context.Context, userCred mcclient.TokenCredential, loca
|
||||
|
||||
if cnt == 0 {
|
||||
// 提前同步instance type.如果同步失败可能导致vm 内存显示为0
|
||||
if err = SyncServerSkusByRegion(ctx, userCred, localRegion); err != nil {
|
||||
msg := fmt.Sprintf("Get Skus for region %s failed %s", localRegion.GetName(), err)
|
||||
if ret := SyncServerSkusByRegion(ctx, userCred, localRegion, nil); ret.IsError() {
|
||||
msg := fmt.Sprintf("Get Skus for region %s failed %s", localRegion.GetName(), ret.Result())
|
||||
log.Errorln(msg)
|
||||
// 暂时不终止同步
|
||||
// logSyncFailed(provider, task, msg)
|
||||
|
||||
@@ -85,9 +85,8 @@ type SDBInstanceBackup struct {
|
||||
// example: 32
|
||||
BackupSizeMb int `nullable:"false" list:"user" json:"backup_size_mb"`
|
||||
|
||||
// RDS实例Id
|
||||
// example: 239b9663-6d06-4ef4-8cfc-320a7fb6660d
|
||||
// DBInstanceId string `width:"36" charset:"ascii" name:"dbinstance_id" nullable:"false" list:"user" create:"required" index:"true"`
|
||||
// 备份方式 Logical|Physical
|
||||
BackupMethod string `width:"32" charset:"ascii" nullable:"true" list:"user" create:"optional" json:"backup_method"`
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceBackupManager) GetContextManagers() [][]db.IModelManager {
|
||||
@@ -369,6 +368,46 @@ func (backup *SDBInstanceBackup) GetIRegion() (cloudprovider.ICloudRegion, error
|
||||
}
|
||||
|
||||
func (backup *SDBInstanceBackup) GetIDBInstanceBackup() (cloudprovider.ICloudDBInstanceBackup, error) {
|
||||
if len(backup.ExternalId) == 0 {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "empty external id")
|
||||
}
|
||||
if len(backup.DBInstanceId) > 0 {
|
||||
rds, err := backup.GetDBInstance()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetDBInstance")
|
||||
}
|
||||
iRds, err := rds.GetIDBInstance()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetIDBInstance")
|
||||
}
|
||||
err = cloudprovider.Wait(time.Second*3, time.Second*15, func() (bool, error) {
|
||||
backups, err := iRds.GetIDBInstanceBackups()
|
||||
if err != nil {
|
||||
return false, errors.Wrapf(err, "GetIDBInstanceBackups")
|
||||
}
|
||||
for i := range backups {
|
||||
if backups[i].GetGlobalId() == backup.ExternalId {
|
||||
return true, nil
|
||||
}
|
||||
}
|
||||
log.Warningf("failed to found backup %s", backup.ExternalId)
|
||||
return false, nil
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "timeout for search backup %s", backup.ExternalId)
|
||||
}
|
||||
backups, err := iRds.GetIDBInstanceBackups()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetIDBInstanceBackups")
|
||||
}
|
||||
for i := range backups {
|
||||
if backups[i].GetGlobalId() == backup.ExternalId {
|
||||
return backups[i], nil
|
||||
}
|
||||
}
|
||||
return nil, errors.Wrapf(cloudprovider.ErrNotFound, "search backup %s", backup.ExternalId)
|
||||
}
|
||||
|
||||
iRegion, err := backup.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "backup.GetIRegion")
|
||||
@@ -439,6 +478,7 @@ func (self *SDBInstanceBackup) SyncWithCloudDBInstanceBackup(
|
||||
self.Engine = extBackup.GetEngine()
|
||||
self.EngineVersion = extBackup.GetEngineVersion()
|
||||
self.DBNames = extBackup.GetDBNames()
|
||||
self.BackupMethod = string(extBackup.GetBackupMethod())
|
||||
|
||||
if dbinstanceId := extBackup.GetDBInstanceId(); len(dbinstanceId) > 0 {
|
||||
//有可能云上删除了实例,未删除备份
|
||||
@@ -497,6 +537,7 @@ func (manager *SDBInstanceBackupManager) newFromCloudDBInstanceBackup(
|
||||
backup.BackupSizeMb = extBackup.GetBackupSizeMb()
|
||||
backup.DBNames = extBackup.GetDBNames()
|
||||
backup.BackupMode = extBackup.GetBackupMode()
|
||||
backup.BackupMethod = string(extBackup.GetBackupMethod())
|
||||
backup.ExternalId = extBackup.GetGlobalId()
|
||||
|
||||
if dbinstanceId := extBackup.GetDBInstanceId(); len(dbinstanceId) > 0 {
|
||||
@@ -591,3 +632,67 @@ func (manager *SDBInstanceBackupManager) ListItemExportKeys(ctx context.Context,
|
||||
func (self *SDBInstanceBackup) GetChangeOwnerCandidateDomainIds() []string {
|
||||
return self.SManagedResourceBase.GetChangeOwnerCandidateDomainIds()
|
||||
}
|
||||
|
||||
func (self *SDBInstanceBackup) fillRdsConfig(output *api.DBInstanceCreateInput) error {
|
||||
if self.Status != api.DBINSTANCE_BACKUP_READY {
|
||||
return fmt.Errorf("backup %s status is %s require %s", self.Name, self.Status, api.DBINSTANCE_BACKUP_READY)
|
||||
}
|
||||
if len(self.DBInstanceId) == 0 {
|
||||
if len(self.Engine) == 0 {
|
||||
return fmt.Errorf("backup engine %s is unknown", self.Name)
|
||||
}
|
||||
output.Engine = self.Engine
|
||||
if len(self.EngineVersion) == 0 {
|
||||
return fmt.Errorf("backup engine version %s is unknown", self.Name)
|
||||
}
|
||||
output.EngineVersion = self.EngineVersion
|
||||
return nil
|
||||
}
|
||||
rds, err := self.GetDBInstance()
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "backup.GetDBInstance")
|
||||
}
|
||||
if len(output.NetworkId) == 0 {
|
||||
network, _ := rds.GetDBNetwork()
|
||||
if network != nil {
|
||||
output.NetworkId = network.NetworkId
|
||||
}
|
||||
}
|
||||
|
||||
if output.VcpuCount == 0 {
|
||||
output.VcpuCount = rds.VcpuCount
|
||||
}
|
||||
if output.VmemSizeMb == 0 {
|
||||
output.VmemSizeMb = rds.VmemSizeMb
|
||||
}
|
||||
if output.DiskSizeGB == 0 {
|
||||
output.DiskSizeGB = rds.DiskSizeGB
|
||||
}
|
||||
if output.Port == 0 {
|
||||
output.Port = rds.Port
|
||||
}
|
||||
if len(output.Category) == 0 {
|
||||
output.Category = rds.Category
|
||||
}
|
||||
if len(output.StorageType) == 0 {
|
||||
output.StorageType = rds.StorageType
|
||||
}
|
||||
output.Engine = rds.Engine
|
||||
output.EngineVersion = rds.EngineVersion
|
||||
if len(output.InstanceType) == 0 {
|
||||
output.InstanceType = rds.InstanceType
|
||||
}
|
||||
if len(output.VpcId) == 0 {
|
||||
output.VpcId = rds.VpcId
|
||||
}
|
||||
if len(output.Zone1) == 0 {
|
||||
output.Zone1 = rds.Zone1
|
||||
}
|
||||
if len(output.Zone2) == 0 {
|
||||
output.Zone2 = rds.Zone2
|
||||
}
|
||||
if len(output.Zone3) == 0 {
|
||||
output.Zone3 = rds.Zone3
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -628,3 +628,19 @@ func (manager *SDBInstanceSkuManager) ListItemExportKeys(ctx context.Context,
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceSkuManager) AllowSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowPerform(userCred, manager, "sync-skus")
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceSkuManager) PerformSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.SkuSyncInput) (jsonutils.JSONObject, error) {
|
||||
return PerformActionSyncSkus(ctx, userCred, manager.Keyword(), input)
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceSkuManager) AllowGetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowGetSpec(userCred, manager, "sync-tasks")
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceSkuManager) GetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query api.SkuTaskQueryInput) (jsonutils.JSONObject, error) {
|
||||
return GetPropertySkusSyncTasks(ctx, userCred, query)
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"net"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -135,6 +136,9 @@ type SDBInstance struct {
|
||||
Zone2 string `width:"36" charset:"ascii" nullable:"false" create:"optional" list:"user"`
|
||||
// 可用区3
|
||||
Zone3 string `width:"36" charset:"ascii" nullable:"false" create:"optional" list:"user"`
|
||||
|
||||
// 从备份创建新实例
|
||||
DBInstancebackupId string `width:"36" name:"dbinstancebackup_id" charset:"ascii" nullable:"false" create:"optional"`
|
||||
}
|
||||
|
||||
func (manager *SDBInstanceManager) GetContextManagers() [][]db.IModelManager {
|
||||
@@ -274,8 +278,18 @@ func (man *SDBInstanceManager) QueryDistinctExtraField(q *sqlchemy.SQuery, field
|
||||
}
|
||||
|
||||
func (man *SDBInstanceManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, input api.DBInstanceCreateInput) (*jsonutils.JSONDict, error) {
|
||||
if len(input.DBInstancebackupId) > 0 {
|
||||
_backup, err := validators.ValidateModel(userCred, DBInstanceBackupManager, &input.DBInstancebackupId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
backup := _backup.(*SDBInstanceBackup)
|
||||
err = backup.fillRdsConfig(&input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
data := input.JSON(input)
|
||||
networkV := validators.NewModelIdOrNameValidator("network", "network", ownerId)
|
||||
addressV := validators.NewIPv4AddrValidator("address")
|
||||
secgroupV := validators.NewModelIdOrNameValidator("secgroup", "secgroup", ownerId)
|
||||
masterV := validators.NewModelIdOrNameValidator("master_instance", "dbinstance", ownerId)
|
||||
@@ -283,7 +297,6 @@ func (man *SDBInstanceManager) ValidateCreateData(ctx context.Context, userCred
|
||||
zone2V := validators.NewModelIdOrNameValidator("zone2", "zone", ownerId)
|
||||
zone3V := validators.NewModelIdOrNameValidator("zone3", "zone", ownerId)
|
||||
keyV := map[string]validators.IValidator{
|
||||
"network": networkV,
|
||||
"address": addressV.Optional(true),
|
||||
"master": masterV.ModelIdKey("master_instance_id").Optional(true),
|
||||
"secgroup": secgroupV.Optional(true),
|
||||
@@ -318,10 +331,36 @@ func (man *SDBInstanceManager) ValidateCreateData(ctx context.Context, userCred
|
||||
}
|
||||
}
|
||||
|
||||
network := networkV.Model.(*SNetwork)
|
||||
input.NetworkExternalId = network.ExternalId
|
||||
var vpc *SVpc
|
||||
var network *SNetwork
|
||||
if len(input.NetworkId) > 0 {
|
||||
_network, err := validators.ValidateModel(userCred, NetworkManager, &input.NetworkId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
network = _network.(*SNetwork)
|
||||
input.NetworkExternalId = network.ExternalId
|
||||
if len(input.Address) > 0 {
|
||||
ip := net.ParseIP(input.Address).To4()
|
||||
if ip == nil {
|
||||
return nil, httperrors.NewInputParameterError("invalid address: %s", input.Address)
|
||||
}
|
||||
addr, _ := netutils.NewIPV4Addr(input.Address)
|
||||
if !network.IsAddressInRange(addr) {
|
||||
return nil, httperrors.NewInputParameterError("Ip %s not in network %s(%s) range", input.Address, network.Name, network.Id)
|
||||
}
|
||||
}
|
||||
vpc = network.GetVpc()
|
||||
} else if len(input.VpcId) > 0 {
|
||||
_vpc, err := validators.ValidateModel(userCred, VpcManager, &input.VpcId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
vpc = _vpc.(*SVpc)
|
||||
} else {
|
||||
return nil, httperrors.NewMissingParameterError("vpc_id")
|
||||
}
|
||||
|
||||
vpc := network.GetVpc()
|
||||
input.VpcId = vpc.Id
|
||||
input.ManagerId = vpc.ManagerId
|
||||
cloudprovider := vpc.GetCloudprovider()
|
||||
|
||||
@@ -191,13 +191,13 @@ func (used *SDomainQuota) Exceed(request quotas.IQuota, quota quotas.IQuota) err
|
||||
sreq := request.(*SDomainQuota)
|
||||
squota := quota.(*SDomainQuota)
|
||||
if quotas.Exceed(used.Globalvpc, sreq.Globalvpc, squota.Globalvpc) {
|
||||
err.Add("globalvpc", squota.Globalvpc, used.Globalvpc, sreq.Globalvpc)
|
||||
err.Add(used, "globalvpc", squota.Globalvpc, used.Globalvpc, sreq.Globalvpc)
|
||||
}
|
||||
if quotas.Exceed(used.Cloudaccount, sreq.Cloudaccount, squota.Cloudaccount) {
|
||||
err.Add("cloudaccount", squota.Cloudaccount, used.Cloudaccount, sreq.Cloudaccount)
|
||||
err.Add(used, "cloudaccount", squota.Cloudaccount, used.Cloudaccount, sreq.Cloudaccount)
|
||||
}
|
||||
if quotas.Exceed(used.DnsZone, sreq.DnsZone, squota.DnsZone) {
|
||||
err.Add("dns_zone", squota.DnsZone, used.DnsZone, sreq.DnsZone)
|
||||
err.Add(used, "dns_zone", squota.DnsZone, used.DnsZone, sreq.DnsZone)
|
||||
}
|
||||
if err.IsError() {
|
||||
return err
|
||||
|
||||
@@ -1164,7 +1164,7 @@ func (self *SElasticcache) GetAdminAccount() (*SElasticcacheAccount, error) {
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("no admin account found for elastic cache %s", self.Id)
|
||||
return nil, httperrors.NewNotFoundError("no admin account found for elastic cache %s", self.Id)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartResetPasswordTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
|
||||
@@ -649,3 +649,19 @@ func (manager *SElasticcacheSkuManager) ListItemExportKeys(ctx context.Context,
|
||||
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) AllowSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowPerform(userCred, manager, "sync-skus")
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) PerformSyncSkus(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.SkuSyncInput) (jsonutils.JSONObject, error) {
|
||||
return PerformActionSyncSkus(ctx, userCred, manager.Keyword(), input)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) AllowGetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowGetSpec(userCred, manager, "sync-tasks")
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) GetPropertySyncTasks(ctx context.Context, userCred mcclient.TokenCredential, query api.SkuTaskQueryInput) (jsonutils.JSONObject, error) {
|
||||
return GetPropertySkusSyncTasks(ctx, userCred, query)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user