You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by mc...@apache.org on 2014/03/13 19:05:51 UTC
[04/50] [abbrv] git commit: updated refs/heads/rbac to 99bdc8d
CLOUDSTACK-5478: Enable publishing uuid for all the async apis in the CallContext.
The advantage would be that event publishing can pick up the uuid and publish them.
Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/ded7e682
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/ded7e682
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/ded7e682
Branch: refs/heads/rbac
Commit: ded7e682dc0a84f41c9953522016a86f4948ea35
Parents: 548c810
Author: Nitin Mehta <ni...@citrix.com>
Authored: Fri Mar 7 16:50:21 2014 -0800
Committer: Nitin Mehta <ni...@citrix.com>
Committed: Fri Mar 7 16:50:21 2014 -0800
----------------------------------------------------------------------
api/src/com/cloud/event/EventTypes.java | 5 +++++
server/src/com/cloud/api/ApiDispatcher.java | 7 +++++++
server/src/com/cloud/api/ApiServer.java | 11 ++++++++++-
server/src/com/cloud/event/ActionEventUtils.java | 12 ++++++++----
server/src/com/cloud/vm/UserVmManagerImpl.java | 1 -
5 files changed, 30 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ded7e682/api/src/com/cloud/event/EventTypes.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/event/EventTypes.java b/api/src/com/cloud/event/EventTypes.java
index ec54ea1..7994ada 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
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ded7e682/server/src/com/cloud/api/ApiDispatcher.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiDispatcher.java b/server/src/com/cloud/api/ApiDispatcher.java
index 5d4b4d3..8f980d9 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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ded7e682/server/src/com/cloud/api/ApiServer.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiServer.java b/server/src/com/cloud/api/ApiServer.java
index a9b1130..7ad7c10 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);
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ded7e682/server/src/com/cloud/event/ActionEventUtils.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/event/ActionEventUtils.java b/server/src/com/cloud/event/ActionEventUtils.java
index 9724d99..5954670 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;
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/ded7e682/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 9c38430..d1df3c1 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<UserVmVO, Map<VirtualMachineProfile.Param, Object>> vmParamPair = null;
try {