Skip to content

Commit 25ab05a

Browse files
author
Alena Prokharchyk
committed
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.
1 parent 5388d34 commit 25ab05a

3 files changed

Lines changed: 5 additions & 15 deletions

File tree

api/src/com/cloud/vm/UserVmService.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
2323
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
24-
import org.apache.cloudstack.api.command.admin.vm.ExpungeVMCmd;
2524
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
2625
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
2726
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
@@ -457,8 +456,6 @@ UserVm moveVMToUser(AssignVMCmd moveUserVMCmd) throws ResourceAllocationExceptio
457456
UserVm upgradeVirtualMachine(ScaleVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException, ManagementServerException,
458457
VirtualMachineMigrationException;
459458

460-
UserVm expungeVm(ExpungeVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException;
461-
462459
UserVm expungeVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException;
463460

464461
/**

api/src/org/apache/cloudstack/api/command/admin/vm/ExpungeVMCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public Long getInstanceId() {
106106
public void execute() throws ResourceUnavailableException, ConcurrentOperationException {
107107
CallContext.current().setEventDetails("Vm Id: " + getId());
108108
try {
109-
UserVm result = _userVmService.expungeVm(this);
109+
UserVm result = _userVmService.expungeVm(this.getId());
110110

111111
if (result != null) {
112112
SuccessResponse response = new SuccessResponse(getCommandName());

server/src/com/cloud/vm/UserVmManagerImpl.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
import javax.inject.Inject;
3636
import javax.naming.ConfigurationException;
3737

38-
import org.apache.commons.codec.binary.Base64;
39-
import org.apache.log4j.Logger;
40-
4138
import org.apache.cloudstack.acl.ControlledEntity.ACLType;
4239
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
4340
import org.apache.cloudstack.affinity.AffinityGroupService;
@@ -47,7 +44,6 @@
4744
import org.apache.cloudstack.api.ApiConstants;
4845
import org.apache.cloudstack.api.BaseCmd.HTTPMethod;
4946
import org.apache.cloudstack.api.command.admin.vm.AssignVMCmd;
50-
import org.apache.cloudstack.api.command.admin.vm.ExpungeVMCmd;
5147
import org.apache.cloudstack.api.command.admin.vm.RecoverVMCmd;
5248
import org.apache.cloudstack.api.command.user.vm.AddNicToVMCmd;
5349
import org.apache.cloudstack.api.command.user.vm.DeployVMCmd;
@@ -87,6 +83,8 @@
8783
import org.apache.cloudstack.storage.command.DettachCommand;
8884
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
8985
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
86+
import org.apache.commons.codec.binary.Base64;
87+
import org.apache.log4j.Logger;
9088

9189
import com.cloud.agent.AgentManager;
9290
import com.cloud.agent.api.Answer;
@@ -1800,7 +1798,7 @@ protected void runInContext() {
18001798
}
18011799
for (UserVmVO vm : vms) {
18021800
try {
1803-
expunge(vm, _accountMgr.getSystemUser().getId(), _accountMgr.getSystemAccount());
1801+
expungeVm(vm.getId());
18041802
} catch (Exception e) {
18051803
s_logger.warn("Unable to expunge " + vm, e);
18061804
}
@@ -2090,12 +2088,6 @@ public UserVm destroyVm(DestroyVMCmd cmd) throws ResourceUnavailableException, C
20902088
return destroyedVm;
20912089
}
20922090

2093-
@Override
2094-
@ActionEvent(eventType = EventTypes.EVENT_VM_EXPUNGE, eventDescription = "expunging Vm", async = true)
2095-
public UserVm expungeVm(ExpungeVMCmd cmd) throws ResourceUnavailableException, ConcurrentOperationException {
2096-
return expungeVm(cmd.getId());
2097-
}
2098-
20992091
@Override
21002092
@DB
21012093
public InstanceGroupVO createVmGroup(CreateVMGroupCmd cmd) {
@@ -3596,6 +3588,7 @@ public void doInTransactionWithoutResult(TransactionStatus status) {
35963588
}
35973589

35983590
@Override
3591+
@ActionEvent(eventType = EventTypes.EVENT_VM_EXPUNGE, eventDescription = "expunging Vm", async = true)
35993592
public UserVm expungeVm(long vmId) throws ResourceUnavailableException, ConcurrentOperationException {
36003593
Account caller = CallContext.current().getCallingAccount();
36013594
Long userId = caller.getId();

0 commit comments

Comments
 (0)