diff --git a/pkg/compute/hostdrivers/esxi.go b/pkg/compute/hostdrivers/esxi.go index e2eda6c3c2..8056c69e80 100644 --- a/pkg/compute/hostdrivers/esxi.go +++ b/pkg/compute/hostdrivers/esxi.go @@ -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()) } diff --git a/pkg/compute/tasks/eip_allocate_task.go b/pkg/compute/tasks/eip_allocate_task.go index 5de5247ee6..bed3e191d2 100644 --- a/pkg/compute/tasks/eip_allocate_task.go +++ b/pkg/compute/tasks/eip_allocate_task.go @@ -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()) +}