fix(region): cloudpods misc fix

This commit is contained in:
Qu Xuan
2021-09-02 15:50:45 +08:00
parent 626ad20587
commit 4bb0e79ba1
3 changed files with 22 additions and 2 deletions
+13
View File
@@ -15,11 +15,14 @@
package guestdrivers
import (
"yunion.io/x/pkg/utils"
api "yunion.io/x/onecloud/pkg/apis/compute"
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudprovider"
"yunion.io/x/onecloud/pkg/compute/models"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
)
@@ -85,6 +88,16 @@ func (self *SCloudpodsGuestDriver) IsSupportLiveMigrate() bool {
return true
}
func (self *SCloudpodsGuestDriver) ValidateResizeDisk(guest *models.SGuest, disk *models.SDisk, storage *models.SStorage) error {
if guest.GetDiskIndex(disk.Id) <= 0 && guest.Status == api.VM_RUNNING {
return httperrors.NewUnsupportOperationError("Cann't online resize root disk")
}
if !utils.IsInStringArray(guest.Status, []string{api.VM_READY, api.VM_RUNNING}) {
return httperrors.NewServerStatusError("Cannot resize disk when guest in status %s", guest.Status)
}
return nil
}
func (self *SCloudpodsGuestDriver) GetComputeQuotaKeys(scope rbacutils.TRbacScope, ownerId mcclient.IIdentityProvider, brand string) models.SComputeResourceKeys {
keys := models.SComputeResourceKeys{}
keys.SBaseProjectQuotaKeys = quotas.OwnerIdProjectQuotaKeys(scope, ownerId)
+4 -1
View File
@@ -62,9 +62,12 @@ func (self *GuestStopTask) stopGuest(ctx context.Context, guest *models.SGuest)
func (self *GuestStopTask) OnGuestStopTaskComplete(ctx context.Context, guest *models.SGuest, data jsonutils.JSONObject) {
db.OpsLog.LogEvent(guest, db.ACT_STOP, guest.GetShortDesc(ctx), self.UserCred)
models.HostManager.ClearSchedDescCache(guest.HostId)
if guest.Status != api.VM_READY { // for kvm
guest.SetStatus(self.GetUserCred(), api.VM_READY, "")
}
logclient.AddActionLogWithStartable(self, guest, logclient.ACT_VM_STOP, "success", self.UserCred, true)
self.SetStageComplete(ctx, nil)
if guest.Status == api.VM_READY && guest.DisableDelete.IsFalse() && guest.ShutdownBehavior == api.SHUTDOWN_TERMINATE {
if guest.DisableDelete.IsFalse() && guest.ShutdownBehavior == api.SHUTDOWN_TERMINATE {
guest.StartAutoDeleteGuestTask(ctx, self.UserCred, "")
return
}
+5 -1
View File
@@ -91,7 +91,7 @@ func (self *SImage) GetOsType() cloudprovider.TOsType {
}
func (self *SImage) GetOsDist() string {
osDist, ok := self.Properties["os_dist"]
osDist, ok := self.Properties["os_distribution"]
if ok {
return osDist
}
@@ -107,6 +107,10 @@ func (self *SImage) GetOsVersion() string {
}
func (self *SImage) GetOsArch() string {
osArch, ok := self.Properties["os_arch"]
if ok {
return osArch
}
return self.OsArch
}