From dac008fc4b669bdc7291592fb3c71e72e7383e62 Mon Sep 17 00:00:00 2001 From: kishan Date: Mon, 20 Dec 2010 14:32:59 +0530 Subject: [PATCH] bug 7504: Added started event when API command execute is called --- server/src/com/cloud/api/ApiDispatcher.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index b18558b194f..d554cc547b1 100644 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -29,6 +29,7 @@ import org.apache.log4j.Logger; import com.cloud.api.BaseCmd.CommandType; import com.cloud.async.AsyncCommandQueued; +import com.cloud.event.EventUtils; import com.cloud.exception.AccountLimitException; import com.cloud.exception.InsufficientCapacityException; import com.cloud.exception.InvalidParameterValueException; @@ -37,6 +38,7 @@ import com.cloud.exception.ResourceAllocationException; import com.cloud.exception.ResourceUnavailableException; import com.cloud.server.ManagementServer; import com.cloud.user.Account; +import com.cloud.user.User; import com.cloud.user.UserContext; import com.cloud.utils.DateUtil; import com.cloud.utils.component.ComponentLocator; @@ -103,6 +105,14 @@ public class ApiDispatcher { public void dispatch(BaseCmd cmd, Map params) { setupParameters(cmd, params); try { + if(cmd instanceof BaseAsyncCmd){ + // save the started event + Long userId = new Long(params.get("ctxUserId")); + BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd; + Long startId = new Long(params.get("starteventid")); + EventUtils.saveStartedEvent((userId == null) ? User.UID_SYSTEM : userId, asyncCmd.getEntityOwnerId(), + asyncCmd.getEventType(), "Starting async job for "+asyncCmd.getEventDescription(), startId); + } cmd.execute(); } catch (Throwable t) { if (t instanceof InvalidParameterValueException || t instanceof IllegalArgumentException) {