fix(region): unified name sync options (#15740)

This commit is contained in:
屈轩
2023-01-15 14:50:31 +08:00
committed by GitHub
parent 515825c69b
commit a95bd97904
27 changed files with 149 additions and 61 deletions
+6 -4
View File
@@ -548,11 +548,13 @@ func (self *SCachedimage) canDeleteLastCache() bool {
func (self *SCachedimage) syncWithCloudImage(ctx context.Context, userCred mcclient.TokenCredential, ownerId mcclient.IIdentityProvider, image cloudprovider.ICloudImage, managerId string) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
newName, err := db.GenerateAlterName(self, image.GetName())
if err != nil {
return errors.Wrap(err, "GenerateAlterName")
if options.Options.EnableSyncName {
newName, err := db.GenerateAlterName(self, image.GetName())
if err != nil {
return errors.Wrap(err, "GenerateAlterName")
}
self.Name = newName
}
self.Name = newName
self.Size = image.GetSizeByte()
self.ExternalId = image.GetGlobalId()
self.ImageType = string(image.GetImageType())
+4 -1
View File
@@ -33,6 +33,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -206,7 +207,9 @@ func (self *SCDNDomain) GetICloudCDNDomain(ctx context.Context) (cloudprovider.I
func (self *SCDNDomain) SyncWithCloudCDNDomain(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudCDNDomain) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.Name = ext.GetName()
if options.Options.EnableSyncName {
self.Name = ext.GetName()
}
self.Status = ext.GetStatus()
self.Area = ext.GetArea()
self.ServiceType = ext.GetServiceType()
+6
View File
@@ -1632,6 +1632,12 @@ func (self *SDBInstance) SyncAllWithCloudDBInstance(ctx context.Context, userCre
func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, ext cloudprovider.ICloudDBInstance) error {
diff, err := db.Update(self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.ExternalId = ext.GetGlobalId()
self.Engine = ext.GetEngine()
self.EngineVersion = ext.GetEngineVersion()
+7 -1
View File
@@ -1652,7 +1652,13 @@ func (self *SDisk) syncWithCloudDisk(ctx context.Context, userCred mcclient.Toke
}
diff, err := db.UpdateWithLock(ctx, self, func() error {
// self.Name = extDisk.GetName()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, extDisk.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = extDisk.GetStatus()
self.DiskFormat = extDisk.GetDiskFormat()
self.DiskSize = extDisk.GetDiskSizeMB()
+8 -1
View File
@@ -34,6 +34,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -412,7 +413,13 @@ func (self *SElasticSearch) syncRemoveCloudElasticSearch(ctx context.Context, us
// 同步资源属性
func (self *SElasticSearch) SyncWithCloudElasticSearch(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudElasticSearch) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.ExternalId = ext.GetGlobalId()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
self.Version = ext.GetVersion()
self.StorageType = ext.GetStorageType()
@@ -587,6 +587,13 @@ func (self *SElasticcache) syncRemoveCloudElasticcache(ctx context.Context, user
func (self *SElasticcache) SyncWithCloudElasticcache(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extInstance cloudprovider.ICloudElasticcache) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, extInstance.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = extInstance.GetStatus()
self.InstanceType = extInstance.GetInstanceType()
self.CapacityMB = extInstance.GetCapacityMB()
+7
View File
@@ -41,6 +41,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -509,6 +510,12 @@ func (self *SElasticip) SyncInstanceWithCloudEip(ctx context.Context, userCred m
func (self *SElasticip) SyncWithCloudEip(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, ext cloudprovider.ICloudEIP, syncOwnerId mcclient.IIdentityProvider) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
if bandwidth := ext.GetBandwidth(); bandwidth != 0 {
self.Bandwidth = bandwidth
}
+7
View File
@@ -446,6 +446,13 @@ func (self *SFileSystem) SyncAllWithCloudFileSystem(ctx context.Context, userCre
func (self *SFileSystem) SyncWithCloudFileSystem(ctx context.Context, userCred mcclient.TokenCredential, fs cloudprovider.ICloudFileSystem) error {
diff, err := db.Update(self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, fs.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = fs.GetStatus()
self.StorageType = fs.GetStorageType()
self.Protocol = fs.GetProtocol()
+3 -3
View File
@@ -2761,7 +2761,7 @@ func (self *SGuest) syncRemoveCloudVM(ctx context.Context, userCred mcclient.Tok
return errors.Wrap(err, "GetIVMById")
}
if options.SyncPurgeRemovedResources.Contains(self.Keyword()) {
if options.Options.EnableSyncPurge {
log.Debugf("purge removed resource %s", self.Name)
err := self.purge(ctx, userCred)
if err != nil {
@@ -2845,7 +2845,7 @@ func (self *SGuest) syncWithCloudVM(ctx context.Context, userCred mcclient.Token
}
diff, err := db.UpdateWithLock(ctx, self, func() error {
if options.NameSyncResources.Contains(self.Keyword()) && !recycle {
if options.Options.EnableSyncName && !recycle {
newName, _ := db.GenerateAlterName(self, extVM.GetName())
if len(newName) > 0 && newName != self.Name {
self.Name = newName
@@ -3024,7 +3024,7 @@ func (manager *SGuestManager) newCloudVM(ctx context.Context, userCred mcclient.
lockman.LockRawObject(ctx, manager.Keyword(), "name")
defer lockman.ReleaseRawObject(ctx, manager.Keyword(), "name")
if options.NameSyncResources.Contains(manager.Keyword()) {
if options.Options.EnableSyncName {
guest.Name = extVM.GetName()
} else {
newName, err := db.GenerateName(ctx, manager, syncOwnerId, extVM.GetName())
+4 -1
View File
@@ -33,6 +33,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -414,7 +415,9 @@ func (self *SInterVpcNetwork) SyncWithCloudInterVpcNetwork(ctx context.Context,
_, err := db.Update(self, func() error {
self.ExternalId = ext.GetGlobalId()
self.Status = ext.GetStatus()
self.Name = ext.GetName()
if options.Options.EnableSyncName {
self.Name = ext.GetName()
}
return nil
})
if err != nil {
+8
View File
@@ -30,6 +30,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -146,6 +147,13 @@ func (self *SIPv6Gateway) syncRemoveCloudIPv6Gateway(ctx context.Context, userCr
func (self *SIPv6Gateway) SyncWithCloudIPv6Gateway(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudIPv6Gateway, provider *SCloudprovider) error {
diff, err := db.Update(self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
self.InstanceType = ext.GetInstanceType()
return nil
+8 -1
View File
@@ -34,6 +34,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -408,7 +409,13 @@ func (self *SKafka) syncRemoveCloudKafka(ctx context.Context, userCred mcclient.
// 同步资源属性
func (self *SKafka) SyncWithCloudKafka(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudKafka) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.ExternalId = ext.GetGlobalId()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
self.InstanceType = ext.GetInstanceType()
self.Version = ext.GetVersion()
+2 -1
View File
@@ -31,6 +31,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -218,7 +219,7 @@ func (self *SCachedLoadbalancerAcl) syncRemoveCloudLoadbalanceAcl(ctx context.Co
func (acl *SCachedLoadbalancerAcl) SyncWithCloudLoadbalancerAcl(ctx context.Context, userCred mcclient.TokenCredential, extAcl cloudprovider.ICloudLoadbalancerAcl, projectId mcclient.IIdentityProvider) error {
diff, err := db.UpdateWithLock(ctx, acl, func() error {
// todo: 华为云acl没有name字段应此不需要同步名称
if !utils.IsInStringArray(acl.GetProviderName(), []string{api.CLOUD_PROVIDER_HUAWEI, api.CLOUD_PROVIDER_HCSO, api.CLOUD_PROVIDER_HCS}) {
if options.Options.EnableSyncName && !utils.IsInStringArray(acl.GetProviderName(), []string{api.CLOUD_PROVIDER_HUAWEI, api.CLOUD_PROVIDER_HCSO, api.CLOUD_PROVIDER_HCS}) {
acl.Name = extAcl.GetName()
}
return nil
+8 -1
View File
@@ -42,6 +42,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -1297,10 +1298,16 @@ func (lb *SLoadbalancer) syncWithCloudLoadbalancer(ctx context.Context, userCred
defer lockman.ReleaseObject(ctx, lb)
diff, err := db.Update(lb, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(lb, ext.GetName())
if len(newName) > 0 {
lb.Name = newName
}
}
lb.Address = ext.GetAddress()
lb.AddressType = ext.GetAddressType()
lb.Status = ext.GetStatus()
// lb.Name = ext.GetName()
lb.LoadbalancerSpec = ext.GetLoadbalancerSpec()
lb.EgressMbps = ext.GetEgressMbps()
lb.ChargeType = ext.GetChargeType()
+8
View File
@@ -32,6 +32,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/validators"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -425,6 +426,13 @@ func (self *SModelartsPool) SyncWithCloudModelartsPool(ctx context.Context, user
return errors.Wrapf(err, "get modelartsPoolSku")
}
diff, err := db.UpdateWithLock(ctx, self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
self.BillingType = ext.GetBillingType()
self.InstanceType = instanceName
+8 -1
View File
@@ -36,6 +36,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/quotas"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/rbacutils"
@@ -490,7 +491,13 @@ func (self *SMongoDB) SyncAllWithCloudMongoDB(ctx context.Context, userCred mccl
func (self *SMongoDB) SyncWithCloudMongoDB(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudMongoDB) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
self.ExternalId = ext.GetGlobalId()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.IpAddr = ext.GetIpAddr()
self.VcpuCount = ext.GetVcpuCount()
self.VmemSizeMb = ext.GetVmemSizeMb()
+7
View File
@@ -478,6 +478,13 @@ func (self *SNatGateway) ValidateDeleteCondition(ctx context.Context, info jsonu
func (self *SNatGateway) SyncWithCloudNatGateway(ctx context.Context, userCred mcclient.TokenCredential, provider *SCloudprovider, extNat cloudprovider.ICloudNatGateway) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, extNat.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = extNat.GetStatus()
self.NatSpec = extNat.GetNatSpec()
self.BandwidthMb = extNat.GetBandwidthMb()
+7 -1
View File
@@ -636,7 +636,13 @@ func (self *SNetwork) syncRemoveCloudNetwork(ctx context.Context, userCred mccli
func (self *SNetwork) SyncWithCloudNetwork(ctx context.Context, userCred mcclient.TokenCredential, extNet cloudprovider.ICloudNetwork, syncOwnerId mcclient.IIdentityProvider, provider *SCloudprovider) error {
vpc, _ := self.GetVpc()
diff, err := db.UpdateWithLock(ctx, self, func() error {
extNet.Refresh()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, extNet.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = extNet.GetStatus()
self.GuestIpStart = extNet.GetIpStart()
self.GuestIpEnd = extNet.GetIpEnd()
+4 -1
View File
@@ -34,6 +34,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -372,7 +373,9 @@ func (self *SSecurityGroupCache) GetSecgroup() (*SSecurityGroup, error) {
func (self *SSecurityGroupCache) SyncBaseInfo(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudSecurityGroup) error {
_, err := db.Update(self, func() error {
self.Status = api.SECGROUP_CACHE_STATUS_READY
self.Name = ext.GetName()
if options.Options.EnableSyncName {
self.Name = ext.GetName()
}
self.Description = ext.GetDescription()
self.ExternalProjectId = ext.GetProjectId()
references, err := ext.GetReferences()
+6 -1
View File
@@ -885,7 +885,12 @@ func (self *SSnapshot) syncRemoveCloudSnapshot(ctx context.Context, userCred mcc
// Only sync snapshot status
func (self *SSnapshot) SyncWithCloudSnapshot(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudSnapshot, syncOwnerId mcclient.IIdentityProvider, region *SCloudregion) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
// self.Name = ext.GetName()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
self.DiskType = ext.GetDiskType()
self.Size = int(ext.GetSizeMb())
+8
View File
@@ -30,6 +30,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/notifyclient"
"yunion.io/x/onecloud/pkg/cloudcommon/policy"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -145,6 +146,13 @@ func (self *STablestore) syncRemoveCloudTablestore(ctx context.Context, userCred
func (self *STablestore) SyncWithCloudTablestore(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudTablestore, provider *SCloudprovider) error {
diff, err := db.Update(self, func() error {
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, ext.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = ext.GetStatus()
return nil
})
+6 -2
View File
@@ -523,8 +523,12 @@ func (self *SVpc) syncRemoveCloudVpc(ctx context.Context, userCred mcclient.Toke
func (self *SVpc) SyncWithCloudVpc(ctx context.Context, userCred mcclient.TokenCredential, extVPC cloudprovider.ICloudVpc, provider *SCloudprovider) error {
diff, err := db.UpdateWithLock(ctx, self, func() error {
extVPC.Refresh()
// self.Name = extVPC.GetName()
if options.Options.EnableSyncName {
newName, _ := db.GenerateAlterName(self, extVPC.GetName())
if len(newName) > 0 {
self.Name = newName
}
}
self.Status = extVPC.GetStatus()
self.CidrBlock = extVPC.GetCidrBlock()
self.IsDefault = extVPC.GetIsDefault()
+4 -1
View File
@@ -28,6 +28,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -248,7 +249,9 @@ func (self *SWafIPSetCache) GetICloudWafIPSet(ctx context.Context) (cloudprovide
func (self *SWafIPSetCache) syncWithCloudIPSet(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudWafIPSet) error {
_, err := db.Update(self, func() error {
self.Status = api.WAF_IPSET_STATUS_AVAILABLE
self.Name = ext.GetName()
if options.Options.EnableSyncName {
self.Name = ext.GetName()
}
self.Description = ext.GetDesc()
return nil
})
+4 -1
View File
@@ -28,6 +28,7 @@ import (
"yunion.io/x/onecloud/pkg/cloudcommon/db"
"yunion.io/x/onecloud/pkg/cloudcommon/db/lockman"
"yunion.io/x/onecloud/pkg/cloudcommon/db/taskman"
"yunion.io/x/onecloud/pkg/compute/options"
"yunion.io/x/onecloud/pkg/httperrors"
"yunion.io/x/onecloud/pkg/mcclient"
"yunion.io/x/onecloud/pkg/util/stringutils2"
@@ -248,7 +249,9 @@ func (self *SWafRegexSetCache) GetICloudWafRegexSet(ctx context.Context) (cloudp
func (self *SWafRegexSetCache) syncWithCloudRegexSet(ctx context.Context, userCred mcclient.TokenCredential, ext cloudprovider.ICloudWafRegexSet) error {
_, err := db.Update(self, func() error {
self.Status = api.WAF_IPSET_STATUS_AVAILABLE
self.Name = ext.GetName()
if options.Options.EnableSyncName {
self.Name = ext.GetName()
}
self.Description = ext.GetDesc()
return nil
})
-35
View File
@@ -1,35 +0,0 @@
// Copyright 2019 Yunion
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package options
import (
"yunion.io/x/log"
"yunion.io/x/onecloud/pkg/util/stringutils2"
)
var (
NameSyncResources stringutils2.SSortedStrings
SyncPurgeRemovedResources stringutils2.SSortedStrings
)
func InitNameSyncResources() {
NameSyncResources = stringutils2.NewSortedStrings(Options.NameSyncResources)
log.Infof("NameSyncResources: %s", NameSyncResources)
SyncPurgeRemovedResources = stringutils2.NewSortedStrings(Options.SyncPurgeRemovedResources)
log.Infof("SyncPurgeRemovedResources: %s", SyncPurgeRemovedResources)
}
+2 -2
View File
@@ -141,9 +141,9 @@ type ComputeOptions struct {
DefaultSyncIntervalSeconds int `help:"minimal synchronization interval, default 15 minutes" default:"900"`
MaxCloudAccountErrorCount int `help:"maximal consecutive error count allow for a cloud account" default:"5"`
NameSyncResources []string `help:"resources that need synchronization of name"`
EnableSyncName bool `help:"enable name sync" default:"true"`
SyncPurgeRemovedResources []string `help:"resources that shoud be purged immediately if found removed" default:"server"`
EnableSyncPurge bool `help:"resources that shoud be purged immediately if found removed" default:"true"`
DisconnectedCloudAccountRetryProbeIntervalHours int `help:"interval to wait to probe status of a disconnected cloud account" default:"2"`
-2
View File
@@ -100,8 +100,6 @@ func StartService() {
db.EnsureAppSyncDB(app, dbOpts, models.InitDB)
defer cloudcommon.CloseDB()
options.InitNameSyncResources()
setInfluxdbRetentionPolicy()
models.InitSyncWorkers(options.Options.CloudSyncWorkerCount)