fix(region): support skip sync resource

This commit is contained in:
ioito
2023-07-03 14:51:06 +08:00
parent 866c4ed8eb
commit 33694abfe5
7 changed files with 236 additions and 47 deletions
+48
View File
@@ -211,6 +211,9 @@ type CloudaccountCreateInput struct {
// 是否立即开始同步资源
StartSync *bool `json:"start_sync"`
// 跳过指定资源同步
SkipSyncResources SkipSyncResources `json:"skip_sync_resources"`
}
type SProjectMappingResourceInput struct {
@@ -376,6 +379,10 @@ type CloudaccountUpdateInput struct {
// 临时清除缺失的权限提示,云账号权限缺失依然会自动刷新
CleanLakeOfPermissions bool `json:"clean_lake_of_permissions"`
SkipSyncResources *SkipSyncResources `json:"skip_sync_resources"`
AddSkipSyncResources []string `json:"add_skip_sync_resources"`
RemoveSkipSyncResources []string `json:"remove_skip_sync_resources"`
ReadOnly bool `json:"read_only"`
}
@@ -546,15 +553,52 @@ type SyncRangeInput struct {
Zone []string `json:"zone"`
Host []string `json:"host"`
// swagger: ignore
SkipSyncResources []string `json:"skip_sync_resources"`
// 按资源类型同步,可输入多个
// enmu: project, compute, network, eip, loadbalancer, objectstore, rds, cache, event, cloudid, dnszone, public_ip, intervpcnetwork, saml_auth, quota, nat, nas, waf, mongodb, es, kafka, app, cdn, container, ipv6_gateway, tablestore, modelarts, vpcpeer, misc
Resources []string `json:"resources" choices:"project|compute|network|eip|loadbalancer|objectstore|rds|cache|event|cloudid|dnszone|public_ip|intervpcnetwork|saml_auth|quota|nat|nas|waf|mongodb|es|kafka|app|cdn|container|ipv6_gateway|tablestore|modelarts|vpcpeer|misc"`
}
type iRes interface {
Keyword() string
}
func (self *SyncRangeInput) IsNotSkipSyncResource(res iRes) bool {
return !utils.IsInStringArray(res.Keyword(), self.SkipSyncResources)
}
type SAccountPermission struct {
Permissions []string
}
type SkipSyncResources []string
func (s SkipSyncResources) String() string {
return jsonutils.Marshal(s).String()
}
func (s *SkipSyncResources) Add(res string) {
if !utils.IsInStringArray(res, *s) {
*s = append(*s, res)
}
}
func (s *SkipSyncResources) Remove(res string) {
ret := []string{}
for _, r := range *s {
if r != res {
ret = append(ret, r)
}
}
*s = ret
}
func (s SkipSyncResources) IsZero() bool {
return len(s) == 0
}
type SAccountPermissions map[string]SAccountPermission
func (s SAccountPermissions) String() string {
@@ -569,4 +613,8 @@ func init() {
gotypes.RegisterSerializable(reflect.TypeOf(&SAccountPermissions{}), func() gotypes.ISerializable {
return &SAccountPermissions{}
})
gotypes.RegisterSerializable(reflect.TypeOf(&SkipSyncResources{}), func() gotypes.ISerializable {
return &SkipSyncResources{}
})
}
+29
View File
@@ -164,6 +164,16 @@ type SCloudaccount struct {
// 缺失的权限,云账号操作资源时自动更新
LakeOfPermissions *api.SAccountPermissions `length:"medium" get:"user" list:"user"`
// 跳过部分资源同步
SkipSyncResources *api.SkipSyncResources `length:"medium" get:"user" update:"domain" list:"user"`
}
func (self *SCloudaccount) IsNotSkipSyncResource(res lockman.ILockedClass) bool {
if self.SkipSyncResources != nil && utils.IsInStringArray(res.Keyword(), *self.SkipSyncResources) {
return false
}
return true
}
func (self *SCloudaccount) GetCloudproviders() []SCloudprovider {
@@ -283,6 +293,19 @@ func (self *SCloudaccount) ValidateUpdateData(
input.Options = optionsJson
}
if self.SkipSyncResources == nil {
self.SkipSyncResources = &api.SkipSyncResources{}
}
if input.SkipSyncResources != nil {
self.SkipSyncResources = input.SkipSyncResources
}
for _, res := range input.AddSkipSyncResources {
self.SkipSyncResources.Add(res)
}
for _, res := range input.RemoveSkipSyncResources {
self.SkipSyncResources.Remove(res)
}
factory, err := self.GetProviderFactory()
if err != nil {
return input, httperrors.NewGeneralError(errors.Wrapf(err, "GetProviderFactory"))
@@ -622,6 +645,12 @@ func (self *SCloudaccount) PerformSync(ctx context.Context, userCred mcclient.To
if syncRange.FullSync || len(syncRange.Region) > 0 || len(syncRange.Zone) > 0 || len(syncRange.Host) > 0 || len(syncRange.Resources) > 0 {
syncRange.DeepSync = true
}
syncRange.SkipSyncResources = []string{}
if self.SkipSyncResources != nil {
for _, res := range *self.SkipSyncResources {
syncRange.SkipSyncResources = append(syncRange.SkipSyncResources, res)
}
}
if self.CanSync() || syncRange.Force {
return nil, self.StartSyncCloudAccountInfoTask(ctx, userCred, &syncRange, "", nil)
}
+6
View File
@@ -657,6 +657,12 @@ func (self *SCloudprovider) PerformSync(ctx context.Context, userCred mcclient.T
if syncRange.FullSync || len(syncRange.Region) > 0 || len(syncRange.Zone) > 0 || len(syncRange.Host) > 0 || len(syncRange.Resources) > 0 {
syncRange.DeepSync = true
}
syncRange.SkipSyncResources = []string{}
if account.SkipSyncResources != nil {
for _, res := range *account.SkipSyncResources {
syncRange.SkipSyncResources = append(syncRange.SkipSyncResources, res)
}
}
if self.CanSync() || syncRange.Force {
return nil, self.StartSyncCloudProviderInfoTask(ctx, userCred, &syncRange, "")
}
+122 -46
View File
@@ -557,7 +557,9 @@ func syncVpcNatgateways(ctx context.Context, userCred mcclient.TokenCredential,
return
}
syncNatGatewayEips(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i])
if syncRange.IsNotSkipSyncResource(ElasticipManager) {
syncNatGatewayEips(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i])
}
syncNatDTable(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i], syncRange.Xor)
syncNatSTable(ctx, userCred, provider, &localNatGateways[i], remoteNatGateways[i], syncRange.Xor)
}()
@@ -1004,9 +1006,12 @@ func syncVMPeripherals(
if err != nil {
log.Errorf("syncVMDisks error %s", err)
}
err = syncVMEip(ctx, userCred, provider, local, remote)
if err != nil {
log.Errorf("syncVMEip error %s", err)
account, _ := provider.GetCloudaccount()
if account == nil || account.IsNotSkipSyncResource(ElasticipManager) {
err = syncVMEip(ctx, userCred, provider, local, remote)
if err != nil {
log.Errorf("syncVMEip error %s", err)
}
}
err = syncVMSecgroups(ctx, userCred, provider, local, remote)
if err != nil {
@@ -1156,7 +1161,7 @@ func syncRegionDBInstances(
return
}
syncDBInstanceResource(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i])
syncDBInstanceResource(ctx, userCred, syncResults, &localInstances[i], remoteInstances[i], syncRange)
}()
}
}
@@ -1202,14 +1207,14 @@ func syncNATSkus(ctx context.Context, userCred mcclient.TokenCredential, syncRes
return
}
result := func() compare.SyncResult {
defer syncResults.AddSqlCost(DBInstanceSkuManager)()
defer syncResults.AddSqlCost(NatSkuManager)()
return localRegion.SyncPrivateCloudNatSkus(ctx, userCred, skus)
}()
syncResults.Add(NasSkuManager, result)
syncResults.Add(NatSkuManager, result)
msg := result.Result()
log.Infof("SyncNasSkus for region %s result: %s", localRegion.Name, msg)
log.Infof("SyncNatSkus for region %s result: %s", localRegion.Name, msg)
if result.IsError() {
return
}
@@ -1233,7 +1238,7 @@ func syncCacheSkus(ctx context.Context, userCred mcclient.TokenCredential, syncR
return localRegion.SyncPrivateCloudCacheSkus(ctx, userCred, skus)
}()
syncResults.Add(NasSkuManager, result)
syncResults.Add(ElasticcacheSkuManager, result)
msg := result.Result()
log.Infof("SyncRedisSkus for region %s result: %s", localRegion.Name, msg)
@@ -1242,7 +1247,14 @@ func syncCacheSkus(ctx context.Context, userCred mcclient.TokenCredential, syncR
}
}
func syncDBInstanceResource(ctx context.Context, userCred mcclient.TokenCredential, syncResults SSyncResultSet, localInstance *SDBInstance, remoteInstance cloudprovider.ICloudDBInstance) {
func syncDBInstanceResource(
ctx context.Context,
userCred mcclient.TokenCredential,
syncResults SSyncResultSet,
localInstance *SDBInstance,
remoteInstance cloudprovider.ICloudDBInstance,
syncRange *SSyncRange,
) {
err := syncDBInstanceNetwork(ctx, userCred, syncResults, localInstance, remoteInstance)
if err != nil {
log.Errorf("syncDBInstanceNetwork error: %v", err)
@@ -1255,9 +1267,11 @@ func syncDBInstanceResource(ctx context.Context, userCred mcclient.TokenCredenti
if err != nil {
log.Errorf("syncDBInstanceParameters error: %v", err)
}
err = syncDBInstanceDatabases(ctx, userCred, syncResults, localInstance, remoteInstance)
if err != nil {
log.Errorf("syncDBInstanceParameters error: %v", err)
if syncRange.IsNotSkipSyncResource(DBInstanceBackupManager) {
err = syncDBInstanceDatabases(ctx, userCred, syncResults, localInstance, remoteInstance)
if err != nil {
log.Errorf("syncDBInstanceParameters error: %v", err)
}
}
err = syncDBInstanceAccounts(ctx, userCred, syncResults, localInstance, remoteInstance)
if err != nil {
@@ -1963,26 +1977,40 @@ func syncPublicCloudProviderInfo(
if !driver.GetFactory().NeedSyncSkuFromCloud() {
syncRegionSkus(ctx, userCred, localRegion, syncRange.Xor)
SyncRegionDBInstanceSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
SyncRegionNatSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
SyncRegionNasSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(DBInstanceManager) {
SyncRegionDBInstanceSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
}
if syncRange.IsNotSkipSyncResource(NatSkuManager) {
SyncRegionNatSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
}
if syncRange.IsNotSkipSyncResource(NasSkuManager) {
SyncRegionNasSkus(ctx, userCred, localRegion.Id, true, syncRange.Xor)
}
} else {
syncSkusFromPrivateCloud(ctx, userCred, syncResults, localRegion, remoteRegion, syncRange.Xor)
if cloudprovider.IsSupportRds(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_RDS) {
syncDBInstanceSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(DBInstanceManager) {
syncDBInstanceSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportNAT(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_NAT) {
syncNATSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(NatSkuManager) {
syncNATSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportElasticCache(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_CACHE) {
syncCacheSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(ElasticcacheManager) {
syncCacheSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
}
// no need to lock public cloud region as cloud region for public cloud is readonly
if cloudprovider.IsSupportObjectstore(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE) {
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(BucketManager) {
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportCompute(driver) {
@@ -1991,12 +2019,16 @@ func syncPublicCloudProviderInfo(
if !(driver.GetFactory().IsPublicCloud() && !syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_NETWORK)) {
syncRegionVPCs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
syncRegionEips(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(ElasticipManager) {
syncRegionEips(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_COMPUTE) {
// sync snapshot policies before sync disks
syncRegionSnapshotPolicies(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(SnapshotPolicyManager) {
// sync snapshot policies before sync disks
syncRegionSnapshotPolicies(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
for j := 0; j < len(localZones); j += 1 {
@@ -2016,71 +2048,113 @@ func syncPublicCloudProviderInfo(
}
// sync snapshots after sync disks
syncRegionSnapshots(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(SnapshotManager) {
syncRegionSnapshots(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
}
if cloudprovider.IsSupportNAS(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_NAS) {
syncRegionAccessGroups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
syncRegionFileSystems(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(AccessGroupManager) {
syncRegionAccessGroups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
if syncRange.IsNotSkipSyncResource(FileSystemManager) {
syncRegionFileSystems(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportLoadbalancer(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_LOADBALANCER) {
syncRegionLoadbalancerAcls(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
syncRegionLoadbalancerCertificates(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
syncRegionLoadbalancers(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(LoadbalancerAclManager) {
syncRegionLoadbalancerAcls(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
if syncRange.IsNotSkipSyncResource(LoadbalancerCertificateManager) {
syncRegionLoadbalancerCertificates(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
if syncRange.IsNotSkipSyncResource(LoadbalancerManager) {
syncRegionLoadbalancers(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportCompute(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_COMPUTE) {
syncRegionNetworkInterfaces(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(NetworkInterfaceManager) {
syncRegionNetworkInterfaces(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportRds(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_RDS) {
syncRegionDBInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
syncRegionDBInstanceBackups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(DBInstanceManager) {
syncRegionDBInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
if syncRange.IsNotSkipSyncResource(DBInstanceBackupManager) {
syncRegionDBInstanceBackups(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportElasticCache(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_CACHE) {
syncElasticcaches(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
if syncRange.IsNotSkipSyncResource(ElasticcacheManager) {
syncElasticcaches(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange)
}
}
if cloudprovider.IsSupportWaf(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_WAF) {
syncWafIPSets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
syncWafRegexSets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
syncWafInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(WafIPSetManager) {
syncWafIPSets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
if syncRange.IsNotSkipSyncResource(WafRegexSetManager) {
syncWafRegexSets(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
if syncRange.IsNotSkipSyncResource(WafInstanceManager) {
syncWafInstances(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportMongoDB(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_MONGO_DB) {
syncMongoDBs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(MongoDBManager) {
syncMongoDBs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportElasticSearch(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_ES) {
syncElasticSearchs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(ElasticSearchManager) {
syncElasticSearchs(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportKafka(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_KAFKA) {
syncKafkas(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(KafkaManager) {
syncKafkas(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportApp(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_APP) {
syncApps(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(AppManager) {
syncApps(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportContainer(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_CONTAINER) {
syncKubeClusters(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(KubeClusterManager) {
syncKubeClusters(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportTablestore(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_TABLESTORE) {
syncTablestore(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(TablestoreManager) {
syncTablestore(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportModelartsPool(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_MODELARTES) {
syncModelartsPoolSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
syncModelartsPools(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(ModelartsPoolManager) {
syncModelartsPoolSkus(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
syncModelartsPools(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportMiscResources(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_MISC) {
syncMiscResources(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(MiscResourceManager) {
syncMiscResources(ctx, userCred, syncResults, provider, localRegion, remoteRegion, syncRange.Xor)
}
}
if cloudprovider.IsSupportCompute(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_COMPUTE) {
@@ -2197,7 +2271,9 @@ func syncOnPremiseCloudProviderInfo(
localRegion := CloudregionManager.FetchDefaultRegion()
if cloudprovider.IsSupportObjectstore(driver) && syncRange.NeedSyncResource(cloudprovider.CLOUD_CAPABILITY_OBJECTSTORE) {
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, iregion, syncRange.Xor)
if syncRange.IsNotSkipSyncResource(BucketManager) {
syncRegionBuckets(ctx, userCred, syncResults, provider, localRegion, iregion, syncRange.Xor)
}
}
var storageCachePairs []sStoragecacheSyncPair
+1 -1
View File
@@ -1648,7 +1648,7 @@ func (self *SDBInstance) SyncAllWithCloudDBInstance(ctx context.Context, userCre
if err != nil {
return errors.Wrapf(err, "SyncWithCloudDBInstance")
}
syncDBInstanceResource(ctx, userCred, SSyncResultSet{}, self, extInstance)
syncDBInstanceResource(ctx, userCred, SSyncResultSet{}, self, extInstance, &SSyncRange{})
return nil
}
+8
View File
@@ -3033,6 +3033,14 @@ func (self *SDisk) syncSnapshots(ctx context.Context, userCred mcclient.TokenCre
}
region, _ := storage.GetRegion()
account, err := provider.GetCloudaccount()
if err != nil {
return
}
if account != nil && !account.IsNotSkipSyncResource(SnapshotManager) {
return
}
extSnapshots, err := extDisk.GetISnapshots()
if err != nil {
syncResult.Error(err)
+22
View File
@@ -140,6 +140,8 @@ type SCloudAccountCreateBaseOptions struct {
ProjectMappingId string
EnableProjectSync bool
EnableResourceSync bool
SkipSyncResources []string `help:"Skip sync resource, etc snapshot"`
}
type SVMwareCloudAccountCreateOptions struct {
@@ -626,6 +628,10 @@ type SCloudAccountUpdateBaseOptions struct {
CleanLakeOfPermissions bool `help:"clean lake of permissions"`
SkipSyncResources []string
AddSkipSyncResources []string
RemoveSkipSyncResources []string
Desc string `help:"Description" json:"description" token:"desc"`
}
@@ -1162,6 +1168,10 @@ type SNutanixCloudAccountUpdateOptions struct {
SCloudAccountUpdateBaseOptions
}
func (opts *SNutanixCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type SBingoCloudAccountCreateOptions struct {
SCloudAccountCreateBaseOptions
Endpoint string
@@ -1178,6 +1188,10 @@ type SBingoCloudAccountUpdateOptions struct {
SCloudAccountUpdateBaseOptions
}
func (opts *SBingoCloudAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type SBingoCloudAccountUpdateCredentialOptions struct {
SCloudAccountIdOptions
SAccessKeyCredential
@@ -1203,6 +1217,10 @@ type SInCloudSphereAccountUpdateOptions struct {
SCloudAccountUpdateBaseOptions
}
func (opts *SInCloudSphereAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type SInCloudSphereAccountUpdateCredentialOptions struct {
SCloudAccountIdOptions
SAccessKeyCredential
@@ -1227,6 +1245,10 @@ type SProxmoxAccountUpdateOptions struct {
SCloudAccountUpdateBaseOptions
}
func (opts *SProxmoxAccountUpdateOptions) Params() (jsonutils.JSONObject, error) {
return jsonutils.Marshal(opts), nil
}
type SProxmoxAccountUpdateCredentialOptions struct {
SCloudAccountIdOptions
SUserPasswordCredential