mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
Automatic merge from release/2.7.0 -> release/2.8.0
* commit 'dc2a6d53fe9a0f7935aa0118f229fb31c8332f88': 补充esix缺失的ValidateDiskSize 避免PerformCreateEip失败后guest状态一直不变
This commit is contained in:
@@ -27,6 +27,10 @@ func (self *SESXiHostDriver) GetHostType() string {
|
||||
return models.HOST_TYPE_ESXI
|
||||
}
|
||||
|
||||
func (self *SESXiHostDriver) ValidateDiskSize(storage *models.SStorage, sizeGb int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (self *SESXiHostDriver) ValidateAttachStorage(host *models.SHost, storage *models.SStorage, data *jsonutils.JSONDict) error {
|
||||
return httperrors.NewUnsupportOperationError("Not support attach storage for %s host", self.GetHostType())
|
||||
}
|
||||
|
||||
@@ -22,9 +22,23 @@ func init() {
|
||||
|
||||
func (self *EipAllocateTask) onFailed(ctx context.Context, resion string) {
|
||||
self.finalReleasePendingUsage(ctx)
|
||||
self.setGuestAllocateEipFailed(resion)
|
||||
self.SetStageFailed(ctx, resion)
|
||||
}
|
||||
|
||||
func (self *EipAllocateTask) setGuestAllocateEipFailed(resion string) {
|
||||
if self.Params != nil && self.Params.Contains("instance_id") {
|
||||
instanceId, _ := self.Params.GetString("instance_id")
|
||||
instance, err := models.GuestManager.FetchById(instanceId)
|
||||
if err != nil {
|
||||
log.Errorf("failed to find guest by id: %s error: %v", instanceId, err)
|
||||
return
|
||||
}
|
||||
guest := instance.(*models.SGuest)
|
||||
guest.SetStatus(self.UserCred, models.VM_ASSOCIATE_EIP_FAILED, resion)
|
||||
}
|
||||
}
|
||||
|
||||
func (self *EipAllocateTask) finalReleasePendingUsage(ctx context.Context) {
|
||||
pendingUsage := models.SQuota{}
|
||||
if err := self.GetPendingUsage(&pendingUsage); err == nil && !pendingUsage.IsEmpty() {
|
||||
@@ -79,3 +93,8 @@ func (self *EipAllocateTask) OnInit(ctx context.Context, obj db.IStandaloneModel
|
||||
func (self *EipAllocateTask) OnEipAssociateComplete(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
self.SetStageComplete(ctx, nil)
|
||||
}
|
||||
|
||||
func (self *EipAllocateTask) OnEipAssociateCompleteFailed(ctx context.Context, obj db.IStandaloneModel, data jsonutils.JSONObject) {
|
||||
self.setGuestAllocateEipFailed(data.String())
|
||||
self.SetStageFailed(ctx, data.String())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user