mirror of
https://hubproxy.babadafafafafa.cn/https://github.com/yunionio/cloudpods.git
synced 2026-09-20 16:13:56 +08:00
Compare commits
59 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e59c6be73 | ||
|
|
41806c9388 | ||
|
|
c498c6f22b | ||
|
|
ec926f9b62 | ||
|
|
43faf5a5bf | ||
|
|
7243b4fd37 | ||
|
|
767aa5c37a | ||
|
|
01000d5334 | ||
|
|
4948869add | ||
|
|
fd94dc34da | ||
|
|
28b9460fb9 | ||
|
|
35f7844c53 | ||
|
|
2e8c9ee159 | ||
|
|
93a7f1b815 | ||
|
|
ac416cdfbc | ||
|
|
daf14eb739 | ||
|
|
883cb64089 | ||
|
|
7b8303e9ab | ||
|
|
c7a9f726b8 | ||
|
|
55525a990c | ||
|
|
54d3962fb3 | ||
|
|
c4685cf58f | ||
|
|
e51e0a7ab4 | ||
|
|
1dbe7b930a | ||
|
|
071576111c | ||
|
|
37516c7b5d | ||
|
|
3a299f0661 | ||
|
|
b4d784d283 | ||
|
|
95ef2bc51c | ||
|
|
02a08bc6da | ||
|
|
10e574d389 | ||
|
|
644a9c1035 | ||
|
|
12209ee0c7 | ||
|
|
e76c1d6c02 | ||
|
|
018ef0d986 | ||
|
|
b71406e6ec | ||
|
|
a67bdedb45 | ||
|
|
913757f138 | ||
|
|
8f41c4165a | ||
|
|
ec709234d7 | ||
|
|
b264e3c074 | ||
|
|
c73de5f64f | ||
|
|
7c7687ae4d | ||
|
|
88046eea10 | ||
|
|
d445b55d68 | ||
|
|
122a07b96b | ||
|
|
984790c18f | ||
|
|
1d4b2a04bd | ||
|
|
cb830ad8e3 | ||
|
|
9a69b8c0d2 | ||
|
|
cf5dcc611f | ||
|
|
1456b93ec2 | ||
|
|
b5fcfb5d16 | ||
|
|
dfee854fb4 | ||
|
|
bba05e4702 | ||
|
|
c93624a093 | ||
|
|
d1da58b42f | ||
|
|
78a9a1ea80 | ||
|
|
2fb095bc5b |
@@ -28,4 +28,6 @@ func init() {
|
||||
cmd.Delete(&options.BaseIdOptions{})
|
||||
cmd.Show(&options.BaseIdOptions{})
|
||||
cmd.Create(&compute.ProjectMappingCreateOption{})
|
||||
cmd.Perform("enable", &options.BaseIdOptions{})
|
||||
cmd.Perform("disable", &options.BaseIdOptions{})
|
||||
}
|
||||
|
||||
@@ -59,6 +59,7 @@ func init() {
|
||||
cmd.BatchPerform("reset", new(options.ServerResetOptions))
|
||||
cmd.BatchPerform("restart", new(options.ServerRestartOptions))
|
||||
cmd.BatchPerform("purge", new(options.ServerIdsOptions))
|
||||
cmd.PrintObjectYAML().Perform("migrate-forecast", new(options.ServerMigrateForecastOptions))
|
||||
cmd.Perform("migrate", new(options.ServerMigrateOptions))
|
||||
cmd.Perform("live-migrate", new(options.ServerLiveMigrateOptions))
|
||||
cmd.Perform("modify-src-check", new(options.ServerModifySrcCheckOptions))
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/pkg/mcclient"
|
||||
"yunion.io/x/onecloud/pkg/mcclient/modulebase"
|
||||
"yunion.io/x/onecloud/pkg/util/printutils"
|
||||
)
|
||||
|
||||
type ResourceCmd struct {
|
||||
@@ -32,12 +33,15 @@ type ResourceCmd struct {
|
||||
|
||||
keyword string
|
||||
prefix string
|
||||
|
||||
printObject func(jsonutils.JSONObject)
|
||||
}
|
||||
|
||||
func NewResourceCmd(manager modulebase.IBaseManager) *ResourceCmd {
|
||||
return &ResourceCmd{
|
||||
manager: manager,
|
||||
keyword: manager.GetKeyword(),
|
||||
manager: manager,
|
||||
keyword: manager.GetKeyword(),
|
||||
printObject: printObjectRecursive,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,6 +66,30 @@ func (cmd *ResourceCmd) SetKeyword(keyword string) *ResourceCmd {
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) PrintObjectYAML() *ResourceCmd {
|
||||
cmd.printObject = func(obj jsonutils.JSONObject) {
|
||||
fmt.Print(obj.YAMLString())
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) PrintObjectTable() *ResourceCmd {
|
||||
cmd.printObject = printutils.PrintJSONObject
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) PrintObjectKV() *ResourceCmd {
|
||||
cmd.printObject = printObjectFmtKv
|
||||
return cmd
|
||||
}
|
||||
|
||||
func (cmd *ResourceCmd) PrintObjectFlattenKV() *ResourceCmd {
|
||||
cmd.printObject = func(obj jsonutils.JSONObject) {
|
||||
printObjectRecursiveEx(obj, printObjectFmtKv)
|
||||
}
|
||||
return cmd
|
||||
}
|
||||
|
||||
type IOpt interface {
|
||||
Params() (jsonutils.JSONObject, error)
|
||||
}
|
||||
@@ -325,7 +353,7 @@ func (cmd ResourceCmd) PerformWithKeyword(keyword, action string, args IPerformO
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(ret)
|
||||
cmd.printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(keyword, args, callback)
|
||||
@@ -342,7 +370,7 @@ func (cmd ResourceCmd) PerformClassWithKeyword(keyword, action string, args IOpt
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(ret)
|
||||
cmd.printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(keyword, args, callback)
|
||||
@@ -363,7 +391,7 @@ func (cmd ResourceCmd) PerformClass(action string, args IOpt) {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
printObjectRecursive(ret)
|
||||
cmd.printObject(ret)
|
||||
return nil
|
||||
}
|
||||
cmd.Run(action, args, callback)
|
||||
|
||||
7135
locales/locales.go
7135
locales/locales.go
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -141,7 +141,7 @@ func (h *AuthHandlers) GetRegionsResponse(ctx context.Context, w http.ResponseWr
|
||||
if options.Options.ReturnFullDomainList {
|
||||
filters := jsonutils.NewDict()
|
||||
if len(currentDomain) > 0 {
|
||||
filters.Add(jsonutils.NewString(currentDomain), "id")
|
||||
filters.Add(jsonutils.NewString(currentDomain), "name")
|
||||
}
|
||||
filters.Add(jsonutils.NewInt(1000), "limit")
|
||||
result, e := modules.Domains.List(s, filters)
|
||||
|
||||
@@ -480,5 +480,6 @@ type CloudaccountEnableAutoSyncInput struct {
|
||||
|
||||
type CloudaccountProjectMappingInput struct {
|
||||
// 同步策略Id, 若不传此参数则解绑
|
||||
// 绑定同步策略要求当前云账号此刻未绑定其他同步策略
|
||||
ProjectMappingId string `json:"project_mapping_id"`
|
||||
}
|
||||
|
||||
@@ -17,8 +17,11 @@ package compute
|
||||
import (
|
||||
"time"
|
||||
|
||||
"yunion.io/x/pkg/util/fileutils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis"
|
||||
"yunion.io/x/onecloud/pkg/apis/billing"
|
||||
"yunion.io/x/onecloud/pkg/httperrors"
|
||||
)
|
||||
|
||||
type DiskCreateInput struct {
|
||||
@@ -249,3 +252,16 @@ type DiskSaveInput struct {
|
||||
// swagger: ignore
|
||||
ImageId string
|
||||
}
|
||||
|
||||
type DiskResizeInput struct {
|
||||
// default unit: Mb
|
||||
// example: 1024; 40G; 1024M
|
||||
Size string `json:"size"`
|
||||
}
|
||||
|
||||
func (self DiskResizeInput) SizeMb() (int, error) {
|
||||
if len(self.Size) == 0 {
|
||||
return 0, httperrors.NewMissingParameterError("size")
|
||||
}
|
||||
return fileutils.GetSizeMb(self.Size, 'M', 1024)
|
||||
}
|
||||
|
||||
@@ -518,3 +518,20 @@ type ServerDetachnetworkInput struct {
|
||||
// 通过Mac解绑网卡, 优先级低于ip_addr
|
||||
Mac string `json:"mac"`
|
||||
}
|
||||
|
||||
type ServerMigrateForecastInput struct {
|
||||
PreferHostId string `json:"prefer_host_id"`
|
||||
// Deprecated
|
||||
PreferHost string `json:"prefer_host" yunion-deprecated-by:"prefer_host_id"`
|
||||
LiveMigrate bool `json:"live_migrate"`
|
||||
SkipCpuCheck bool `josn:"skip_cpu_check"`
|
||||
}
|
||||
|
||||
type ServerResizeDiskInput struct {
|
||||
// swagger: ignore
|
||||
Disk string `json:"disk" yunion-deprecated-by:"disk_id"`
|
||||
// 磁盘Id
|
||||
DiskId string `json:"disk_id"`
|
||||
|
||||
DiskResizeInput
|
||||
}
|
||||
|
||||
@@ -21,6 +21,8 @@ type LoadbalancerCertificateDetails struct {
|
||||
SLoadbalancerCertificate
|
||||
|
||||
LbListenerCount int `json:"lb_listener_count"`
|
||||
// 证书内容是否完整
|
||||
IsComplete bool `json:"is_complete"`
|
||||
}
|
||||
|
||||
type LoadbalancerCertificateResourceInfo struct {
|
||||
|
||||
@@ -34,23 +34,29 @@ const (
|
||||
)
|
||||
|
||||
type STag struct {
|
||||
Key string
|
||||
Value string
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
|
||||
type ProjectMappingRuleInfo struct {
|
||||
// 标签列表, 不可为空
|
||||
Tags []STag
|
||||
Tags []STag `json:"tags"`
|
||||
// 条件表达式
|
||||
// enmu: and, or
|
||||
// default: and
|
||||
Condition string
|
||||
Condition string `json:"condition"`
|
||||
// 是否自动根据标签值创建项目, 仅标签列表中有且仅有一个没有value的key时支持
|
||||
AutoCreateProject bool
|
||||
AutoCreateProject bool `json:"auto_create_project"`
|
||||
// 符合条件时,资源放置的项目id, 此参数和auto_create_project互斥
|
||||
ProjectId string
|
||||
ProjectId string `json:"project_id"`
|
||||
// 只读信息
|
||||
// swagger:ignore
|
||||
DomainId string
|
||||
Project string `json:"project"`
|
||||
// swagger:ignore
|
||||
DomainId string `json:"domain_id"`
|
||||
// 只读信息
|
||||
// swagger:ignore
|
||||
Domain string `json:"domain"`
|
||||
}
|
||||
|
||||
type MappingRules []ProjectMappingRuleInfo
|
||||
@@ -105,7 +111,7 @@ func (self *ProjectMappingRuleInfo) IsMatchTags(_extTags map[string]string) (str
|
||||
case MAPPING_CONDITION_OR:
|
||||
for _, tag := range self.Tags {
|
||||
extTag, ok := extTags[strings.ToUpper(tag.Key)]
|
||||
if ok && len(tag.Value) == 0 || tag.Value == extTag {
|
||||
if ok && (len(tag.Value) == 0 || tag.Value == extTag) {
|
||||
if self.AutoCreateProject && len(tag.Value) == 0 && len(extTag) > 0 {
|
||||
return "", "", extTag, true
|
||||
} else {
|
||||
@@ -135,15 +141,18 @@ type ProjectMappingRuleInfoDetails struct {
|
||||
Domain string
|
||||
}
|
||||
|
||||
type SProjectMappingAccount struct {
|
||||
Id string `json:"id"`
|
||||
Name string `json:"name"`
|
||||
}
|
||||
|
||||
type ProjectMappingDetails struct {
|
||||
apis.EnabledStatusInfrasResourceBaseDetails
|
||||
|
||||
Rules []ProjectMappingRuleInfoDetails
|
||||
|
||||
Accounts []struct {
|
||||
Id string
|
||||
Name string
|
||||
}
|
||||
// 所绑定的云账号列表
|
||||
Accounts []SProjectMappingAccount `json:"accounts"`
|
||||
}
|
||||
|
||||
type ProjectMappingCreateInput struct {
|
||||
|
||||
@@ -222,4 +222,7 @@ type StorageListInput struct {
|
||||
|
||||
// filter by cachedimage
|
||||
ImageId string `json:"image_id"`
|
||||
|
||||
// filter storages which attached the specified host
|
||||
HostId string `json:"host_id"`
|
||||
}
|
||||
|
||||
@@ -146,8 +146,8 @@ var (
|
||||
}
|
||||
|
||||
StorageTags = map[string]string{
|
||||
"id": "storage_id",
|
||||
"name": "storage_name",
|
||||
"storage_id": "id",
|
||||
"storage_name": "name",
|
||||
"zone": "zone",
|
||||
"zone_id": "zone_id",
|
||||
"zone_ext_id": "zone_ext_id",
|
||||
|
||||
@@ -117,6 +117,12 @@ func (dev *MegaRaidPhyDev) parseLine(line string) bool {
|
||||
dev.Status = "online"
|
||||
} else if val == "Rebuild" {
|
||||
dev.Status = "rebuild"
|
||||
} else if strings.Contains(strings.ToLower(val), "hotspare") {
|
||||
dev.Status = "hotspare"
|
||||
} else if strings.Contains(strings.ToLower(val), "copyback") {
|
||||
dev.Status = "copyback"
|
||||
} else if strings.Contains(strings.ToLower(val), "unconfigured(good)") {
|
||||
dev.Status = "unconfigured_good"
|
||||
} else {
|
||||
dev.Status = "offline"
|
||||
}
|
||||
|
||||
@@ -2870,6 +2870,9 @@ func (self *SCloudaccount) PerformProjectMapping(ctx context.Context, userCred m
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if len(self.ProjectMappingId) > 0 && self.ProjectMappingId != input.ProjectMappingId {
|
||||
return nil, httperrors.NewInputParameterError("account %s has aleady bind project mapping %s", self.Name, self.ProjectMappingId)
|
||||
}
|
||||
}
|
||||
// no changes
|
||||
if self.ProjectMappingId == input.ProjectMappingId {
|
||||
|
||||
@@ -1436,6 +1436,7 @@ func (self *SCloudprovider) RealDelete(ctx context.Context, userCred mcclient.To
|
||||
LoadbalancerBackendGroupManager,
|
||||
CachedLoadbalancerAclManager,
|
||||
CachedLoadbalancerCertificateManager,
|
||||
LoadbalancerCertificateManager,
|
||||
NatGatewayManager,
|
||||
DBInstanceManager,
|
||||
DBInstanceBackupManager,
|
||||
|
||||
@@ -758,7 +758,6 @@ func syncHostVMs(ctx context.Context, userCred mcclient.TokenCredential, syncRes
|
||||
}
|
||||
|
||||
func syncVMPeripherals(ctx context.Context, userCred mcclient.TokenCredential, local *SGuest, remote cloudprovider.ICloudVM, host *SHost, provider *SCloudprovider, driver cloudprovider.ICloudProvider) {
|
||||
syncVirtualResourceMetadata(ctx, userCred, local, remote)
|
||||
err := syncVMNics(ctx, userCred, provider, host, local, remote)
|
||||
if err != nil {
|
||||
log.Errorf("syncVMNics error %s", err)
|
||||
|
||||
@@ -27,7 +27,6 @@ import (
|
||||
"yunion.io/x/pkg/errors"
|
||||
"yunion.io/x/pkg/tristate"
|
||||
"yunion.io/x/pkg/util/compare"
|
||||
"yunion.io/x/pkg/util/fileutils"
|
||||
"yunion.io/x/pkg/util/sets"
|
||||
"yunion.io/x/pkg/utils"
|
||||
"yunion.io/x/sqlchemy"
|
||||
@@ -859,9 +858,16 @@ func (self *SDisk) AllowPerformResize(ctx context.Context, userCred mcclient.Tok
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "resize")
|
||||
}
|
||||
|
||||
func (disk *SDisk) PerformResize(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
func (disk *SDisk) PerformResize(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.DiskResizeInput) (jsonutils.JSONObject, error) {
|
||||
guest := disk.GetGuest()
|
||||
err := disk.doResize(ctx, userCred, data, guest)
|
||||
if guest != nil {
|
||||
return nil, httperrors.NewUnsupportOperationError("try use /servers/<%s>/resize-disk API", guest.Id)
|
||||
}
|
||||
sizeMb, err := input.SizeMb()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = disk.doResize(ctx, userCred, sizeMb, guest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -902,15 +908,7 @@ func (disk *SDisk) GetQuotaKeys() (quotas.IQuotaKeys, error) {
|
||||
), nil
|
||||
}
|
||||
|
||||
func (disk *SDisk) doResize(ctx context.Context, userCred mcclient.TokenCredential, data jsonutils.JSONObject, guest *SGuest) error {
|
||||
sizeStr, err := data.GetString("size")
|
||||
if err != nil {
|
||||
return httperrors.NewMissingParameterError("size")
|
||||
}
|
||||
sizeMb, err := fileutils.GetSizeMb(sizeStr, 'M', 1024)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
func (disk *SDisk) doResize(ctx context.Context, userCred mcclient.TokenCredential, sizeMb int, guest *SGuest) error {
|
||||
if disk.Status != api.DISK_READY {
|
||||
return httperrors.NewResourceNotReadyError("Resize disk when disk is READY")
|
||||
}
|
||||
@@ -1248,42 +1246,34 @@ func (manager *SDiskManager) getDisksByStorage(storage *SStorage) ([]SDisk, erro
|
||||
}
|
||||
|
||||
func (manager *SDiskManager) syncCloudDisk(ctx context.Context, userCred mcclient.TokenCredential, provider cloudprovider.ICloudProvider, vdisk cloudprovider.ICloudDisk, index int, syncOwnerId mcclient.IIdentityProvider, managerId string) (*SDisk, error) {
|
||||
// ownerProjId := projectId
|
||||
|
||||
lockman.LockClass(ctx, manager, db.GetLockClassKey(manager, syncOwnerId))
|
||||
defer lockman.ReleaseClass(ctx, manager, db.GetLockClassKey(manager, syncOwnerId))
|
||||
|
||||
diskObj, err := db.FetchByExternalIdAndManagerId(manager, vdisk.GetGlobalId(), func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
sq := StorageManager.Query().SubQuery()
|
||||
return q.Join(sq, sqlchemy.Equals(sq.Field("id"), q.Field("storage_id"))).Filter(sqlchemy.Equals(sq.Field("manager_id"), managerId))
|
||||
})
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
vstorage, err := vdisk.GetIStorage()
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "unable to GetIStorage of vdisk %q", vdisk.GetName())
|
||||
}
|
||||
|
||||
storageObj, err := db.FetchByExternalIdAndManagerId(StorageManager, vstorage.GetGlobalId(), func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
return q.Equals("manager_id", managerId)
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("cannot find storage of vdisk %s", err)
|
||||
return nil, err
|
||||
}
|
||||
storage := storageObj.(*SStorage)
|
||||
return manager.newFromCloudDisk(ctx, userCred, provider, vdisk, storage, -1, syncOwnerId)
|
||||
} else {
|
||||
return nil, err
|
||||
if errors.Cause(err) != sql.ErrNoRows {
|
||||
return nil, errors.Wrapf(err, "db.FetchByExternalIdAndManagerId")
|
||||
}
|
||||
} else {
|
||||
disk := diskObj.(*SDisk)
|
||||
err = disk.syncWithCloudDisk(ctx, userCred, provider, vdisk, index, syncOwnerId, managerId)
|
||||
vstorage, err := vdisk.GetIStorage()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, errors.Wrapf(err, "unable to GetIStorage of vdisk %q", vdisk.GetName())
|
||||
}
|
||||
return disk, nil
|
||||
|
||||
storageObj, err := db.FetchByExternalIdAndManagerId(StorageManager, vstorage.GetGlobalId(), func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
return q.Equals("manager_id", managerId)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "cannot find storage of vdisk %s", vdisk.GetName())
|
||||
}
|
||||
storage := storageObj.(*SStorage)
|
||||
return manager.newFromCloudDisk(ctx, userCred, provider, vdisk, storage, -1, syncOwnerId)
|
||||
}
|
||||
disk := diskObj.(*SDisk)
|
||||
err = disk.syncWithCloudDisk(ctx, userCred, provider, vdisk, index, syncOwnerId, managerId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "syncWithCloudDisk")
|
||||
}
|
||||
return disk, nil
|
||||
}
|
||||
|
||||
func (manager *SDiskManager) SyncDisks(ctx context.Context, userCred mcclient.TokenCredential, provider cloudprovider.ICloudProvider, storage *SStorage, disks []cloudprovider.ICloudDisk, syncOwnerId mcclient.IIdentityProvider) ([]SDisk, []cloudprovider.ICloudDisk, compare.SyncResult) {
|
||||
@@ -1327,7 +1317,6 @@ func (manager *SDiskManager) SyncDisks(ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
syncResult.UpdateError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, &commondb[i], commonext[i])
|
||||
localDisks = append(localDisks, commondb[i])
|
||||
remoteDisks = append(remoteDisks, commonext[i])
|
||||
syncResult.Update()
|
||||
@@ -1360,7 +1349,6 @@ func (manager *SDiskManager) SyncDisks(ctx context.Context, userCred mcclient.To
|
||||
if err != nil {
|
||||
syncResult.AddError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, new, added[i])
|
||||
localDisks = append(localDisks, *new)
|
||||
remoteDisks = append(remoteDisks, added[i])
|
||||
syncResult.Add()
|
||||
@@ -1371,19 +1359,16 @@ func (manager *SDiskManager) SyncDisks(ctx context.Context, userCred mcclient.To
|
||||
}
|
||||
|
||||
func (self *SDisk) syncDiskStorage(ctx context.Context, userCred mcclient.TokenCredential, idisk cloudprovider.ICloudDisk, managerId string) error {
|
||||
extId := idisk.GetGlobalId()
|
||||
istorage, err := idisk.GetIStorage()
|
||||
if err != nil {
|
||||
log.Errorf("failed to get istorage for disk %s error: %v", extId, err)
|
||||
return err
|
||||
return errors.Wrapf(err, "idisk.GetIStorage %s", idisk.GetGlobalId())
|
||||
}
|
||||
storageExtId := istorage.GetGlobalId()
|
||||
storage, err := db.FetchByExternalIdAndManagerId(StorageManager, storageExtId, func(q *sqlchemy.SQuery) *sqlchemy.SQuery {
|
||||
return q.Equals("manager_id", managerId)
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("failed to found storage by istorage %s error: %v", storageExtId, err)
|
||||
return err
|
||||
return errors.Wrapf(err, "storage db.FetchByExternalIdAndManagerId(%s)", storageExtId)
|
||||
}
|
||||
diff, err := db.UpdateWithLock(ctx, self, func() error {
|
||||
self.StorageId = storage.GetId()
|
||||
@@ -1391,8 +1376,7 @@ func (self *SDisk) syncDiskStorage(ctx context.Context, userCred mcclient.TokenC
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("syncWithCloudDisk error %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "db.UpdateWithLock")
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
return nil
|
||||
@@ -1515,8 +1499,7 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("syncWithCloudDisk error %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "db.UpdateWithLock")
|
||||
}
|
||||
|
||||
// sync disk's snapshotpolicy
|
||||
@@ -1534,7 +1517,13 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extDisk, storage.ManagerId)
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extDisk)
|
||||
|
||||
if len(guests) == 0 {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extDisk, storage.ManagerId)
|
||||
} else {
|
||||
self.SyncCloudProjectId(userCred, guests[0].GetOwnerId())
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -1591,6 +1580,8 @@ func (manager *SDiskManager) newFromCloudDisk(ctx context.Context, userCred mccl
|
||||
return nil, err
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &disk, extDisk)
|
||||
|
||||
SyncCloudProject(userCred, &disk, syncOwnerId, extDisk, storage.ManagerId)
|
||||
|
||||
db.OpsLog.LogEvent(&disk, db.ACT_CREATE, disk.GetShortDesc(ctx), userCred)
|
||||
|
||||
@@ -379,16 +379,14 @@ func (manager *SElasticipManager) SyncEips(ctx context.Context, userCred mcclien
|
||||
if err != nil {
|
||||
syncResult.UpdateError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, &commondb[i], commonext[i])
|
||||
syncResult.Update()
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(added); i += 1 {
|
||||
new, err := manager.newFromCloudEip(ctx, userCred, added[i], provider, region, syncOwnerId)
|
||||
_, err := manager.newFromCloudEip(ctx, userCred, added[i], provider, region, syncOwnerId)
|
||||
if err != nil {
|
||||
syncResult.AddError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, new, added[i])
|
||||
syncResult.Add()
|
||||
}
|
||||
}
|
||||
@@ -493,8 +491,7 @@ func (self *SElasticip) SyncWithCloudEip(ctx context.Context, userCred mcclient.
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
log.Errorf("SyncWithCloudEip fail %s", err)
|
||||
return err
|
||||
return errors.Wrapf(err, "db.UpdateWithLock")
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
@@ -502,7 +499,13 @@ func (self *SElasticip) SyncWithCloudEip(ctx context.Context, userCred mcclient.
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "fail to sync associated instance of EIP")
|
||||
}
|
||||
SyncCloudProject(userCred, self, syncOwnerId, ext, self.ManagerId)
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
|
||||
if res := self.GetAssociateResource(); res != nil {
|
||||
self.SyncCloudProjectId(userCred, res.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, ext, self.ManagerId)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -550,13 +553,19 @@ func (manager *SElasticipManager) newFromCloudEip(ctx context.Context, userCred
|
||||
return nil, err
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &eip, syncOwnerId, extEip, eip.ManagerId)
|
||||
|
||||
err = eip.SyncInstanceWithCloudEip(ctx, userCred, extEip)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "fail to sync associated instance of EIP")
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &eip, extEip)
|
||||
|
||||
if res := eip.GetAssociateResource(); res != nil {
|
||||
eip.SyncCloudProjectId(userCred, res.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, &eip, syncOwnerId, extEip, eip.ManagerId)
|
||||
}
|
||||
|
||||
db.OpsLog.LogEvent(&eip, db.ACT_CREATE, eip.GetShortDesc(ctx), userCred)
|
||||
|
||||
return &eip, nil
|
||||
|
||||
@@ -358,31 +358,129 @@ func (self *SGuest) CheckQemuVersion(qemuVer, compareVer string) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (self *SGuest) validateMigrate(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
migrateInput *api.GuestMigrateInput,
|
||||
liveMigrateInput *api.GuestLiveMigrateInput,
|
||||
) error {
|
||||
isLiveMigrate := false
|
||||
if liveMigrateInput != nil {
|
||||
isLiveMigrate = true
|
||||
}
|
||||
|
||||
if isLiveMigrate {
|
||||
// do live migrate check
|
||||
if !self.GetDriver().IsSupportLiveMigrate() {
|
||||
return httperrors.NewNotAcceptableError("Not allow for hypervisor %s", self.GetHypervisor())
|
||||
}
|
||||
if err := self.GetDriver().CheckLiveMigrate(self, userCred, *liveMigrateInput); err != nil {
|
||||
return err
|
||||
}
|
||||
if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_SUSPEND}) {
|
||||
if len(liveMigrateInput.PreferHost) > 0 {
|
||||
iHost, _ := HostManager.FetchByIdOrName(userCred, liveMigrateInput.PreferHost)
|
||||
if iHost == nil {
|
||||
return httperrors.NewBadRequestError("Host %s not found", liveMigrateInput.PreferHost)
|
||||
}
|
||||
host := iHost.(*SHost)
|
||||
liveMigrateInput.PreferHost = host.Id
|
||||
}
|
||||
return nil
|
||||
}
|
||||
return httperrors.NewBadRequestError("Cannot live migrate in status %s", self.Status)
|
||||
} else {
|
||||
// do migrate check
|
||||
if !self.GetDriver().IsSupportMigrate() {
|
||||
return httperrors.NewNotAcceptableError("Not allow for hypervisor %s", self.GetHypervisor())
|
||||
}
|
||||
if !migrateInput.IsRescueMode && self.Status != api.VM_READY {
|
||||
return httperrors.NewServerStatusError("Cannot normal migrate guest in status %s, try rescue mode or server-live-migrate?", self.Status)
|
||||
}
|
||||
if err := self.GetDriver().CheckMigrate(self, userCred, *migrateInput); err != nil {
|
||||
return err
|
||||
}
|
||||
if len(migrateInput.PreferHost) > 0 {
|
||||
iHost, _ := HostManager.FetchByIdOrName(userCred, migrateInput.PreferHost)
|
||||
if iHost == nil {
|
||||
return httperrors.NewBadRequestError("Host %s not found", migrateInput.PreferHost)
|
||||
}
|
||||
host := iHost.(*SHost)
|
||||
migrateInput.PreferHost = host.Id
|
||||
}
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SGuest) PerformMigrateForecast(ctx context.Context, userCred mcclient.TokenCredential, _ jsonutils.JSONObject, input *api.ServerMigrateForecastInput) (jsonutils.JSONObject, error) {
|
||||
var (
|
||||
mInput *api.GuestMigrateInput = nil
|
||||
lmInput *api.GuestLiveMigrateInput = nil
|
||||
)
|
||||
|
||||
if input.LiveMigrate {
|
||||
lmInput = &api.GuestLiveMigrateInput{
|
||||
PreferHost: input.PreferHostId,
|
||||
SkipCpuCheck: &input.SkipCpuCheck,
|
||||
}
|
||||
if err := self.validateMigrate(ctx, userCred, nil, lmInput); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
input.PreferHostId = lmInput.PreferHost
|
||||
} else {
|
||||
mInput = &api.GuestMigrateInput{
|
||||
PreferHost: input.PreferHostId,
|
||||
}
|
||||
if err := self.validateMigrate(ctx, userCred, mInput, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
input.PreferHostId = mInput.PreferHost
|
||||
}
|
||||
|
||||
schedParams := self.GetSchedMigrateParams(userCred, input)
|
||||
s := auth.GetAdminSession(ctx, options.Options.Region, "")
|
||||
_, res, err := modules.SchedManager.DoScheduleForecast(s, schedParams, 1)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "Do schedule migrate forecast")
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
||||
|
||||
func (self *SGuest) GetSchedMigrateParams(
|
||||
userCred mcclient.TokenCredential,
|
||||
input *api.ServerMigrateForecastInput,
|
||||
) *schedapi.ScheduleInput {
|
||||
schedDesc := self.ToSchedDesc()
|
||||
if input.PreferHostId != "" {
|
||||
schedDesc.ServerConfig.PreferHost = input.PreferHostId
|
||||
}
|
||||
if input.LiveMigrate {
|
||||
schedDesc.LiveMigrate = input.LiveMigrate
|
||||
if self.GetMetadata("__cpu_mode", userCred) != api.CPU_MODE_QEMU {
|
||||
host := self.GetHost()
|
||||
schedDesc.CpuDesc = host.CpuDesc
|
||||
schedDesc.CpuMicrocode = host.CpuMicrocode
|
||||
schedDesc.CpuMode = api.CPU_MODE_HOST
|
||||
} else {
|
||||
schedDesc.CpuMode = api.CPU_MODE_QEMU
|
||||
}
|
||||
schedDesc.SkipCpuCheck = &input.SkipCpuCheck
|
||||
}
|
||||
schedDesc.ReuseNetwork = true
|
||||
return schedDesc
|
||||
}
|
||||
|
||||
func (self *SGuest) AllowPerformMigrate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.GuestMigrateInput) bool {
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "migrate")
|
||||
}
|
||||
|
||||
func (self *SGuest) PerformMigrate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.GuestMigrateInput) (jsonutils.JSONObject, error) {
|
||||
if !self.GetDriver().IsSupportMigrate() {
|
||||
return nil, httperrors.NewNotAcceptableError("Not allow for hypervisor %s", self.GetHypervisor())
|
||||
}
|
||||
if err := self.GetDriver().CheckMigrate(self, userCred, input); err != nil {
|
||||
func (self *SGuest) PerformMigrate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input *api.GuestMigrateInput) (jsonutils.JSONObject, error) {
|
||||
if err := self.validateMigrate(ctx, userCred, input, nil); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if self.Status != api.VM_READY {
|
||||
return nil, httperrors.NewServerStatusError("Cannot normal migrate guest in status %s, try rescue mode or server-live-migrate?", self.Status)
|
||||
}
|
||||
var preferHostId string
|
||||
if len(input.PreferHost) > 0 {
|
||||
iHost, _ := HostManager.FetchByIdOrName(userCred, input.PreferHost)
|
||||
if iHost == nil {
|
||||
return nil, httperrors.NewBadRequestError("Host %s not found", input.PreferHost)
|
||||
}
|
||||
host := iHost.(*SHost)
|
||||
preferHostId = host.Id
|
||||
}
|
||||
|
||||
return nil, self.StartMigrateTask(ctx, userCred, input.IsRescueMode, input.AutoStart, self.Status, preferHostId, "")
|
||||
return nil, self.StartMigrateTask(ctx, userCred, input.IsRescueMode, input.AutoStart, self.Status, input.PreferHost, "")
|
||||
}
|
||||
|
||||
func (self *SGuest) StartMigrateTask(
|
||||
@@ -418,27 +516,11 @@ func (self *SGuest) AllowPerformLiveMigrate(ctx context.Context, userCred mcclie
|
||||
return self.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, self, "live-migrate")
|
||||
}
|
||||
|
||||
func (self *SGuest) PerformLiveMigrate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.GuestLiveMigrateInput) (jsonutils.JSONObject, error) {
|
||||
if !self.GetDriver().IsSupportLiveMigrate() {
|
||||
return nil, httperrors.NewNotAcceptableError("Not allow for hypervisor %s", self.GetHypervisor())
|
||||
}
|
||||
if err := self.GetDriver().CheckLiveMigrate(self, userCred, input); err != nil {
|
||||
func (self *SGuest) PerformLiveMigrate(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input *api.GuestLiveMigrateInput) (jsonutils.JSONObject, error) {
|
||||
if err := self.validateMigrate(ctx, userCred, nil, input); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if utils.IsInStringArray(self.Status, []string{api.VM_RUNNING, api.VM_SUSPEND}) {
|
||||
var preferHostId string
|
||||
if len(input.PreferHost) > 0 {
|
||||
iHost, _ := HostManager.FetchByIdOrName(userCred, input.PreferHost)
|
||||
if iHost == nil {
|
||||
return nil, httperrors.NewBadRequestError("Host %s not found", input.PreferHost)
|
||||
}
|
||||
host := iHost.(*SHost)
|
||||
preferHostId = host.Id
|
||||
}
|
||||
err := self.StartGuestLiveMigrateTask(ctx, userCred, self.Status, preferHostId, input.SkipCpuCheck, "")
|
||||
return nil, err
|
||||
}
|
||||
return nil, httperrors.NewBadRequestError("Cannot live migrate in status %s", self.Status)
|
||||
return nil, self.StartGuestLiveMigrateTask(ctx, userCred, self.Status, input.PreferHost, input.SkipCpuCheck, "")
|
||||
}
|
||||
|
||||
func (self *SGuest) StartGuestLiveMigrateTask(ctx context.Context, userCred mcclient.TokenCredential, guestStatus, preferHostId string, skipCpuCheck *bool, parentTaskId string) error {
|
||||
@@ -4418,25 +4500,24 @@ func (guest *SGuest) AllowPerformResizeDisk(ctx context.Context, userCred mcclie
|
||||
return guest.IsOwner(userCred) || db.IsAdminAllowPerform(userCred, guest, "resize-disk")
|
||||
}
|
||||
|
||||
func (guest *SGuest) PerformResizeDisk(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
diskStr, _ := data.GetString("disk")
|
||||
if len(diskStr) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("disk")
|
||||
func (guest *SGuest) PerformResizeDisk(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input api.ServerResizeDiskInput) (jsonutils.JSONObject, error) {
|
||||
if len(input.DiskId) == 0 {
|
||||
return nil, httperrors.NewMissingParameterError("disk_id")
|
||||
}
|
||||
diskObj, err := DiskManager.FetchByIdOrName(userCred, diskStr)
|
||||
diskObj, err := validators.ValidateModel(userCred, DiskManager, &input.DiskId)
|
||||
if err != nil {
|
||||
if err == sql.ErrNoRows {
|
||||
return nil, httperrors.NewResourceNotFoundError2(DiskManager.Keyword(), diskStr)
|
||||
} else {
|
||||
return nil, httperrors.NewGeneralError(err)
|
||||
}
|
||||
return nil, err
|
||||
}
|
||||
guestdisk := guest.GetGuestDisk(diskObj.GetId())
|
||||
guestdisk := guest.GetGuestDisk(input.DiskId)
|
||||
if guestdisk == nil {
|
||||
return nil, httperrors.NewInvalidStatusError("disk %s not attached to server", diskStr)
|
||||
return nil, httperrors.NewInvalidStatusError("disk %s not attached to server", input.DiskId)
|
||||
}
|
||||
disk := diskObj.(*SDisk)
|
||||
err = disk.doResize(ctx, userCred, data, guest)
|
||||
sizeMb, err := input.SizeMb()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
err = disk.doResize(ctx, userCred, sizeMb, guest)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -2579,6 +2579,7 @@ func (self *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.Token
|
||||
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extVM)
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extVM, host.ManagerId)
|
||||
|
||||
if provider.GetFactory().IsSupportPrepaidResources() && recycle {
|
||||
@@ -3263,9 +3264,9 @@ func (self *SGuest) SyncVMDisks(ctx context.Context, userCred mcclient.TokenCred
|
||||
vdisk := needAdds[i].vdisk
|
||||
err := self.attach2Disk(ctx, needAdds[i].disk, userCred, vdisk.GetDriver(), vdisk.GetCacheMode(), vdisk.GetMountpoint())
|
||||
if err != nil {
|
||||
log.Errorf("attach2Disk error: %v", err)
|
||||
result.AddError(err)
|
||||
result.AddError(errors.Wrapf(err, "attach2Disk"))
|
||||
} else {
|
||||
needAdds[i].disk.SyncCloudProjectId(userCred, self.GetOwnerId())
|
||||
result.Add()
|
||||
}
|
||||
}
|
||||
@@ -4954,13 +4955,11 @@ func (self *SGuest) SyncVMEip(ctx context.Context, userCred mcclient.TokenCreden
|
||||
// add
|
||||
neip, err := ElasticipManager.getEipByExtEip(ctx, userCred, extEip, provider, self.getRegion(), syncOwnerId)
|
||||
if err != nil {
|
||||
log.Errorf("getEipByExtEip error %v", err)
|
||||
result.AddError(err)
|
||||
result.AddError(errors.Wrapf(err, "getEipByExtEip"))
|
||||
} else {
|
||||
err = neip.AssociateInstance(ctx, userCred, api.EIP_ASSOCIATE_TYPE_SERVER, self)
|
||||
if err != nil {
|
||||
log.Errorf("AssociateVM error %v", err)
|
||||
result.AddError(err)
|
||||
result.AddError(errors.Wrapf(err, "neip.AssociateInstance"))
|
||||
} else {
|
||||
result.Add()
|
||||
}
|
||||
|
||||
@@ -325,7 +325,7 @@ func (man *SCachedLoadbalancerCertificateManager) newFromCloudLoadbalancerCertif
|
||||
if err != nil {
|
||||
switch err {
|
||||
case sql.ErrNoRows:
|
||||
localcert, err := LoadbalancerCertificateManager.CreateCertificate(ctx, userCred, provider, lbcert.Name, extCertificate)
|
||||
localcert, err := LoadbalancerCertificateManager.CreateCertificate(ctx, userCred, provider, extCertificate.GetName(), extCertificate)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("newFromCloudLoadbalancerCertificate CreateCertificate %s", err)
|
||||
}
|
||||
@@ -584,7 +584,7 @@ func (manager *SCachedLoadbalancerCertificateManager) ListItemExportKeys(ctx con
|
||||
}
|
||||
|
||||
func (man *SCachedLoadbalancerCertificateManager) InitializeData() error {
|
||||
certs := man.Query().SubQuery()
|
||||
certs := man.Query().IsFalse("pending_deleted").SubQuery()
|
||||
sq := certs.Query(certs.Field("id"), certs.Field("external_id"), sqlchemy.COUNT("external_id").Label("total"))
|
||||
sq2 := sq.GroupBy("external_id").SubQuery()
|
||||
sq3 := sq2.Query(sq2.Field("external_id")).GT("total", 1).SubQuery()
|
||||
|
||||
@@ -77,7 +77,7 @@ type SLoadbalancerCertificate struct {
|
||||
|
||||
func (lbcert *SLoadbalancerCertificate) GetCachedCerts() ([]SCachedLoadbalancerCertificate, error) {
|
||||
ret := []SCachedLoadbalancerCertificate{}
|
||||
q := CachedLoadbalancerCertificateManager.Query().Equals("certificate_id", lbcert.Id)
|
||||
q := CachedLoadbalancerCertificateManager.Query().Equals("certificate_id", lbcert.Id).IsFalse("pending_deleted")
|
||||
err := db.FetchModelObjects(CachedLoadbalancerCertificateManager, q, &ret)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -131,6 +131,10 @@ func (lbcert *SLoadbalancerCertificate) GetExtraDetails(
|
||||
return api.LoadbalancerCertificateDetails{}, nil
|
||||
}
|
||||
|
||||
func (lbcert *SLoadbalancerCertificate) IsComplete() bool {
|
||||
return lbcert.PrivateKey != "" && lbcert.Certificate != ""
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancerCertificateManager) FetchCustomizeColumns(
|
||||
ctx context.Context,
|
||||
userCred mcclient.TokenCredential,
|
||||
@@ -146,6 +150,7 @@ func (manager *SLoadbalancerCertificateManager) FetchCustomizeColumns(
|
||||
for i := range rows {
|
||||
rows[i] = api.LoadbalancerCertificateDetails{
|
||||
SharableVirtualResourceDetails: virtRows[i],
|
||||
IsComplete: objs[i].(*SLoadbalancerCertificate).IsComplete(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -703,7 +703,6 @@ func (manager *SNetworkManager) SyncNetworks(ctx context.Context, userCred mccli
|
||||
if err != nil {
|
||||
syncResult.UpdateError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, &commondb[i], commonext[i])
|
||||
localNets = append(localNets, commondb[i])
|
||||
remoteNets = append(remoteNets, commonext[i])
|
||||
syncResult.Update()
|
||||
@@ -714,7 +713,6 @@ func (manager *SNetworkManager) SyncNetworks(ctx context.Context, userCred mccli
|
||||
if err != nil {
|
||||
syncResult.AddError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, new, added[i])
|
||||
localNets = append(localNets, *new)
|
||||
remoteNets = append(remoteNets, added[i])
|
||||
syncResult.Add()
|
||||
@@ -763,6 +761,7 @@ func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclien
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extNet)
|
||||
SyncCloudProject(userCred, self, syncOwnerId, extNet, vpc.ManagerId)
|
||||
|
||||
if provider != nil {
|
||||
@@ -812,6 +811,7 @@ func (manager *SNetworkManager) newFromCloudNetwork(ctx context.Context, userCre
|
||||
}
|
||||
|
||||
vpc := wire.GetVpc()
|
||||
syncVirtualResourceMetadata(ctx, userCred, &net, extNet)
|
||||
SyncCloudProject(userCred, &net, syncOwnerId, extNet, vpc.ManagerId)
|
||||
|
||||
if provider != nil {
|
||||
|
||||
@@ -105,6 +105,8 @@ func (manager *SProjectMappingManager) ValidateCreateData(
|
||||
return input, err
|
||||
}
|
||||
input.Rules[i].DomainId = tenant.DomainId
|
||||
input.Rules[i].Domain = tenant.Domain
|
||||
input.Rules[i].Project = tenant.Name
|
||||
}
|
||||
}
|
||||
input.SetEnabled()
|
||||
@@ -132,97 +134,38 @@ func (manager *SProjectMappingManager) FetchCustomizeColumns(
|
||||
rows := make([]api.ProjectMappingDetails, len(objs))
|
||||
stdRows := manager.SEnabledStatusInfrasResourceBaseManager.FetchCustomizeColumns(ctx, userCred, query, objs, fields, isList)
|
||||
mpIds := make([]string, len(objs))
|
||||
projIds := []string{}
|
||||
domainIds := []string{}
|
||||
for i := range rows {
|
||||
rows[i] = api.ProjectMappingDetails{
|
||||
EnabledStatusInfrasResourceBaseDetails: stdRows[i],
|
||||
}
|
||||
mp := objs[i].(*SProjectMapping)
|
||||
mpIds[i] = mp.Id
|
||||
if mp.Rules != nil {
|
||||
for _, r := range *mp.Rules {
|
||||
if len(r.ProjectId) > 0 {
|
||||
projIds = append(projIds, r.ProjectId)
|
||||
domainIds = append(domainIds, r.DomainId)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
q := db.DefaultDomainQuery("domain", "domain_id").In("domain_id", domainIds)
|
||||
domains := []struct {
|
||||
DomainId string
|
||||
Domain string
|
||||
}{}
|
||||
err := q.All(&domainIds)
|
||||
if err != nil {
|
||||
return rows
|
||||
}
|
||||
domainMaps := map[string]string{}
|
||||
for _, domain := range domains {
|
||||
domainMaps[domain.DomainId] = domain.Domain
|
||||
}
|
||||
q = db.DefaultProjectQuery("id", "name").In("id", projIds)
|
||||
projects := []struct {
|
||||
Id string
|
||||
Name string
|
||||
}{}
|
||||
err = q.All(&projects)
|
||||
if err != nil {
|
||||
return rows
|
||||
}
|
||||
projectMaps := map[string]string{}
|
||||
for _, proj := range projects {
|
||||
projectMaps[proj.Id] = proj.Name
|
||||
}
|
||||
accounts := []struct {
|
||||
Id string
|
||||
Name string
|
||||
ProjectMappingId string
|
||||
}{}
|
||||
q = CloudaccountManager.Query().In("project_mapping_id", mpIds)
|
||||
err = q.All(&accounts)
|
||||
q := CloudaccountManager.Query().In("project_mapping_id", mpIds)
|
||||
err := q.All(&accounts)
|
||||
if err != nil {
|
||||
return rows
|
||||
}
|
||||
accountMapping := map[string][]struct {
|
||||
Id string
|
||||
Name string
|
||||
}{}
|
||||
accountMapping := map[string][]api.SProjectMappingAccount{}
|
||||
for i := range accounts {
|
||||
_, ok := accountMapping[accounts[i].ProjectMappingId]
|
||||
if !ok {
|
||||
accountMapping[accounts[i].ProjectMappingId] = []struct {
|
||||
Id string
|
||||
Name string
|
||||
}{}
|
||||
accountMapping[accounts[i].ProjectMappingId] = []api.SProjectMappingAccount{}
|
||||
}
|
||||
accountMapping[accounts[i].ProjectMappingId] = append(accountMapping[accounts[i].ProjectMappingId],
|
||||
struct {
|
||||
Id string
|
||||
Name string
|
||||
}{
|
||||
Id: accounts[i].Id,
|
||||
Name: accounts[i].Name,
|
||||
})
|
||||
account := api.SProjectMappingAccount{
|
||||
Id: accounts[i].Id,
|
||||
Name: accounts[i].Name,
|
||||
}
|
||||
accountMapping[accounts[i].ProjectMappingId] = append(accountMapping[accounts[i].ProjectMappingId], account)
|
||||
}
|
||||
|
||||
for i := range rows {
|
||||
mp := objs[i].(*SProjectMapping)
|
||||
rows[i].Accounts, _ = accountMapping[mpIds[i]]
|
||||
if mp.Rules != nil {
|
||||
rows[i].Rules = []api.ProjectMappingRuleInfoDetails{}
|
||||
for j := range *mp.Rules {
|
||||
rules := *mp.Rules
|
||||
rule := api.ProjectMappingRuleInfoDetails{
|
||||
ProjectMappingRuleInfo: rules[j],
|
||||
}
|
||||
rule.Tenant, _ = projectMaps[rules[j].ProjectId]
|
||||
rule.Project = rule.Tenant
|
||||
rule.Domain, _ = domainMaps[rules[j].DomainId]
|
||||
rows[i].Rules = append(rows[i].Rules, rule)
|
||||
}
|
||||
}
|
||||
}
|
||||
return rows
|
||||
}
|
||||
@@ -275,6 +218,8 @@ func (self *SProjectMapping) ValidateUpdateData(ctx context.Context, userCred mc
|
||||
return input, err
|
||||
}
|
||||
input.Rules[i].DomainId = tenant.DomainId
|
||||
input.Rules[i].Domain = tenant.Domain
|
||||
input.Rules[i].Project = tenant.Name
|
||||
}
|
||||
}
|
||||
input.EnabledStatusInfrasResourceBaseUpdateInput, err = self.SEnabledStatusInfrasResourceBase.ValidateUpdateData(ctx, userCred, query, input.EnabledStatusInfrasResourceBaseUpdateInput)
|
||||
@@ -316,3 +261,29 @@ func (self *SProjectMapping) refreshMapping() error {
|
||||
projectRuleMapping[self.Id] = self
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SProjectMapping) AllowPerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) bool {
|
||||
return db.IsDomainAllowPerform(userCred, self, "enable")
|
||||
}
|
||||
|
||||
// 启用资源映射
|
||||
func (self *SProjectMapping) PerformEnable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformEnableInput) (jsonutils.JSONObject, error) {
|
||||
_, err := self.SEnabledStatusInfrasResourceBase.PerformEnable(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, self.refreshMapping()
|
||||
}
|
||||
|
||||
func (self *SProjectMapping) AllowPerformDisable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformDisableInput) bool {
|
||||
return db.IsDomainAllowPerform(userCred, self, "disable")
|
||||
}
|
||||
|
||||
// 禁用资源映射
|
||||
func (self *SProjectMapping) PerformDisable(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, input apis.PerformDisableInput) (jsonutils.JSONObject, error) {
|
||||
_, err := self.SEnabledStatusInfrasResourceBase.PerformDisable(ctx, userCred, query, input)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return nil, self.refreshMapping()
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ import (
|
||||
"yunion.io/x/onecloud/pkg/util/rbacutils"
|
||||
)
|
||||
|
||||
var LB_CERTS_TO_BE_PURGE = map[string][]string{}
|
||||
|
||||
type IPurgeableManager interface {
|
||||
Keyword() string
|
||||
purgeAll(ctx context.Context, userCred mcclient.TokenCredential, providerId string) error
|
||||
@@ -195,12 +197,23 @@ func (manager *SCachedLoadbalancerCertificateManager) purgeAll(ctx context.Conte
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
lbcertIds := []string{}
|
||||
if certs, ok := LB_CERTS_TO_BE_PURGE[providerId]; ok {
|
||||
lbcertIds = certs
|
||||
}
|
||||
|
||||
for i := range lbcs {
|
||||
err := lbcs[i].purge(ctx, userCred)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if len(lbcs[i].CertificateId) > 0 && !utils.IsInStringArray(lbcs[i].CertificateId, lbcertIds) {
|
||||
lbcertIds = append(lbcertIds, lbcs[i].CertificateId)
|
||||
}
|
||||
}
|
||||
LB_CERTS_TO_BE_PURGE[providerId] = lbcertIds
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -216,6 +229,50 @@ func (lbcert *SCachedLoadbalancerCertificate) purge(ctx context.Context, userCre
|
||||
return lbcert.DoPendingDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (manager *SLoadbalancerCertificateManager) purgeAll(ctx context.Context, userCred mcclient.TokenCredential, providerId string) error {
|
||||
if certs, ok := LB_CERTS_TO_BE_PURGE[providerId]; ok {
|
||||
lbcs := make([]SLoadbalancerCertificate, 0)
|
||||
err := db.FetchModelObjects(manager, manager.Query().In("id", certs), &lbcs)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for i := range lbcs {
|
||||
err := lbcs[i].purge(ctx, userCred)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
delete(LB_CERTS_TO_BE_PURGE, providerId)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (lbcert *SLoadbalancerCertificate) purge(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
lockman.LockObject(ctx, lbcert)
|
||||
defer lockman.ReleaseObject(ctx, lbcert)
|
||||
|
||||
if !lbcert.PendingDeleted {
|
||||
// 内容完整的证书不需要删除
|
||||
if lbcert.IsComplete() {
|
||||
return nil
|
||||
}
|
||||
|
||||
caches, err := lbcert.GetCachedCerts()
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "GetCachedCerts")
|
||||
}
|
||||
|
||||
if len(caches) > 0 {
|
||||
log.Debugf("the lb cert %s (%s) is in use.can not purge.", lbcert.Name, lbcert.Id)
|
||||
return nil
|
||||
}
|
||||
return lbcert.DoPendingDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (manager *SCachedLoadbalancerAclManager) purgeAll(ctx context.Context, userCred mcclient.TokenCredential, providerId string) error {
|
||||
lbacls := make([]SCachedLoadbalancerAcl, 0)
|
||||
err := fetchByManagerId(manager, providerId, &lbacls)
|
||||
|
||||
@@ -890,13 +890,14 @@ func (self *SSnapshot) SyncWithCloudSnapshot(ctx context.Context, userCred mccli
|
||||
}
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
|
||||
// bugfix for now:
|
||||
disk, err := self.GetDisk()
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return errors.Wrapf(err, "get disk of snapshot %s error", self.Id)
|
||||
}
|
||||
if err == nil {
|
||||
disk, _ := self.GetDisk()
|
||||
if disk != nil {
|
||||
self.SyncCloudProjectId(userCred, disk.GetOwnerId())
|
||||
} else {
|
||||
SyncCloudProject(userCred, self, syncOwnerId, ext, disk.GetCloudprovider().Id)
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -938,6 +939,8 @@ func (manager *SSnapshotManager) newFromCloudSnapshot(ctx context.Context, userC
|
||||
return nil, err
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &snapshot, extSnapshot)
|
||||
|
||||
// bugfix for now:
|
||||
if localDisk != nil {
|
||||
snapshot.SyncCloudProjectId(userCred, localDisk.GetOwnerId())
|
||||
@@ -996,16 +999,14 @@ func (manager *SSnapshotManager) SyncSnapshots(ctx context.Context, userCred mcc
|
||||
if err != nil {
|
||||
syncResult.UpdateError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, &commondb[i], commonext[i])
|
||||
syncResult.Update()
|
||||
}
|
||||
}
|
||||
for i := 0; i < len(added); i += 1 {
|
||||
local, err := manager.newFromCloudSnapshot(ctx, userCred, added[i], region, syncOwnerId, provider)
|
||||
_, err := manager.newFromCloudSnapshot(ctx, userCred, added[i], region, syncOwnerId, provider)
|
||||
if err != nil {
|
||||
syncResult.AddError(err)
|
||||
} else {
|
||||
syncVirtualResourceMetadata(ctx, userCred, local, added[i])
|
||||
syncResult.Add()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1476,6 +1476,11 @@ func (manager *SStorageManager) ListItemFilter(
|
||||
q = q.In("id", subq.SubQuery())
|
||||
}
|
||||
|
||||
if len(query.HostId) > 0 {
|
||||
sq := HoststorageManager.Query("storage_id").Equals("host_id", query.HostId)
|
||||
q = q.In("id", sq.SubQuery())
|
||||
}
|
||||
|
||||
return q, err
|
||||
}
|
||||
|
||||
|
||||
@@ -610,6 +610,8 @@ func (self *SVpc) SyncWithCloudVpc(ctx context.Context, userCred mcclient.TokenC
|
||||
return err
|
||||
}
|
||||
|
||||
syncMetadata(ctx, userCred, self, extVPC)
|
||||
|
||||
if provider != nil {
|
||||
SyncCloudDomain(userCred, self, provider.GetOwnerId())
|
||||
self.SyncShareState(ctx, userCred, provider.getAccountShareInfo())
|
||||
@@ -645,6 +647,7 @@ func (manager *SVpcManager) newFromCloudVpc(ctx context.Context, userCred mcclie
|
||||
return nil, err
|
||||
}
|
||||
|
||||
syncMetadata(ctx, userCred, &vpc, extVPC)
|
||||
SyncCloudDomain(userCred, &vpc, provider.GetOwnerId())
|
||||
|
||||
if provider != nil {
|
||||
|
||||
@@ -116,7 +116,7 @@ type ComputeOptions struct {
|
||||
SyncCloudImagesDay int `default:"1" help:"Days auto sync public cloud images data, default 1 day"`
|
||||
SyncCloudImagesHour int `default:"3" help:"What hour start sync public cloud images, default 03:00"`
|
||||
|
||||
EnablePreAllocateIpAddr bool `help:"Enable private and public cloud private ip pre allocate, default true" default:"true"`
|
||||
EnablePreAllocateIpAddr bool `help:"Enable private and public cloud private ip pre allocate, default false" default:"false"`
|
||||
|
||||
DefaultImageCacheDir string `default:"image_cache"`
|
||||
|
||||
|
||||
@@ -60,27 +60,18 @@ func (self *GuestMigrateTask) OnInit(ctx context.Context, obj db.IStandaloneMode
|
||||
func (self *GuestMigrateTask) GetSchedParams() (*schedapi.ScheduleInput, error) {
|
||||
obj := self.GetObject()
|
||||
guest := obj.(*models.SGuest)
|
||||
schedDesc := guest.ToSchedDesc()
|
||||
input := new(api.ServerMigrateForecastInput)
|
||||
if self.Params.Contains("prefer_host_id") {
|
||||
preferHostId, _ := self.Params.GetString("prefer_host_id")
|
||||
schedDesc.ServerConfig.PreferHost = preferHostId
|
||||
input.PreferHostId = preferHostId
|
||||
}
|
||||
guestStatus, _ := self.Params.GetString("guest_status")
|
||||
if !jsonutils.QueryBoolean(self.Params, "is_rescue_mode", false) && (guestStatus == api.VM_RUNNING || guestStatus == api.VM_SUSPEND) {
|
||||
schedDesc.LiveMigrate = true
|
||||
if guest.GetMetadata("__cpu_mode", self.UserCred) != api.CPU_MODE_QEMU {
|
||||
host := guest.GetHost()
|
||||
schedDesc.CpuDesc = host.CpuDesc
|
||||
schedDesc.CpuMicrocode = host.CpuMicrocode
|
||||
schedDesc.CpuMode = api.CPU_MODE_HOST
|
||||
} else {
|
||||
schedDesc.CpuMode = api.CPU_MODE_QEMU
|
||||
}
|
||||
input.LiveMigrate = true
|
||||
skipCpuCheck := jsonutils.QueryBoolean(self.Params, "skip_cpu_check", false)
|
||||
schedDesc.SkipCpuCheck = &skipCpuCheck
|
||||
input.SkipCpuCheck = skipCpuCheck
|
||||
}
|
||||
schedDesc.ReuseNetwork = true
|
||||
return schedDesc, nil
|
||||
return guest.GetSchedMigrateParams(self.GetUserCred(), input), nil
|
||||
}
|
||||
|
||||
func (self *GuestMigrateTask) OnStartSchedule(obj IScheduleModel) {
|
||||
|
||||
@@ -511,5 +511,5 @@ func (w *SWindowsRootFs) DetectIsUEFISupport(part IDiskPartition) bool {
|
||||
}
|
||||
|
||||
func (l *SWindowsRootFs) IsResizeFsPartitionSupport() bool {
|
||||
return false
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ function mtw_mount_disk() {
|
||||
function mtw_extend_c() {
|
||||
cmd_lines = [
|
||||
'select volume c',
|
||||
'extend',
|
||||
'extend filesystem',
|
||||
];
|
||||
mtw_execute_diskpart(cmd_lines);
|
||||
mtw_append_debug(["extend c"], ["success"]);
|
||||
|
||||
@@ -689,12 +689,13 @@ func (m *SGuestManager) GuestStart(ctx context.Context, sid string, body jsonuti
|
||||
guest.SaveDesc(desc)
|
||||
}
|
||||
if guest.IsStopped() {
|
||||
var data *jsonutils.JSONDict
|
||||
params, err := body.Get("params")
|
||||
if err != nil {
|
||||
data, _ = params.(*jsonutils.JSONDict)
|
||||
data := struct {
|
||||
Params *jsonutils.JSONDict
|
||||
}{
|
||||
Params: jsonutils.NewDict(),
|
||||
}
|
||||
guest.StartGuest(ctx, data)
|
||||
body.Unmarshal(&data)
|
||||
guest.StartGuest(ctx, data.Params)
|
||||
res := jsonutils.NewDict()
|
||||
res.Set("vnc_port", jsonutils.NewInt(0))
|
||||
return res, nil
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
|
||||
api "yunion.io/x/onecloud/pkg/apis/compute"
|
||||
"yunion.io/x/onecloud/pkg/appctx"
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/hostman/hostutils"
|
||||
"yunion.io/x/onecloud/pkg/hostman/options"
|
||||
"yunion.io/x/onecloud/pkg/hostman/storageman/remotefile"
|
||||
@@ -85,11 +86,12 @@ func (d *SLocalDisk) Probe() error {
|
||||
if fileutils2.Exists(d.getPath()) {
|
||||
d.isAlter = false
|
||||
return nil
|
||||
} else if fileutils2.Exists(d.getAlterPath()) {
|
||||
}
|
||||
if fileutils2.Exists(d.getAlterPath()) {
|
||||
d.isAlter = true
|
||||
return nil
|
||||
}
|
||||
return fmt.Errorf("Disk not found")
|
||||
return errors.Wrapf(cloudprovider.ErrNotFound, "%s", d.getPath())
|
||||
}
|
||||
|
||||
func (d *SLocalDisk) UmountFuseImage() {
|
||||
|
||||
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"yunion.io/x/onecloud/pkg/apis/image"
|
||||
"yunion.io/x/onecloud/pkg/image/drivers/s3"
|
||||
"yunion.io/x/onecloud/pkg/image/options"
|
||||
"yunion.io/x/onecloud/pkg/util/procutils"
|
||||
)
|
||||
|
||||
@@ -159,7 +160,7 @@ func (s *S3Storage) GetImage(imagePath string) (int64, io.ReadCloser, error) {
|
||||
}
|
||||
|
||||
func (s *S3Storage) IsCheckStatusEnabled() bool {
|
||||
return false
|
||||
return options.Options.S3CheckImageStatus
|
||||
}
|
||||
|
||||
func (s *S3Storage) RemoveImage(fileName string) error {
|
||||
|
||||
@@ -44,12 +44,13 @@ type SImageOptions struct {
|
||||
|
||||
StorageDriver string `help:"image backend storage" default:"local" choices:"s3|local"`
|
||||
|
||||
S3AccessKey string `help:"s3 access key"`
|
||||
S3SecretKey string `help:"s3 secret key"`
|
||||
S3Endpoint string `help:"s3 endpoint"`
|
||||
S3UseSSL bool `help:"s3 access use ssl"`
|
||||
S3BucketName string `help:"s3 bucket name" default:"onecloud-images"`
|
||||
S3MountPoint string `help:"s3fs mount point" default:"/opt/cloud/workspace/data/glance/s3images"`
|
||||
S3AccessKey string `help:"s3 access key"`
|
||||
S3SecretKey string `help:"s3 secret key"`
|
||||
S3Endpoint string `help:"s3 endpoint"`
|
||||
S3UseSSL bool `help:"s3 access use ssl"`
|
||||
S3BucketName string `help:"s3 bucket name" default:"onecloud-images"`
|
||||
S3MountPoint string `help:"s3fs mount point" default:"/opt/cloud/workspace/data/glance/s3images"`
|
||||
S3CheckImageStatus bool `help:"Enable s3 check image status"`
|
||||
}
|
||||
|
||||
var (
|
||||
|
||||
@@ -31,6 +31,7 @@ type StorageListOptions struct {
|
||||
Zone string `help:"List storages in zone" json:"-"`
|
||||
Region string `help:"List storages in region"`
|
||||
Schedtag string `help:"filter storage by schedtag"`
|
||||
HostId string `help:"filter storages which attached the specified host"`
|
||||
|
||||
HostSchedtagId string `help:"filter storage by host schedtag"`
|
||||
ImageId string `help:"filter storage by image"`
|
||||
|
||||
@@ -874,6 +874,21 @@ func (o *ServerRestartOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return StructToParams(o)
|
||||
}
|
||||
|
||||
type ServerMigrateForecastOptions struct {
|
||||
ID string `help:"ID of server" json:"-"`
|
||||
PreferHost string `help:"Server migration prefer host id or name" json:"prefer_host"`
|
||||
LiveMigrate *bool `help:"Use live migrate"`
|
||||
SkipCpuCheck *bool `help:"Skip check CPU mode of the target host" json:"skip_cpu_check"`
|
||||
}
|
||||
|
||||
func (o *ServerMigrateForecastOptions) GetId() string {
|
||||
return o.ID
|
||||
}
|
||||
|
||||
func (o *ServerMigrateForecastOptions) Params() (jsonutils.JSONObject, error) {
|
||||
return StructToParams(o)
|
||||
}
|
||||
|
||||
type ServerMigrateOptions struct {
|
||||
ID string `help:"ID of server" json:"-"`
|
||||
PreferHost string `help:"Server migration prefer host id or name" json:"prefer_host"`
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
|
||||
type SBucket struct {
|
||||
multicloud.SBaseBucket
|
||||
multicloud.AliyunTags
|
||||
|
||||
region *SRegion
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
|
||||
type SCen struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
client *SAliyunClient
|
||||
Status string `json:"Status"`
|
||||
ProtectionLevel string `json:"ProtectionLevel"`
|
||||
|
||||
@@ -58,6 +58,7 @@ type Conflict struct {
|
||||
|
||||
type SCenRouteEntry struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
ChildInstance *SCenChildInstance
|
||||
NextHopInstanceID string `json:"NextHopInstanceId,omitempty"`
|
||||
Status string `json:"Status"`
|
||||
|
||||
@@ -46,6 +46,7 @@ type SDBInstanceExtra struct {
|
||||
|
||||
type SDBInstance struct {
|
||||
multicloud.SDBInstanceBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
netInfo []SDBInstanceNetwork
|
||||
|
||||
@@ -851,18 +852,6 @@ func (region *SRegion) RenewDBInstance(instanceId string, bc billing.SBillingCyc
|
||||
return err
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) GetTags() (map[string]string, error) {
|
||||
tags, err := rds.region.ListTags(ALIYUN_SERVICE_RDS, "INSTANCE", rds.GetId())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, `rds.region.ListTags`)
|
||||
}
|
||||
ret := map[string]string{}
|
||||
for _, tag := range tags {
|
||||
ret[tag.TagKey] = tag.TagValue
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) SetTags(tags map[string]string, replace bool) error {
|
||||
return rds.region.SetResourceTags(ALIYUN_SERVICE_RDS, "INSTANCE", rds.GetId(), tags, replace)
|
||||
}
|
||||
|
||||
@@ -30,6 +30,7 @@ type SDatabasePrivileges struct {
|
||||
|
||||
type SDBInstanceAccount struct {
|
||||
multicloud.SDBInstanceAccountBase
|
||||
multicloud.AliyunTags
|
||||
instance *SDBInstance
|
||||
|
||||
AccountDescription string
|
||||
|
||||
@@ -30,6 +30,7 @@ import (
|
||||
|
||||
type SDBInstanceBackup struct {
|
||||
multicloud.SDBInstanceBackupBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
BackupDBNames string
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
type SDBInstanceDatabase struct {
|
||||
multicloud.SDBInstanceDatabaseBase
|
||||
multicloud.AliyunTags
|
||||
instance *SDBInstance
|
||||
|
||||
CharacterSetName string
|
||||
|
||||
@@ -33,13 +33,10 @@ type SMountInstances struct {
|
||||
MountInstance []string
|
||||
}
|
||||
|
||||
type STags struct {
|
||||
Tag []string
|
||||
}
|
||||
|
||||
type SDisk struct {
|
||||
storage *SStorage
|
||||
multicloud.SDisk
|
||||
multicloud.AliyunTags
|
||||
|
||||
AttachedTime time.Time
|
||||
AutoSnapshotPolicyId string
|
||||
@@ -69,7 +66,6 @@ type SDisk struct {
|
||||
Size int
|
||||
SourceSnapshotId string
|
||||
Status string
|
||||
Tags STags
|
||||
Type string
|
||||
ZoneId string
|
||||
}
|
||||
@@ -317,18 +313,19 @@ func (self *SRegion) resetDisk(diskId, snapshotId string) error {
|
||||
}
|
||||
|
||||
func (self *SDisk) CreateISnapshot(ctx context.Context, name, desc string) (cloudprovider.ICloudSnapshot, error) {
|
||||
if snapshotId, err := self.storage.zone.region.CreateSnapshot(self.DiskId, name, desc); err != nil {
|
||||
log.Errorf("createSnapshot fail %s", err)
|
||||
return nil, err
|
||||
} else if snapshot, err := self.getSnapshot(snapshotId); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
snapshot.region = self.storage.zone.region
|
||||
if err := cloudprovider.WaitStatus(snapshot, api.SNAPSHOT_READY, 15*time.Second, 3600*time.Second); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return snapshot, nil
|
||||
snapshotId, err := self.storage.zone.region.CreateSnapshot(self.DiskId, name, desc)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "CreateSnapshot")
|
||||
}
|
||||
snapshot, err := self.storage.zone.region.GetISnapshotById(snapshotId)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "getSnapshot(%s)", snapshotId)
|
||||
}
|
||||
err = cloudprovider.WaitStatus(snapshot, api.SNAPSHOT_READY, 15*time.Second, 3600*time.Second)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "cloudprovider.WaitStatus")
|
||||
}
|
||||
return snapshot, nil
|
||||
}
|
||||
|
||||
func (self *SRegion) CreateSnapshot(diskId, name, desc string) (string, error) {
|
||||
@@ -347,41 +344,25 @@ func (self *SRegion) CreateSnapshot(diskId, name, desc string) (string, error) {
|
||||
}
|
||||
|
||||
func (self *SDisk) GetISnapshot(snapshotId string) (cloudprovider.ICloudSnapshot, error) {
|
||||
if snapshot, err := self.getSnapshot(snapshotId); err != nil {
|
||||
return nil, err
|
||||
} else {
|
||||
snapshot.region = self.storage.zone.region
|
||||
return snapshot, nil
|
||||
}
|
||||
}
|
||||
|
||||
func (self *SDisk) getSnapshot(snapshotId string) (*SSnapshot, error) {
|
||||
if snapshots, total, err := self.storage.zone.region.GetSnapshots("", "", "", []string{snapshotId}, 0, 1); err != nil {
|
||||
return nil, err
|
||||
} else if total != 1 {
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
} else {
|
||||
return &snapshots[0], nil
|
||||
}
|
||||
return self.storage.zone.region.GetISnapshotById(snapshotId)
|
||||
}
|
||||
|
||||
func (self *SDisk) GetISnapshots() ([]cloudprovider.ICloudSnapshot, error) {
|
||||
snapshots := make([]SSnapshot, 0)
|
||||
for {
|
||||
if parts, total, err := self.storage.zone.region.GetSnapshots("", self.DiskId, "", []string{}, 0, 20); err != nil {
|
||||
log.Errorf("GetDisks fail %s", err)
|
||||
return nil, err
|
||||
} else {
|
||||
snapshots = append(snapshots, parts...)
|
||||
if len(snapshots) >= total {
|
||||
break
|
||||
}
|
||||
parts, total, err := self.storage.zone.region.GetSnapshots("", self.DiskId, "", []string{}, 0, 20)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "GetSnapshots(%s)", self.DiskId)
|
||||
}
|
||||
snapshots = append(snapshots, parts...)
|
||||
if len(snapshots) >= total {
|
||||
break
|
||||
}
|
||||
}
|
||||
isnapshots := make([]cloudprovider.ICloudSnapshot, len(snapshots))
|
||||
isnapshots := []cloudprovider.ICloudSnapshot{}
|
||||
for i := 0; i < len(snapshots); i++ {
|
||||
snapshots[i].region = self.storage.zone.region
|
||||
isnapshots[i] = &snapshots[i]
|
||||
isnapshots = append(isnapshots, &snapshots[i])
|
||||
}
|
||||
return isnapshots, nil
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
|
||||
type SDomain struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
client *SAliyunClient
|
||||
ttlMinValue int64
|
||||
PunyCode string `json:"PunyCode"`
|
||||
|
||||
@@ -71,6 +71,7 @@ const (
|
||||
type SEipAddress struct {
|
||||
region *SRegion
|
||||
multicloud.SEipBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
Name string
|
||||
AllocationId string
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
// https://help.aliyun.com/document_detail/95802.html?spm=a2c4g.11186623.6.746.1d4b302ayCuzXB
|
||||
type SElasticcacheAccount struct {
|
||||
multicloud.SElasticcacheAccountBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
type SElasticcacheAcl struct {
|
||||
multicloud.SElasticcacheAclBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
// https://help.aliyun.com/document_detail/61081.html?spm=a2c4g.11186623.6.752.3d7630beuL57kI
|
||||
type SElasticcacheBackup struct {
|
||||
multicloud.SElasticcacheBackupBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import (
|
||||
// https://help.aliyun.com/document_detail/60933.html?spm=a2c4g.11186623.6.726.38f82ca9U1Gtxw
|
||||
type SElasticcache struct {
|
||||
multicloud.SElasticcacheBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
region *SRegion
|
||||
attribute *SElasticcacheAttribute
|
||||
@@ -61,7 +62,6 @@ type SElasticcache struct {
|
||||
Bandwidth int64 `json:"Bandwidth"`
|
||||
ChargeType TChargeType `json:"ChargeType"`
|
||||
InstanceType string `json:"InstanceType"`
|
||||
Tags Tags `json:"Tags"`
|
||||
InstanceStatus string `json:"InstanceStatus"`
|
||||
Port int `json:"Port"`
|
||||
InstanceClass string `json:"InstanceClass"`
|
||||
@@ -101,7 +101,6 @@ type SElasticcacheAttribute struct {
|
||||
ReplicationMode string `json:"ReplicationMode"`
|
||||
InstanceType string `json:"InstanceType"`
|
||||
InstanceStatus string `json:"InstanceStatus"`
|
||||
Tags Tags `json:"Tags"`
|
||||
Port int64 `json:"Port"`
|
||||
InstanceClass string `json:"InstanceClass"`
|
||||
CreateTime time.Time `json:"CreateTime"`
|
||||
@@ -925,18 +924,6 @@ func (self *SElasticcache) GetICloudElasticcacheBackup(backupId string) (cloudpr
|
||||
return nil, cloudprovider.ErrNotFound
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) GetTags() (map[string]string, error) {
|
||||
tags, err := instance.region.ListTags(ALIYUN_SERVICE_KVS, "INSTANCE", instance.GetId())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "instance.region.ListTags")
|
||||
}
|
||||
ret := map[string]string{}
|
||||
for _, tag := range tags {
|
||||
ret[tag.TagKey] = tag.TagValue
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (instance *SElasticcache) SetTags(tags map[string]string, replace bool) error {
|
||||
return instance.region.SetResourceTags(ALIYUN_SERVICE_KVS, "INSTANCE", instance.GetId(), tags, replace)
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
|
||||
type SElasticcacheParameter struct {
|
||||
multicloud.SElasticcacheParameterBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ type Packages struct {
|
||||
|
||||
type SFileSystem struct {
|
||||
multicloud.SNasBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
Status string
|
||||
@@ -70,8 +71,6 @@ type SFileSystem struct {
|
||||
FileSystemType string
|
||||
FileSystemId string
|
||||
RegionId string
|
||||
|
||||
Tags Tags
|
||||
}
|
||||
|
||||
func (self *SFileSystem) GetId() string {
|
||||
@@ -167,10 +166,6 @@ func (self *SFileSystem) Refresh() error {
|
||||
return jsonutils.Update(self, fs)
|
||||
}
|
||||
|
||||
func (self *SFileSystem) GetTags() (map[string]string, error) {
|
||||
return self.Tags.GetTags()
|
||||
}
|
||||
|
||||
func (self *SRegion) GetFileSystems(id string, pageSize, pageNum int) ([]SFileSystem, int, error) {
|
||||
if pageSize < 1 || pageSize > 100 {
|
||||
pageSize = 50
|
||||
|
||||
@@ -58,6 +58,7 @@ const (
|
||||
|
||||
type SImage struct {
|
||||
multicloud.SImageBase
|
||||
multicloud.AliyunTags
|
||||
storageCache *SStoragecache
|
||||
|
||||
// normalized image info
|
||||
|
||||
@@ -80,6 +80,7 @@ type SVpcAttributes struct {
|
||||
|
||||
type SInstance struct {
|
||||
multicloud.SInstanceBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
host *SHost
|
||||
|
||||
@@ -130,9 +131,6 @@ type SInstance struct {
|
||||
VlanId string
|
||||
VpcAttributes SVpcAttributes
|
||||
ZoneId string
|
||||
|
||||
sys map[string]string
|
||||
user map[string]string
|
||||
}
|
||||
|
||||
// {"AutoReleaseTime":"","ClusterId":"","Cpu":1,"CreationTime":"2018-05-23T07:58Z","DedicatedHostAttribute":{"DedicatedHostId":"","DedicatedHostName":""},"Description":"","DeviceAvailable":true,"EipAddress":{"AllocationId":"","InternetChargeType":"","IpAddress":""},"ExpiredTime":"2018-05-30T16:00Z","GPUAmount":0,"GPUSpec":"","HostName":"iZ2ze57isp1ali72tzkjowZ","ImageId":"centos_7_04_64_20G_alibase_201701015.vhd","InnerIpAddress":{"IpAddress":[]},"InstanceChargeType":"PrePaid","InstanceId":"i-2ze57isp1ali72tzkjow","InstanceName":"gaoxianqi-test-7days","InstanceNetworkType":"vpc","InstanceType":"ecs.t5-lc2m1.nano","InstanceTypeFamily":"ecs.t5","InternetChargeType":"PayByBandwidth","InternetMaxBandwidthIn":-1,"InternetMaxBandwidthOut":0,"IoOptimized":true,"Memory":512,"NetworkInterfaces":{"NetworkInterface":[{"MacAddress":"00:16:3e:10:f0:c9","NetworkInterfaceId":"eni-2zecqsagtpztl6x5hu2r","PrimaryIpAddress":"192.168.220.214"}]},"OSName":"CentOS 7.4 64位","OSType":"linux","OperationLocks":{"LockReason":[]},"PublicIpAddress":{"IpAddress":[]},"Recyclable":false,"RegionId":"cn-beijing","ResourceGroupId":"","SaleCycle":"Week","SecurityGroupIds":{"SecurityGroupId":["sg-2zecqsagtpztl6x9zynl"]},"SerialNumber":"df05d9b4-df3d-4400-88d1-5f843f0dd088","SpotPriceLimit":0.000000,"SpotStrategy":"NoSpot","StartTime":"2018-05-23T07:58Z","Status":"Running","StoppedMode":"Not-applicable","VlanId":"","VpcAttributes":{"NatIpAddress":"","PrivateIpAddress":{"IpAddress":["192.168.220.214"]},"VSwitchId":"vsw-2ze9cqwza4upoyujq1thd","VpcId":"vpc-2zer4jy8ix3i8f0coc5uw"},"ZoneId":"cn-beijing-f"}
|
||||
@@ -183,14 +181,6 @@ func (self *SInstance) GetSecurityGroupIds() ([]string, error) {
|
||||
|
||||
func (self *SInstance) GetSysTags() map[string]string {
|
||||
data := map[string]string{}
|
||||
// The pricingInfo key structure is 'RegionId::InstanceType::NetworkType::OSType::IoOptimized'
|
||||
optimized := "optimized"
|
||||
if !self.IoOptimized {
|
||||
optimized = "none"
|
||||
}
|
||||
priceKey := fmt.Sprintf("%s::%s::%s::%s::%s", self.RegionId, self.InstanceType, self.InstanceNetworkType, self.OSType, optimized)
|
||||
data["price_key"] = priceKey
|
||||
data["zone_ext_id"] = self.host.zone.GetGlobalId()
|
||||
if len(self.ImageId) > 0 {
|
||||
if image, err := self.host.zone.region.GetImage(self.ImageId); err != nil {
|
||||
log.Errorf("Failed to find image %s for instance %s", self.ImageId, self.GetName())
|
||||
@@ -201,33 +191,13 @@ func (self *SInstance) GetSysTags() map[string]string {
|
||||
}
|
||||
}
|
||||
}
|
||||
sys, _, _ := self.fetchTags()
|
||||
sys := self.AliyunTags.GetSysTags()
|
||||
for k, v := range sys {
|
||||
data[k] = v
|
||||
}
|
||||
return data
|
||||
}
|
||||
|
||||
func (self *SInstance) GetTags() (map[string]string, error) {
|
||||
_, tags, err := self.fetchTags()
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "self.fetchTags")
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) fetchTags() (map[string]string, map[string]string, error) {
|
||||
if self.sys != nil || self.user != nil {
|
||||
return self.sys, self.user, nil
|
||||
}
|
||||
var err error
|
||||
self.sys, self.user, err = self.host.zone.region.ListSysAndUserTags(ALIYUN_SERVICE_ECS, "instance", self.InstanceId)
|
||||
if err != nil {
|
||||
return nil, nil, errors.Wrapf(err, "ListSysAndUserTags")
|
||||
}
|
||||
return self.sys, self.user, nil
|
||||
}
|
||||
|
||||
func (self *SInstance) GetIHost() cloudprovider.ICloudHost {
|
||||
return self.host
|
||||
}
|
||||
@@ -384,12 +354,11 @@ func (self *SInstance) GetStatus() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) Refresh() error {
|
||||
self.sys, self.user = nil, nil
|
||||
new, err := self.host.zone.region.GetInstance(self.InstanceId)
|
||||
ins, err := self.host.zone.region.GetInstance(self.InstanceId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return jsonutils.Update(self, new)
|
||||
return jsonutils.Update(self, ins)
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -59,6 +59,7 @@ type BackendServers struct {
|
||||
|
||||
type SLoadbalancer struct {
|
||||
multicloud.SLoadbalancerBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
LoadBalancerId string //负载均衡实例ID。
|
||||
@@ -105,18 +106,6 @@ func (lb *SLoadbalancer) GetStatus() string {
|
||||
return api.LB_STATUS_DISABLED
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetTags() (map[string]string, error) {
|
||||
tags, err := lb.region.ListTags(ALIYUN_SERVICE_SLB, "instance", lb.GetId())
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "lb.region.ListTags")
|
||||
}
|
||||
ret := map[string]string{}
|
||||
for _, tag := range tags {
|
||||
ret[tag.TagKey] = tag.TagValue
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
func (lb *SLoadbalancer) GetAddress() string {
|
||||
return lb.Address
|
||||
}
|
||||
|
||||
@@ -33,6 +33,7 @@ type AclEntry struct {
|
||||
|
||||
type SLoadbalancerAcl struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
AclId string
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerBackend struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lbbg *SLoadbalancerBackendGroup
|
||||
|
||||
ServerId string
|
||||
|
||||
@@ -52,6 +52,7 @@ type AssociatedObjects struct {
|
||||
|
||||
type SLoadbalancerBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
VServerGroupId string
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
type SLoadbalancerDefaultBackend struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lbbg *SLoadbalancerDefaultBackendGroup
|
||||
|
||||
ServerId string
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerDefaultBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerHTTPListener struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerHTTPSListener struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerListenerRule struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
httpListener *SLoadbalancerHTTPListener
|
||||
httpsListener *SLoadbalancerHTTPSListener
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
type SLoadbalancerMasterSlaveBackend struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lbbg *SLoadbalancerMasterSlaveBackendGroup
|
||||
|
||||
ServerId string
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerMasterSlaveBackendGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
MasterSlaveServerGroupId string
|
||||
|
||||
@@ -28,6 +28,7 @@ type SubjectAlternativeNames struct {
|
||||
|
||||
type SLoadbalancerServerCertificate struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
ServerCertificateId string // 服务器证书ID。
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
|
||||
type SLoadbalancerTCPListener struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SLoadbalancerUDPListener struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
lb *SLoadbalancer
|
||||
|
||||
ListenerPort int // 负载均衡实例前端使用的端口。
|
||||
|
||||
@@ -44,7 +44,6 @@ type SMountTarget struct {
|
||||
MountTargetDomain string
|
||||
AccessGroup string
|
||||
ClientMasterNodes ClientMasterNodes
|
||||
Tags Tags
|
||||
}
|
||||
|
||||
func (self *SMountTarget) GetGlobalId() string {
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SForwardTableEntry struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
nat *SNatGateway
|
||||
|
||||
ForwardEntryId string
|
||||
|
||||
@@ -50,6 +50,7 @@ type NatGatewayPrivateInfo struct {
|
||||
|
||||
type SNatGateway struct {
|
||||
multicloud.SNatGatewayBase
|
||||
multicloud.AliyunTags
|
||||
|
||||
vpc *SVpc
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import (
|
||||
|
||||
type SSNATTableEntry struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
nat *SNatGateway
|
||||
|
||||
SnatEntryId string
|
||||
|
||||
@@ -53,6 +53,7 @@ type SPrivateIpSets struct {
|
||||
|
||||
type SNetworkInterface struct {
|
||||
multicloud.SNetworkInterfaceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
InstanceId string
|
||||
|
||||
@@ -40,6 +40,7 @@ type SPvtzBindVpcs struct {
|
||||
|
||||
type SPrivateZone struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
client *SAliyunClient
|
||||
|
||||
// RequestID string `json:"RequestId"`
|
||||
|
||||
@@ -28,6 +28,7 @@ import (
|
||||
|
||||
type SResourceGroup struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
client *SAliyunClient
|
||||
|
||||
Status string
|
||||
|
||||
@@ -451,7 +451,7 @@ func (self *SRegion) GetVpcs(vpcId []string, offset int, limit int) ([]SVpc, int
|
||||
params["VpcId"] = strings.Join(vpcId, ",")
|
||||
}
|
||||
|
||||
body, err := self.ecsRequest("DescribeVpcs", params)
|
||||
body, err := self.vpcRequest("DescribeVpcs", params)
|
||||
if err != nil {
|
||||
log.Errorf("GetVpcs fail %s", err)
|
||||
return nil, 0, err
|
||||
|
||||
@@ -34,6 +34,7 @@ type SNextHops struct {
|
||||
|
||||
type SRouteEntry struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
routeTable *SRouteTable
|
||||
|
||||
RouteTableId string
|
||||
@@ -114,6 +115,7 @@ type SRouteEntrys struct {
|
||||
|
||||
type SRouteTable struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
vpc *SVpc
|
||||
routes []cloudprovider.ICloudRoute
|
||||
|
||||
@@ -33,6 +33,7 @@ import (
|
||||
|
||||
type SAMLProvider struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
client *SAliyunClient
|
||||
|
||||
Arn string
|
||||
|
||||
@@ -62,25 +62,9 @@ type SPermissions struct {
|
||||
Permission []SPermission
|
||||
}
|
||||
|
||||
type Tags struct {
|
||||
Tag []Tag
|
||||
}
|
||||
|
||||
func (t Tags) GetTags() (map[string]string, error) {
|
||||
ret := map[string]string{}
|
||||
for _, tag := range t.Tag {
|
||||
ret[tag.TagKey] = tag.TagValue
|
||||
}
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
type Tag struct {
|
||||
TagKey string
|
||||
TagValue string
|
||||
}
|
||||
|
||||
type SSecurityGroup struct {
|
||||
multicloud.SSecurityGroup
|
||||
multicloud.AliyunTags
|
||||
|
||||
vpc *SVpc
|
||||
CreationTime time.Time
|
||||
@@ -91,21 +75,12 @@ type SSecurityGroup struct {
|
||||
InnerAccessPolicy string
|
||||
Permissions SPermissions
|
||||
RegionId string
|
||||
Tags Tags
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetVpcId() string {
|
||||
return self.VpcId
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetTags() (map[string]string, error) {
|
||||
tags := map[string]string{}
|
||||
for _, value := range self.Tags.Tag {
|
||||
tags[value.TagKey] = value.TagValue
|
||||
}
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (self *SSecurityGroup) GetId() string {
|
||||
return self.SecurityGroupId
|
||||
}
|
||||
|
||||
@@ -40,6 +40,7 @@ const (
|
||||
|
||||
type SSnapshot struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
Progress string
|
||||
|
||||
@@ -36,6 +36,7 @@ const (
|
||||
|
||||
type SSnapshotPolicy struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
AutoSnapshotPolicyName string
|
||||
|
||||
@@ -42,6 +42,7 @@ import (
|
||||
|
||||
type SStorage struct {
|
||||
multicloud.SStorageBase
|
||||
multicloud.AliyunTags
|
||||
zone *SZone
|
||||
storageType string
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import (
|
||||
|
||||
type SStoragecache struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ type SVSwitchIds struct {
|
||||
|
||||
type SVpc struct {
|
||||
multicloud.SVpc
|
||||
multicloud.AliyunTags
|
||||
|
||||
region *SRegion
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ type SCloudResources struct {
|
||||
|
||||
type SVSwitch struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
wire *SWire
|
||||
|
||||
AvailableIpAddressCount int
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
type SWire struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
zone *SZone
|
||||
vpc *SVpc
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ type SDedicatedHostTypes struct {
|
||||
|
||||
type SZone struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.AliyunTags
|
||||
region *SRegion
|
||||
|
||||
iwires []cloudprovider.ICloudWire
|
||||
|
||||
@@ -32,6 +32,7 @@ import (
|
||||
|
||||
type SBucket struct {
|
||||
multicloud.SBaseBucket
|
||||
multicloud.ApsaraTags
|
||||
|
||||
region *SRegion
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ type SDBInstanceExtra struct {
|
||||
|
||||
type SDBInstance struct {
|
||||
multicloud.SDBInstanceBase
|
||||
multicloud.ApsaraTags
|
||||
|
||||
netInfo []SDBInstanceNetwork
|
||||
|
||||
|
||||
@@ -30,6 +30,7 @@ type SDatabasePrivileges struct {
|
||||
|
||||
type SDBInstanceAccount struct {
|
||||
multicloud.SDBInstanceAccountBase
|
||||
multicloud.ApsaraTags
|
||||
instance *SDBInstance
|
||||
|
||||
AccountDescription string
|
||||
|
||||
@@ -31,6 +31,7 @@ import (
|
||||
|
||||
type SDBInstanceBackup struct {
|
||||
multicloud.SDBInstanceBackupBase
|
||||
multicloud.ApsaraTags
|
||||
region *SRegion
|
||||
|
||||
BackupDBNames string
|
||||
|
||||
@@ -25,6 +25,7 @@ import (
|
||||
|
||||
type SDBInstanceDatabase struct {
|
||||
multicloud.SDBInstanceDatabaseBase
|
||||
multicloud.ApsaraTags
|
||||
instance *SDBInstance
|
||||
|
||||
CharacterSetName string
|
||||
|
||||
@@ -39,6 +39,7 @@ type STags struct {
|
||||
|
||||
type SDisk struct {
|
||||
multicloud.SResourceBase
|
||||
multicloud.ApsaraTags
|
||||
storage *SStorage
|
||||
multicloud.SDisk
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ const (
|
||||
type SEipAddress struct {
|
||||
region *SRegion
|
||||
multicloud.SEipBase
|
||||
multicloud.ApsaraTags
|
||||
|
||||
AllocationId string
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
// https://help.apsara.com/document_detail/95802.html?spm=a2c4g.11186623.6.746.1d4b302ayCuzXB
|
||||
type SElasticcacheAccount struct {
|
||||
multicloud.SElasticcacheAccountBase
|
||||
multicloud.ApsaraTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
type SElasticcacheAcl struct {
|
||||
multicloud.SElasticcacheAclBase
|
||||
multicloud.ApsaraTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@ import (
|
||||
// https://help.apsara.com/document_detail/61081.html?spm=a2c4g.11186623.6.752.3d7630beuL57kI
|
||||
type SElasticcacheBackup struct {
|
||||
multicloud.SElasticcacheBackupBase
|
||||
multicloud.ApsaraTags
|
||||
|
||||
cacheDB *SElasticcache
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user