Automatic merge from release/2.6.0 -> release/2.7.0

* commit 'bfb7d69eab18488ead051755bad361bb67e0123f':
  补充esix缺失的ValidateDiskSize
  避免PerformCreateEip失败后guest状态一直不变
This commit is contained in:
邱剑
2019-03-18 10:31:57 +08:00
2 changed files with 23 additions and 0 deletions
+4
View File
@@ -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())
}
+19
View File
@@ -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())
}