@@ -72,7 +72,7 @@ func (model SStatusResourceBase) GetProgress() float32 {
7272}
7373
7474func StatusBaseSetStatus (ctx context.Context , model IStatusBaseModel , userCred mcclient.TokenCredential , status string , reason string ) error {
75- return statusBaseSetStatus (ctx , model , userCred , status , reason )
75+ return statusBaseSetStatus (ctx , model , userCred , status , reason , nil )
7676}
7777
7878func statusBaseSetProgress (model IStatusBaseModel , progress float32 ) error {
@@ -86,13 +86,16 @@ func statusBaseSetProgress(model IStatusBaseModel, progress float32) error {
8686 return nil
8787}
8888
89- func statusBaseSetStatus (ctx context.Context , model IStatusBaseModel , userCred mcclient.TokenCredential , status string , reason string ) error {
89+ func statusBaseSetStatus (ctx context.Context , model IStatusBaseModel , userCred mcclient.TokenCredential , status string , reason string , otherUpdates func () ) error {
9090 if model .GetStatus () == status {
9191 return nil
9292 }
9393 oldStatus := model .GetStatus ()
9494 _ , err := Update (model , func () error {
9595 model .SetStatusValue (status )
96+ if otherUpdates != nil {
97+ otherUpdates ()
98+ }
9699 return nil
97100 })
98101 if err != nil {
@@ -121,10 +124,14 @@ func statusBaseSetStatus(ctx context.Context, model IStatusBaseModel, userCred m
121124}
122125
123126func StatusBasePerformStatus (ctx context.Context , model IStatusBaseModel , userCred mcclient.TokenCredential , input apis.PerformStatusInput ) error {
127+ return StatusBasePerformStatusWithOtherUpdates (ctx , model , userCred , input , nil )
128+ }
129+
130+ func StatusBasePerformStatusWithOtherUpdates (ctx context.Context , model IStatusBaseModel , userCred mcclient.TokenCredential , input apis.PerformStatusInput , otherUpdates func ()) error {
124131 if len (input .Status ) == 0 {
125132 return httperrors .NewMissingParameterError ("status" )
126133 }
127- err := statusBaseSetStatus (ctx , model , userCred , input .Status , input .Reason )
134+ err := statusBaseSetStatus (ctx , model , userCred , input .Status , input .Reason , otherUpdates )
128135 if err != nil {
129136 return errors .Wrap (err , "statusBaseSetStatus" )
130137 }
0 commit comments