mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 08:03:53 +08:00
redis support 2
This commit is contained in:
@@ -1,3 +1,17 @@
|
||||
// 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 cloudnet
|
||||
|
||||
import (
|
||||
|
||||
386
cmd/climc/shell/elasticcache.go
Normal file
386
cmd/climc/shell/elasticcache.go
Normal file
@@ -0,0 +1,386 @@
|
||||
// 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 shell
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modules"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/options"
|
||||
)
|
||||
|
||||
func init() {
|
||||
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 {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCache.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheCreateOptions{}, "elastic-cache-create", "Create elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheCreateOptions) error {
|
||||
params, err := options.StructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCache.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-restart", "Restart elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "restart", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-flush-instance", "Flush elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "flush-instance", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-delete", "Delete elastisc cache instance", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCache.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticCacheChangeSpecOptions struct {
|
||||
options.ElasticCacheIdOptions
|
||||
Sku string `help:"elastic cache sku id"`
|
||||
}
|
||||
|
||||
R(&ElasticCacheChangeSpecOptions{}, "elastic-cache-change-spec", "Change elastisc cache instance specification", func(s *mcclient.ClientSession, opts *ElasticCacheChangeSpecOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("sku", jsonutils.NewString(opts.Sku))
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "change-spec", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticCacheMainteananceTimeOptions struct {
|
||||
options.ElasticCacheIdOptions
|
||||
START_TIME string `help:"elastic cache sku maintenance start time,format: HH:mm"`
|
||||
END_TIME string `help:"elastic cache sku maintenance end time, format: HH:mm"`
|
||||
}
|
||||
|
||||
R(&ElasticCacheMainteananceTimeOptions{}, "elastic-cache-set-maintenance-time", "set elastisc cache instance maintenance time", func(s *mcclient.ClientSession, opts *ElasticCacheMainteananceTimeOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
start := fmt.Sprintf("%sZ", opts.START_TIME)
|
||||
end := fmt.Sprintf("%sZ", opts.END_TIME)
|
||||
params.Set("maintain_start_time", jsonutils.NewString(start))
|
||||
params.Set("maintain_end_time", jsonutils.NewString(end))
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "set-maintain-time", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-allocate-public-connect", "Allocate elastisc cache instance public access connection", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "allocate-public-connection", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-enable-auth", "Enable elastisc cache instance auth", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("auth_mode", jsonutils.NewString("on"))
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "update-auth-mode", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-disable-auth", "Disable elastisc cache instance auth", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("auth_mode", jsonutils.NewString("off"))
|
||||
result, err := modules.ElasticCache.PerformAction(s, opts.ID, "update-auth-mode", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticCacheAccountResetPasswordOptions struct {
|
||||
options.ElasticCacheIdOptions
|
||||
PASSWORD string `help:"elastic cache account password."`
|
||||
}
|
||||
|
||||
R(&ElasticCacheAccountResetPasswordOptions{}, "elastic-cache-account-reset-password", "Reset elastisc cache instance account password", func(s *mcclient.ClientSession, opts *ElasticCacheAccountResetPasswordOptions) error {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("password", jsonutils.NewString(opts.PASSWORD))
|
||||
result, err := modules.ElasticCacheAccount.PerformAction(s, opts.ID, "reset-password", params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticCacheBaseListOptions struct {
|
||||
options.BaseListOptions
|
||||
ElasticcacheId string `help:"elastic cache id"`
|
||||
}
|
||||
|
||||
R(&ElasticCacheBaseListOptions{}, "elastic-cache-account-list", "List elastisc cache account", func(s *mcclient.ClientSession, opts *ElasticCacheBaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheAccount.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheAccountCreateOptions{}, "elastic-cache-account-create", "Create elastisc cache account", func(s *mcclient.ClientSession, opts *options.ElasticCacheAccountCreateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheAccount.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-account-delete", "Delete elastisc cache account", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCacheAccount.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheBackupCreateOptions{}, "elastic-cache-backup-create", "Create elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheBackupCreateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheBackup.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.BaseListOptions{}, "elastic-cache-backup-list", "List elastisc cache backup", func(s *mcclient.ClientSession, opts *options.BaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheBackup.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-backup-delete", "Delete elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCacheBackup.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-backup-restore", "Restore elastisc cache backup", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCacheBackup.PerformAction(s, opts.ID, "restore-instance", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheAclCreateOptions{}, "elastic-cache-acl-create", "Create elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheAclCreateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheAcl.Create(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheIdOptions{}, "elastic-cache-acl-delete", "Delete elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheIdOptions) error {
|
||||
result, err := modules.ElasticCacheAcl.Delete(s, opts.ID, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.BaseListOptions{}, "elastic-cache-acl-list", "List elastisc cache acl", func(s *mcclient.ClientSession, opts *options.BaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheAcl.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheAclUpdateOptions{}, "elastic-cache-acl-update", "Update elastisc cache acl", func(s *mcclient.ClientSession, opts *options.ElasticCacheAclUpdateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.Remove("id")
|
||||
result, err := modules.ElasticCacheAcl.Update(s, opts.Id, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.BaseListOptions{}, "elastic-cache-parameter-list", "List elastisc cache parameters", func(s *mcclient.ClientSession, opts *options.BaseListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticCacheParameter.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
|
||||
R(&options.ElasticCacheParameterUpdateOptions{}, "elastic-cache-parameter-update", "Update elastisc cache parameter", func(s *mcclient.ClientSession, opts *options.ElasticCacheParameterUpdateOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
params.Remove("id")
|
||||
result, err := modules.ElasticCacheParameter.Update(s, opts.Id, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printObject(result)
|
||||
return nil
|
||||
})
|
||||
|
||||
type ElasticCacheSkusListOptions struct {
|
||||
options.BaseListOptions
|
||||
Cloudregion string `help:"region Id or name"`
|
||||
Usable bool `help:"Filter usable sku"`
|
||||
Zone string `help:"zone Id or name"`
|
||||
City *string `help:"city name,eg. BeiJing"`
|
||||
LocalCategory *string `help:"local category,eg. single"`
|
||||
EngineVersion *string `help:"engine version,eg. 3.0"`
|
||||
Cpu *int `help:"Cpu core count" json:"cpu_core_count"`
|
||||
Mem *int `help:"Memory size in MB" json:"memory_size_mb"`
|
||||
Name string `help:"Name of Sku"`
|
||||
}
|
||||
|
||||
R(&ElasticCacheSkusListOptions{}, "elastic-cache-sku-list", "List elastisc cache sku", func(s *mcclient.ClientSession, opts *ElasticCacheSkusListOptions) error {
|
||||
params, err := options.ListStructToParams(opts)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
result, err := modules.ElasticcacheSkus.List(s, params)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
printList(result, nil)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 shell
|
||||
|
||||
import (
|
||||
|
||||
12
docs/cloudaccount/disable-auto-sync.yaml
Normal file
12
docs/cloudaccount/disable-auto-sync.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 关闭云账号自动同步
|
||||
parameters:
|
||||
- $ref: "../parameters/cloudaccount.yaml#/cloudaccountId"
|
||||
responses:
|
||||
200:
|
||||
description: 云账号信息
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountResponse"
|
||||
|
||||
tags:
|
||||
- cloudaccount
|
||||
12
docs/cloudaccount/disable.yaml
Normal file
12
docs/cloudaccount/disable.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 禁用云账号
|
||||
parameters:
|
||||
- $ref: "../parameters/cloudaccount.yaml#/cloudaccountId"
|
||||
responses:
|
||||
200:
|
||||
description: 禁用的云账号信息
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountResponse"
|
||||
|
||||
tags:
|
||||
- cloudaccount
|
||||
17
docs/cloudaccount/enable-auto-sync.yaml
Normal file
17
docs/cloudaccount/enable-auto-sync.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
post:
|
||||
summary: 开启云账号自动同步
|
||||
parameters:
|
||||
- $ref: "../parameters/cloudaccount.yaml#/cloudaccountId"
|
||||
- in: body
|
||||
name: cloudaccount
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountEnableAutoSync"
|
||||
responses:
|
||||
200:
|
||||
description: 云账号信息
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountResponse"
|
||||
|
||||
tags:
|
||||
- cloudaccount
|
||||
12
docs/cloudaccount/enable.yaml
Normal file
12
docs/cloudaccount/enable.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 启用云账号
|
||||
parameters:
|
||||
- $ref: "../parameters/cloudaccount.yaml#/cloudaccountId"
|
||||
responses:
|
||||
200:
|
||||
description: 启用的云账号信息
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountResponse"
|
||||
|
||||
tags:
|
||||
- cloudaccount
|
||||
12
docs/cloudaccount/private.yaml
Normal file
12
docs/cloudaccount/private.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 取消云账号共享
|
||||
parameters:
|
||||
- $ref: "../parameters/cloudaccount.yaml#/cloudaccountId"
|
||||
responses:
|
||||
200:
|
||||
description: 云账号信息
|
||||
schema:
|
||||
$ref: "../schemas/cloudaccount.yaml#/CloudaccountResponse"
|
||||
|
||||
tags:
|
||||
- cloudaccount
|
||||
@@ -1,16 +1,16 @@
|
||||
post:
|
||||
summary: 调整RDS实例配置
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/dbinstanceId'
|
||||
- in: body
|
||||
name: dbinstance
|
||||
required: true
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/dbinstanceId"
|
||||
- in: body
|
||||
name: dbinstance
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#DBInstanceChangeConfig'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstanceChangeConfig"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#/DBInstanceResponse'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstanceResponse"
|
||||
tags:
|
||||
- dbinstance
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
post:
|
||||
summary: 开放关闭RDS实例外网地址
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/dbinstanceId'
|
||||
- in: body
|
||||
name: dbinstance
|
||||
required: true
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/dbinstanceId"
|
||||
- in: body
|
||||
name: dbinstance
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#DBInstancePublicConnection'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstancePublicConnection"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#/DBInstanceResponse'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstanceResponse"
|
||||
tags:
|
||||
- dbinstance
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
post:
|
||||
summary: 从备份恢复实例数据库
|
||||
description: 要求RDS实例状态正常
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/dbinstanceId'
|
||||
- in: body
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/dbinstanceId"
|
||||
- in: body
|
||||
name: dbinstance
|
||||
required: true
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#DBInstanceRecovery'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstanceRecovery"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance.yaml#/DBInstanceResponse'
|
||||
$ref: "../schemas/dbinstance.yaml#/DBInstanceResponse"
|
||||
tags:
|
||||
- dbinstance
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
post:
|
||||
summary: 赋予RDS实例的数据库权限
|
||||
description: 要求RDS实例状态正常
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/accountId'
|
||||
- in: body
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/accountId"
|
||||
- in: body
|
||||
name: dbinstanceaccount
|
||||
required: true
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#DBInstanceAccountGrantPrivilege'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountGrantPrivilege"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例账户信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse"
|
||||
tags:
|
||||
- dbinstanceaccount
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
post:
|
||||
summary: 重置RDS实例用户密码
|
||||
description: 要求RDS实例状态正常
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/accountId'
|
||||
- in: body
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/accountId"
|
||||
- in: body
|
||||
name: dbinstanceaccount
|
||||
required: true
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#DBInstanceAccountResetPassword'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountResetPassword"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例账户信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse"
|
||||
tags:
|
||||
- dbinstanceaccount
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
post:
|
||||
summary: 解除RDS实例的数据库权限
|
||||
description: 要求RDS实例状态正常
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/accountId'
|
||||
- in: body
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/accountId"
|
||||
- in: body
|
||||
name: dbinstanceaccount
|
||||
required: true
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#DBInstanceAccountRevokePrivilege'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountRevokePrivilege"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例账户信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse"
|
||||
tags:
|
||||
- dbinstanceaccount
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
post:
|
||||
summary: 设置RDS实例的数据库权限
|
||||
description: 要求RDS实例及账号状态正常
|
||||
parameters:
|
||||
- $ref: '../parameters/dbinstance.yaml#/accountId'
|
||||
- in: body
|
||||
parameters:
|
||||
- $ref: "../parameters/dbinstance.yaml#/accountId"
|
||||
- in: body
|
||||
name: dbinstanceaccount
|
||||
required: true
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#DBInstanceAccountSetPrivileges'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountSetPrivileges"
|
||||
responses:
|
||||
200:
|
||||
description: RDS实例账户信息
|
||||
schema:
|
||||
$ref: '../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse'
|
||||
$ref: "../schemas/dbinstance_account.yaml#/DBInstanceAccountResponse"
|
||||
tags:
|
||||
- dbinstanceaccount
|
||||
|
||||
11
docs/disk/private.yaml
Normal file
11
docs/disk/private.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 取消磁盘共享
|
||||
parameters:
|
||||
- $ref: "../parameters/disk.yaml#/diskId"
|
||||
responses:
|
||||
200:
|
||||
description: 磁盘信息
|
||||
schema:
|
||||
$ref: "../schemas/disk.yaml#/DiskResponse"
|
||||
tags:
|
||||
- disk
|
||||
12
docs/disk/public.yaml
Normal file
12
docs/disk/public.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 磁盘共享
|
||||
parameters:
|
||||
- $ref: "../parameters/disk.yaml#/diskId"
|
||||
responses:
|
||||
200:
|
||||
description: 磁盘信息
|
||||
schema:
|
||||
$ref: "../schemas/disk.yaml#/DiskResponse"
|
||||
|
||||
tags:
|
||||
- disk
|
||||
12
docs/disk/purge.yaml
Normal file
12
docs/disk/purge.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 清除磁盘数据库记录
|
||||
parameters:
|
||||
- $ref: "../parameters/disk.yaml#/diskId"
|
||||
responses:
|
||||
200:
|
||||
description: 磁盘信息
|
||||
schema:
|
||||
$ref: "../schemas/disk.yaml#/DiskResponse"
|
||||
|
||||
tags:
|
||||
- disk
|
||||
17
docs/disk/reset.yaml
Normal file
17
docs/disk/reset.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
post:
|
||||
summary: 回滚磁盘到指定快照
|
||||
parameters:
|
||||
- $ref: "../parameters/disk.yaml#/diskId"
|
||||
- in: body
|
||||
name: disk
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/disk.yaml#/DiskReset"
|
||||
responses:
|
||||
200:
|
||||
description: 磁盘信息
|
||||
schema:
|
||||
$ref: "../schemas/disk.yaml#/DiskResponse"
|
||||
|
||||
tags:
|
||||
- disk
|
||||
15
docs/elasticcache/allocate-public-connection.yaml
Normal file
15
docs/elasticcache/allocate-public-connection.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 获取ElasticCache实例公网访问地址
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAllocatePublicConnection"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
15
docs/elasticcache/change-spec.yaml
Normal file
15
docs/elasticcache/change-spec.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 变更ElasticCache实例规格
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheChangeSpec"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
23
docs/elasticcache/elasticcache.yaml
Normal file
23
docs/elasticcache/elasticcache.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例详情信息
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcacheId"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
|
||||
delete:
|
||||
summary: 删除指定ElasticCache实例
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcacheId"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
23
docs/elasticcache/elasticcacheaccount.yaml
Normal file
23
docs/elasticcache/elasticcacheaccount.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例用户详情信息
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/accountId"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例用户信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountResponse"
|
||||
tags:
|
||||
- elasticcacheaccount
|
||||
|
||||
delete:
|
||||
summary: 删除指定ElasticCache实例用户
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/accountId"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的用户信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountResponse"
|
||||
tags:
|
||||
- elasticcacheaccount
|
||||
30
docs/elasticcache/elasticcacheaccounts.yaml
Normal file
30
docs/elasticcache/elasticcacheaccounts.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCache实例用户列表
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcache_id"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例用户列表信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountListResponse"
|
||||
tags:
|
||||
- elasticcacheaccount
|
||||
|
||||
post:
|
||||
summary: 创建ElasticCache实例管理账号
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcacheaccount
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountCreate"
|
||||
responses:
|
||||
200:
|
||||
description: 新创建的ElasticCache实例账号信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountResponse"
|
||||
tags:
|
||||
- elasticcacheaccount
|
||||
40
docs/elasticcache/elasticcacheacl.yaml
Normal file
40
docs/elasticcache/elasticcacheacl.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例访问控制详情信息
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/aclId"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例访问控制信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclResponse"
|
||||
tags:
|
||||
- elasticcacheacl
|
||||
|
||||
put:
|
||||
summary: 更新指定ElasticCache实例访问控制
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/aclId"
|
||||
- in: body
|
||||
name: elasticcacheacl
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclUpdate"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的访问控制信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclResponse"
|
||||
tags:
|
||||
- elasticcacheacl
|
||||
|
||||
delete:
|
||||
summary: 删除指定ElasticCache实例访问控制
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/aclId"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的访问控制信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclResponse"
|
||||
tags:
|
||||
- elasticcacheacl
|
||||
30
docs/elasticcache/elasticcacheacls.yaml
Normal file
30
docs/elasticcache/elasticcacheacls.yaml
Normal file
@@ -0,0 +1,30 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCache实例访问控制列表
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcache_id"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例访问控制列表信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclListResponse"
|
||||
tags:
|
||||
- elasticcacheacl
|
||||
|
||||
post:
|
||||
summary: 创建ElasticCache实例ACL
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcacheacl
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclCreate"
|
||||
responses:
|
||||
200:
|
||||
description: 新创建的ElasticCache实例ACL信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAclResponse"
|
||||
tags:
|
||||
- elasticcacheacl
|
||||
23
docs/elasticcache/elasticcachebackup.yaml
Normal file
23
docs/elasticcache/elasticcachebackup.yaml
Normal file
@@ -0,0 +1,23 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例备份详情信息
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/backupId"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例备份信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupResponse"
|
||||
tags:
|
||||
- elasticcachebackup
|
||||
|
||||
delete:
|
||||
summary: 删除指定ElasticCache实例备份
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/backupId"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的备份信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupResponse"
|
||||
tags:
|
||||
- elasticcachebackup
|
||||
25
docs/elasticcache/elasticcachebackups.yaml
Normal file
25
docs/elasticcache/elasticcachebackups.yaml
Normal file
@@ -0,0 +1,25 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCache实例备份列表
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/common.yaml#/cloudregion"
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcache_id"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例备份列表信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupListResponse"
|
||||
tags:
|
||||
- elasticcachebackup
|
||||
|
||||
post:
|
||||
summary: 创建ElasticCache实例备份
|
||||
responses:
|
||||
200:
|
||||
description: 新创建的ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupResponse"
|
||||
tags:
|
||||
- elasticcachebackup
|
||||
40
docs/elasticcache/elasticcacheparameter.yaml
Normal file
40
docs/elasticcache/elasticcacheparameter.yaml
Normal file
@@ -0,0 +1,40 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例参数详情信息
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/parameterId"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheParameterResponse"
|
||||
tags:
|
||||
- elasticcacheparameter
|
||||
|
||||
put:
|
||||
summary: 更新ElasticCache实例配置参数
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/parameterId"
|
||||
- in: body
|
||||
name: elasticcacheparameter
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheParameterUpdate"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例配置参数信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheParameterResponse"
|
||||
tags:
|
||||
- elasticcacheparameter
|
||||
|
||||
delete:
|
||||
summary: 删除指定ElasticCache实例参数
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticcache.yaml#/parameterId"
|
||||
responses:
|
||||
200:
|
||||
description: 被删除ElasticCache实例的参数信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheParameterResponse"
|
||||
tags:
|
||||
- elasticcacheparameter
|
||||
14
docs/elasticcache/elasticcacheparameters.yaml
Normal file
14
docs/elasticcache/elasticcacheparameters.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCache实例参数列表
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/elasticcache.yaml#/elasticcache_id"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例参数列表信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheParameterListResponse"
|
||||
tags:
|
||||
- elasticcacheparameter
|
||||
36
docs/elasticcache/elasticcaches.yaml
Normal file
36
docs/elasticcache/elasticcaches.yaml
Normal file
@@ -0,0 +1,36 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCache实例
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/common.yaml#/provider"
|
||||
- $ref: "../parameters/common.yaml#/account"
|
||||
- $ref: "../parameters/common.yaml#/cloudprovider"
|
||||
- $ref: "../parameters/common.yaml#/billing_type"
|
||||
- $ref: "../parameters/common.yaml#/cloudregion"
|
||||
- $ref: "../parameters/common.yaml#/zone"
|
||||
- $ref: "../parameters/common.yaml#/vpc"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例列表信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheListResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
|
||||
post:
|
||||
summary: 创建ElasticCache实例
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheCreate"
|
||||
responses:
|
||||
200:
|
||||
description: 新创建的ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
19
docs/elasticcache/elasticcacheskus.yaml
Normal file
19
docs/elasticcache/elasticcacheskus.yaml
Normal file
@@ -0,0 +1,19 @@
|
||||
get:
|
||||
summary: 按指定条件列出ElasticCaches实例套餐列表
|
||||
parameters:
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/common.yaml#/provider"
|
||||
- $ref: "../parameters/common.yaml#/zone"
|
||||
- $ref: "../parameters/common.yaml#/city"
|
||||
- $ref: "../parameters/common.yaml#/cloudregion"
|
||||
- $ref: "../parameters/elasticcache.yaml#/engine_version"
|
||||
- $ref: "../parameters/elasticcache.yaml#/local_category"
|
||||
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例套餐信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheSkuListResponse"
|
||||
tags:
|
||||
- elasticcachesku
|
||||
9
docs/elasticcache/flush-instance.yaml
Normal file
9
docs/elasticcache/flush-instance.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
post:
|
||||
summary: 清空ElasticCache实例
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
9
docs/elasticcache/login-info.yaml
Normal file
9
docs/elasticcache/login-info.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
get:
|
||||
summary: 获取指定ElasticCache实例管理员密码
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例密码信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheLoginInfoResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
9
docs/elasticcache/release-public-connection.yaml
Normal file
9
docs/elasticcache/release-public-connection.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
post:
|
||||
summary: 释放ElasticCache实例公网访问地址
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
15
docs/elasticcache/reset-password.yaml
Normal file
15
docs/elasticcache/reset-password.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 重置ElasticCache实例账号密码
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcacheaccount
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResetPassword"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAccountResponse"
|
||||
tags:
|
||||
- elasticcacheaccount
|
||||
9
docs/elasticcache/restart.yaml
Normal file
9
docs/elasticcache/restart.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
post:
|
||||
summary: 重启ElasticCache实例
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
9
docs/elasticcache/restore-instance.yaml
Normal file
9
docs/elasticcache/restore-instance.yaml
Normal file
@@ -0,0 +1,9 @@
|
||||
post:
|
||||
summary: ElasticCache实例备份恢复
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupResponse"
|
||||
tags:
|
||||
- elasticcachebackup
|
||||
15
docs/elasticcache/set-maintain-time.yaml
Normal file
15
docs/elasticcache/set-maintain-time.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 设置ElasticCache实例维护时间段
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheSetMaintainTime"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
15
docs/elasticcache/update-auth-mode.yaml
Normal file
15
docs/elasticcache/update-auth-mode.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 设置ElasticCache实例密码认证
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheAuthMode"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
15
docs/elasticcache/update-backup-policy.yaml
Normal file
15
docs/elasticcache/update-backup-policy.yaml
Normal file
@@ -0,0 +1,15 @@
|
||||
post:
|
||||
summary: 设置ElasticCache实例备份策略
|
||||
parameters:
|
||||
- in: body
|
||||
name: elasticcache
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheBackupPolicy"
|
||||
responses:
|
||||
200:
|
||||
description: ElasticCache实例信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticcache.yaml#/ElasticCacheResponse"
|
||||
tags:
|
||||
- elasticcache
|
||||
0
docs/elasticcache/update-instance-parameters.yaml
Normal file
0
docs/elasticcache/update-instance-parameters.yaml
Normal file
14
docs/elasticip/associate.yaml
Normal file
14
docs/elasticip/associate.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
post:
|
||||
summary: 绑定资源
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticip.yaml#/elasticipId"
|
||||
- $ref: "../parameters/elasticip.yaml#/instance_id"
|
||||
- $ref: "../parameters/elasticip.yaml#/instance_type"
|
||||
responses:
|
||||
200:
|
||||
description: 弹性IP信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticip.yaml#/ElasticIpResponse"
|
||||
|
||||
tags:
|
||||
- elasticips
|
||||
13
docs/elasticip/change-bandwidth.yaml
Normal file
13
docs/elasticip/change-bandwidth.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
post:
|
||||
summary: 更改弹性IP带宽大小
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticip.yaml#/elasticipId"
|
||||
- $ref: "../parameters/elasticip.yaml#/bandwidth"
|
||||
responses:
|
||||
200:
|
||||
description: 弹性IP信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticip.yaml#/ElasticIpResponse"
|
||||
|
||||
tags:
|
||||
- elasticips
|
||||
13
docs/elasticip/dissociate.yaml
Normal file
13
docs/elasticip/dissociate.yaml
Normal file
@@ -0,0 +1,13 @@
|
||||
post:
|
||||
summary: 解绑弹性EIP
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticip.yaml#/elasticipId"
|
||||
- $ref: "../parameters/elasticip.yaml#/auto_delete"
|
||||
responses:
|
||||
200:
|
||||
description: 弹性IP信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticip.yaml#/ElasticIpResponse"
|
||||
|
||||
tags:
|
||||
- elasticips
|
||||
12
docs/elasticip/purge.yaml
Normal file
12
docs/elasticip/purge.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 清除弹性EIP数据库记录(并不真正删除资源)
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticip.yaml#/elasticipId"
|
||||
responses:
|
||||
200:
|
||||
description: 弹性IP信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticip.yaml#/ElasticIpResponse"
|
||||
|
||||
tags:
|
||||
- elasticips
|
||||
12
docs/elasticip/sync.yaml
Normal file
12
docs/elasticip/sync.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 同步弹性EIP状态
|
||||
parameters:
|
||||
- $ref: "../parameters/elasticip.yaml#/elasticipId"
|
||||
responses:
|
||||
200:
|
||||
description: 弹性IP信息
|
||||
schema:
|
||||
$ref: "../schemas/elasticip.yaml#/ElasticIpResponse"
|
||||
|
||||
tags:
|
||||
- elasticips
|
||||
16
docs/host/add-netif.yaml
Normal file
16
docs/host/add-netif.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
post:
|
||||
summary: 物理机添加网卡
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
- in: body
|
||||
name: host
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostAddNetif"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
16
docs/host/convert-hypervisor.yaml
Normal file
16
docs/host/convert-hypervisor.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
post:
|
||||
summary: 将物理机转换成宿主机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
- in: body
|
||||
name: host
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostConvertHypervisor"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/disable.yaml
Normal file
11
docs/host/disable.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 禁用宿主机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/enable.yaml
Normal file
11
docs/host/enable.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 启用宿主机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/ipmi.yaml
Normal file
11
docs/host/ipmi.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
get:
|
||||
summary: 获取物理机IPMI信息
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: ipmi信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostIpmi"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/maintenance.yaml
Normal file
11
docs/host/maintenance.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 重启物理机进入PXE系统,做维护工作
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/ping.yaml
Normal file
11
docs/host/ping.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: ping Host
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/prepare.yaml
Normal file
11
docs/host/prepare.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 重新收集物理机信息
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
16
docs/host/remove-netif.yaml
Normal file
16
docs/host/remove-netif.yaml
Normal file
@@ -0,0 +1,16 @@
|
||||
post:
|
||||
summary: 物理机删除网卡
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
- in: body
|
||||
name: host
|
||||
required: true
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostRemoveNetif"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/renew-prepaid-recycle.yaml
Normal file
11
docs/host/renew-prepaid-recycle.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 为预付费宿主机续费
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/reset.yaml
Normal file
11
docs/host/reset.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 物理机重启
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/spec.yaml
Normal file
11
docs/host/spec.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
get:
|
||||
summary: 获取宿主机缩略信息
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机缩略信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostSpec"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/start.yaml
Normal file
11
docs/host/start.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 启动物理机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/stop.yaml
Normal file
11
docs/host/stop.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 物理机关机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/syncstatus.yaml
Normal file
11
docs/host/syncstatus.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 同步物理机状态
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/undo-convert.yaml
Normal file
11
docs/host/undo-convert.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 将转换成宿主机的物理机转回成物理机
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/undo-prepaid-recycle.yaml
Normal file
11
docs/host/undo-prepaid-recycle.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 从预付费资源池中移除
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
11
docs/host/unmaintenance.yaml
Normal file
11
docs/host/unmaintenance.yaml
Normal file
@@ -0,0 +1,11 @@
|
||||
post:
|
||||
summary: 重启物理机,进入磁盘安装的操作系统
|
||||
parameters:
|
||||
- $ref: "../parameters/host.yaml#/hostId"
|
||||
responses:
|
||||
200:
|
||||
description: 宿主机信息
|
||||
schema:
|
||||
$ref: "../schemas/host.yaml#/HostResponse"
|
||||
tags:
|
||||
- host
|
||||
@@ -1,14 +1,14 @@
|
||||
get:
|
||||
summary: 按指定条件列出镜像
|
||||
parameters:
|
||||
- $ref: '../parameters/common.yaml#/offset'
|
||||
- $ref: '../parameters/common.yaml#/limit'
|
||||
- $ref: '../parameters/common.yaml#/pending_delete'
|
||||
- $ref: '../parameters/image.yaml#/is_public'
|
||||
- $ref: '../parameters/image.yaml#/owner'
|
||||
- $ref: '../parameters/image.yaml#/name'
|
||||
- $ref: '../parameters/image.yaml#/disk_format'
|
||||
- $ref: '../parameters/image.yaml#/disk_formats'
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/pending_delete"
|
||||
- $ref: "../parameters/image.yaml#/is_public"
|
||||
- $ref: "../parameters/image.yaml#/owner"
|
||||
- $ref: "../parameters/image.yaml#/name"
|
||||
- $ref: "../parameters/image.yaml#/disk_format"
|
||||
- $ref: "../parameters/image.yaml#/disk_formats"
|
||||
responses:
|
||||
200:
|
||||
description: 镜像列表信息
|
||||
@@ -16,3 +16,20 @@ get:
|
||||
$ref: "../schemas/image.yaml#/ImageListResponse"
|
||||
tags:
|
||||
- images
|
||||
|
||||
post:
|
||||
summary: 上传或创建镜像
|
||||
parameters:
|
||||
- $ref: "../parameters/image.yaml#/content-type"
|
||||
- $ref: "../parameters/image.yaml#/x-image-meta-name"
|
||||
- $ref: "../parameters/image.yaml#/x-image-meta-description"
|
||||
- in: body
|
||||
type: file
|
||||
description: 镜像二进制文件内容,若body为空,仅创建镜像数据库字段,可以通过put接口再次上传body内容
|
||||
responses:
|
||||
200:
|
||||
description: 上传的镜像信息
|
||||
schema:
|
||||
$ref: "../schemas/image.yaml#/ImageResponse"
|
||||
tags:
|
||||
- images
|
||||
|
||||
@@ -456,6 +456,52 @@ paths:
|
||||
$ref: "./dbinstanceaccount/set-privileges.yaml"
|
||||
|
||||
|
||||
/elasticcaches:
|
||||
$ref: "./elasticcache/elasticcaches.yaml"
|
||||
/elasticcaches/{elasticcacheId}:
|
||||
$ref: "./elasticcache/elasticcache.yaml"
|
||||
/elasticcaches/{elasticcacheId}/allocate-public-connection:
|
||||
$ref: "./elasticcache/allocate-public-connection.yaml"
|
||||
/elasticcaches/{elasticcacheId}/release-public-connection:
|
||||
$ref: "./elasticcache/release-public-connection.yaml"
|
||||
/elasticcaches/{elasticcacheId}/change-spec:
|
||||
$ref: "./elasticcache/change-spec.yaml"
|
||||
/elasticcaches/{elasticcacheId}/login-info:
|
||||
$ref: "./elasticcache/login-info.yaml"
|
||||
/elasticcaches/{elasticcacheId}/flush-instance:
|
||||
$ref: "./elasticcache/flush-instance.yaml"
|
||||
/elasticcaches/{elasticcacheId}/restart:
|
||||
$ref: "./elasticcache/restart.yaml"
|
||||
/elasticcaches/{elasticcacheId}/set-maintain-time:
|
||||
$ref: "./elasticcache/set-maintain-time.yaml"
|
||||
/elasticcaches/{elasticcacheId}/update-auth-mode:
|
||||
$ref: "./elasticcache/update-auth-mode.yaml"
|
||||
/elasticcaches/{elasticcacheId}/update-backup-policy:
|
||||
$ref: "./elasticcache/update-backup-policy.yaml"
|
||||
/elasticcaches/{elasticcacheId}/update-instance-parameters:
|
||||
$ref: "./elasticcache/update-instance-parameters.yaml"
|
||||
/elasticcacheparameters:
|
||||
$ref: "./elasticcache/elasticcacheparameters.yaml"
|
||||
/elasticcacheparameters/{parameterId}:
|
||||
$ref: "./elasticcache/elasticcacheparameter.yaml"
|
||||
/elasticcacheacls:
|
||||
$ref: "./elasticcache/elasticcacheacls.yaml"
|
||||
/elasticcacheacls/{aclId}:
|
||||
$ref: "./elasticcache/elasticcacheacl.yaml"
|
||||
/elasticcachebackups:
|
||||
$ref: "./elasticcache/elasticcachebackups.yaml"
|
||||
/elasticcachebackups/{backupId}:
|
||||
$ref: "./elasticcache/elasticcachebackup.yaml"
|
||||
/elasticcachebackups/{backupId}/restore-instance:
|
||||
$ref: "./elasticcache/restore-instance.yaml"
|
||||
/elasticcacheaccounts:
|
||||
$ref: "./elasticcache/elasticcacheaccounts.yaml"
|
||||
/elasticcacheaccounts/{accountId}:
|
||||
$ref: "./elasticcache/elasticcacheaccount.yaml"
|
||||
/elasticcacheaccounts/{accountId}/reset-password:
|
||||
$ref: "./elasticcache/reset-password.yaml"
|
||||
/elasticcacheskus:
|
||||
$ref: "./elasticcache/elasticcacheskus.yaml"
|
||||
|
||||
/cloudaccounts:
|
||||
$ref: "./cloudaccount/cloudaccounts.yaml"
|
||||
|
||||
52
docs/parameters/elasticcache.yaml
Normal file
52
docs/parameters/elasticcache.yaml
Normal file
@@ -0,0 +1,52 @@
|
||||
elasticcacheId:
|
||||
name: elasticcacheId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: ElasticCache实例名称或ID,建议使用ID
|
||||
|
||||
parameterId:
|
||||
name: parameterId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: ElasticCache实例参数名称或ID,建议使用ID
|
||||
|
||||
aclId:
|
||||
name: aclId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: ElasticCache实例访问控制名称或ID,建议使用ID
|
||||
|
||||
backupId:
|
||||
name: backupId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: ElasticCache实例备份名称或ID,建议使用ID
|
||||
|
||||
accountId:
|
||||
name: accountId
|
||||
required: true
|
||||
in: path
|
||||
type: string
|
||||
description: ElasticCache实例用户名称或ID,建议使用ID
|
||||
|
||||
elasticcache_id:
|
||||
name: elasticcache_id
|
||||
in: query
|
||||
type: string
|
||||
description: 根据ElasticCache实例名称或ID过滤资源
|
||||
|
||||
engine_version:
|
||||
name: engine_version
|
||||
in: query
|
||||
type: string
|
||||
description: 根据ElasticCache实例版本过滤资源
|
||||
|
||||
local_category:
|
||||
name: local_category
|
||||
in: query
|
||||
type: string
|
||||
description: 根据ElasticCache类型过滤资源
|
||||
@@ -167,5 +167,45 @@ SharableVirtualResourceBaseResponse:
|
||||
type: string
|
||||
example: system
|
||||
description: public_scope
|
||||
readOnly: true
|
||||
|
||||
readOnly: true
|
||||
|
||||
BillingBaseResponse:
|
||||
type: object
|
||||
properties:
|
||||
billing_type:
|
||||
type: string
|
||||
example: postpaid
|
||||
enum: [postpaid, prepaid]
|
||||
description: 资源计费类型
|
||||
expired_at:
|
||||
type: string
|
||||
example: "2019-06-11T03:39:02.000000Z"
|
||||
description: 资源到期时间,仅对预付费类型资源有效
|
||||
|
||||
ProviderBaseResponse:
|
||||
type: object
|
||||
properties:
|
||||
region_id:
|
||||
type: string
|
||||
example: 5fbbdfaa-46ba-433a-81be-b3581ac55bfa
|
||||
description: 区域ID
|
||||
region_external_id:
|
||||
type: string
|
||||
example: 5fbbdfaa-46ba-433a-81be-b3581ac55bfa
|
||||
description: 区域云端ID
|
||||
region:
|
||||
type: string
|
||||
example: 阿里云 马来西亚(吉隆坡)
|
||||
description: 区域名称
|
||||
project_domain:
|
||||
type: string
|
||||
example: Default
|
||||
description: 项目
|
||||
manager:
|
||||
type: string
|
||||
example: Default
|
||||
description: 云账号
|
||||
manager_id:
|
||||
type: string
|
||||
example: 7b972be9-fd8a-43f5-8058-3820553f61c4
|
||||
description: 云账号ID
|
||||
626
docs/schemas/elasticcache.yaml
Normal file
626
docs/schemas/elasticcache.yaml
Normal file
@@ -0,0 +1,626 @@
|
||||
ElasticCache:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/VirtualResourceBaseResponse"
|
||||
- $ref: "./common.yaml#/BillingResourceBaseResponse"
|
||||
- $ref: "./common.yaml#/ManagedResourceBaseResponse"
|
||||
- $ref: "./common.yaml#/ProviderBaseResponse"
|
||||
- $ref: "./common.yaml#/ZoneResourceBaseResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例
|
||||
properties:
|
||||
engine:
|
||||
type: string
|
||||
example: Redis
|
||||
description: ElasticCache实例引擎
|
||||
readOnly: true
|
||||
engine_version:
|
||||
type: string
|
||||
example: "3.0"
|
||||
description: ElasticCache实例引擎版本
|
||||
instance_type:
|
||||
type: string
|
||||
example: redis.master.micro.default
|
||||
description: ElasticCache实例规格
|
||||
arch_type:
|
||||
type: string
|
||||
example: cluster
|
||||
description: ElasticCache实例架构类型
|
||||
network_id:
|
||||
type: string
|
||||
example: 39326a92-8691-49e9-886a-097125c48067
|
||||
description: ElasticCache实例子网ID
|
||||
vcpu_count:
|
||||
type: integer
|
||||
example: 1
|
||||
description: ElasticCache实例CPU核数
|
||||
capacity_mb:
|
||||
type: integer
|
||||
example: 1024
|
||||
description: ElasticCache实例内存大小
|
||||
vpc_id:
|
||||
type: string
|
||||
example: 5d0a3589-4ec5-4509-8e53-6505457577b0
|
||||
description: ElasticCache实例VPC ID
|
||||
vpc:
|
||||
type: string
|
||||
example: vpc-2zecuo9v4idebme295ofy
|
||||
description: ElasticCache实例VPC ID
|
||||
private_connect_port:
|
||||
type: integer
|
||||
example: 6379
|
||||
description: ElasticCache实例内网端口
|
||||
private_ip_addr:
|
||||
type: string
|
||||
example: 192.168.0.100
|
||||
description: ElasticCache实例内网IP
|
||||
private_dns:
|
||||
type: string
|
||||
example: redisx.aliyuncs.com
|
||||
description: ElasticCache实例内网域名
|
||||
public_connect_port:
|
||||
type: integer
|
||||
example: 6379
|
||||
description: ElasticCache实例公网端口
|
||||
public_ip_addr:
|
||||
type: string
|
||||
example: 192.168.0.100
|
||||
description: ElasticCache实例公网IP
|
||||
public_dns:
|
||||
type: string
|
||||
example: redisx.aliyuncs.com
|
||||
description: ElasticCache实例公网域名
|
||||
maintain_start_time:
|
||||
type: string
|
||||
example: 00:00Z
|
||||
description: ElasticCache实例维护开始时间
|
||||
maintain_end_time:
|
||||
type: string
|
||||
example: 02:00Z
|
||||
description: ElasticCache实例维护结束时间
|
||||
|
||||
ElasticCacheListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcaches:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCache"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcache:
|
||||
type: object
|
||||
$ref: "#/ElasticCache"
|
||||
|
||||
ElasticCacheNetwork:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/ResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例网络
|
||||
properties:
|
||||
elasticcache_id:
|
||||
type: string
|
||||
example: "20f8b552-1b86-4595-89e3-49d123b25215"
|
||||
description: ElasticCache实例ID
|
||||
ip_addr:
|
||||
type: string
|
||||
example: 10.10.140.141
|
||||
description: 实例内网IP地址
|
||||
network_id:
|
||||
type: string
|
||||
example: "38897a74-17b4-4c21-86b3-4f8528ced003"
|
||||
description: 实例子网ID
|
||||
|
||||
ElasticCacheNetworkListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcachenetworks:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheNetwork"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheNetworkResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcachenetwork:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheNetwork"
|
||||
|
||||
ElasticCacheParameter:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/StandaloneResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例参数
|
||||
properties:
|
||||
key:
|
||||
type: string
|
||||
example: read_buffer_size
|
||||
description: ElasticCache实例参数
|
||||
value:
|
||||
type: string
|
||||
example: "131072"
|
||||
description: ElasticCache实例参数值
|
||||
readOnly: true
|
||||
force_restart:
|
||||
type: boolean
|
||||
example: false
|
||||
description: 重启生效, True(重启生效)/False
|
||||
readOnly: true
|
||||
modifiable:
|
||||
type: boolean
|
||||
example: false
|
||||
description: 参数可修改, True(可修改)/False(不可修改)
|
||||
readOnly: true
|
||||
|
||||
ElasticCacheParameterListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcacheparameters:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheParameter"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheParameterResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcacheparameter:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheParameter"
|
||||
|
||||
ElasticCacheAcl:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/StatusStandaloneResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例访问控制参数
|
||||
properties:
|
||||
Name:
|
||||
type: string
|
||||
example: web_acl
|
||||
description: ElasticCache实例访问控制Name参数
|
||||
IpList:
|
||||
type: string
|
||||
example: 192.168.0.1,192.168.0.2
|
||||
description: ElasticCache实例访问控制IpList参数
|
||||
elasticcache_id:
|
||||
type: string
|
||||
example: d0fe1519-8de5-4e13-844a-7367f4210f83
|
||||
description: ElasticCache实例ID
|
||||
readOnly: true
|
||||
|
||||
ElasticCacheAclListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcacheacls:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheAcl"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheAclResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcacheacl:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheAcl"
|
||||
|
||||
ElasticCacheBackup:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/StatusStandaloneResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例备份参数
|
||||
properties:
|
||||
start_time:
|
||||
type: string
|
||||
example: "2019-06-22T02:31:08.000000Z"
|
||||
description: ElasticCache实例备份开始时间
|
||||
end_time:
|
||||
type: string
|
||||
example: "2019-06-22T02:33:24.000000Z"
|
||||
description: ElasticCache实例备份结束时间
|
||||
backup_type:
|
||||
type: string
|
||||
example: full_backup
|
||||
description: ElasticCache实例备份类型, 全量|增量额
|
||||
backup_mode:
|
||||
type: string
|
||||
example: manual
|
||||
description: ElasticCache实例备份类型, 自动|手动
|
||||
backup_size_mb:
|
||||
type: integer
|
||||
example: 21
|
||||
description: 备份大小
|
||||
elasticcache_id:
|
||||
type: string
|
||||
example: d0fe1519-8de5-4e13-844a-7367f4210f83
|
||||
description: ElasticCache实例ID
|
||||
readOnly: true
|
||||
download_url:
|
||||
type: string
|
||||
example: redisx.aliyuncs.com/redis.bak
|
||||
description: ElasticCache备份下载链接
|
||||
readOnly: true
|
||||
|
||||
ElasticCacheBackupListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcachebackups:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheBackup"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheBackupResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcachebackup:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheBackup"
|
||||
|
||||
ElasticCacheAccount:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/StandaloneResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例账号参数
|
||||
properties:
|
||||
password:
|
||||
type: string
|
||||
example: abcFFFssx
|
||||
description: 账号密码
|
||||
account_privilege:
|
||||
type: string
|
||||
example: read
|
||||
description: 账号权限 read | write | repl(复制, 复制权限支持读写,且开放SYNC/PSYNC命令)
|
||||
account_type:
|
||||
type: string
|
||||
example: normal
|
||||
description: 账号类型 normal |admin
|
||||
elasticcache_id:
|
||||
type: string
|
||||
example: d0fe1519-8de5-4e13-844a-7367f4210f83
|
||||
description: ElasticCache实例ID
|
||||
readOnly: true
|
||||
|
||||
ElasticCacheAccountListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcacheaccounts:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheAccount"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheAccountResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcacheaccount:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheAccount"
|
||||
|
||||
ElasticCacheSku:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/StandaloneResponse"
|
||||
- $ref: "./common.yaml#/ExternalizedResourceBaseResponse"
|
||||
- type: object
|
||||
description: ElasticCache实例套餐信息
|
||||
properties:
|
||||
cloudregion_id:
|
||||
type: string
|
||||
example: 2c328dbb-dc40-41f0-8fbd-20a0cbe1829b
|
||||
description: 实例所在区域ID
|
||||
engine:
|
||||
type: string
|
||||
example: redis
|
||||
description: 实例引擎
|
||||
engine_arch:
|
||||
type: string
|
||||
example: cluster
|
||||
description: 实例架构
|
||||
engine_version:
|
||||
type: string
|
||||
example: "2.8"
|
||||
description: 实例版本
|
||||
readOnly: true
|
||||
id:
|
||||
type: string
|
||||
example: de76d65b-6134-4945-8ce7-0789d37b5072
|
||||
description: 实例ID
|
||||
readOnly: true
|
||||
instance_spec:
|
||||
type: string
|
||||
example: redis.sharding.basic.small.defaut
|
||||
description: 实例规格
|
||||
readOnly: true
|
||||
name:
|
||||
type: string
|
||||
example: redis.sharding.basic.small.default:v2.8
|
||||
description: 实例规格名称
|
||||
readOnly: true
|
||||
local_category:
|
||||
type: string
|
||||
example: cluster
|
||||
description: 实例在Onecloud中所属类别
|
||||
readOnly: true
|
||||
memory_size_mb:
|
||||
type: integer
|
||||
example: 16384
|
||||
description: 实例内存大小MB
|
||||
readOnly: true
|
||||
postpaid_status:
|
||||
type: string
|
||||
example: available
|
||||
description: 实例按需付费可用状态 available|soldout
|
||||
readOnly: true
|
||||
prepaid_status:
|
||||
type: string
|
||||
example: available
|
||||
description: 实例预付费可用状态 available|soldout
|
||||
readOnly: true
|
||||
provider:
|
||||
type: string
|
||||
example: Aliyun
|
||||
description: 实例Provider
|
||||
readOnly: true
|
||||
zone_id:
|
||||
type: string
|
||||
example: Aliyun
|
||||
description: 实例所在可用区ID
|
||||
readOnly: true
|
||||
storage_type:
|
||||
type: string
|
||||
example: inmemory
|
||||
description: 实例存储类型
|
||||
readOnly: true
|
||||
max_connections:
|
||||
type: integer
|
||||
example: 1000000
|
||||
description: 实例最大连接数
|
||||
readOnly: true
|
||||
|
||||
ElasticCacheSkuListResponse:
|
||||
type: object
|
||||
properties:
|
||||
limit:
|
||||
type: integer
|
||||
example: 20
|
||||
elasticcacheskus:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/ElasticCacheSku"
|
||||
total:
|
||||
type: integer
|
||||
example: 124
|
||||
|
||||
ElasticCacheSkuResponse:
|
||||
type: object
|
||||
properties:
|
||||
elasticcachesku:
|
||||
type: object
|
||||
$ref: "#/ElasticCacheSku"
|
||||
|
||||
ElasticCacheCreate:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: test-instance
|
||||
description: 实例名称
|
||||
cloudregion:
|
||||
type: string
|
||||
example: ebb5abd3-8ffb-42ec-8bc6-38ba5b949885
|
||||
description: 实例所在区域 Id
|
||||
zone:
|
||||
type: string
|
||||
example: 70802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 实例所在可用区 Id
|
||||
network:
|
||||
type: string
|
||||
example: 70802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 实例所在子网 Id
|
||||
engine:
|
||||
type: string
|
||||
example: redis
|
||||
description: 实例引擎 redis
|
||||
engine_version:
|
||||
type: string
|
||||
example: "4.0"
|
||||
enum: ["2.8", "3.0", "4.0", "5.0"]
|
||||
password:
|
||||
type: string
|
||||
example: dfdf11AAZ
|
||||
description: 实例访问密码
|
||||
instance_type:
|
||||
type: string
|
||||
example: 80802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 实例规格ID
|
||||
billing_type:
|
||||
type: string
|
||||
example: postpaid
|
||||
description: 计费类型, postpaid|prepaid
|
||||
billing_cycle:
|
||||
type: string
|
||||
example: 1M
|
||||
description: 计费周期, eg. 1M 1Y
|
||||
|
||||
ElasticCacheAccountCreate:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: test-instance
|
||||
description: 账号名称
|
||||
password:
|
||||
type: string
|
||||
example: dfdf11AAZ
|
||||
description: 账号访问密码
|
||||
account_privilege:
|
||||
type: string
|
||||
example: read
|
||||
description: 账号权限 read|write|repl
|
||||
elasticache:
|
||||
type: string
|
||||
example: 90802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 实例ID
|
||||
|
||||
ElasticCacheAclCreate:
|
||||
type: object
|
||||
properties:
|
||||
name:
|
||||
type: string
|
||||
example: test-instance
|
||||
description: 访问控制名称
|
||||
ip_list:
|
||||
type: string
|
||||
example: 192.168.0.1,192.168.0.2
|
||||
description: 访问控制IP列表,逗号分隔
|
||||
elasticache:
|
||||
type: string
|
||||
example: 90802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 实例ID
|
||||
|
||||
ElasticCacheAclUpdate:
|
||||
type: object
|
||||
properties:
|
||||
ip_list:
|
||||
type: string
|
||||
example: 192.168.0.1,192.168.0.2
|
||||
description: 访问控制IP列表,逗号分隔
|
||||
|
||||
ElasticCacheParameterUpdate:
|
||||
type: object
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
example: 10802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 参数ID
|
||||
value:
|
||||
type: string
|
||||
example: 1000
|
||||
description: 参数值
|
||||
|
||||
ElasticCacheAllocatePublicConnection:
|
||||
type: object
|
||||
properties:
|
||||
port:
|
||||
type: integer
|
||||
required: false
|
||||
example: 6379
|
||||
description: 公网访问端口号, 1024~65535
|
||||
|
||||
ElasticCacheChangeSpec:
|
||||
type: object
|
||||
properties:
|
||||
sku:
|
||||
type: string
|
||||
required: true
|
||||
example: 10802da8-affe-4247-8ce8-610f205019ca
|
||||
description: 规格ID
|
||||
|
||||
ElasticCacheSetMaintainTime:
|
||||
type: object
|
||||
properties:
|
||||
maintain_start_time:
|
||||
type: string
|
||||
required: true
|
||||
example: "00:00"
|
||||
description: 维护开始时间, 格式:'HH:mm'
|
||||
maintain_end_time:
|
||||
type: string
|
||||
required: true
|
||||
example: "02:00"
|
||||
description: 维护结束时间, 格式:'HH:mm'
|
||||
|
||||
ElasticCacheAuthMode:
|
||||
type: object
|
||||
properties:
|
||||
auth_mode:
|
||||
type: string
|
||||
required: true
|
||||
example: on
|
||||
description: 认证模式, on(开启密码认证)|off(关闭密码认证)
|
||||
|
||||
ElasticCacheBackupPolicy:
|
||||
type: object
|
||||
properties:
|
||||
backup_type:
|
||||
type: string
|
||||
required: false
|
||||
example: automated
|
||||
description: 备份类型, automated | manual
|
||||
backup_reserved_days:
|
||||
type: integer
|
||||
required: false
|
||||
example: 7
|
||||
description: 备份保留天数, 1~7
|
||||
preferred_backup_period:
|
||||
type: string
|
||||
required: true
|
||||
example: Monday
|
||||
description: 备份周期, Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday
|
||||
preferred_backup_time:
|
||||
type: string
|
||||
required: true
|
||||
example: 00:00Z-02:00Z
|
||||
description: 备份时间段, 格式: 'HH:mmZ-HH:mmZ'
|
||||
|
||||
ElasticCacheResetPassword:
|
||||
type: object
|
||||
properties:
|
||||
password:
|
||||
type: string
|
||||
required: false
|
||||
example: pxxxword
|
||||
description: 新密码
|
||||
reset_password:
|
||||
type: boolean
|
||||
required: false
|
||||
example: true
|
||||
description: 新密码
|
||||
|
||||
ElasticCacheLoginInfoResponse:
|
||||
type: object
|
||||
properties:
|
||||
password:
|
||||
type: string
|
||||
example: 1111111
|
||||
username:
|
||||
type: string
|
||||
example: testUser
|
||||
@@ -227,6 +227,7 @@ LoadbalancerAclEntries:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/LoadbalancerAclEntry"
|
||||
|
||||
LoadbalancerCachedAclCreateRequest:
|
||||
type: object
|
||||
properties:
|
||||
@@ -249,6 +250,7 @@ LoadbalancerCachedAclCreateRequest:
|
||||
listener:
|
||||
type: string
|
||||
description: 指定负载均衡监听器ID,华为云必须指定该参数。
|
||||
|
||||
LoadbalancerCachedAcl:
|
||||
allOf:
|
||||
- $ref: "./common.yaml#/SharableVirtualResourceBaseResponse"
|
||||
@@ -351,4 +353,303 @@ LoadbalancerCachedCertificateListResponse:
|
||||
cached_loadbalancercertificates:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/LoadbalancerCachedCertificateResponse"
|
||||
$ref: "#/LoadbalancerCachedCertificateResponse"
|
||||
|
||||
LoadbalancerCluster:
|
||||
type: object
|
||||
description: Loadbalancer集群实例
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: 实例uuid
|
||||
readOnly: true
|
||||
zone_id:
|
||||
type: string
|
||||
description: 集群所在的zone uuid
|
||||
readOnly: true
|
||||
|
||||
LoadbalancerClusterCreateRequest:
|
||||
type: object
|
||||
properties:
|
||||
loadbalancercluster:
|
||||
type: object
|
||||
required:
|
||||
- zone
|
||||
properties:
|
||||
zone:
|
||||
type: string
|
||||
description: 指定集群所属的zone uuid
|
||||
LoadbalancerClusterListResponse:
|
||||
type: object
|
||||
properties:
|
||||
loadbalancerclusters:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/LoadbalancerCluster"
|
||||
LoadbalancerClusterResponse:
|
||||
type: object
|
||||
properties:
|
||||
loadbalancercluster:
|
||||
type: object
|
||||
$ref: "#/LoadbalancerCluster"
|
||||
|
||||
LoadbalancerAgent:
|
||||
type: object
|
||||
description: |
|
||||
Loadbalancer转发实例
|
||||
|
||||
- 同cluster中的lbagent
|
||||
- vrrp virtual_router_id, preempt, pass必须相同
|
||||
- vrrp priority必须不同
|
||||
- 同zone不同cluster中的lbagent
|
||||
- vrrp virtual_router_id必须不同
|
||||
- 创建时,若不满足以上条件,则创建失败
|
||||
- 更新参数时(`params-patch`),同时更新同cluster的peer lbagents
|
||||
|
||||
properties:
|
||||
id:
|
||||
type: string
|
||||
description: 实例uuid
|
||||
readOnly: true
|
||||
cluster_id:
|
||||
type: string
|
||||
description: 转发实例所属的集群id
|
||||
readOnly: true
|
||||
ha_state:
|
||||
type: string
|
||||
description: 转发实例的主备状态
|
||||
readOnly: true
|
||||
enum:
|
||||
- MASTER
|
||||
- BACKUP
|
||||
- UNKNOWN
|
||||
ha_last_seen:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例上次心跳UTC时间
|
||||
readOnly: true
|
||||
example: "2019-07-24T06:38:07.000000Z"
|
||||
ha_timeout:
|
||||
type: integer
|
||||
description: |
|
||||
转发实例心跳超时时间
|
||||
|
||||
若上次心跳时间距离当前时间超过此值,则认为实例已离线,进入非活跃状态
|
||||
unit: seconds
|
||||
ip:
|
||||
type: string
|
||||
description: 转发实例自上报的IP地址
|
||||
readOnly: true
|
||||
params:
|
||||
$ref: "#/LoadbalancerAgentParams"
|
||||
deployment:
|
||||
$ref: "#/LoadbalancerAgentDeployment"
|
||||
readOnly: true
|
||||
loadbalancer_acls:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB访问控制对象时戳
|
||||
loadbalancer_backend_groups:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB后端服务器组对象时戳
|
||||
loadbalancer_backends:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB后端对象时戳
|
||||
loadbalancer_certificates:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB证书对象时戳
|
||||
loadbalancer_listener_rules:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB访问策略对象时戳
|
||||
loadbalancer_listeners:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB监听对象时戳
|
||||
loadbalancers:
|
||||
type: string
|
||||
format: date-time
|
||||
description: 转发实例当前同步到的最新LB对象时戳
|
||||
|
||||
LoadbalancerAgentDeployment:
|
||||
type: object
|
||||
properties:
|
||||
host:
|
||||
type: string
|
||||
ansibleplaybook:
|
||||
type: string
|
||||
description: |
|
||||
部署对应的ansibleplaybook uuid
|
||||
|
||||
可通过此字段获取部署的执行结果
|
||||
|
||||
LoadbalancerAgentParams:
|
||||
type: object
|
||||
properties:
|
||||
vrrp:
|
||||
$ref: "#/LoadbalancerAgentParamsVrrp"
|
||||
haproxy:
|
||||
$ref: "#/LoadbalancerAgentParamsHaproxy"
|
||||
telegraf:
|
||||
$ref: "#/LoadbalancerAgentParamsTelegraf"
|
||||
keepalived_conf_tmpl:
|
||||
type: string
|
||||
description: |
|
||||
以base64编码的KeepAlived配置模板
|
||||
|
||||
创建时可选,服务端会设定默认值
|
||||
example: Z2xvYmFsX2RlZnMgewoJcm91dGVyX2lkIHt7IC5hZ2VudC5pZCB9fQoJI3ZycnBfc3RyaWN0Cgl2cnJwX3NraXBfY2hlY2tfYWR2X2FkZHIKCWVuYWJsZV9zY3JpcHRfc2VjdXJpdHkKfQoKdnJycF9pbnN0YW5jZSBZdW5pb25MQiB7CglpbnRlcmZhY2Uge3sgLnZycnAuaW50ZXJmYWNlIH19Cgl2aXJ0dWFsX3JvdXRlcl9pZCB7eyAudnJycC52aXJ0dWFsX3JvdXRlcl9pZCB9fQoJYXV0aGVudGljYXRpb24gewoJCWF1dGhfdHlwZSBQQVNTCgkJYXV0aF9wYXNzIHt7IC52cnJwLnBhc3MgfX0KCX0KCXt7IGlmIC52cnJwLm5vdGlmeV9zY3JpcHQgLX19IG5vdGlmeSB7eyAudnJycC5ub3RpZnlfc2NyaXB0IH19IHJvb3Qge3stIGVuZCB9fQoJe3sgaWYgLnZycnAudW5pY2FzdF9wZWVyIC19fSB1bmljYXN0X3BlZXIgeyB7ey0gcHJpbnRsbiB9fQoJCXt7LSByYW5nZSAudnJycC51bmljYXN0X3BlZXIgfX0JCXt7IHByaW50bG4gLiB9fSB7ey0gZW5kIH19Cgl9Cgl7ey0gZW5kIH19Cglwcmlvcml0eSB7eyAudnJycC5wcmlvcml0eSB9fQoJYWR2ZXJ0X2ludCB7eyAudnJycC5hZHZlcnRfaW50IH19CglnYXJwX21hc3Rlcl9yZWZyZXNoIHt7IC52cnJwLmdhcnBfbWFzdGVyX3JlZnJlc2ggfX0KCXt7IGlmIC52cnJwLnByZWVtcHQgLX19IHByZWVtcHQge3stIGVsc2UgLX19IG5vcHJlZW1wdCB7ey0gZW5kIH19Cgl2aXJ0dWFsX2lwYWRkcmVzcyB7CgkJe3stIHByaW50ZiAiXG4iIH19CgkJe3stIHJhbmdlIC52cnJwLmFkZHJlc3NlcyB9fQkJe3sgcHJpbnRsbiAuIH19IHt7LSBlbmQgfX0KCQl7ey0gcHJpbnRmICJcdCIgLX19Cgl9Cn0K
|
||||
haproxy_conf_tmpl:
|
||||
type: string
|
||||
description: |
|
||||
以base64编码的HAProxy配置模板
|
||||
|
||||
创建时可选,服务端会设定默认值
|
||||
example: Cmdsb2JhbAoJbWF4Y29ubiA0MDk2MAoJdHVuZS5zc2wuZGVmYXVsdC1kaC1wYXJhbSAyMDQ4Cgl7ey0gcHJpbnRsbiB9fQoJe3stIGlmIC5oYXByb3h5Lmdsb2JhbF9zdGF0c19zb2NrZXQgfX0Je3sgcHJpbnRsbiAuaGFwcm94eS5nbG9iYWxfc3RhdHNfc29ja2V0IH19IHt7LSBlbmQgfX0KCXt7LSBpZiAuaGFwcm94eS5nbG9iYWxfbmJ0aHJlYWQgfX0JbmJ0aHJlYWQge3sgcHJpbnRsbiAuaGFwcm94eS5nbG9iYWxfbmJ0aHJlYWQgfX0ge3stIGVuZCB9fQoJe3stIGlmIC5oYXByb3h5Lmdsb2JhbF9sb2cgfX0Je3sgcHJpbnRsbiAuaGFwcm94eS5nbG9iYWxfbG9nIH19IHt7LSBlbmQgfX0KCmRlZmF1bHRzCgl0aW1lb3V0IGNvbm5lY3QgMTBzCgl0aW1lb3V0IGNsaWVudCA2MHMKCXRpbWVvdXQgc2VydmVyIDYwcwoJdGltZW91dCB0dW5uZWwgMWgKCXt7LSBwcmludGxuIH19Cgl7ey0gaWYgLmhhcHJveHkuZ2xvYmFsX2xvZyB9fQl7eyBwcmludGxuICJsb2cgZ2xvYmFsIiB9fSB7ey0gZW5kIH19Cgl7ey0gaWYgbm90IC5oYXByb3h5LmxvZ19ub3JtYWwgfX0Je3sgcHJpbnRsbiAib3B0aW9uIGRvbnRsb2ctbm9ybWFsIiB9fSB7ey0gZW5kIH19CgpsaXN0ZW4gc3RhdHMKCW1vZGUgaHR0cAoJYmluZCA6Nzc4CglzdGF0cyBlbmFibGUKCXN0YXRzIGhpZGUtdmVyc2lvbgoJc3RhdHMgcmVhbG0gIkhhcHJveHkgU3RhdGlzdGljcyIKCXN0YXRzIGF1dGggWXVuaW9uOkxCU3RhdHMKCXN0YXRzIHVyaSAvCg==
|
||||
telegraf_conf_tmpl:
|
||||
type: string
|
||||
description: |
|
||||
以base64编码的Telegraf配置模板
|
||||
|
||||
创建时可选,服务端会设定默认值
|
||||
example: Cltbb3V0cHV0cy5pbmZsdXhkYl1dCgl1cmxzID0gWyJ7eyAudGVsZWdyYWYuaW5mbHV4X2RiX291dHB1dF91cmwgfX0iXQoJZGF0YWJhc2UgPSAie3sgLnRlbGVncmFmLmluZmx1eF9kYl9vdXRwdXRfbmFtZSB9fSIKCWluc2VjdXJlX3NraXBfdmVyaWZ5ID0gdHJ1ZQoKW1tpbnB1dHMuaGFwcm94eV1dCglpbnRlcnZhbCA9ICJ7eyAudGVsZWdyYWYuaGFwcm94eV9pbnB1dF9pbnRlcnZhbCB9fXMiCglzZXJ2ZXJzID0gWyJ7eyAudGVsZWdyYWYuaGFwcm94eV9pbnB1dF9zdGF0c19zb2NrZXQgfX0iXQoJa2VlcF9maWVsZF9uYW1lcyA9IHRydWUK
|
||||
|
||||
LoadbalancerAgentParamsVrrp:
|
||||
type: object
|
||||
description: VRRP参数
|
||||
properties:
|
||||
advert_int:
|
||||
type: integer
|
||||
description: VRRP通告间隔,单位秒
|
||||
mininum: 1
|
||||
example: 1
|
||||
interface:
|
||||
type: string
|
||||
description: VRRP通告发送的网口名
|
||||
example: eth0
|
||||
garp_master_refresh:
|
||||
type: integer
|
||||
description: |
|
||||
MASTER状态时发送免费ARP通告的最小间隔
|
||||
|
||||
单位秒,默认值27,为0时表示不发送通告
|
||||
unit: seconds
|
||||
mininum: 0
|
||||
example: 27
|
||||
pass:
|
||||
type: string
|
||||
description: VRRP通告共享密码
|
||||
example: OneCloudLB
|
||||
preempt:
|
||||
type: boolean
|
||||
description: 是否进行抢占式选举
|
||||
example: false
|
||||
priority:
|
||||
type: integer
|
||||
description: VRRP实例优先级
|
||||
mininum: 1
|
||||
maximum: 255
|
||||
example: 110
|
||||
virtual_router_id:
|
||||
type: integer
|
||||
description: VRRP集群ID
|
||||
mininum: 1
|
||||
maximum: 255
|
||||
example: 100
|
||||
LoadbalancerAgentParamsHaproxy:
|
||||
type: object
|
||||
description: HAProxy参数
|
||||
properties:
|
||||
global_log:
|
||||
type: string
|
||||
description: HAProxy配置文件global段中关于日志的配置
|
||||
example: "log /dev/log local0 info"
|
||||
global_nbthread:
|
||||
type: integer
|
||||
description: HAProxy配置文件global段中关于线程数的配置
|
||||
example: 1
|
||||
mininum: 1
|
||||
maximum: 64
|
||||
log_http:
|
||||
type: boolean
|
||||
description: 是否记录HTTP访问日志
|
||||
log_tcp:
|
||||
type: boolean
|
||||
description: 是否记录TCP访问日志
|
||||
log_normal:
|
||||
type: boolean
|
||||
description: 是否记录结果正常的访问
|
||||
LoadbalancerAgentParamsTelegraf:
|
||||
type: object
|
||||
description: Telegraf参数
|
||||
properties:
|
||||
haproxy_input_interval:
|
||||
type: integer
|
||||
description: HAProxy统计数据的采样间隔
|
||||
unit: seconds
|
||||
minimum: 1
|
||||
influx_db_output_name:
|
||||
type: string
|
||||
description: 存储监控数据的InfluxDB数据库的名称
|
||||
example: "telegraf"
|
||||
influx_db_output_unsafe_ssl:
|
||||
type: boolean
|
||||
description: 访问InfluxDB时是否忽略证书校验
|
||||
influx_db_output_url:
|
||||
type: string
|
||||
description: InfluxDB的API地址
|
||||
example: https://10.168.222.136:8086/
|
||||
|
||||
LoadbalancerAgentCreateRequest:
|
||||
type: object
|
||||
properties:
|
||||
loadbalanceragent:
|
||||
type: object
|
||||
required:
|
||||
- cluster
|
||||
properties:
|
||||
cluster:
|
||||
type: string
|
||||
description: 指定转发实例所属的集群
|
||||
params:
|
||||
$ref: "#/LoadbalancerAgentParams"
|
||||
LoadbalancerAgentListResponse:
|
||||
type: object
|
||||
properties:
|
||||
loadbalanceragents:
|
||||
type: array
|
||||
items:
|
||||
$ref: "#/LoadbalancerAgent"
|
||||
LoadbalancerAgentResponse:
|
||||
type: object
|
||||
properties:
|
||||
loadbalanceragent:
|
||||
type: object
|
||||
$ref: "#/LoadbalancerAgent"
|
||||
|
||||
LoadbalancerAgentDeployRequest:
|
||||
type: object
|
||||
properties:
|
||||
loadbalanceragent:
|
||||
type: object
|
||||
properties:
|
||||
host:
|
||||
$ref: "./ansibleplaybook.yaml#/AnsiblePlaybookInventoryHost"
|
||||
deploy_method:
|
||||
type: string
|
||||
description: 部署方法
|
||||
enum:
|
||||
- yum
|
||||
- copy
|
||||
example:
|
||||
host:
|
||||
name: server:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
|
||||
vars:
|
||||
user: lbagent
|
||||
pass: lbagentpassword
|
||||
proj: system
|
||||
repo_base_url: https://10.168.222.136/yumrepo
|
||||
deploy_method: yum
|
||||
12
docs/secgroup/private.yaml
Normal file
12
docs/secgroup/private.yaml
Normal file
@@ -0,0 +1,12 @@
|
||||
post:
|
||||
summary: 取消安全组共享
|
||||
parameters:
|
||||
- $ref: "../parameters/secgroup.yaml#/secgroupId"
|
||||
responses:
|
||||
200:
|
||||
description: 安全组信息
|
||||
schema:
|
||||
$ref: "../schemas/secgroup.yaml#/SecgroupResponse"
|
||||
|
||||
tags:
|
||||
- secgroups
|
||||
14
docs/secgroup/public.yaml
Normal file
14
docs/secgroup/public.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
post:
|
||||
summary: 共享安全组
|
||||
parameters:
|
||||
- $ref: "../parameters/secgroup.yaml#/secgroupId"
|
||||
- $ref: "../parameters/secgroup.yaml#/scope"
|
||||
- $ref: "../parameters/secgroup.yaml#/shared_projects"
|
||||
responses:
|
||||
200:
|
||||
description: 安全组信息
|
||||
schema:
|
||||
$ref: "../schemas/secgroup.yaml#/SecgroupResponse"
|
||||
|
||||
tags:
|
||||
- secgroups
|
||||
@@ -1,12 +1,12 @@
|
||||
post:
|
||||
summary: 禁用实例套餐
|
||||
parameters:
|
||||
parameters:
|
||||
- $ref: "../parameters/serversku.yaml#/serverskuId"
|
||||
responses:
|
||||
200:
|
||||
description: 禁用的实例套餐信息
|
||||
schema:
|
||||
$ref: "../schemas/serversku.yaml#ServerSkuResponse"
|
||||
$ref: "../schemas/serversku.yaml#/ServerSkuResponse"
|
||||
|
||||
tags:
|
||||
- serverskus
|
||||
- serverskus
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
post:
|
||||
summary: 启用实例套餐
|
||||
parameters:
|
||||
parameters:
|
||||
- $ref: "../parameters/serversku.yaml#/serverskuId"
|
||||
responses:
|
||||
200:
|
||||
description: 启用的实例套餐信息
|
||||
schema:
|
||||
$ref: "../schemas/serversku.yaml#ServerSkuResponse"
|
||||
$ref: "../schemas/serversku.yaml#/ServerSkuResponse"
|
||||
|
||||
tags:
|
||||
- serverskus
|
||||
- serverskus
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
get:
|
||||
summary: 按指定条件列出实例套餐
|
||||
parameters:
|
||||
- $ref: '../parameters/common.yaml#/limit'
|
||||
- $ref: '../parameters/common.yaml#/offset'
|
||||
- $ref: '../parameters/common.yaml#/cloud_env'
|
||||
- $ref: '../parameters/common.yaml#/cloudregion'
|
||||
- $ref: '../parameters/common.yaml#/zone'
|
||||
- $ref: '../parameters/common.yaml#/city'
|
||||
- $ref: '../parameters/serversku.yaml#/provider'
|
||||
- $ref: '../parameters/serversku.yaml#/memory_size_mb'
|
||||
- $ref: '../parameters/serversku.yaml#/usable'
|
||||
- $ref: "../parameters/common.yaml#/limit"
|
||||
- $ref: "../parameters/common.yaml#/offset"
|
||||
- $ref: "../parameters/common.yaml#/cloud_env"
|
||||
- $ref: "../parameters/common.yaml#/cloudregion"
|
||||
- $ref: "../parameters/common.yaml#/zone"
|
||||
- $ref: "../parameters/common.yaml#/city"
|
||||
- $ref: "../parameters/serversku.yaml#/provider"
|
||||
- $ref: "../parameters/serversku.yaml#/memory_size_mb"
|
||||
- $ref: "../parameters/serversku.yaml#/usable"
|
||||
responses:
|
||||
200:
|
||||
description: 实例套餐列表信息
|
||||
@@ -24,12 +24,12 @@ post:
|
||||
name: serversku
|
||||
required: true
|
||||
schema:
|
||||
$ref: '../schemas/serversku.yaml#/ServerSkuCreate'
|
||||
$ref: "../schemas/serversku.yaml#/ServerSkuCreate"
|
||||
responses:
|
||||
200:
|
||||
description: 新创建的实例套餐信息
|
||||
schema:
|
||||
$ref: "../schemas/serversku.yaml#ServerSkuResponse"
|
||||
$ref: "../schemas/serversku.yaml#/ServerSkuResponse"
|
||||
|
||||
tags:
|
||||
- serverskus
|
||||
|
||||
14
docs/storagecache/cache-image.yaml
Normal file
14
docs/storagecache/cache-image.yaml
Normal file
@@ -0,0 +1,14 @@
|
||||
post:
|
||||
summary: 缓存镜像到此存储缓存上
|
||||
parameters:
|
||||
- $ref: "../parameters/storagecache.yaml#/storagecacheId"
|
||||
- $ref: "../parameters/storagecache.yaml#/image"
|
||||
- $ref: "../parameters/storagecache.yaml#/is_force"
|
||||
- $ref: "../parameters/storagecache.yaml#/format"
|
||||
responses:
|
||||
200:
|
||||
description: 存储缓存信息
|
||||
schema:
|
||||
$ref: "../schemas/storagecache.yaml#/StorageCacheResponse"
|
||||
tags:
|
||||
- storagecaches
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/apis"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
const (
|
||||
|
||||
@@ -16,25 +16,81 @@ package compute
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_STATUS_RUNNING = "running" //(正常)
|
||||
ELASTIC_CACHE_STATUS_RESTARTING = "restarting" //(重启中)
|
||||
ELASTIC_CACHE_STATUS_RESTART_FAILED = "restart_failed" //(重启失败)
|
||||
ELASTIC_CACHE_STATUS_DEPLOYING = "deploying" //(创建中)
|
||||
ELASTIC_CACHE_STATUS_CREATE_FAILED = "create_failed" //(创建失败)
|
||||
ELASTIC_CACHE_STATUS_CHANGING = "changing" //(修改中)
|
||||
ELASTIC_CACHE_STATUS_CHANGE_FAILED = "change_failed" //(修改失败)
|
||||
ELASTIC_CACHE_STATUS_INACTIVE = "inactive" //(被禁用)
|
||||
ELASTIC_CACHE_STATUS_FLUSHING = "flushing" //(清除中)
|
||||
ELASTIC_CACHE_STATUS_RELEASED = "released" //(已释放)
|
||||
ELASTIC_CACHE_STATUS_RELEASE_FAILED = "release_failed" //(释放失败)
|
||||
ELASTIC_CACHE_STATUS_TRANSFORMING = "transforming" //(转换中)
|
||||
ELASTIC_CACHE_STATUS_UNAVAILABLE = "unavailable" //(服务停止)
|
||||
ELASTIC_CACHE_STATUS_ERROR = "error" //(创建失败)
|
||||
ELASTIC_CACHE_STATUS_ERROR = "error" //(删除失败)
|
||||
ELASTIC_CACHE_STATUS_MIGRATING = "migrating" //(迁移中)
|
||||
ELASTIC_CACHE_STATUS_BACKUPRECOVERING = "backuprecovering" //(备份恢复中)
|
||||
ELASTIC_CACHE_STATUS_MINORVERSIONUPGRADING = "minorversionupgrading" //(小版本升级中)
|
||||
ELASTIC_CACHE_STATUS_NETWORKMODIFYING = "networkmodifying" //(网络变更中)
|
||||
ELASTIC_CACHE_STATUS_SSLMODIFYING = "sslmodifying" //(SSL变更中)
|
||||
ELASTIC_CACHE_STATUS_MAJORVERSIONUPGRADING = "majorversionupgrading" //(大版本升级中,可正常访问)
|
||||
ELASTIC_CACHE_STATUS_UNKNOWN = "unknown" //(未知状态)
|
||||
ELASTIC_CACHE_STATUS_SYNCING = "syncing" //(同步中)
|
||||
ELASTIC_CACHE_STATUS_SYNC_FAILED = "sync_failed" //(同步失败)
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_ARCH_TYPE_STAND_ALONE = "standalone" //
|
||||
ELASTIC_CACHE_ARCH_TYPE_MASTER_SLAVE = "master_slave" //
|
||||
ELASTIC_CACHE_ARCH_TYPE_CLUSTER = "cluster" // 集群
|
||||
ELASTIC_CACHE_ARCH_TYPE_PROXY = "proxy" // 代理集群
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_AVAILABLE = "available" // 正常可用
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_UNAVAILABLE = "unavailable" // 不可用
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_CREATING = "creating" // 创建中
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_CREATE_FAILED = "create_failed" //(创建失败)
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_DELETING = "deleting" // 删除中
|
||||
ELASTIC_CACHE_ACCOUNT_STATUS_DELETE_FAILED = "delete_failed" // 删除失败
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_ACCOUNT_TYPE_NORMAL = "normal" // 普通账号
|
||||
ELASTIC_CACHE_ACCOUNT_TYPE_ADMIN = "admin" // 管理账号
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_ACCOUNT_PRIVILEGE_READ = "read" // 只读
|
||||
ELASTIC_CACHE_ACCOUNT_PRIVILEGE_WRITE = "write" // 读写
|
||||
ELASTIC_CACHE_ACCOUNT_PRIVILEGE_REPL = "repl" // 复制,复制权限支持读写,且支持使用SYNC/PSYNC命令。
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_BACKUP_STATUS_CREATING = "creating" // 备份中
|
||||
ELASTIC_CACHE_BACKUP_STATUS_CREATE_EXPIRED = "expired" //(备份文件已过期)
|
||||
ELASTIC_CACHE_BACKUP_STATUS_CREATE_DELETED = "deleted" //(备份文件已删除)
|
||||
ELASTIC_CACHE_BACKUP_STATUS_DELETING = "deleting" // 删除中
|
||||
ELASTIC_CACHE_BACKUP_STATUS_SUCCESS = "success" // 备份成功
|
||||
ELASTIC_CACHE_BACKUP_STATUS_FAILED = "failed" // 备份失败
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_BACKUP_TYPE_FULL = "full" // 全量备份
|
||||
ELASTIC_CACHE_BACKUP_TYPE_INCREMENTAL = "incremental" // 增量备份
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_BACKUP_MODE_AUTOMATED = "automated" // 自动备份
|
||||
ELASTIC_CACHE_BACKUP_MODE_MANUAL = "manual" // 手动触发备份
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_ACL_STATUS_AVAILABLE = "available" // 正常可用
|
||||
ELASTIC_CACHE_ACL_STATUS_CREATING = "creating" // 创建中
|
||||
ELASTIC_CACHE_ACL_STATUS_CREATE_FAILED = "create_failed" //(创建失败)
|
||||
ELASTIC_CACHE_ACL_STATUS_DELETING = "deleting" // 删除中
|
||||
ELASTIC_CACHE_ACL_STATUS_DELETE_FAILED = "delete_failed" // 删除失败
|
||||
ELASTIC_CACHE_ACL_STATUS_UPDATING = "updating" // 更新中
|
||||
ELASTIC_CACHE_ACL_STATUS_UPDATE_FAILED = "update_failed" // 更新失败
|
||||
)
|
||||
|
||||
const (
|
||||
ELASTIC_CACHE_PARAMETER_STATUS_AVAILABLE = "available" // 正常可用
|
||||
ELASTIC_CACHE_PARAMETER_STATUS_UPDATING = "updating" // 更新中
|
||||
ELASTIC_CACHE_PARAMETER_STATUS_UPDATE_FAILED = "update_failed" // 更新失败
|
||||
)
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 compute
|
||||
|
||||
import (
|
||||
|
||||
@@ -65,6 +65,9 @@ const (
|
||||
ACT_BACKUP_START = "backup_start"
|
||||
ACT_BACKUP_START_FAILED = "backup_start_fail"
|
||||
|
||||
ACT_RESTARING = "restarting"
|
||||
ACT_RESTART_FAIL = "restart_fail"
|
||||
|
||||
ACT_STOPPING = "stopping"
|
||||
ACT_STOP = "stop"
|
||||
ACT_STOP_FAIL = "stop_fail"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 models
|
||||
|
||||
type (
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 models
|
||||
|
||||
import (
|
||||
|
||||
@@ -1 +1,15 @@
|
||||
// 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 utils // import "yunion.io/x/onecloud/pkg/cloudnet/utils"
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 utils
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 utils
|
||||
|
||||
import (
|
||||
|
||||
70
pkg/cloudprovider/elasticcache.go
Normal file
70
pkg/cloudprovider/elasticcache.go
Normal file
@@ -0,0 +1,70 @@
|
||||
// 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 cloudprovider
|
||||
|
||||
import "yunion.io/x/onecloud/pkg/util/billing"
|
||||
|
||||
// https://support.huaweicloud.com/api-dcs/dcs-zh-api-180423019.html
|
||||
// https://help.aliyun.com/document_detail/60873.html?spm=a2c4g.11174283.6.715.7412dce0qSYemb
|
||||
type SCloudElasticCacheInput struct {
|
||||
RegionId string // 地域
|
||||
InstanceType string // 实例规格 redis.master.small.default
|
||||
CapacityGB int64 // 缓存容量 华为云此项参数必选
|
||||
InstanceName string // 实例名称
|
||||
UserName string // redis 用户名,可选
|
||||
Password string // redis 用户密码,可选
|
||||
ZoneIds []string // 可用区, 可选
|
||||
ChargeType string // 计费类型,可选
|
||||
NodeType string // 节点类型,可选
|
||||
NetworkType string // 网络类型 VPC|CLASSIC,可选
|
||||
VpcId string // VPC ,可选
|
||||
NetworkId string // 子网ID,可选
|
||||
Engine string // Redis|Memcache
|
||||
EngineVersion string // 版本类型
|
||||
PrivateIpAddress string // 指定新实例的内网IP地址。
|
||||
SecurityGroupId string // 安全组ID
|
||||
EipId string // 绑定弹性IP
|
||||
MaintainBegin string // 维护时间窗开始时间,格式为HH:mm:ss
|
||||
MaintainEnd string // 维护时间窗结束时间,格式为HH:mm:ss
|
||||
BC *billing.SBillingCycle // 包年包月
|
||||
}
|
||||
|
||||
type SCloudElasticCacheAccountInput struct {
|
||||
AccountName string // 账号名称
|
||||
AccountPassword string // 账号密码
|
||||
AccountPrivilege string // 账号权限
|
||||
Description string // 账号描述
|
||||
}
|
||||
|
||||
type SCloudElasticCacheAccountResetPasswordInput struct {
|
||||
NoPasswordAccess *bool // 免密码访问
|
||||
NewPassword string // 新密码
|
||||
OldPassword *string // 旧密码。required by huawei
|
||||
}
|
||||
|
||||
type SCloudElasticCacheAccountUpdateInput struct {
|
||||
NoPasswordAccess *bool // 免密码访问
|
||||
Password *string // 新密码
|
||||
OldPassword *string // 旧密码。required by huawei
|
||||
AccountPrivilege *string
|
||||
Description *string
|
||||
}
|
||||
|
||||
type SCloudElasticCacheBackupPolicyUpdateInput struct {
|
||||
BackupType string // auto:自动备份 / manual:手动备份
|
||||
BackupReservedDays int // 1-7
|
||||
PreferredBackupPeriod string // Monday(周一) / Tuesday(周二) / Wednesday(周三) / Thursday(周四) / Friday(周五) / Saturday(周六) / Sunday(周日)
|
||||
PreferredBackupTime string // 备份时间,格式:HH:mmZ-HH:mmZ
|
||||
}
|
||||
@@ -128,6 +128,8 @@ type ICloudRegion interface {
|
||||
CreateIDBInstance(desc *SManagedDBInstanceCreateConfig) (ICloudDBInstance, error)
|
||||
|
||||
GetIElasticcaches() ([]ICloudElasticcache, error)
|
||||
GetIElasticcacheById(id string) (ICloudElasticcache, error)
|
||||
CreateIElasticcaches(ec *SCloudElasticCacheInput) (ICloudElasticcache, error)
|
||||
|
||||
GetProvider() string
|
||||
}
|
||||
@@ -839,10 +841,31 @@ type ICloudElasticcache interface {
|
||||
GetMaintainStartTime() string
|
||||
GetMaintainEndTime() string
|
||||
|
||||
GetAuthMode() string
|
||||
|
||||
GetICloudElasticcacheAccounts() ([]ICloudElasticcacheAccount, error)
|
||||
GetICloudElasticcacheAcls() ([]ICloudElasticcacheAcl, error)
|
||||
GetICloudElasticcacheBackups() ([]ICloudElasticcacheBackup, error)
|
||||
GetICloudElasticcacheParameters() ([]ICloudElasticcacheParameter, error)
|
||||
|
||||
GetICloudElasticcacheAccount(accountId string) (ICloudElasticcacheAccount, error)
|
||||
GetICloudElasticcacheAcl(aclId string) (ICloudElasticcacheAcl, error)
|
||||
GetICloudElasticcacheBackup(backupId string) (ICloudElasticcacheBackup, error)
|
||||
|
||||
Restart() error
|
||||
Delete() error
|
||||
ChangeInstanceSpec(spec string) error
|
||||
SetMaintainTime(maintainStartTime, maintainEndTime string) error
|
||||
AllocatePublicConnection(port int) (string, error) // return url & error info
|
||||
ReleasePublicConnection() error
|
||||
|
||||
CreateAccount(account SCloudElasticCacheAccountInput) (ICloudElasticcacheAccount, error)
|
||||
CreateAcl(aclName, securityIps string) (ICloudElasticcacheAcl, error)
|
||||
CreateBackup() (ICloudElasticcacheBackup, error)
|
||||
FlushInstance() error
|
||||
UpdateAuthMode(noPasswordAccess bool) error
|
||||
UpdateInstanceParameters(config jsonutils.JSONObject) error
|
||||
UpdateBackupPolicy(config SCloudElasticCacheBackupPolicyUpdateInput) error
|
||||
}
|
||||
|
||||
type ICloudElasticcacheAccount interface {
|
||||
@@ -850,12 +873,19 @@ type ICloudElasticcacheAccount interface {
|
||||
|
||||
GetAccountType() string
|
||||
GetAccountPrivilege() string
|
||||
|
||||
Delete() error
|
||||
ResetPassword(input SCloudElasticCacheAccountResetPasswordInput) error
|
||||
UpdateAccount(input SCloudElasticCacheAccountUpdateInput) error
|
||||
}
|
||||
|
||||
type ICloudElasticcacheAcl interface {
|
||||
ICloudResource
|
||||
|
||||
GetIpList() string
|
||||
|
||||
Delete() error
|
||||
UpdateAcl(securityIps string) error
|
||||
}
|
||||
|
||||
type ICloudElasticcacheBackup interface {
|
||||
@@ -868,6 +898,9 @@ type ICloudElasticcacheBackup interface {
|
||||
|
||||
GetStartTime() time.Time
|
||||
GetEndTime() time.Time
|
||||
|
||||
Delete() error
|
||||
RestoreInstance(instanceId string) error
|
||||
}
|
||||
|
||||
type ICloudElasticcacheParameter interface {
|
||||
|
||||
@@ -126,6 +126,8 @@ func syncRegionSkus(ctx context.Context, localRegion *SCloudregion) {
|
||||
if err != nil {
|
||||
log.Errorf("SchedManager SyncSku %s", err)
|
||||
}
|
||||
|
||||
syncElasticCacheSkusByRegion(localRegion)
|
||||
}
|
||||
|
||||
func syncProjects(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, driver cloudprovider.ICloudProvider, provider *SCloudprovider) {
|
||||
|
||||
@@ -1,3 +1,17 @@
|
||||
// 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 models
|
||||
|
||||
import (
|
||||
|
||||
@@ -16,14 +16,24 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"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/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/choices"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
|
||||
// SElasticcache.Account
|
||||
@@ -51,8 +61,9 @@ type SElasticcacheAccount struct {
|
||||
|
||||
ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
AccountType string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"` // 账号类型 normal |admin
|
||||
AccountPrivilege string `width:"16" charset:"ascii" nullable:"true" list:"user" update:"user" create:"optional"` // 账号权限 read | write
|
||||
AccountType string `width:"16" charset:"ascii" nullable:"false" list:"user" update:"user" create:"optional"` // 账号类型 normal |admin
|
||||
AccountPrivilege string `width:"16" charset:"ascii" nullable:"false" list:"user" update:"user" create:"optional"` // 账号权限 read | write | repl(复制, 复制权限支持读写,且开放SYNC/PSYNC命令)
|
||||
Password string `width:"256" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 账号密码
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAccountManager) SyncElasticcacheAccounts(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, cloudElasticcacheAccounts []cloudprovider.ICloudElasticcacheAccount) compare.SyncResult {
|
||||
@@ -133,6 +144,15 @@ func (self *SElasticcacheAccount) SyncWithCloudElasticcacheAccount(ctx context.C
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetRegion() *SCloudregion {
|
||||
iec, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return iec.(*SElasticcache).GetRegion()
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAccountManager) newFromCloudElasticcacheAccount(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, extAccount cloudprovider.ICloudElasticcacheAccount) (*SElasticcacheAccount, error) {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, userCred))
|
||||
@@ -154,3 +174,222 @@ func (manager *SElasticcacheAccountManager) newFromCloudElasticcacheAccount(ctx
|
||||
|
||||
return &account, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAccountManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowCreate(userCred, manager)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAccountManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
var region *SCloudregion
|
||||
if id, _ := data.GetString("elasticcache"); len(id) > 0 {
|
||||
ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting elastic cache instance failed")
|
||||
}
|
||||
region = ec.(*SElasticcache).GetRegion()
|
||||
} else {
|
||||
return nil, httperrors.NewMissingParameterError("elasticcache_id")
|
||||
}
|
||||
|
||||
data, err := manager.SStatusStandaloneResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return region.GetDriver().ValidateCreateElasticcacheAccountData(ctx, userCred, ownerId, data)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SStatusStandaloneResourceBase.PostCreate(ctx, userCred, ownerId, query, data)
|
||||
if len(self.Password) > 0 {
|
||||
self.SavePassword(self.Password)
|
||||
}
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_ACCOUNT_STATUS_CREATING, "")
|
||||
if err := self.StartElasticcacheAccountCreateTask(ctx, userCred, data.(*jsonutils.JSONDict), ""); err != nil {
|
||||
log.Errorf("Failed to create elastic account cache error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) StartElasticcacheAccountCreateTask(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAccountCreateTask", self, userCred, jsonutils.NewDict(), parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetCreateAliyunElasticcacheAccountParams() (cloudprovider.SCloudElasticCacheAccountInput, error) {
|
||||
ret := cloudprovider.SCloudElasticCacheAccountInput{}
|
||||
ret.AccountName = self.Name
|
||||
ret.Description = self.Description
|
||||
passwd, err := self.GetDecodedPassword()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
ret.AccountPassword = passwd
|
||||
|
||||
switch self.AccountPrivilege {
|
||||
case "read":
|
||||
ret.AccountPrivilege = "RoleReadOnly"
|
||||
case "write":
|
||||
ret.AccountPrivilege = "RoleReadWrite"
|
||||
case "repl":
|
||||
ret.AccountPrivilege = "RoleRepl"
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetUpdateAliyunElasticcacheAccountParams(data jsonutils.JSONDict) (cloudprovider.SCloudElasticCacheAccountUpdateInput, error) {
|
||||
ret := cloudprovider.SCloudElasticCacheAccountUpdateInput{}
|
||||
|
||||
if desc, _ := data.GetString("description"); len(desc) > 0 {
|
||||
ret.Description = &desc
|
||||
}
|
||||
|
||||
if password, _ := data.GetString("password"); len(password) > 0 {
|
||||
ret.Password = &password
|
||||
}
|
||||
|
||||
if ok := data.Contains("no_password_access"); ok {
|
||||
passwordAccess, _ := data.Bool("no_password_access")
|
||||
ret.NoPasswordAccess = &passwordAccess
|
||||
}
|
||||
|
||||
if privilege, _ := data.GetString("account_privilege"); len(privilege) > 0 {
|
||||
var p string
|
||||
switch privilege {
|
||||
case "read":
|
||||
p = "RoleReadOnly"
|
||||
case "write":
|
||||
p = "RoleReadWrite"
|
||||
case "repl":
|
||||
p = "RoleRepl"
|
||||
default:
|
||||
return ret, fmt.Errorf("ElasticcacheAccount.GetUpdateAliyunElasticcacheAccountParams invalid account_privilege %s", privilege)
|
||||
}
|
||||
|
||||
ret.AccountPrivilege = &p
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetUpdateHuaweiElasticcacheAccountParams(data jsonutils.JSONDict) (cloudprovider.SCloudElasticCacheAccountUpdateInput, error) {
|
||||
ret := cloudprovider.SCloudElasticCacheAccountUpdateInput{}
|
||||
|
||||
if desc, _ := data.GetString("description"); len(desc) > 0 {
|
||||
ret.Description = &desc
|
||||
}
|
||||
|
||||
if password, _ := data.GetString("password"); len(password) > 0 {
|
||||
ret.Password = &password
|
||||
oldpasswd, err := self.GetDecodedPassword()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
ret.OldPassword = &oldpasswd
|
||||
}
|
||||
|
||||
if ok := data.Contains("no_password_access"); ok {
|
||||
passwordAccess, _ := data.Bool("no_password_access")
|
||||
ret.NoPasswordAccess = &passwordAccess
|
||||
}
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) SavePassword(passwd string) error {
|
||||
passwd, err := utils.EncryptAESBase64(self.Id, passwd)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = db.Update(self, func() error {
|
||||
self.Password = passwd
|
||||
return nil
|
||||
})
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetDecodedPassword() (string, error) {
|
||||
return utils.DescryptAESBase64(self.Id, self.Password)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_ACCOUNT_STATUS_DELETING, "")
|
||||
return self.StartDeleteElasticcacheAccountTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) StartDeleteElasticcacheAccountTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAccountDeleteTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
_ec, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ec := _ec.(*SElasticcache)
|
||||
provider, err := ec.GetDriver()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("No cloudprovider for elastic cache %s: %s", ec.Name, err)
|
||||
}
|
||||
region := self.GetRegion()
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("failed to find region for elastic cache %s", self.Name)
|
||||
}
|
||||
return provider.GetIRegionById(region.ExternalId)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) AllowPerformResetPassword(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowPerform(userCred, self, "reset_password")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) ValidatorResetPasswordData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
passwd, err := data.GetString("password")
|
||||
if err == nil && !seclib2.MeetComplxity(passwd) {
|
||||
return nil, httperrors.NewWeakPasswordError()
|
||||
}
|
||||
|
||||
privilegeV := validators.NewStringChoicesValidator("account_privilege", choices.NewChoices(api.ELASTIC_CACHE_ACCOUNT_PRIVILEGE_READ, api.ELASTIC_CACHE_ACCOUNT_PRIVILEGE_WRITE, api.ELASTIC_CACHE_ACCOUNT_PRIVILEGE_REPL)).Optional(true)
|
||||
if err := privilegeV.Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) PerformResetPassword(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
data, err := self.ValidatorResetPasswordData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, self.StartResetPasswordTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAccount) StartResetPasswordTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAccountResetPasswordTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,13 +16,21 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"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/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -46,7 +54,7 @@ func init() {
|
||||
}
|
||||
|
||||
type SElasticcacheAcl struct {
|
||||
db.SStandaloneResourceBase
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
@@ -120,7 +128,7 @@ func (self *SElasticcacheAcl) syncRemoveCloudElasticcacheAcl(ctx context.Context
|
||||
func (self *SElasticcacheAcl) SyncWithCloudElasticcacheAcl(ctx context.Context, userCred mcclient.TokenCredential, extAcl cloudprovider.ICloudElasticcacheAcl) error {
|
||||
_, err := db.UpdateWithLock(ctx, self, func() error {
|
||||
self.IpList = extAcl.GetIpList()
|
||||
|
||||
self.Status = extAcl.GetStatus()
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -138,6 +146,7 @@ func (manager *SElasticcacheAclManager) newFromCloudElasticcacheAcl(ctx context.
|
||||
acl.SetModelManager(manager, &acl)
|
||||
|
||||
acl.ElasticcacheId = elasticcache.GetId()
|
||||
acl.Status = extAcl.GetStatus()
|
||||
acl.Name = extAcl.GetName()
|
||||
acl.ExternalId = extAcl.GetGlobalId()
|
||||
acl.IpList = extAcl.GetIpList()
|
||||
@@ -149,3 +158,139 @@ func (manager *SElasticcacheAclManager) newFromCloudElasticcacheAcl(ctx context.
|
||||
|
||||
return &acl, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAclManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowCreate(userCred, manager)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheAclManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
var region *SCloudregion
|
||||
if id, _ := data.GetString("elasticcache"); len(id) > 0 {
|
||||
ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting elastic cache instance failed")
|
||||
}
|
||||
region = ec.(*SElasticcache).GetRegion()
|
||||
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("getting elastic cache region failed")
|
||||
}
|
||||
} else {
|
||||
return nil, httperrors.NewMissingParameterError("elasticcache")
|
||||
}
|
||||
|
||||
data, err := manager.SStandaloneResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return region.GetDriver().ValidateCreateElasticcacheAclData(ctx, userCred, ownerId, data)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SStandaloneResourceBase.PostCreate(ctx, userCred, ownerId, query, data)
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_ACL_STATUS_CREATING, "")
|
||||
if err := self.StartElasticcacheAclCreateTask(ctx, userCred, data.(*jsonutils.JSONDict), ""); err != nil {
|
||||
log.Errorf("Failed to create elastic cache acl error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) StartElasticcacheAclCreateTask(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAclCreateTask", self, userCred, jsonutils.NewDict(), parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
_ec, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ec := _ec.(*SElasticcache)
|
||||
provider, err := ec.GetDriver()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("No cloudprovider for elastic cache %s: %s", ec.Name, err)
|
||||
}
|
||||
region := ec.GetRegion()
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("failed to find region for elastic cache %s", self.Name)
|
||||
}
|
||||
return provider.GetIRegionById(region.ExternalId)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) GetRegion() *SCloudregion {
|
||||
ieb, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ieb.(*SElasticcache).GetRegion()
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) AllowUpdateItem(ctx context.Context, userCred mcclient.TokenCredential) bool {
|
||||
// todo: fix me self.IsOwner(userCred) ||
|
||||
return db.IsAdminAllowUpdate(userCred, self)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
ips, err := data.GetString("ip_list")
|
||||
if err != nil || ips == "" {
|
||||
return nil, httperrors.NewMissingParameterError("ip_list")
|
||||
}
|
||||
|
||||
ipV := validators.NewIPv4AddrValidator("ip")
|
||||
_ips := strings.Split(ips, ",")
|
||||
for _, ip := range _ips {
|
||||
params := jsonutils.NewDict()
|
||||
params.Set("ip", jsonutils.NewString(ip))
|
||||
if err := ipV.Validate(params); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_ACL_STATUS_UPDATING, "")
|
||||
if err := self.StartUpdateElasticcacheAclTask(ctx, userCred, data.(*jsonutils.JSONDict), ""); err != nil {
|
||||
log.Errorf("ElasticcacheAcl %s", err.Error())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) StartUpdateElasticcacheAclTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAclUpdateTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) ValidateDeleteCondition(ctx context.Context) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_ACL_STATUS_DELETING, "")
|
||||
return self.StartDeleteElasticcacheAclTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) StartDeleteElasticcacheAclTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAclDeleteTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheAcl) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,14 +16,20 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"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/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -52,13 +58,13 @@ type SElasticcacheBackup struct {
|
||||
|
||||
ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
|
||||
BackupSizeMb int `nullable:"false" list:"user"`
|
||||
BackupType string `width:"32" charset:"ascii" nullable:"true" list:"user"` // 全量|增量额
|
||||
BackupMode string `width:"32" charset:"ascii" nullable:"true" list:"user"` // 自动|手动
|
||||
DownloadURL string `width:"512" charset:"ascii" nullable:"true" list:"user"`
|
||||
BackupSizeMb int `nullable:"false" list:"user" create:"optional"`
|
||||
BackupType string `width:"32" charset:"ascii" nullable:"true" create:"optional" list:"user"` // 全量|增量额
|
||||
BackupMode string `width:"32" charset:"ascii" nullable:"true" create:"optional" list:"user"` // 自动|手动
|
||||
DownloadURL string `width:"512" charset:"ascii" nullable:"true" create:"optional" list:"user"`
|
||||
|
||||
StartTime time.Time `list:"user"`
|
||||
EndTime time.Time `list:"user"`
|
||||
StartTime time.Time `list:"user" create:"optional"`
|
||||
EndTime time.Time `list:"user" create:"optional"`
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheBackupManager) SyncElasticcacheBackups(ctx context.Context, userCred mcclient.TokenCredential, elasticcache *SElasticcache, cloudElasticcacheBackups []cloudprovider.ICloudElasticcacheBackup) compare.SyncResult {
|
||||
@@ -113,6 +119,26 @@ func (manager *SElasticcacheBackupManager) SyncElasticcacheBackups(ctx context.C
|
||||
return syncResult
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) GetCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
extra := self.SStatusStandaloneResourceBase.GetCustomizeColumns(ctx, userCred, query)
|
||||
icache, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err == nil {
|
||||
ec := icache.(*SElasticcache)
|
||||
provider := ec.GetCloudprovider()
|
||||
region := ec.GetRegion()
|
||||
zone := ec.GetZone()
|
||||
info := MakeCloudProviderInfo(region, zone, provider)
|
||||
extra.Update(jsonutils.Marshal(&info))
|
||||
|
||||
info2 := jsonutils.NewDict()
|
||||
info2.Set("engine", jsonutils.NewString(ec.Engine))
|
||||
info2.Set("engine_version", jsonutils.NewString(ec.EngineVersion))
|
||||
extra.Update(info2)
|
||||
}
|
||||
|
||||
return extra
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) syncRemoveCloudElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, self)
|
||||
defer lockman.ReleaseObject(ctx, self)
|
||||
@@ -127,9 +153,15 @@ func (self *SElasticcacheBackup) syncRemoveCloudElasticcacheBackup(ctx context.C
|
||||
func (self *SElasticcacheBackup) SyncWithCloudElasticcacheBackup(ctx context.Context, userCred mcclient.TokenCredential, extBackup cloudprovider.ICloudElasticcacheBackup) error {
|
||||
_, err := db.UpdateWithLock(ctx, self, func() error {
|
||||
self.Status = extBackup.GetStatus()
|
||||
|
||||
self.BackupSizeMb = extBackup.GetBackupSizeMb()
|
||||
self.BackupType = extBackup.GetBackupType()
|
||||
self.BackupMode = extBackup.GetBackupMode()
|
||||
self.DownloadURL = extBackup.GetDownloadURL()
|
||||
|
||||
self.StartTime = extBackup.GetStartTime()
|
||||
self.EndTime = extBackup.GetEndTime()
|
||||
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@@ -166,3 +198,121 @@ func (manager *SElasticcacheBackupManager) newFromCloudElasticcacheBackup(ctx co
|
||||
|
||||
return &backup, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheBackupManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowCreate(userCred, manager)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheBackupManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
var region *SCloudregion
|
||||
if id, _ := data.GetString("elasticcache"); len(id) > 0 {
|
||||
ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, id)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting elastic cache instance failed")
|
||||
}
|
||||
region = ec.(*SElasticcache).GetRegion()
|
||||
} else {
|
||||
return nil, httperrors.NewMissingParameterError("elasticcache")
|
||||
}
|
||||
|
||||
data, err := manager.SStandaloneResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return region.GetDriver().ValidateCreateElasticcacheBackupData(ctx, userCred, ownerId, data)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SStandaloneResourceBase.PostCreate(ctx, userCred, ownerId, query, data)
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_BACKUP_STATUS_CREATING, "")
|
||||
if err := self.StartElasticcacheBackupCreateTask(ctx, userCred, data.(*jsonutils.JSONDict), ""); err != nil {
|
||||
log.Errorf("Failed to create elastic cache backup error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) StartElasticcacheBackupCreateTask(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheBackupCreateTask", self, userCred, jsonutils.NewDict(), parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
_eb, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
eb := _eb.(*SElasticcache)
|
||||
provider, err := eb.GetDriver()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("No cloudprovider for elastic cache %s: %s", eb.Name, err)
|
||||
}
|
||||
region := eb.GetRegion()
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("failed to find region for elastic cache %s", self.Name)
|
||||
}
|
||||
return provider.GetIRegionById(region.ExternalId)
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) AllowPerformRestoreInstance(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
// todo : fix me self.IsOwner(userCred) ||
|
||||
return db.IsAdminAllowPerform(userCred, self, "restore_instance")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) ValidatorRestoreInstanceData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
ec, err := db.FetchByIdOrName(ElasticcacheManager, userCred, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting elastic cache instance failed")
|
||||
}
|
||||
|
||||
if ec.(*SElasticcache).Status != api.ELASTIC_CACHE_STATUS_RUNNING {
|
||||
return nil, httperrors.NewConflictError("can't restore elastic cache in status %s", ec.(*SElasticcache).Status)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) PerformRestoreInstance(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorRestoreInstanceData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, self.StartRestoreInstanceTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) StartRestoreInstanceTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheBackupRestoreInstanceTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) GetRegion() *SCloudregion {
|
||||
ieb, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ieb.(*SElasticcache).GetRegion()
|
||||
}
|
||||
|
||||
func (self *SElasticcacheBackup) ValidateDeleteCondition(ctx context.Context) error {
|
||||
icache, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if icache.(*SElasticcache).GetProviderName() == api.CLOUD_PROVIDER_ALIYUN && len(self.ExternalId) == 0 {
|
||||
return httperrors.NewUnsupportOperationError("unsupport delete %s backups", api.CLOUD_PROVIDER_ALIYUN)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,16 +16,29 @@ package models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis/billing"
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"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/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
bc "yunion.io/x/onecloud/pkg/util/billing"
|
||||
"yunion.io/x/onecloud/pkg/util/choices"
|
||||
"yunion.io/x/onecloud/pkg/util/seclib2"
|
||||
)
|
||||
|
||||
type SElasticcacheManager struct {
|
||||
@@ -53,18 +66,20 @@ type SElasticcache struct {
|
||||
SManagedResourceBase
|
||||
|
||||
SCloudregionResourceBase
|
||||
SZoneResourceBase
|
||||
SZoneResourceBase // 主可用区.
|
||||
SlaveZones string `width:"128" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 备可用区
|
||||
|
||||
InstanceType string `width:"64" charset:"ascii" nullable:"true" list:"user" create:"optional"` // redis.master.micro.default
|
||||
CapacityMB int `nullable:"true" list:"user" create:"optional"` // 1024
|
||||
ArchType string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"optional"` // 集群版 | 标准版 | 读写分离版 | 单机 ?
|
||||
NodeType string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"optional"` // STAND_ALONE(单节点) MASTER_SLAVE(多节点) ?
|
||||
InstanceType string `width:"96" charset:"ascii" nullable:"true" list:"user" create:"optional"` // redis.master.micro.default
|
||||
CapacityMB int `nullable:"false" list:"user" create:"optional"` // 1024
|
||||
LocalCategory string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 对应Sku local_category
|
||||
NodeType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` // single(单副本) | double(双副本) | readone (单可读) | readthree (3可读) | readfive(5只读)
|
||||
Engine string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required"` // Redis | Memcache
|
||||
EngineVersion string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"required"` // 4.0 5.0
|
||||
|
||||
VpcId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
NetworkType string `width:"16" charset:"ascii" nullable:"true" list:"user" create:"optional"` // CLASSIC(经典网络) VPC(专有网络)
|
||||
NetworkId string `width:"36" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
VpcId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
NetworkType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"optional"` // CLASSIC(经典网络) VPC(专有网络)
|
||||
NetworkId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
SecurityGroupId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"optional"`
|
||||
|
||||
PrivateDNS string `width:"256" charset:"ascii" nullable:"true" list:"user" create:"optional"` // 内网DNS
|
||||
PrivateIpAddr string `width:"17" charset:"ascii" list:"user" create:"optional"` // 内网IP地址
|
||||
@@ -76,12 +91,33 @@ type SElasticcache struct {
|
||||
MaintainStartTime string `width:"8" charset:"ascii" nullable:"true" list:"user" create:"optional"` // HH:mmZ eg. 02:00Z
|
||||
MaintainEndTime string `width:"8" charset:"ascii" nullable:"true" list:"user" create:"optional"`
|
||||
|
||||
AuthMode string `width:"8" charset:"ascii" nullable:"false" list:"user" create:"optional"` // 访问密码? on (开启密码)|off (免密码访问)
|
||||
// AutoRenew // 自动续费
|
||||
// AutoRenewPeriod // 自动续费周期
|
||||
}
|
||||
|
||||
func (self *SElasticcache) getCloudProviderInfo() SCloudProviderInfo {
|
||||
region := self.GetRegion()
|
||||
provider := self.GetCloudprovider()
|
||||
zone := self.GetZone()
|
||||
return MakeCloudProviderInfo(region, zone, provider)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetExtraDetails(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*jsonutils.JSONDict, error) {
|
||||
extra, err := self.SStatusStandaloneResourceBase.GetExtraDetails(ctx, userCred, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
info := self.getCloudProviderInfo()
|
||||
extra.Update(jsonutils.Marshal(&info))
|
||||
return extra, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
extra := self.SStatusStandaloneResourceBase.GetCustomizeColumns(ctx, userCred, query)
|
||||
info := self.getCloudProviderInfo()
|
||||
extra.Update(jsonutils.Marshal(&info))
|
||||
return extra
|
||||
}
|
||||
|
||||
@@ -125,6 +161,48 @@ func (self *SElasticcache) GetElasticcacheBackups() ([]SElasticcacheBackup, erro
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowGetDetailsLoginInfo(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowGetSpec(userCred, self, "login-info")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetDetailsLoginInfo(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
account, err := self.GetAdminAccount()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
password, err := account.GetDecodedPassword()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ret := jsonutils.NewDict()
|
||||
ret.Add(jsonutils.NewString(account.Name), "username")
|
||||
ret.Add(jsonutils.NewString(password), "password")
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
q, err := manager.SVirtualResourceBaseManager.ListItemFilter(ctx, q, userCred, query)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
data := query.(*jsonutils.JSONDict)
|
||||
q, err = validators.ApplyModelFilters(q, data, []*validators.ModelFilterOptions{
|
||||
{Key: "vpc", ModelKeyword: "vpc", OwnerId: userCred},
|
||||
{Key: "zone", ModelKeyword: "zone", OwnerId: userCred},
|
||||
{Key: "cloudregion", ModelKeyword: "cloudregion", OwnerId: userCred},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
q, err = managedResourceFilterByAccount(q, query, "", nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return q, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheManager) SyncElasticcaches(ctx context.Context, userCred mcclient.TokenCredential, syncOwnerId mcclient.IIdentityProvider, provider *SCloudprovider, region *SCloudregion, cloudElasticcaches []cloudprovider.ICloudElasticcache) ([]SElasticcache, []cloudprovider.ICloudElasticcache, compare.SyncResult) {
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, provider.GetOwnerId()))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, provider.GetOwnerId()))
|
||||
@@ -199,7 +277,7 @@ func (self *SElasticcache) SyncWithCloudElasticcache(ctx context.Context, userCr
|
||||
self.Status = extInstance.GetStatus()
|
||||
self.InstanceType = extInstance.GetInstanceType()
|
||||
self.CapacityMB = extInstance.GetCapacityMB()
|
||||
self.ArchType = extInstance.GetArchType()
|
||||
self.LocalCategory = extInstance.GetArchType()
|
||||
self.NodeType = extInstance.GetNodeType()
|
||||
self.Engine = extInstance.GetEngine()
|
||||
self.EngineVersion = extInstance.GetEngineVersion()
|
||||
@@ -213,6 +291,7 @@ func (self *SElasticcache) SyncWithCloudElasticcache(ctx context.Context, userCr
|
||||
self.PublicConnectPort = extInstance.GetPublicConnectPort()
|
||||
self.MaintainStartTime = extInstance.GetMaintainStartTime()
|
||||
self.MaintainEndTime = extInstance.GetMaintainEndTime()
|
||||
self.AuthMode = extInstance.GetAuthMode()
|
||||
|
||||
return nil
|
||||
})
|
||||
@@ -244,7 +323,7 @@ func (manager *SElasticcacheManager) newFromCloudElasticcache(ctx context.Contex
|
||||
|
||||
instance.InstanceType = extInstance.GetInstanceType()
|
||||
instance.CapacityMB = extInstance.GetCapacityMB()
|
||||
instance.ArchType = extInstance.GetArchType()
|
||||
instance.LocalCategory = extInstance.GetArchType()
|
||||
instance.NodeType = extInstance.GetNodeType()
|
||||
instance.Engine = extInstance.GetEngine()
|
||||
instance.EngineVersion = extInstance.GetEngineVersion()
|
||||
@@ -258,6 +337,7 @@ func (manager *SElasticcacheManager) newFromCloudElasticcache(ctx context.Contex
|
||||
instance.PublicConnectPort = extInstance.GetPublicConnectPort()
|
||||
instance.MaintainStartTime = extInstance.GetMaintainStartTime()
|
||||
instance.MaintainEndTime = extInstance.GetMaintainEndTime()
|
||||
instance.AuthMode = extInstance.GetAuthMode()
|
||||
|
||||
if zoneId := extInstance.GetZoneId(); len(zoneId) > 0 {
|
||||
zone, err := db.FetchByExternalId(ZoneManager, zoneId)
|
||||
@@ -316,3 +396,738 @@ func (manager *SElasticcacheManager) getElasticcachesByProviderId(providerId str
|
||||
}
|
||||
return instances, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheManager) AllowCreateItem(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return db.IsAdminAllowCreate(userCred, manager)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheManager) ValidateCreateData(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
var region *SCloudregion
|
||||
if id, _ := data.GetString("network"); len(id) > 0 {
|
||||
network, err := db.FetchByIdOrName(NetworkManager, userCred, strings.Split(id, ",")[0])
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("getting network failed")
|
||||
}
|
||||
region = network.(*SNetwork).getRegion()
|
||||
}
|
||||
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("getting region failed")
|
||||
}
|
||||
|
||||
data, err := manager.SVirtualResourceBaseManager.ValidateCreateData(ctx, userCred, ownerId, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if reset, _ := data.Bool("reset_password"); reset {
|
||||
if _, err := data.GetString("password"); err != nil {
|
||||
randomPasswd := seclib2.RandomPassword2(12)
|
||||
data.Set("password", jsonutils.NewString(randomPasswd))
|
||||
}
|
||||
}
|
||||
|
||||
return region.GetDriver().ValidateCreateElasticcacheData(ctx, userCred, nil, data)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PostCreate(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
self.SVirtualResourceBase.PostCreate(ctx, userCred, ownerId, query, data)
|
||||
|
||||
self.SetStatus(userCred, api.LB_CREATING, "")
|
||||
if err := self.StartElasticcacheCreateTask(ctx, userCred, data.(*jsonutils.JSONDict), ""); err != nil {
|
||||
log.Errorf("Failed to create elastic cache error: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartElasticcacheCreateTask(ctx context.Context, userCred mcclient.TokenCredential, data *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheCreateTask", self, userCred, jsonutils.NewDict(), parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetIRegion() (cloudprovider.ICloudRegion, error) {
|
||||
provider, err := self.GetDriver()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("No cloudprovider for elastic cache %s: %s", self.Name, err)
|
||||
}
|
||||
region := self.GetRegion()
|
||||
if region == nil {
|
||||
return nil, fmt.Errorf("failed to find region for elastic cache %s", self.Name)
|
||||
}
|
||||
return provider.GetIRegionById(region.ExternalId)
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetCreateAliyunElasticcacheParams() (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
input := &cloudprovider.SCloudElasticCacheInput{}
|
||||
iregion, err := self.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("elastic cache %s(%s) region not found", self.Name, self.Id)
|
||||
} else {
|
||||
input.RegionId = iregion.GetId()
|
||||
}
|
||||
|
||||
input.InstanceType = self.InstanceType
|
||||
input.InstanceName = self.GetName()
|
||||
|
||||
// todo: inject password here
|
||||
// input.Password = "xxxx"
|
||||
input.Engine = strings.Title(self.Engine)
|
||||
input.EngineVersion = self.EngineVersion
|
||||
input.PrivateIpAddress = self.PrivateIpAddr
|
||||
|
||||
zone := self.GetZone()
|
||||
if zone != nil {
|
||||
izone, err := iregion.GetIZoneById(zone.ExternalId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateAliyunElasticcacheParams.Zone")
|
||||
}
|
||||
input.ZoneIds = []string{izone.GetId()}
|
||||
}
|
||||
|
||||
switch self.BillingType {
|
||||
case billing.BILLING_TYPE_PREPAID:
|
||||
input.ChargeType = "PrePaid"
|
||||
billingCycle, err := bc.ParseBillingCycle(self.BillingCycle)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateAliyunElasticcacheParams.BillingCycle")
|
||||
}
|
||||
input.BC = &billingCycle
|
||||
default:
|
||||
input.ChargeType = "PostPaid"
|
||||
}
|
||||
|
||||
// todo: fix me
|
||||
if len(self.NodeType) > 0 {
|
||||
switch self.NodeType {
|
||||
case "single":
|
||||
input.NodeType = "STAND_ALONE"
|
||||
case "double":
|
||||
input.NodeType = "MASTER_SLAVE"
|
||||
default:
|
||||
input.NodeType = ""
|
||||
}
|
||||
}
|
||||
|
||||
switch self.NetworkType {
|
||||
case api.LB_NETWORK_TYPE_CLASSIC:
|
||||
input.NetworkType = "CLASSIC"
|
||||
default:
|
||||
input.NetworkType = "VPC"
|
||||
}
|
||||
|
||||
if ivpc, err := db.FetchById(VpcManager, self.VpcId); err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateAliyunElasticcacheParams.Vpc")
|
||||
} else {
|
||||
if ivpc != nil {
|
||||
vpc := ivpc.(*SVpc)
|
||||
input.VpcId = vpc.ExternalId
|
||||
}
|
||||
}
|
||||
|
||||
if inetwork, err := db.FetchById(NetworkManager, self.NetworkId); err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateAliyunElasticcacheParams.Network")
|
||||
} else {
|
||||
if inetwork != nil {
|
||||
network := inetwork.(*SNetwork)
|
||||
input.NetworkId = network.ExternalId
|
||||
}
|
||||
}
|
||||
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetCreateHuaweiElasticcacheParams() (*cloudprovider.SCloudElasticCacheInput, error) {
|
||||
input := &cloudprovider.SCloudElasticCacheInput{}
|
||||
iregion, err := self.GetIRegion()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("elastic cache %s(%s) region not found", self.Name, self.Id)
|
||||
} else {
|
||||
input.RegionId = iregion.GetId()
|
||||
}
|
||||
|
||||
if self.CapacityMB > 0 {
|
||||
input.CapacityGB = int64(self.CapacityMB / 1024)
|
||||
}
|
||||
|
||||
sku, err := db.FetchById(ElasticcacheSkuManager, self.InstanceType)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
input.InstanceType = sku.(*SElasticcacheSku).InstanceSpec
|
||||
input.InstanceName = self.GetName()
|
||||
|
||||
// todo: inject password here
|
||||
// input.Password = "xxxx"
|
||||
switch self.Engine {
|
||||
case "redis":
|
||||
input.Engine = "Redis"
|
||||
case "memcache":
|
||||
input.Engine = "Memcached"
|
||||
}
|
||||
input.EngineVersion = self.EngineVersion
|
||||
input.PrivateIpAddress = self.PrivateIpAddr
|
||||
|
||||
zone := self.GetZone()
|
||||
if zone != nil {
|
||||
izone, err := iregion.GetIZoneById(zone.ExternalId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.Zone")
|
||||
}
|
||||
input.ZoneIds = []string{izone.GetId()}
|
||||
}
|
||||
|
||||
switch self.BillingType {
|
||||
case billing.BILLING_TYPE_PREPAID:
|
||||
input.ChargeType = "PrePaid"
|
||||
billingCycle, err := bc.ParseBillingCycle(self.BillingCycle)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.BillingCycle")
|
||||
}
|
||||
input.BC = &billingCycle
|
||||
default:
|
||||
input.ChargeType = "PostPaid"
|
||||
}
|
||||
|
||||
if len(self.NodeType) > 0 {
|
||||
input.NodeType = self.NodeType
|
||||
}
|
||||
|
||||
switch self.NetworkType {
|
||||
case api.LB_NETWORK_TYPE_CLASSIC:
|
||||
input.NetworkType = "CLASSIC"
|
||||
default:
|
||||
input.NetworkType = "VPC"
|
||||
}
|
||||
|
||||
if ivpc, err := db.FetchById(VpcManager, self.VpcId); err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.Vpc")
|
||||
} else {
|
||||
if ivpc != nil {
|
||||
vpc := ivpc.(*SVpc)
|
||||
input.VpcId = vpc.ExternalId
|
||||
}
|
||||
}
|
||||
|
||||
if inetwork, err := db.FetchById(NetworkManager, self.NetworkId); err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.Network")
|
||||
} else {
|
||||
if inetwork != nil {
|
||||
network := inetwork.(*SNetwork)
|
||||
input.NetworkId = network.ExternalId
|
||||
}
|
||||
}
|
||||
|
||||
// fill security group here
|
||||
if len(self.SecurityGroupId) > 0 {
|
||||
sgCache, err := SecurityGroupCacheManager.GetSecgroupCache(context.Background(), nil, self.SecurityGroupId, self.VpcId, self.CloudregionId, self.ManagerId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "elasticcache.GetCreateHuaweiElasticcacheParams.SecurityGroup")
|
||||
}
|
||||
|
||||
if sgCache == nil {
|
||||
return nil, errors.Wrap(fmt.Errorf("cached security group not found"), "elasticcache.GetCreateHuaweiElasticcacheParams.SecurityGroup")
|
||||
}
|
||||
|
||||
input.SecurityGroupId = sgCache.GetExternalId()
|
||||
}
|
||||
|
||||
if len(self.MaintainEndTime) > 0 {
|
||||
input.MaintainBegin = self.MaintainStartTime
|
||||
input.MaintainEnd = self.MaintainEndTime
|
||||
}
|
||||
return input, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformRestart(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "restart")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformRestart(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if utils.IsInStringArray(self.Status, []string{api.ELASTIC_CACHE_STATUS_RUNNING, api.ELASTIC_CACHE_STATUS_INACTIVE}) {
|
||||
return nil, self.StartRestartTask(ctx, userCred, "", data)
|
||||
} else {
|
||||
return nil, httperrors.NewInvalidStatusError("Cannot do restart elasticcache instance in status %s", self.Status)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartRestartTask(ctx context.Context, userCred mcclient.TokenCredential, parentTaskId string, data jsonutils.JSONObject) error {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_RESTARTING, "")
|
||||
if task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheRestartTask", self, userCred, data.(*jsonutils.JSONDict), parentTaskId, "", nil); err != nil {
|
||||
log.Errorln(err)
|
||||
return err
|
||||
} else {
|
||||
task.ScheduleRun(nil)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) CustomizeDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
|
||||
return self.StartDeleteElasticcacheTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartDeleteElasticcacheTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheDeleteTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformChangeSpec(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "change_spec")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorChangeSpecData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
skuV := validators.NewModelIdOrNameValidator("sku", "elasticcachesku", self.GetOwnerId())
|
||||
if err := skuV.Optional(false).Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
sku := skuV.Model.(*SElasticcacheSku)
|
||||
if sku.Provider != self.GetProviderName() {
|
||||
return nil, httperrors.NewInputParameterError("provider mismatch: %s instance can't use %s sku", self.GetProviderName(), sku.Provider)
|
||||
}
|
||||
|
||||
if sku.CloudregionId != self.CloudregionId {
|
||||
return nil, httperrors.NewInputParameterError("region mismatch: instance region %s, sku region %s", self.CloudregionId, sku.CloudregionId)
|
||||
}
|
||||
|
||||
if sku.ZoneId != "" && sku.ZoneId != self.ZoneId {
|
||||
return nil, httperrors.NewInputParameterError("zone mismatch: instance zone %s, sku zone %s", self.ZoneId, sku.ZoneId)
|
||||
}
|
||||
|
||||
if self.EngineVersion != "" && sku.EngineVersion != self.EngineVersion {
|
||||
return nil, httperrors.NewInputParameterError("engine version mismatch: instance version %s, sku version %s", self.EngineVersion, sku.EngineVersion)
|
||||
}
|
||||
|
||||
data.(*jsonutils.JSONDict).Set("sku_ext_id", jsonutils.NewString(skuV.Model.(*SElasticcacheSku).GetName()))
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformChangeSpec(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if !utils.IsInStringArray(self.Status, []string{api.ELASTIC_CACHE_STATUS_RUNNING}) {
|
||||
return nil, httperrors.NewResourceNotReadyError("can not change specification in status %s", self.Status)
|
||||
}
|
||||
|
||||
data, err := self.ValidatorChangeSpecData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
sku, _ := data.GetString("sku_ext_id")
|
||||
params.Set("sku_ext_id", jsonutils.NewString(sku))
|
||||
return nil, self.StartChangeSpecTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartChangeSpecTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_CHANGING, "")
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheChangeSpecTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformUpdateAuthMode(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "update_auth_mode")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorUpdateAuthModeData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
authModeV := validators.NewStringChoicesValidator("auth_mode", choices.NewChoices("on", "off"))
|
||||
if err := authModeV.Optional(false).Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if authModeV.Value == self.AuthMode {
|
||||
return nil, httperrors.NewConflictError("auth mode aready in status %s", self.AuthMode)
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformUpdateAuthMode(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorUpdateAuthModeData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
authMode, _ := data.GetString("auth_mode")
|
||||
params.Set("auth_mode", jsonutils.NewString(authMode))
|
||||
return nil, self.StartUpdateAuthModeTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartUpdateAuthModeTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheUpdateAuthModeTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformResetPassword(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "reset-password")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorResetPasswordData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if reset, _ := data.Bool("reset_password"); reset {
|
||||
if _, err := data.GetString("password"); err != nil {
|
||||
randomPasswd := seclib2.RandomPassword2(12)
|
||||
data.(*jsonutils.JSONDict).Set("password", jsonutils.NewString(randomPasswd))
|
||||
}
|
||||
}
|
||||
|
||||
if password, err := data.GetString("password"); err != nil || len(password) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("password")
|
||||
} else {
|
||||
if !seclib2.MeetComplxity(password) {
|
||||
return nil, httperrors.NewWeakPasswordError()
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformResetPassword(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorResetPasswordData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, self.StartResetPasswordTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) GetAdminAccount() (*SElasticcacheAccount, error) {
|
||||
accounts, err := self.GetElasticcacheAccounts()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := range accounts {
|
||||
if accounts[i].AccountType == api.ELASTIC_CACHE_ACCOUNT_TYPE_ADMIN {
|
||||
return &accounts[i], nil
|
||||
}
|
||||
}
|
||||
|
||||
return nil, fmt.Errorf("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 {
|
||||
account, err := self.GetAdminAccount()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAccountResetPasswordTask", account, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformSetMaintainTime(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "set_maintain_time")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorSetMaintainTimeData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
timeReg, _ := regexp.Compile("^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]Z$")
|
||||
startTimeV := validators.NewRegexpValidator("maintain_start_time", timeReg)
|
||||
endTimeV := validators.NewRegexpValidator("maintain_end_time", timeReg)
|
||||
keyV := map[string]validators.IValidator{
|
||||
"maintain_start_time": startTimeV.Optional(false),
|
||||
"maintain_end_time": endTimeV.Optional(false),
|
||||
}
|
||||
|
||||
for _, v := range keyV {
|
||||
if err := v.Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
if startTimeV.Value == self.MaintainStartTime && endTimeV.Value == self.MaintainEndTime {
|
||||
return nil, httperrors.NewInputParameterError("maintain time has no change")
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformSetMaintainTime(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorSetMaintainTimeData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
startTime, _ := data.GetString("maintain_start_time")
|
||||
endTime, _ := data.GetString("maintain_end_time")
|
||||
params.Set("maintain_start_time", jsonutils.NewString(startTime))
|
||||
params.Set("maintain_end_time", jsonutils.NewString(endTime))
|
||||
return nil, self.StartSetMaintainTimeTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartSetMaintainTimeTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheSetMaintainTimeTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformAllocatePublicConnection(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "allocate_public_connection")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorAllocatePublicConnectionData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.PublicDNS != "" || self.PublicIpAddr != "" {
|
||||
return nil, httperrors.NewConflictError("public connection aready allocated")
|
||||
}
|
||||
|
||||
portV := validators.NewRangeValidator("port", 1024, 65535)
|
||||
portV.Default(6379).Optional(true)
|
||||
if err := portV.Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformAllocatePublicConnection(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorAllocatePublicConnectionData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
port, _ := data.Int("port")
|
||||
params.Set("port", jsonutils.NewInt(port))
|
||||
return nil, self.StartAllocatePublicConnectionTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartAllocatePublicConnectionTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheAllocatePublicConnectionTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformReleasePublicConnection(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "release_public_connection")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorReleasePublicConnectionData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.PublicIpAddr == "" && self.PublicDNS == "" {
|
||||
return nil, httperrors.NewConflictError("release public connection aready released")
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformReleasePublicConnection(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorReleasePublicConnectionData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, self.StartReleasePublicConnectionTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartReleasePublicConnectionTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheReleasePublicConnectionTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformFlushInstance(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "flush_instance")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformFlushInstance(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_STATUS_FLUSHING, "")
|
||||
return nil, self.StartFlushInstanceTask(ctx, userCred, jsonutils.NewDict(), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartFlushInstanceTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheFlushInstanceTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformUpdateInstanceParameters(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "update_instance_parameters")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorUpdateInstanceParametersData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
parameters, err := data.Get("parameters")
|
||||
if err != nil {
|
||||
return nil, httperrors.NewMissingParameterError("parameters")
|
||||
}
|
||||
|
||||
_, ok := parameters.(*jsonutils.JSONDict)
|
||||
if !ok {
|
||||
return nil, httperrors.NewInputParameterError("invalid parameter format. json dict required")
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformUpdateInstanceParameters(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorUpdateInstanceParametersData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
params := jsonutils.NewDict()
|
||||
parameters, _ := data.Get("parameters")
|
||||
params.Set("parameters", parameters)
|
||||
return nil, self.StartUpdateInstanceParametersTask(ctx, userCred, params, "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartUpdateInstanceParametersTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheUpdateInstanceParametersTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformUpdateBackupPolicy(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "update_backup_policy")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) ValidatorUpdateBackupPolicyData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
timeReg, _ := regexp.Compile("^(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]Z-(0[0-9]|1[0-9]|2[0-3]|[0-9]):[0-5][0-9]Z$")
|
||||
backupTypeV := validators.NewStringChoicesValidator("backup_type", choices.NewChoices(api.BACKUP_MODE_AUTOMATED, api.ELASTIC_CACHE_BACKUP_MODE_MANUAL))
|
||||
BackupReservedDaysV := validators.NewRangeValidator("backup_reserved_days", 1, 7).Default(7)
|
||||
PreferredBackupPeriodV := validators.NewStringChoicesValidator("preferred_backup_period", choices.NewChoices("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"))
|
||||
PreferredBackupTimeV := validators.NewRegexpValidator("preferred_backup_time", timeReg)
|
||||
|
||||
keyV := map[string]validators.IValidator{
|
||||
"backup_type": backupTypeV.Optional(true),
|
||||
"backup_reserved_days": BackupReservedDaysV.Optional(true),
|
||||
"preferred_backup_period": PreferredBackupPeriodV.Optional(false),
|
||||
"preferred_backup_time": PreferredBackupTimeV.Optional(false),
|
||||
}
|
||||
|
||||
for _, v := range keyV {
|
||||
if err := v.Validate(data.(*jsonutils.JSONDict)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformUpdateBackupPolicy(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
data, err := self.ValidatorUpdateBackupPolicyData(ctx, userCred, query, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return nil, self.StartUpdateBackupPolicyTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartUpdateBackupPolicyTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheUpdateBackupPolicyTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SElasticcache) AllowPerformSync(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "sync")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) PerformSync(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
return nil, self.StartSyncTask(ctx, userCred, data.(*jsonutils.JSONDict), "")
|
||||
}
|
||||
|
||||
func (self *SElasticcache) StartSyncTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheSyncTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
// 清理所有关联资源记录
|
||||
func (self *SElasticcache) DeleteSubResources(ctx context.Context, userCred mcclient.TokenCredential) {
|
||||
ms := []db.IResourceModelManager{
|
||||
ElasticcacheAccountManager,
|
||||
ElasticcacheAclManager,
|
||||
ElasticcacheBackupManager,
|
||||
ElasticcacheParameterManager,
|
||||
}
|
||||
|
||||
ownerId := self.GetOwnerId()
|
||||
for _, m := range ms {
|
||||
func(man db.IResourceModelManager) {
|
||||
lockman.LockClass(ctx, man, db.GetLockClassKey(man, ownerId))
|
||||
defer lockman.ReleaseClass(ctx, man, db.GetLockClassKey(man, ownerId))
|
||||
q := man.Query().IsFalse("deleted").Equals("elasticcache_id", self.GetId())
|
||||
|
||||
models := make([]interface{}, 0)
|
||||
err := db.FetchModelObjects(man, q, &models)
|
||||
if err != nil {
|
||||
log.Errorf("elasticcache.DeleteSubResources.FetchModelObjects %s", err)
|
||||
}
|
||||
|
||||
for i := range models {
|
||||
var imodel db.IModel
|
||||
switch models[i].(type) {
|
||||
case SElasticcacheAccount:
|
||||
_m := models[i].(SElasticcacheAccount)
|
||||
imodel = &_m
|
||||
case SElasticcacheAcl:
|
||||
_m := models[i].(SElasticcacheAcl)
|
||||
imodel = &_m
|
||||
case SElasticcacheBackup:
|
||||
_m := models[i].(SElasticcacheBackup)
|
||||
imodel = &_m
|
||||
case SElasticcacheParameter:
|
||||
_m := models[i].(SElasticcacheParameter)
|
||||
imodel = &_m
|
||||
default:
|
||||
log.Errorf("elasticcache.DeleteSubResources.UnknownModelType %s", models[i])
|
||||
}
|
||||
|
||||
err = db.DeleteModel(ctx, userCred, imodel)
|
||||
if err != nil {
|
||||
log.Errorf("elasticcache.DeleteSubResources.DeleteModel %s", err)
|
||||
}
|
||||
}
|
||||
}(m)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,12 +17,17 @@ package models
|
||||
import (
|
||||
"context"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"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/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
)
|
||||
|
||||
@@ -46,7 +51,7 @@ func init() {
|
||||
}
|
||||
|
||||
type SElasticcacheParameter struct {
|
||||
db.SStandaloneResourceBase
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
ElasticcacheId string `width:"36" charset:"ascii" nullable:"false" list:"user" create:"required" index:"true"` // elastic cache instance id
|
||||
@@ -123,6 +128,7 @@ func (self *SElasticcacheParameter) syncRemoveCloudElasticcacheParameter(ctx con
|
||||
|
||||
func (self *SElasticcacheParameter) SyncWithCloudElasticcacheParameter(ctx context.Context, userCred mcclient.TokenCredential, extParameter cloudprovider.ICloudElasticcacheParameter) error {
|
||||
_, err := db.UpdateWithLock(ctx, self, func() error {
|
||||
self.Status = extParameter.GetStatus()
|
||||
self.Key = extParameter.GetParameterKey()
|
||||
self.Value = extParameter.GetParameterValue()
|
||||
self.Modifiable = extParameter.GetModifiable()
|
||||
@@ -144,6 +150,7 @@ func (manager *SElasticcacheParameterManager) newFromCloudElasticcacheParameter(
|
||||
parameter.SetModelManager(manager, ¶meter)
|
||||
|
||||
parameter.ElasticcacheId = elasticcache.Id
|
||||
parameter.Status = extParameter.GetStatus()
|
||||
parameter.Name = extParameter.GetName()
|
||||
parameter.ExternalId = extParameter.GetGlobalId()
|
||||
parameter.Key = extParameter.GetParameterKey()
|
||||
@@ -160,3 +167,49 @@ func (manager *SElasticcacheParameterManager) newFromCloudElasticcacheParameter(
|
||||
|
||||
return ¶meter, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheParameter) GetRegion() *SCloudregion {
|
||||
ieb, err := db.FetchById(ElasticcacheManager, self.ElasticcacheId)
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return ieb.(*SElasticcache).GetRegion()
|
||||
}
|
||||
|
||||
func (self *SElasticcacheParameter) ValidateUpdateData(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data *jsonutils.JSONDict) (*jsonutils.JSONDict, error) {
|
||||
if !self.Modifiable {
|
||||
return nil, httperrors.NewConflictError("%s is not modifiable", self.Name)
|
||||
}
|
||||
|
||||
_, err := data.GetString("value")
|
||||
if err != nil {
|
||||
return nil, httperrors.NewMissingParameterError("value")
|
||||
}
|
||||
|
||||
return data, nil
|
||||
}
|
||||
|
||||
func (self *SElasticcacheParameter) PostUpdate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) {
|
||||
v, _ := data.Get("value")
|
||||
params := jsonutils.NewDict()
|
||||
paramsObj := jsonutils.NewDict()
|
||||
paramsObj.Add(v, self.Name)
|
||||
params.Add(paramsObj, "parameters")
|
||||
|
||||
self.SetStatus(userCred, api.ELASTIC_CACHE_PARAMETER_STATUS_UPDATING, "")
|
||||
if err := self.StartUpdateElasticcacheParameterTask(ctx, userCred, params, ""); err != nil {
|
||||
log.Errorf("ElasticcacheParameter %s", err.Error())
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (self *SElasticcacheParameter) StartUpdateElasticcacheParameterTask(ctx context.Context, userCred mcclient.TokenCredential, params *jsonutils.JSONDict, parentTaskId string) error {
|
||||
task, err := taskman.TaskManager.NewTask(ctx, "ElasticcacheParameterUpdateTask", self, userCred, params, parentTaskId, "", nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
task.ScheduleRun(nil)
|
||||
return nil
|
||||
}
|
||||
|
||||
275
pkg/compute/models/elasticcache_skus.go
Normal file
275
pkg/compute/models/elasticcache_skus.go
Normal file
@@ -0,0 +1,275 @@
|
||||
// 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 models
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/sqlchemy"
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/db"
|
||||
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/util/stringutils2"
|
||||
)
|
||||
|
||||
type SElasticcacheSkuManager struct {
|
||||
db.SStatusStandaloneResourceBaseManager
|
||||
}
|
||||
|
||||
var ElasticcacheSkuManager *SElasticcacheSkuManager
|
||||
|
||||
func init() {
|
||||
ElasticcacheSkuManager = &SElasticcacheSkuManager{
|
||||
SStatusStandaloneResourceBaseManager: db.NewStatusStandaloneResourceBaseManager(
|
||||
SElasticcacheSku{},
|
||||
"elasticcacheskus_tbl",
|
||||
"elasticcachesku",
|
||||
"elasticcacheskus",
|
||||
),
|
||||
}
|
||||
ElasticcacheSkuManager.NameRequireAscii = false
|
||||
ElasticcacheSkuManager.SetVirtualObject(ElasticcacheSkuManager)
|
||||
}
|
||||
|
||||
type SElasticcacheSku struct {
|
||||
db.SStatusStandaloneResourceBase
|
||||
db.SExternalizedResourceBase
|
||||
|
||||
SCloudregionResourceBase // 区域
|
||||
SZoneResourceBase // 主可用区
|
||||
SlaveZoneId string `width:"64" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 备可用区
|
||||
|
||||
InstanceSpec string `width:"96" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"`
|
||||
EngineArch string `width:"32" charset:"utf8" nullable:"false" list:"user" create:"admin_optional" update:"admin"`
|
||||
LocalCategory string `width:"32" charset:"utf8" nullable:"false" list:"user" create:"admin_optional" update:"admin" default:""`
|
||||
|
||||
PrepaidStatus string `width:"32" charset:"utf8" nullable:"false" list:"user" create:"admin_optional" update:"admin" default:"available"`
|
||||
PostpaidStatus string `width:"32" charset:"utf8" nullable:"false" list:"user" create:"admin_optional" update:"admin" default:"available"`
|
||||
|
||||
Engine string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 引擎 redis|memcached
|
||||
EngineVersion string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 引擎版本 3.0
|
||||
CpuArch string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // CPU 架构 x86|ARM
|
||||
StorageType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 存储类型 DRAM|SCM
|
||||
PerformanceType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // standrad|enhanced
|
||||
NodeType string `width:"16" charset:"ascii" nullable:"false" list:"user" create:"admin_optional" update:"admin"` // single(单副本) | double(双副本) | readone (单可读) | readthree (3可读) | readfive(5只读)
|
||||
|
||||
MemorySizeMB int `nullable:"false" list:"user" create:"admin_required" update:"admin"` // 内存容量
|
||||
DiskSizeGB int `nullable:"false" list:"user" create:"admin_required" update:"admin"` // 套餐附带硬盘容量
|
||||
ShardNum int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最小分片数量
|
||||
MaxShardNum int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最大分片数量
|
||||
ReplicasNum int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最小副本数量
|
||||
MaxReplicasNum int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最大副本数量
|
||||
|
||||
MaxClients int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最大客户端数
|
||||
MaxConnections int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最大连接数
|
||||
MaxInBandwidthMb int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 最大内网带宽
|
||||
MaxMemoryMB int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // 实际可使用的最大内存
|
||||
QPS int `nullable:"false" list:"user" create:"admin_optional" update:"admin"` // QPS参考值
|
||||
|
||||
Provider string `width:"32" charset:"ascii" nullable:"false" list:"user" create:"admin_required" update:"admin"` // 公有云厂商 Aliyun/Azure/AWS/Qcloud/...
|
||||
}
|
||||
|
||||
func (self *SElasticcacheSku) GetCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject) *jsonutils.JSONDict {
|
||||
return self.SStatusStandaloneResourceBase.GetCustomizeColumns(ctx, userCred, query)
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) FetchCustomizeColumns(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, objs []db.IModel, fields stringutils2.SSortedStrings) []*jsonutils.JSONDict {
|
||||
regions := map[string]string{}
|
||||
for i := range objs {
|
||||
cloudregionId := objs[i].(*SElasticcacheSku).CloudregionId
|
||||
if _, ok := regions[cloudregionId]; !ok {
|
||||
regions[cloudregionId] = cloudregionId
|
||||
}
|
||||
}
|
||||
|
||||
regionIds := []string{}
|
||||
for k, _ := range regions {
|
||||
regionIds = append(regionIds, regions[k])
|
||||
}
|
||||
|
||||
if len(regionIds) == 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
regionObjs := []SCloudregion{}
|
||||
err := CloudregionManager.Query().In("id", regionIds).All(®ionObjs)
|
||||
if err != nil {
|
||||
log.Errorf("elasticcacheSkuManager.FetchCustomizeColumns %s", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
for i := range regionObjs {
|
||||
regionObj := regionObjs[i]
|
||||
regions[regionObj.Id] = regionObj.Name
|
||||
}
|
||||
|
||||
ret := []*jsonutils.JSONDict{}
|
||||
for i := range objs {
|
||||
cloudregionId := objs[i].(*SElasticcacheSku).CloudregionId
|
||||
|
||||
fileds := jsonutils.NewDict()
|
||||
fileds.Set("region", jsonutils.NewString(regions[cloudregionId]))
|
||||
|
||||
ret = append(ret, fileds)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) ListItemFilter(ctx context.Context, q *sqlchemy.SQuery, userCred mcclient.TokenCredential, query jsonutils.JSONObject) (*sqlchemy.SQuery, error) {
|
||||
data := query.(*jsonutils.JSONDict)
|
||||
brands := jsonutils.GetQueryStringArray(query, "brand")
|
||||
if len(brands) > 0 {
|
||||
q = q.Filter(sqlchemy.In(q.Field("brand"), brands))
|
||||
data.Remove("brand")
|
||||
}
|
||||
|
||||
q, err := manager.SStatusStandaloneResourceBaseManager.ListItemFilter(ctx, q, userCred, data)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
if usable, _ := query.Bool("usable"); usable {
|
||||
q = usableFilter(q, true)
|
||||
q = q.Equals("postpaid_status", "available")
|
||||
q = q.Equals("prepaid_status", "available")
|
||||
}
|
||||
|
||||
q, err = validators.ApplyModelFilters(q, data, []*validators.ModelFilterOptions{
|
||||
{Key: "zone", ModelKeyword: "zone", OwnerId: userCred},
|
||||
{Key: "cloudregion", ModelKeyword: "cloudregion", OwnerId: userCred},
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
city, _ := query.GetString("city")
|
||||
if len(city) > 0 {
|
||||
regionTable := CloudregionManager.Query().SubQuery()
|
||||
q = q.Join(regionTable, sqlchemy.Equals(regionTable.Field("id"), q.Field("cloudregion_id"))).Filter(sqlchemy.Equals(regionTable.Field("city"), city))
|
||||
}
|
||||
|
||||
return q, err
|
||||
}
|
||||
|
||||
// 获取所有Available状态的sku id
|
||||
func (manager *SElasticcacheSkuManager) FetchAllAvailableSkuId() ([]string, error) {
|
||||
q := manager.Query()
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.Equals(q.Field("prepaid_status"), api.SkuStatusAvailable),
|
||||
sqlchemy.Equals(q.Field("postpaid_status"), api.SkuStatusAvailable)))
|
||||
|
||||
skus := make([]SElasticcacheSku, 0)
|
||||
err := db.FetchModelObjects(manager, q, &skus)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids := make([]string, len(skus))
|
||||
for i := range skus {
|
||||
ids[i] = skus[i].GetId()
|
||||
}
|
||||
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
// 获取region下所有Available状态的sku id
|
||||
func (manager *SElasticcacheSkuManager) FetchAllAvailableSkuIdByRegion(regionID string) ([]string, error) {
|
||||
q := manager.Query()
|
||||
q = q.Filter(sqlchemy.OR(
|
||||
sqlchemy.Equals(q.Field("prepaid_status"), api.SkuStatusAvailable),
|
||||
sqlchemy.Equals(q.Field("postpaid_status"), api.SkuStatusAvailable)))
|
||||
q = q.Equals("cloudregion_id", regionID)
|
||||
|
||||
skus := make([]SElasticcacheSku, 0)
|
||||
err := db.FetchModelObjects(manager, q, &skus)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
ids := make([]string, len(skus))
|
||||
for i := range skus {
|
||||
ids[i] = skus[i].GetId()
|
||||
}
|
||||
|
||||
return ids, nil
|
||||
}
|
||||
|
||||
func (manager *SElasticcacheSkuManager) InitializeData() error {
|
||||
count, err := manager.Query().Limit(1).CountWithError()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return err
|
||||
}
|
||||
|
||||
if count > 0 {
|
||||
return nil
|
||||
}
|
||||
|
||||
count, err = CloudaccountManager.Query().IsTrue("is_public_cloud").CountWithError()
|
||||
if count > 0 {
|
||||
SyncElasticCacheSkus(nil, nil, true)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// sku标记为soldout状态。
|
||||
func (manager *SElasticcacheSkuManager) MarkAsSoldout(id string) error {
|
||||
if len(id) == 0 {
|
||||
log.Debugf("MarkAsSoldout sku id should not be emtpy")
|
||||
return nil
|
||||
}
|
||||
|
||||
isku, err := manager.FetchById(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sku, ok := isku.(*SServerSku)
|
||||
if !ok {
|
||||
return fmt.Errorf("%s is not a sku object", id)
|
||||
}
|
||||
|
||||
_, err = manager.TableSpec().Update(sku, func() error {
|
||||
sku.PrepaidStatus = api.SkuStatusSoldout
|
||||
sku.PostpaidStatus = api.SkuStatusSoldout
|
||||
return nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// sku标记为soldout状态。
|
||||
func (manager *SElasticcacheSkuManager) MarkAllAsSoldout(ids []string) error {
|
||||
var err error
|
||||
for _, id := range ids {
|
||||
err = manager.MarkAsSoldout(id)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user