mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-24 16:03:43 +08:00
fix(region): sync owner id
This commit is contained in:
@@ -1641,7 +1641,7 @@ func (self *SDBInstance) SyncWithCloudDBInstance(ctx context.Context, userCred m
|
||||
return err
|
||||
}
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, ext)
|
||||
SyncCloudProject(userCred, self, userCred, ext, provider.Id)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), ext, provider.Id)
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
if len(diff) > 0 {
|
||||
notifyclient.EventNotify(ctx, userCred, notifyclient.SEventNotifyParam{
|
||||
@@ -1735,7 +1735,7 @@ func (manager *SDBInstanceManager) newFromCloudDBInstance(ctx context.Context, u
|
||||
}
|
||||
|
||||
syncVirtualResourceMetadata(ctx, userCred, &instance, extInstance)
|
||||
SyncCloudProject(userCred, &instance, ownerId, extInstance, provider.Id)
|
||||
SyncCloudProject(userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
|
||||
db.OpsLog.LogEvent(&instance, db.ACT_CREATE, instance.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -621,7 +621,7 @@ func (self *SElasticcache) SyncWithCloudElasticcache(ctx context.Context, userCr
|
||||
if err != nil {
|
||||
return errors.Wrapf(err, "syncWithCloudElasticcache.Update")
|
||||
}
|
||||
SyncCloudProject(userCred, self, userCred, extInstance, provider.Id)
|
||||
SyncCloudProject(userCred, self, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
syncVirtualResourceMetadata(ctx, userCred, self, extInstance)
|
||||
db.OpsLog.LogSyncUpdate(self, diff, userCred)
|
||||
if len(diff) > 0 {
|
||||
@@ -746,7 +746,7 @@ func (manager *SElasticcacheManager) newFromCloudElasticcache(ctx context.Contex
|
||||
return nil, errors.Wrapf(err, "newFromCloudElasticcache.Insert")
|
||||
}
|
||||
|
||||
SyncCloudProject(userCred, &instance, ownerId, extInstance, provider.Id)
|
||||
SyncCloudProject(userCred, &instance, provider.GetOwnerId(), extInstance, provider.Id)
|
||||
syncVirtualResourceMetadata(ctx, userCred, &instance, extInstance)
|
||||
db.OpsLog.LogEvent(&instance, db.ACT_CREATE, instance.GetShortDesc(ctx), userCred)
|
||||
|
||||
|
||||
@@ -918,11 +918,17 @@ func (self *SAzureClient) GetIStorageById(id string) (cloudprovider.ICloudStorag
|
||||
}
|
||||
|
||||
func getResourceGroup(id string) string {
|
||||
if info := strings.Split(id, "/resourceGroups/"); len(info) == 2 {
|
||||
if resourcegroupInfo := strings.Split(info[1], "/"); len(resourcegroupInfo) > 0 {
|
||||
return strings.ToLower(resourcegroupInfo[0])
|
||||
info := strings.Split(strings.ToLower(id), "/")
|
||||
idx := -1
|
||||
for i := range info {
|
||||
if info[i] == "resourcegroups" {
|
||||
idx = i + 1
|
||||
break
|
||||
}
|
||||
}
|
||||
if idx > 0 && idx < len(info)-1 {
|
||||
return info[idx]
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
|
||||
@@ -69,6 +69,10 @@ func (self *SEnterpriseRedisCache) GetName() string {
|
||||
return self.Name
|
||||
}
|
||||
|
||||
func (self *SEnterpriseRedisCache) GetProjectId() string {
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
func (self *SEnterpriseRedisCache) GetStatus() string {
|
||||
switch self.Properties.Provisioningstate {
|
||||
case "Creating":
|
||||
|
||||
@@ -92,6 +92,10 @@ func (self *SManagedSQLServer) GetCategory() string {
|
||||
return self.Sku.Family
|
||||
}
|
||||
|
||||
func (self *SManagedSQLServer) GetProjectId() string {
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
func (self *SManagedSQLServer) GetIVpcId() string {
|
||||
if len(self.Properties.Subnetid) > 0 {
|
||||
info := strings.Split(self.Properties.Subnetid, "/")
|
||||
|
||||
@@ -100,6 +100,10 @@ func (self *SSQLServer) GetGlobalId() string {
|
||||
return strings.ToLower(self.ID)
|
||||
}
|
||||
|
||||
func (self *SSQLServer) GetProjectId() string {
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
func (self *SSQLServer) GetCategory() string {
|
||||
return api.AZURE_DBINSTANCE_CATEGORY_BASIC
|
||||
}
|
||||
|
||||
@@ -90,6 +90,10 @@ func (self *SRedisCache) GetName() string {
|
||||
return self.Name
|
||||
}
|
||||
|
||||
func (self *SRedisCache) GetProjectId() string {
|
||||
return getResourceGroup(self.ID)
|
||||
}
|
||||
|
||||
func (self *SRedisCache) GetStatus() string {
|
||||
switch self.Properties.Provisioningstate {
|
||||
case "Creating":
|
||||
|
||||
Reference in New Issue
Block a user