@@ -18,7 +18,6 @@ import (
1818 "strconv"
1919
2020 "yunion.io/x/jsonutils"
21- "yunion.io/x/log"
2221 "yunion.io/x/pkg/errors"
2322
2423 api "yunion.io/x/cloudmux/pkg/apis/compute"
@@ -333,60 +332,20 @@ func (self *SDomain) Delete() error {
333332 return self .client .DeleteDomain (self .DomainName )
334333}
335334
336- func TDnsProductType (productName string ) cloudprovider.TDnsProductType {
337- switch productName {
338- case "企业旗舰版" :
339- return cloudprovider .DnsProductEnterpriseUltimate
340- case "企业标准版" :
341- return cloudprovider .DnsProductEnterpriseStandard
342- case "个人版" :
343- return cloudprovider .DnsProductPersonalProfessional
344- default :
345- return cloudprovider .DnsProductFree
346- }
347- }
348-
349335func (self * SDomain ) GetDnsProductType () cloudprovider.TDnsProductType {
350- sproducts , err := self .client .GetAllDnsProductInstances ()
351- if err != nil {
352- log .Errorf ("self.client.GetAllDnsProductInstances():%s" , err )
336+ switch self .VersionCode {
337+ case "version_enterprise_advanced" :
338+ return cloudprovider .DnsProductEnterprise
339+ case "mianfei" :
353340 return cloudprovider .DnsProductFree
341+ default :
342+ return cloudprovider .TDnsProductType (self .VersionCode )
354343 }
355- // https://help.aliyun.com/document_detail/29806.html?spm=a2c4g.11186623.4.1.67728197c8SCN9
356- // 免费版,最低600
357- self .ttlMinValue = 600
358- for i := 0 ; i < len (sproducts ); i ++ {
359- if sproducts [i ].Domain == self .DomainName {
360- return TDnsProductType (sproducts [i ].VersionName )
361- }
362- }
363- return cloudprovider .DnsProductFree
364- }
365-
366- func (self * SDomain ) fetchTTLMinValue () (int64 , error ) {
367- if self .ttlMinValue != 0 {
368- return self .ttlMinValue , nil
369- }
370- sproducts , err := self .client .GetAllDnsProductInstances ()
371- if err != nil {
372- return 0 , errors .Wrap (err , "self.client.GetAllDnsProductInstances()" )
373- }
374- // https://help.aliyun.com/document_detail/29806.html?spm=a2c4g.11186623.4.1.67728197c8SCN9
375- // 免费版,最低600
376- self .ttlMinValue = 600
377- for i := 0 ; i < len (sproducts ); i ++ {
378- if sproducts [i ].Domain == self .DomainName {
379- self .ttlMinValue = sproducts [i ].TTLMinValue
380- return self .ttlMinValue , nil
381- }
382- }
383- return self .ttlMinValue , nil
384344}
385345
386346func (self * SDomain ) GetProperlyTTL (ttl int64 ) int64 {
387- ttlMin , err := self .fetchTTLMinValue ()
388- if err != nil {
389- log .Errorf ("self.fetchTTLMinValue():%s" , err )
347+ ttlMin := int64 (1 )
348+ if self .GetDnsProductType () == cloudprovider .DnsProductFree {
390349 ttlMin = 600
391350 }
392351 if ttl <= ttlMin {
0 commit comments