mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
增加:1.
包年包月主机加入资源池后,如果auto_delete=true,则自动删除该主机 2.
包年包月资源池的宿主机支持续费操作Perform(host.id,
"renew-prepaid-recycle", {"duration": "1m"})
This commit is contained in:
@@ -83,7 +83,7 @@ func _jsonRequest(client *sdk.Client, domain string, version string, apiName str
|
||||
|
||||
resp, err := processCommonRequest(client, req)
|
||||
if err != nil {
|
||||
log.Errorf("request error %s", err)
|
||||
log.Errorf("request error %s parameters %s", err, params)
|
||||
return nil, err
|
||||
}
|
||||
body, err := jsonutils.Parse(resp.GetHttpContentBytes())
|
||||
|
||||
@@ -905,7 +905,13 @@ func (self *SInstance) GetBillingType() string {
|
||||
}
|
||||
|
||||
func (self *SInstance) GetExpiredAt() time.Time {
|
||||
return self.ExpiredTime
|
||||
if !self.ExpiredTime.IsZero() {
|
||||
now := time.Now()
|
||||
if self.ExpiredTime.Sub(now) < time.Hour*24*365*6 {
|
||||
return self.ExpiredTime
|
||||
}
|
||||
}
|
||||
return time.Time{}
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateUserData(userData string) error {
|
||||
@@ -925,10 +931,10 @@ func (region *SRegion) RenewInstance(instanceId string, bc billing.SBillingCycle
|
||||
params["InstanceId"] = instanceId
|
||||
if bc.GetWeeks() <= 4 {
|
||||
params["PeriodUnit"] = "Week"
|
||||
params["Period"] = fmt.Sprintf("%s", bc.GetWeeks())
|
||||
params["Period"] = fmt.Sprintf("%d", bc.GetWeeks())
|
||||
} else {
|
||||
params["PeriodUnit"] = "Month"
|
||||
params["Period"] = fmt.Sprintf("%s", bc.GetMonths())
|
||||
params["Period"] = fmt.Sprintf("%d", bc.GetMonths())
|
||||
}
|
||||
params["ClientToken"] = utils.GenRequestId(20)
|
||||
_, err := region.ecsRequest("RenewInstance", params)
|
||||
|
||||
@@ -5,6 +5,7 @@ import (
|
||||
|
||||
"yunion.io/x/jsonutils"
|
||||
"yunion.io/x/log"
|
||||
"yunion.io/x/pkg/utils"
|
||||
|
||||
"yunion.io/x/onecloud/pkg/cloudprovider"
|
||||
"yunion.io/x/onecloud/pkg/compute/models"
|
||||
@@ -134,7 +135,7 @@ func (self *SZone) IsEmulated() bool {
|
||||
}
|
||||
|
||||
func (self *SZone) GetStatus() string {
|
||||
if len(self.AvailableResourceCreation.ResourceTypes) == 0 {
|
||||
if len(self.AvailableResourceCreation.ResourceTypes) == 0 || !utils.IsInStringArray("Instance", self.AvailableResourceCreation.ResourceTypes) {
|
||||
return models.ZONE_SOLDOUT
|
||||
} else {
|
||||
return models.ZONE_ENABLE
|
||||
|
||||
Reference in New Issue
Block a user