mirror of https://github.com/apache/cloudstack.git
CLOUDSTACK-6595: call expunge method marked with @ActionEvent from expunge thread context. So the action even EXPUNGE.VM is generated when vm is expunged by the thread.
This commit is contained in:
parent
5388d349a4
commit
25ab05a189
|
|
@ -21,7 +21,6 @@ import java.util.Map;
|
|||
|
||||
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.ExpungeVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
|
|
@ -457,8 +456,6 @@ public interface UserVmService {
|
|||
UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
|
||||
VirtualMachineMigrationException;
|
||||
|
||||
UserVm expungeVm(ExpungeVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
UserVm expungeVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -106,7 +106,7 @@ public class ExpungeVMCmd extends BaseAsyncCmd {
|
|||
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
CallContext.current().setEventDetails("Vm Id: " + getId());
|
||||
try {
|
||||
UserVm result = _userVmService.expungeVm(this);
|
||||
UserVm result = _userVmService.expungeVm(this.getId());
|
||||
|
||||
if (result != null) {
|
||||
SuccessResponse response = new SuccessResponse(getCommandName());
|
||||
|
|
|
|||
|
|
@ -35,9 +35,6 @@ import javax.ejb.Local;
|
|||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
|
|
@ -47,7 +44,6 @@ import org.apache.cloudstack.affinity.dao.AffinityGroupVMMapDao;
|
|||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
|
||||
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.ExpungeVMCmd;
|
||||
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
|
||||
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
|
||||
|
|
@ -87,6 +83,8 @@ import org.apache.cloudstack.storage.command.DeleteCommand;
|
|||
import org.apache.cloudstack.storage.command.DettachCommand;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.agent.AgentManager;
|
||||
import com.cloud.agent.api.Answer;
|
||||
|
|
@ -1800,7 +1798,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
for (UserVmVO vm : vms) {
|
||||
try {
|
||||
expunge(vm, _accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount());
|
||||
expungeVm(vm.getId());
|
||||
} catch (Exception e) {
|
||||
s_logger.warn("Unable to expunge " + vm, e);
|
||||
}
|
||||
|
|
@ -2090,12 +2088,6 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
return destroyedVm;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VM_EXPUNGE, eventDescription = "expunging Vm", async = true)
|
||||
public UserVm expungeVm(ExpungeVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
return expungeVm(cmd.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
@DB
|
||||
public InstanceGroupVO createVmGroup(CreateVMGroupCmd cmd) {
|
||||
|
|
@ -3596,6 +3588,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
}
|
||||
|
||||
@Override
|
||||
@ActionEvent(eventType = EventTypes.EVENT_VM_EXPUNGE, eventDescription = "expunging Vm", async = true)
|
||||
public UserVm expungeVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
|
||||
Account caller = CallContext.current().getCallingAccount();
|
||||
Long userId = caller.getId();
|
||||
|
|
|
|||
Loading…
Reference in New Issue