mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): support delete huawei prepaid resource (#20029)
This commit is contained in:
@@ -89,7 +89,7 @@ require (
|
||||
k8s.io/cluster-bootstrap v0.19.3
|
||||
k8s.io/cri-api v0.22.17
|
||||
moul.io/http2curl/v2 v2.3.0
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240414044505-f2da647a5300
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240416095221-40e74d0a722d
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32
|
||||
yunion.io/x/jsonutils v1.0.1-0.20240203102553-4096f103b401
|
||||
yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91
|
||||
|
||||
@@ -1210,8 +1210,8 @@ sigs.k8s.io/structured-merge-diff/v4 v4.0.1/go.mod h1:bJZC9H9iH24zzfZ/41RGcq60oK
|
||||
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
|
||||
sigs.k8s.io/yaml v1.2.0 h1:kr/MCeFWJWTwyaHoR9c8EjH9OumOmoF9YGiZd7lFm/Q=
|
||||
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240414044505-f2da647a5300 h1:+Enkr8vGwKTKWtWlxMheWCXZDBMJ/b9BZ0uGURQtRH8=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240414044505-f2da647a5300/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240416095221-40e74d0a722d h1:3MKLW5Tn17b3xhXFznehE+piKiHurIBJIEIhhTej+7E=
|
||||
yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240416095221-40e74d0a722d/go.mod h1:dsUESXIbXJ+/ywbNClhldOrbPOiBi2udrgOnB/ffoWk=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 h1:v7POYkQwo1XzOxBoIoRVr/k0V9Y5JyjpshlIFa9raug=
|
||||
yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32/go.mod h1:Uxuou9WQIeJXNpy7t2fPLL0BYLvLiMvGQwY7Qc6aSws=
|
||||
yunion.io/x/jsonutils v0.0.0-20190625054549-a964e1e8a051/go.mod h1:4N0/RVzsYL3kH3WE/H1BjUQdFiWu50JGCFQuuy+Z634=
|
||||
|
||||
Vendored
+1
-1
@@ -1476,7 +1476,7 @@ sigs.k8s.io/structured-merge-diff/v4/value
|
||||
# sigs.k8s.io/yaml v1.2.0
|
||||
## explicit; go 1.12
|
||||
sigs.k8s.io/yaml
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240414044505-f2da647a5300
|
||||
# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20240416095221-40e74d0a722d
|
||||
## explicit; go 1.18
|
||||
yunion.io/x/cloudmux/pkg/apis
|
||||
yunion.io/x/cloudmux/pkg/apis/billing
|
||||
|
||||
+3
@@ -451,6 +451,9 @@ func (rds *SDBInstance) GetIDBInstanceAccounts() ([]cloudprovider.ICloudDBInstan
|
||||
}
|
||||
|
||||
func (rds *SDBInstance) Delete() error {
|
||||
if rds.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
|
||||
return rds.region.CancelResourcesSubscription([]string{rds.Id})
|
||||
}
|
||||
return rds.region.DeleteDBInstance(rds.Id)
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -295,6 +295,9 @@ func (self *SDisk) GetAccessPath() string {
|
||||
}
|
||||
|
||||
func (self *SDisk) Delete(ctx context.Context) error {
|
||||
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
|
||||
return self.storage.zone.region.CancelResourcesSubscription([]string{self.ID})
|
||||
}
|
||||
disk, err := self.storage.zone.region.GetDisk(self.GetId())
|
||||
if err != nil {
|
||||
if errors.Cause(err) == cloudprovider.ErrNotFound {
|
||||
|
||||
+5
-2
@@ -139,9 +139,9 @@ func (self *SEipAddress) GetInternetChargeType() string {
|
||||
|
||||
func (self *SEipAddress) GetBillingType() string {
|
||||
if len(self.BillingInfo) > 0 {
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
return billing_api.BILLING_TYPE_PREPAID
|
||||
}
|
||||
return billing_api.BILLING_TYPE_PREPAID
|
||||
return billing_api.BILLING_TYPE_POSTPAID
|
||||
}
|
||||
|
||||
func (self *SEipAddress) GetCreatedAt() time.Time {
|
||||
@@ -153,6 +153,9 @@ func (self *SEipAddress) GetExpiredAt() time.Time {
|
||||
}
|
||||
|
||||
func (self *SEipAddress) Delete() error {
|
||||
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
|
||||
return self.region.CancelResourcesSubscription([]string{self.Id})
|
||||
}
|
||||
return self.region.DeallocateEIP(self.Id)
|
||||
}
|
||||
|
||||
|
||||
+3
@@ -501,6 +501,9 @@ func (self *SElasticcache) Restart() error {
|
||||
}
|
||||
|
||||
func (self *SElasticcache) Delete() error {
|
||||
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
|
||||
return self.region.CancelResourcesSubscription([]string{self.InstanceID})
|
||||
}
|
||||
_, err := self.region.delete(SERVICE_DCS, "instances/"+self.GetId())
|
||||
return err
|
||||
}
|
||||
|
||||
+14
@@ -570,9 +570,23 @@ func (self *SInstance) StopVM(ctx context.Context, opts *cloudprovider.ServerSto
|
||||
}
|
||||
|
||||
func (self *SInstance) DeleteVM(ctx context.Context) error {
|
||||
if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID {
|
||||
return self.host.zone.region.CancelResourcesSubscription([]string{self.ID})
|
||||
}
|
||||
return self.host.zone.region.DeleteVM(self.GetId())
|
||||
}
|
||||
|
||||
func (self *SRegion) CancelResourcesSubscription(resourceIds []string) error {
|
||||
params := map[string]interface{}{
|
||||
"resource_ids": resourceIds,
|
||||
"unsubscribe_type": 1,
|
||||
"unsubscribe_reason_type": 5,
|
||||
"unsubscribe_reason": "cloudpods auto delete prepaid resources",
|
||||
}
|
||||
_, err := self.post(SERVICE_BSS, "orders/subscriptions/resources/unsubscribe", params)
|
||||
return err
|
||||
}
|
||||
|
||||
func (self *SInstance) UpdateVM(ctx context.Context, input cloudprovider.SInstanceUpdateOptions) error {
|
||||
return self.host.zone.region.UpdateVM(self.GetId(), input)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user