bug 7504: Added started event when API command execute is called

This commit is contained in:
kishan 2010-12-20 14:32:59 +05:30
parent 7c44823a2e
commit dac008fc4b
1 changed files with 10 additions and 0 deletions

View File

@ -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<String, String> 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) {