mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
api,server: fix VM.CREATE events on vm deploy without start (#7421)
Fixes #6697 Allows the server to generate started and completed events for VM.CREATE event type when VM is deployed with startvm=false. Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
This commit is contained in:
parent
8c546bd5a6
commit
a0eb0aa5f7
@ -54,6 +54,8 @@ import org.apache.cloudstack.api.response.ZoneResponse;
|
|||||||
import org.apache.cloudstack.context.CallContext;
|
import org.apache.cloudstack.context.CallContext;
|
||||||
import org.apache.commons.collections.CollectionUtils;
|
import org.apache.commons.collections.CollectionUtils;
|
||||||
import org.apache.commons.collections.MapUtils;
|
import org.apache.commons.collections.MapUtils;
|
||||||
|
import org.apache.commons.lang3.BooleanUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import com.cloud.agent.api.LogLevel;
|
import com.cloud.agent.api.LogLevel;
|
||||||
@ -75,9 +77,6 @@ import com.cloud.utils.net.NetUtils;
|
|||||||
import com.cloud.vm.VirtualMachine;
|
import com.cloud.vm.VirtualMachine;
|
||||||
import com.cloud.vm.VmDetailConstants;
|
import com.cloud.vm.VmDetailConstants;
|
||||||
|
|
||||||
import org.apache.commons.lang3.BooleanUtils;
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
|
@APICommand(name = "deployVirtualMachine", description = "Creates and automatically starts a virtual machine based on a service offering, disk offering, and template.", responseObject = UserVmResponse.class, responseView = ResponseView.Restricted, entityType = {VirtualMachine.class},
|
||||||
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
|
requestHasSensitiveInfo = false, responseHasSensitiveInfo = true)
|
||||||
public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityGroupAction, UserCmd {
|
public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityGroupAction, UserCmd {
|
||||||
@ -766,7 +765,6 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||||||
public void execute() {
|
public void execute() {
|
||||||
UserVm result;
|
UserVm result;
|
||||||
|
|
||||||
if (getStartVm()) {
|
|
||||||
try {
|
try {
|
||||||
CallContext.current().setEventDetails("Vm Id: " + getEntityUuid());
|
CallContext.current().setEventDetails("Vm Id: " + getEntityUuid());
|
||||||
result = _userVmService.startVirtualMachine(this);
|
result = _userVmService.startVirtualMachine(this);
|
||||||
@ -790,9 +788,6 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG
|
|||||||
s_logger.info(message.toString(), ex);
|
s_logger.info(message.toString(), ex);
|
||||||
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString());
|
throw new ServerApiException(ApiErrorCode.INSUFFICIENT_CAPACITY_ERROR, message.toString());
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
result = _userVmService.getUserVm(getEntityId());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (result != null) {
|
if (result != null) {
|
||||||
UserVmResponse response = _responseGenerator.createUserVmResponse(getResponseView(), "virtualmachine", result).get(0);
|
UserVmResponse response = _responseGenerator.createUserVmResponse(getResponseView(), "virtualmachine", result).get(0);
|
||||||
|
|||||||
@ -4810,9 +4810,12 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "starting Vm", async = true)
|
@ActionEvent(eventType = EventTypes.EVENT_VM_CREATE, eventDescription = "deploying Vm", async = true)
|
||||||
public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
public UserVm startVirtualMachine(DeployVMCmd cmd) throws ResourceUnavailableException, InsufficientCapacityException, ConcurrentOperationException, ResourceAllocationException {
|
||||||
long vmId = cmd.getEntityId();
|
long vmId = cmd.getEntityId();
|
||||||
|
if (!cmd.getStartVm()) {
|
||||||
|
return getUserVm(vmId);
|
||||||
|
}
|
||||||
Long podId = null;
|
Long podId = null;
|
||||||
Long clusterId = null;
|
Long clusterId = null;
|
||||||
Long hostId = cmd.getHostId();
|
Long hostId = cmd.getHostId();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user