mirror of https://github.com/apache/cloudstack.git
bug 8362: Included VmId in event description
status 8362: resolved fixed
This commit is contained in:
parent
ee1c53ecf3
commit
a9fd67cab6
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue