5353import javax .servlet .http .HttpServletResponse ;
5454import javax .servlet .http .HttpSession ;
5555
56+ import com .cloud .event .EventTypes ;
5657import org .apache .cloudstack .acl .APIChecker ;
5758import org .apache .cloudstack .api .APICommand ;
5859import org .apache .cloudstack .api .ApiConstants ;
@@ -517,6 +518,8 @@ private String queueCommand(final BaseCmd cmdObj, final Map<String, String> para
517518 objectUuid = createCmd .getEntityUuid ();
518519 params .put ("id" , objectId .toString ());
519520 } else {
521+ // Extract the uuid before params are processed and id reflects internal db id
522+ objectUuid = params .get ("id" );
520523 dispatchChainFactory .getStandardDispatchChain ().dispatch (new DispatchTask (cmdObj , params ));
521524 }
522525
@@ -528,10 +531,16 @@ private String queueCommand(final BaseCmd cmdObj, final Map<String, String> para
528531 if (caller != null ) {
529532 params .put ("ctxAccountId" , String .valueOf (caller .getId ()));
530533 }
534+ if (objectUuid != null ){
535+ params .put ("uuid" , objectUuid );
536+ }
531537
532538 long startEventId = ctx .getStartEventId ();
533539 asyncCmd .setStartEventId (startEventId );
534540
541+ if (EventTypes .getEntityForEvent (asyncCmd .getEventType ()) != null ){
542+ ctx .putContextParameter (EventTypes .getEntityForEvent (asyncCmd .getEventType ()), objectUuid );
543+ }
535544 // save the scheduled event
536545 final Long eventId =
537546 ActionEventUtils .onScheduledActionEvent ((callerUserId == null ) ? User .UID_SYSTEM : callerUserId , asyncCmd .getEntityOwnerId (), asyncCmd .getEventType (),
@@ -577,7 +586,7 @@ private String queueCommand(final BaseCmd cmdObj, final Map<String, String> para
577586 !(cmdObj instanceof ListVolumesCmd ) && !(cmdObj instanceof ListUsersCmd ) && !(cmdObj instanceof ListAccountsCmd ) &&
578587 !(cmdObj instanceof ListStoragePoolsCmd ) && !(cmdObj instanceof ListDiskOfferingsCmd ) && !(cmdObj instanceof ListServiceOfferingsCmd ) &&
579588 !(cmdObj instanceof ListZonesByCmd )) {
580- buildAsyncListResponse ((BaseListCmd )cmdObj , caller );
589+ buildAsyncListResponse ((BaseListCmd ) cmdObj , caller );
581590 }
582591
583592 SerializationContext .current ().setUuidTranslation (true );
0 commit comments