diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java index ec54ea14521..7994adab82e 100755 --- a/api/src/com/cloud/event/EventTypes.java +++ b/api/src/com/cloud/event/EventTypes.java @@ -493,10 +493,13 @@ public class EventTypes { entityEventDetails.put(EVENT_VM_REBOOT, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_UPDATE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_UPGRADE, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_DYNAMIC_SCALE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_RESETPASSWORD, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_RESETSSHKEY, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_MIGRATE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_MOVE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_VM_RESTORE, VirtualMachine.class.getName()); + entityEventDetails.put(EVENT_VM_EXPUNGE, VirtualMachine.class.getName()); entityEventDetails.put(EVENT_ROUTER_CREATE, VirtualRouter.class.getName()); entityEventDetails.put(EVENT_ROUTER_DESTROY, VirtualRouter.class.getName()); @@ -544,9 +547,11 @@ public class EventTypes { entityEventDetails.put(EVENT_LB_CERT_REMOVE, LoadBalancer.class.getName()); // Account events + entityEventDetails.put(EVENT_ACCOUNT_ENABLE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_DISABLE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_CREATE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_DELETE, Account.class.getName()); + entityEventDetails.put(EVENT_ACCOUNT_UPDATE, Account.class.getName()); entityEventDetails.put(EVENT_ACCOUNT_MARK_DEFAULT_ZONE, Account.class.getName()); // UserVO Events diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java index 5d4b4d3368c..8f980d99038 100755 --- a/server/src/com/cloud/api/ApiDispatcher.java +++ b/server/src/com/cloud/api/ApiDispatcher.java @@ -21,6 +21,7 @@ import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; +import com.cloud.event.EventTypes; import org.apache.cloudstack.api.ApiConstants; import org.apache.cloudstack.api.BaseAsyncCmd; import org.apache.cloudstack.api.BaseAsyncCreateCmd; @@ -82,8 +83,14 @@ public class ApiDispatcher { final BaseAsyncCmd asyncCmd = (BaseAsyncCmd)cmd; final String startEventId = params.get(ApiConstants.CTX_START_EVENT_ID); + String uuid = params.get("uuid"); ctx.setStartEventId(Long.valueOf(startEventId)); + // Fow now use the key from EventTypes.java rather than getInstanceType bcz the later doesn't refer to the interfaces + if(EventTypes.getEntityForEvent(asyncCmd.getEventType()) != null){ + ctx.putContextParameter(EventTypes.getEntityForEvent(asyncCmd.getEventType()), uuid); + } + // Synchronise job on the object if needed if (asyncCmd.getJob() != null && asyncCmd.getSyncObjId() != null && asyncCmd.getSyncObjType() != null) { Long queueSizeLimit = null; diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java index a9b1130eed1..7ad7c106952 100755 --- a/server/src/com/cloud/api/ApiServer.java +++ b/server/src/com/cloud/api/ApiServer.java @@ -53,6 +53,7 @@ import javax.naming.ConfigurationException; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import com.cloud.event.EventTypes; import org.apache.cloudstack.acl.APIChecker; import org.apache.cloudstack.api.APICommand; import org.apache.cloudstack.api.ApiConstants; @@ -517,6 +518,8 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer objectUuid = createCmd.getEntityUuid(); params.put("id", objectId.toString()); } else { + // Extract the uuid before params are processed and id reflects internal db id + objectUuid = params.get("id"); dispatchChainFactory.getStandardDispatchChain().dispatch(new DispatchTask(cmdObj, params)); } @@ -528,10 +531,16 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer if (caller != null) { params.put("ctxAccountId", String.valueOf(caller.getId())); } + if(objectUuid != null){ + params.put("uuid", objectUuid); + } long startEventId = ctx.getStartEventId(); asyncCmd.setStartEventId(startEventId); + if(EventTypes.getEntityForEvent(asyncCmd.getEventType()) != null){ + ctx.putContextParameter(EventTypes.getEntityForEvent(asyncCmd.getEventType()), objectUuid); + } // save the scheduled event final Long eventId = ActionEventUtils.onScheduledActionEvent((callerUserId == null) ? User.UID_SYSTEM : callerUserId, asyncCmd.getEntityOwnerId(), asyncCmd.getEventType(), @@ -577,7 +586,7 @@ public class ApiServer extends ManagerBase implements HttpRequestHandler, ApiSer !(cmdObj instanceof ListVolumesCmd) && !(cmdObj instanceof ListUsersCmd) && !(cmdObj instanceof ListAccountsCmd) && !(cmdObj instanceof ListStoragePoolsCmd) && !(cmdObj instanceof ListDiskOfferingsCmd) && !(cmdObj instanceof ListServiceOfferingsCmd) && !(cmdObj instanceof ListZonesByCmd)) { - buildAsyncListResponse((BaseListCmd)cmdObj, caller); + buildAsyncListResponse((BaseListCmd) cmdObj, caller); } SerializationContext.current().setUuidTranslation(true); diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java index 9724d99e5e6..59546708bce 100755 --- a/server/src/com/cloud/event/ActionEventUtils.java +++ b/server/src/com/cloud/event/ActionEventUtils.java @@ -25,7 +25,6 @@ import java.util.Map; import javax.annotation.PostConstruct; import javax.inject.Inject; -import com.cloud.vm.VirtualMachine; import org.apache.log4j.Logger; import org.springframework.beans.factory.NoSuchBeanDefinitionException; @@ -186,13 +185,19 @@ public class ActionEventUtils { // get the entity details for which ActionEvent is generated String entityType = null; String entityUuid = null; + CallContext context = CallContext.current(); Class entityKey = getEntityKey(eventType); if (entityKey != null) { - CallContext context = CallContext.current(); + //FIXME - Remove this entityUuid = (String)context.getContextParameter(entityKey); if (entityUuid != null) entityType = entityKey.getName(); + }else if (EventTypes.getEntityForEvent(eventType) != null){ + entityType = EventTypes.getEntityForEvent(eventType); + if (entityType != null){ + entityUuid = (String)context.getContextParameter(entityType); + } } org.apache.cloudstack.framework.events.Event event = @@ -240,6 +245,7 @@ public class ActionEventUtils { private static Class getEntityKey(String eventType) { + // FIXME - Remove this if (eventType.startsWith("DOMAIN.")) { return Domain.class; @@ -251,8 +257,6 @@ public class ActionEventUtils { else if (eventType.startsWith("USER.")) { return User.class; - }else if (eventType.startsWith("VM.")){ - return VirtualMachine.class; } return null; diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 9c38430ab1c..d1df3c11a61 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -2982,7 +2982,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir long vmId = cmd.getEntityId(); Long hostId = cmd.getHostId(); UserVmVO vm = _vmDao.findById(vmId); - CallContext.current().putContextParameter(VirtualMachine.class, vm.getUuid()); Pair> vmParamPair = null; try {