mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
修正:阿里云回收站主机恢复后无系统盘
This commit is contained in:
@@ -256,6 +256,10 @@ func (model *SVirtualResourceBase) AllowPerformCancelDelete(ctx context.Context,
|
||||
return false
|
||||
}
|
||||
|
||||
/*func DoCancelPendingDelete(model IVirtualModel, ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
return model.DoCancelPendingDelete(ctx, userCred)
|
||||
}*/
|
||||
|
||||
func (model *SVirtualResourceBase) PerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if model.PendingDeleted {
|
||||
err := model.DoCancelPendingDelete(ctx, userCred)
|
||||
|
||||
@@ -486,7 +486,8 @@ func (self *SDisk) fetchDiskInfo(diskConfig *SDiskConfig) {
|
||||
if len(diskConfig.ImageId) > 0 {
|
||||
self.TemplateId = diskConfig.ImageId
|
||||
self.DiskType = DISK_TYPE_SYS
|
||||
} else if len(diskConfig.Fs) > 0 {
|
||||
}
|
||||
if len(diskConfig.Fs) > 0 {
|
||||
self.FsFormat = diskConfig.Fs
|
||||
}
|
||||
if self.FsFormat == "swap" {
|
||||
@@ -619,3 +620,15 @@ func (self *SDisk) isReady() bool {
|
||||
func (self *SDisk) isInit() bool {
|
||||
return self.Status == DISK_INIT
|
||||
}
|
||||
|
||||
func (model *SDisk) AllowPerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return userCred.IsSystemAdmin()
|
||||
}
|
||||
|
||||
func (self *SDisk) PerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.PendingDeleted {
|
||||
err := self.DoCancelPendingDelete(ctx, userCred)
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
@@ -1953,7 +1953,7 @@ func (self *SGuest) DoPendingDelete(ctx context.Context, userCred mcclient.Token
|
||||
for _, guestdisk := range self.GetDisks() {
|
||||
disk := guestdisk.GetDisk()
|
||||
storage := disk.GetStorage()
|
||||
if utils.IsInStringArray(storage.StorageType, sysutils.LOCAL_STORAGE_TYPES) || disk.DiskType == DISK_TYPE_SYS || disk.DiskType == DISK_TYPE_SWAP {
|
||||
if utils.IsInStringArray(storage.StorageType, sysutils.LOCAL_STORAGE_TYPES) || disk.DiskType == DISK_TYPE_SYS || disk.DiskType == DISK_TYPE_SWAP || self.Hypervisor == HYPERVISOR_ALIYUN {
|
||||
disk.DoPendingDelete(ctx, userCred)
|
||||
} else {
|
||||
self.detachDisk(ctx, disk, userCred)
|
||||
@@ -1962,6 +1962,26 @@ func (self *SGuest) DoPendingDelete(ctx context.Context, userCred mcclient.Token
|
||||
self.SVirtualResourceBase.DoPendingDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (model *SGuest) AllowPerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return userCred.IsSystemAdmin()
|
||||
}
|
||||
|
||||
func (self *SGuest) PerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) (jsonutils.JSONObject, error) {
|
||||
if self.PendingDeleted {
|
||||
err := self.DoCancelPendingDelete(ctx, userCred)
|
||||
return nil, err
|
||||
}
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func (self *SGuest) DoCancelPendingDelete(ctx context.Context, userCred mcclient.TokenCredential) error {
|
||||
for _, guestdisk := range self.GetDisks() {
|
||||
disk := guestdisk.GetDisk()
|
||||
disk.DoCancelPendingDelete(ctx, userCred)
|
||||
}
|
||||
return self.SVirtualResourceBase.DoCancelPendingDelete(ctx, userCred)
|
||||
}
|
||||
|
||||
func (self *SGuest) StartUndeployGuestTask(ctx context.Context, userCred mcclient.TokenCredential, parentTaskId string, targetHostId string) error {
|
||||
data := jsonutils.NewDict()
|
||||
if len(targetHostId) > 0 {
|
||||
@@ -2548,10 +2568,6 @@ func (self *SGuest) GetDetailsVnc(ctx context.Context, userCred mcclient.TokenCr
|
||||
}
|
||||
}
|
||||
|
||||
func (model *SGuestManager) AllowPerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return userCred.IsSystemAdmin()
|
||||
}
|
||||
|
||||
func (self *SGuest) GetKeypairPublicKey() string {
|
||||
keypair := self.getKeypair()
|
||||
if keypair != nil {
|
||||
@@ -2560,10 +2576,6 @@ func (self *SGuest) GetKeypairPublicKey() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (model *SGuest) AllowPerformCancelDelete(ctx context.Context, userCred mcclient.TokenCredential, query jsonutils.JSONObject, data jsonutils.JSONObject) bool {
|
||||
return userCred.IsSystemAdmin()
|
||||
}
|
||||
|
||||
func (manager *SGuestManager) GetIpInProjectWithName(projectId, name string, isExitOnly bool) []string {
|
||||
guestnics := GuestnetworkManager.Query().SubQuery()
|
||||
guests := manager.Query().SubQuery()
|
||||
|
||||
Reference in New Issue
Block a user