validate prepaid resource delete condition

This commit is contained in:
TangBin
2019-11-27 16:46:24 +08:00
parent 25b04f50be
commit 86a30141df
@@ -19,6 +19,7 @@ import (
"fmt"
"regexp"
"strings"
"time"
"yunion.io/x/jsonutils"
"yunion.io/x/log"
@@ -697,6 +698,10 @@ func (self *SElasticcache) ValidateDeleteCondition(ctx context.Context) error {
return httperrors.NewInvalidStatusError("Elastic cache is locked, cannot delete")
}
if self.GetChargeType() == billing.BILLING_TYPE_PREPAID && self.ExpiredAt.Sub(time.Now()).Seconds() > 0 {
return httperrors.NewInvalidStatusError("Elastic cache is not expired, cannot delete")
}
return self.ValidatePurgeCondition(ctx)
}