Skip to content

Commit

Permalink
fix/as: Set ScalingPolicy's project as its ScalingGroup's project
Browse files Browse the repository at this point in the history
  • Loading branch information
rainzm committed Apr 28, 2020
1 parent be5c539 commit 352e912
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/compute/models/scaling_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,17 @@ func (spm *SScalingPolicyManager) ValidateCreateData(ctx context.Context, userCr
return input, err
}

func (sp *SScalingPolicy) CustomizeCreate(ctx context.Context, userCred mcclient.TokenCredential,
ownerId mcclient.IIdentityProvider, query jsonutils.JSONObject, data jsonutils.JSONObject) error {
// sp.Project must be same with sp.ScalingGroup
sg, err := sp.ScalingGroup()
if err != nil {
return err
}
ownerId = sg.GetOwnerId()
return sp.SVirtualResourceBase.CustomizeCreate(ctx, userCred, ownerId, query, data)
}

func (sp *SScalingPolicy) Delete(ctx context.Context, userCred mcclient.TokenCredential) error {
// do nothing
sp.SetStatus(userCred, api.SP_STATUS_DELETING, "")
Expand Down

0 comments on commit 352e912

Please sign in to comment.