diff --git a/api/src/com/cloud/api/commands/DeployVMCmd.java b/api/src/com/cloud/api/commands/DeployVMCmd.java index 00ffc2a3c8d..7487e78a6f3 100644 --- a/api/src/com/cloud/api/commands/DeployVMCmd.java +++ b/api/src/com/cloud/api/commands/DeployVMCmd.java @@ -215,7 +215,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { @Override public String getEventDescription() { - return "starting Vm"; + return "starting Vm. Vm Id: "+getEntityId(); } @Override @@ -227,6 +227,7 @@ public class DeployVMCmd extends BaseAsyncCreateCmd { public void execute(){ UserVm result; try { + UserContext.current().setEventDetails("Vm Id: "+getEntityId()); result = _userVmService.startVirtualMachine(this); if (result != null) { UserVmResponse response = _responseGenerator.createUserVmResponse(result); diff --git a/api/src/com/cloud/user/UserContext.java b/api/src/com/cloud/user/UserContext.java index 17df27ba20d..380c10dae7d 100644 --- a/api/src/com/cloud/user/UserContext.java +++ b/api/src/com/cloud/user/UserContext.java @@ -32,6 +32,7 @@ public class UserContext { private Account account; private long startEventId = 0; private long accountId; + private String eventDetails; private boolean apiServer; @@ -126,4 +127,12 @@ public class UserContext { public void setAccountId(long accountId) { this.accountId = accountId; } + + public void setEventDetails(String eventDetails) { + this.eventDetails = eventDetails; + } + + public String getEventDetails() { + return eventDetails; + } } diff --git a/server/src/com/cloud/event/ActionEventCallback.java b/server/src/com/cloud/event/ActionEventCallback.java index c25ac2e7a1c..db6a8552396 100644 --- a/server/src/com/cloud/event/ActionEventCallback.java +++ b/server/src/com/cloud/event/ActionEventCallback.java @@ -66,7 +66,11 @@ public class ActionEventCallback implements MethodInterceptor, AnnotationInterce long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); - EventUtils.saveStartedEvent(userId, accountId, actionEvent.eventType(), actionEvent.eventDescription(), startEventId); + String eventDescription = actionEvent.eventDescription(); + if(ctx.getEventDetails() != null){ + eventDescription += ". "+ctx.getEventDetails(); + } + EventUtils.saveStartedEvent(userId, accountId, actionEvent.eventType(), eventDescription, startEventId); } } return event; @@ -81,12 +85,16 @@ public class ActionEventCallback implements MethodInterceptor, AnnotationInterce long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); + String eventDescription = actionEvent.eventDescription(); + if(ctx.getEventDetails() != null){ + eventDescription += ". "+ctx.getEventDetails(); + } if(actionEvent.create()){ //This start event has to be used for subsequent events of this action - startEventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for "+actionEvent.eventDescription()); + startEventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully created entity for "+eventDescription); ctx.setStartEventId(startEventId); } else { - EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed "+actionEvent.eventDescription(), startEventId); + EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_INFO, actionEvent.eventType(), "Successfully completed "+eventDescription, startEventId); } } } @@ -100,11 +108,15 @@ public class ActionEventCallback implements MethodInterceptor, AnnotationInterce long userId = ctx.getCallerUserId(); long accountId = ctx.getAccountId(); long startEventId = ctx.getStartEventId(); + String eventDescription = actionEvent.eventDescription(); + if(ctx.getEventDetails() != null){ + eventDescription += ". "+ctx.getEventDetails(); + } if(actionEvent.create()){ - long eventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for "+actionEvent.eventDescription()); + long eventId = EventUtils.saveCreatedEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while creating entity for "+eventDescription); ctx.setStartEventId(eventId); } else { - EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while "+actionEvent.eventDescription(), startEventId); + EventUtils.saveEvent(userId, accountId, EventVO.LEVEL_ERROR, actionEvent.eventType(), "Error while "+eventDescription, startEventId); } } } diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java index 206bc373919..b8ae46abd60 100755 --- a/server/src/com/cloud/vm/UserVmManagerImpl.java +++ b/server/src/com/cloud/vm/UserVmManagerImpl.java @@ -1878,7 +1878,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager return true; } - @Override @DB @ActionEvent (eventType=EventTypes.EVENT_VM_CREATE, eventDescription="creating Vm", create=true) + @Override @DB @ActionEvent (eventType=EventTypes.EVENT_VM_CREATE, eventDescription="deploying Vm", create=true) public UserVm createVirtualMachine(DeployVMCmd cmd) throws InsufficientCapacityException, ResourceUnavailableException, ConcurrentOperationException, StorageUnavailableException, ResourceAllocationException { Account caller = UserContext.current().getCaller(); @@ -2119,6 +2119,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService, Manager if (s_logger.isDebugEnabled()) { s_logger.debug("Successfully allocated DB entry for " + vm); } + UserContext.current().setEventDetails("Vm Id: "+vm.getId()); UsageEventVO usageEvent = new UsageEventVO(EventTypes.EVENT_VM_CREATE, accountId, dc.getId(), vm.getId(), vm.getName(), offering.getId(), template.getId(), null); _usageEventDao.persist(usageEvent);