mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-09-21 14:19:49 +08:00
fix(region): omit vpc quota check if vpc created by owner
Vpc quota check is omitted if vpc is create by owner user
This commit is contained in:
@@ -3092,7 +3092,7 @@ func (self *SHost) PostCreate(
|
||||
}
|
||||
}
|
||||
|
||||
keys := GetHostQuotaKeysFromCreateInput(input)
|
||||
keys := GetHostQuotaKeysFromCreateInput(ownerId, input)
|
||||
quota := SInfrasQuota{Host: 1}
|
||||
quota.SetKeys(keys)
|
||||
err = quotas.CancelPendingUsage(ctx, userCred, "a, "a, true)
|
||||
@@ -3386,7 +3386,7 @@ func (manager *SHostManager) ValidateCreateData(
|
||||
return input, errors.Wrap(err, "SEnabledStatusInfrasResourceBaseManager.ValidateCreateData")
|
||||
}
|
||||
|
||||
keys := GetHostQuotaKeysFromCreateInput(input)
|
||||
keys := GetHostQuotaKeysFromCreateInput(ownerId, input)
|
||||
quota := SInfrasQuota{Host: 1}
|
||||
quota.SetKeys(keys)
|
||||
err = quotas.CheckSetPendingQuota(ctx, userCred, "a)
|
||||
@@ -5622,8 +5622,8 @@ func (host *SHost) GetChangeOwnerRequiredDomainIds() []string {
|
||||
return requires
|
||||
}
|
||||
|
||||
func GetHostQuotaKeysFromCreateInput(input api.HostCreateInput) quotas.SDomainRegionalCloudResourceKeys {
|
||||
ownerId := &db.SOwnerId{DomainId: input.ProjectDomainId}
|
||||
func GetHostQuotaKeysFromCreateInput(owner mcclient.IIdentityProvider, input api.HostCreateInput) quotas.SDomainRegionalCloudResourceKeys {
|
||||
ownerId := &db.SOwnerId{DomainId: owner.GetProjectDomainId()}
|
||||
var zone *SZone
|
||||
if len(input.ZoneId) > 0 {
|
||||
zone = ZoneManager.FetchZoneById(input.ZoneId)
|
||||
|
||||
@@ -866,7 +866,7 @@ func (manager *SVpcManager) ValidateCreateData(
|
||||
return input, httperrors.NewMissingParameterError("cidr")
|
||||
}
|
||||
|
||||
keys := GetVpcQuotaKeysFromCreateInput(input)
|
||||
keys := GetVpcQuotaKeysFromCreateInput(ownerId, input)
|
||||
quota := &SInfrasQuota{Vpc: 1}
|
||||
quota.SetKeys(keys)
|
||||
err = quotas.CheckSetPendingQuota(ctx, userCred, quota)
|
||||
@@ -884,7 +884,7 @@ func (self *SVpc) PostCreate(ctx context.Context, userCred mcclient.TokenCredent
|
||||
log.Errorf("input unmarshal error %s", err)
|
||||
} else {
|
||||
pendingUsage := &SInfrasQuota{Vpc: 1}
|
||||
keys := GetVpcQuotaKeysFromCreateInput(input)
|
||||
keys := GetVpcQuotaKeysFromCreateInput(ownerId, input)
|
||||
pendingUsage.SetKeys(keys)
|
||||
quotas.CancelPendingUsage(ctx, userCred, pendingUsage, pendingUsage, true)
|
||||
}
|
||||
@@ -1290,8 +1290,8 @@ func (self *SVpc) initWire(ctx context.Context, zone *SZone) (*SWire, error) {
|
||||
return wire, nil
|
||||
}
|
||||
|
||||
func GetVpcQuotaKeysFromCreateInput(input api.VpcCreateInput) quotas.SDomainRegionalCloudResourceKeys {
|
||||
ownerId := &db.SOwnerId{DomainId: input.ProjectDomainId}
|
||||
func GetVpcQuotaKeysFromCreateInput(owner mcclient.IIdentityProvider, input api.VpcCreateInput) quotas.SDomainRegionalCloudResourceKeys {
|
||||
ownerId := &db.SOwnerId{DomainId: owner.GetProjectDomainId()}
|
||||
var region *SCloudregion
|
||||
if len(input.CloudregionId) > 0 {
|
||||
region = CloudregionManager.FetchRegionById(input.CloudregionId)
|
||||
|
||||
Reference in New Issue
Block a user