diff --git a/go.mod b/go.mod index 13c8dbe870..968e7099bb 100644 --- a/go.mod +++ b/go.mod @@ -87,7 +87,7 @@ require ( k8s.io/client-go v0.19.3 k8s.io/cluster-bootstrap v0.19.3 moul.io/http2curl/v2 v2.3.0 - yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241025091256-d552aef5b421 + yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241029090712-4a5b6fd13960 yunion.io/x/executor v0.0.0-20230705125604-c5ac3141db32 yunion.io/x/jsonutils v1.0.1-0.20240930100528-1671a2d0d22f yunion.io/x/log v1.0.1-0.20240305175729-7cf2d6cd5a91 diff --git a/go.sum b/go.sum index 64fe4662aa..ec0f9d0a73 100644 --- a/go.sum +++ b/go.sum @@ -1274,8 +1274,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.20241025091256-d552aef5b421 h1:oE9ZrlZv1br/OGlLxZJDlQPrYzxJllqvtjMqVDUKxjM= -yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241025091256-d552aef5b421/go.mod h1:rj/pb3DitJlQaQD8UW1oxx/KD+PzDZqoywzqRJaFE9A= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241029090712-4a5b6fd13960 h1:1O5sJZ9KjaUTEXKTuioLFU6/+poCWHTwWjid8i2W8vc= +yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241029090712-4a5b6fd13960/go.mod h1:rj/pb3DitJlQaQD8UW1oxx/KD+PzDZqoywzqRJaFE9A= 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= diff --git a/vendor/modules.txt b/vendor/modules.txt index 76660128d8..234c4bd12a 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -1576,7 +1576,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.20241025091256-d552aef5b421 +# yunion.io/x/cloudmux v0.3.10-0-alpha.1.0.20241029090712-4a5b6fd13960 ## explicit; go 1.21 yunion.io/x/cloudmux/pkg/apis yunion.io/x/cloudmux/pkg/apis/billing diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/eip.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/eip.go index 42d4ff5534..d752df53dc 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/eip.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/eip.go @@ -20,7 +20,6 @@ import ( "yunion.io/x/jsonutils" "yunion.io/x/pkg/errors" - "yunion.io/x/pkg/util/timeutils" "yunion.io/x/pkg/utils" billing_api "yunion.io/x/cloudmux/pkg/apis/billing" @@ -45,12 +44,12 @@ type SEip struct { Tags string CreatedAt time.Time UpdatedAt time.Time - ExpiredAt string + ExpiredAt time.Time ProjectId string } func (self *SEip) GetBillingType() string { - if len(self.ExpiredAt) > 0 { + if !self.ExpiredAt.IsZero() { return billing_api.BILLING_TYPE_PREPAID } return billing_api.BILLING_TYPE_POSTPAID @@ -61,11 +60,7 @@ func (self *SEip) GetCreatedAt() time.Time { } func (self *SEip) GetExpiredAt() time.Time { - if len(self.ExpiredAt) > 0 { - t, _ := timeutils.ParseTimeStr(self.ExpiredAt) - return t - } - return time.Time{} + return self.ExpiredAt } func (self *SEip) GetId() string { @@ -133,7 +128,10 @@ func (self *SEip) GetBandwidth() int { } func (self *SEip) GetInternetChargeType() string { - return "" + if self.GetBillingType() == billing_api.BILLING_TYPE_PREPAID { + return api.EIP_CHARGE_TYPE_BY_BANDWIDTH + } + return api.EIP_CHARGE_TYPE_BY_TRAFFIC } func (self *SEip) Delete() error { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go index 69e79127d5..de2bb1502e 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ctyun/instance.go @@ -17,7 +17,6 @@ package ctyun import ( "context" "fmt" - "strconv" "strings" "time" @@ -41,7 +40,7 @@ type SInstance struct { image *SImage AzName string - ExpiredTime string + ExpiredTime time.Time CreatedTime time.Time ProjectId string AttachedVolume []string @@ -96,7 +95,7 @@ type SInstance struct { } func (self *SInstance) GetBillingType() string { - if len(self.ExpiredTime) > 0 { + if !self.OnDemand { return billing_api.BILLING_TYPE_PREPAID } return billing_api.BILLING_TYPE_POSTPAID @@ -107,11 +106,7 @@ func (self *SInstance) GetCreatedAt() time.Time { } func (self *SInstance) GetExpiredAt() time.Time { - if len(self.ExpiredTime) > 0 { - expire, _ := strconv.Atoi(self.ExpiredTime) - return time.Unix(int64(expire/1000), 0) - } - return time.Time{} + return self.ExpiredTime } func (self *SInstance) GetId() string { diff --git a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go index 91158dd5ae..4f2cbc6040 100644 --- a/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go +++ b/vendor/yunion.io/x/cloudmux/pkg/multicloud/ucloud/instance.go @@ -184,28 +184,6 @@ func (self *SInstance) Refresh() error { return jsonutils.Update(self, new) } -func (self *SInstance) IsEmulated() bool { - return false -} - -func (self *SInstance) GetSysTags() map[string]string { - data := map[string]string{} - // todo: add price key here - data["zone_ext_id"] = self.host.zone.GetGlobalId() - if len(self.BasicImageID) > 0 { - if image, err := self.host.zone.region.GetImage(self.BasicImageID); err != nil { - log.Errorf("Failed to find image %s for instance %s", self.BasicImageID, self.GetName()) - } else { - meta := image.GetSysTags() - for k, v := range meta { - data[k] = v - } - } - } - - return data -} - // 计费模式,枚举值为: Year,按年付费; Month,按月付费; Dynamic,按需付费(需开启权限); func (self *SInstance) GetBillingType() string { switch self.ChargeType {