mirror of https://github.com/apache/cloudstack.git
VOLUME.DETACH, created during VM removal has type VirtualMachine instead of Volume and has "Vm Id: XXX" in the description. (#199)
Volume detach should publish volume resource info, not VM resource info Co-authored-by: Maxim Prokopchuk <mprokopchuk@apple.com>
This commit is contained in:
parent
a652570408
commit
1fcd32fa33
|
|
@ -7833,8 +7833,22 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||
private void detachVolumesFromVm(List<VolumeVO> volumes) {
|
||||
|
||||
for (VolumeVO volume : volumes) {
|
||||
CallContext vmContext = CallContext.current();
|
||||
// Create new context and inject correct event resource type, id and details,
|
||||
// otherwise VOLUME.DETACH event will be associated with VirtualMachine and contain VM id and other information.
|
||||
CallContext volumeContext = CallContext.register(vmContext.getCallingUserId(), vmContext.getCallingAccountId());
|
||||
volumeContext.setEventDetails("Volume Id: " + this._uuidMgr.getUuid(Volume.class, volume.getId()) + " Vm Id: " + this._uuidMgr.getUuid(VirtualMachine.class, volume.getInstanceId()));
|
||||
volumeContext.setEventResourceType(ApiCommandResourceType.Volume);
|
||||
volumeContext.setEventResourceId(volume.getId());
|
||||
volumeContext.setStartEventId(vmContext.getStartEventId());
|
||||
|
||||
Volume detachResult = _volumeService.detachVolumeViaDestroyVM(volume.getInstanceId(), volume.getId());
|
||||
Volume detachResult = null;
|
||||
try {
|
||||
detachResult = _volumeService.detachVolumeViaDestroyVM(volume.getInstanceId(), volume.getId());
|
||||
} finally {
|
||||
// Remove volumeContext and pop vmContext back
|
||||
CallContext.unregister();
|
||||
}
|
||||
|
||||
if (detachResult == null) {
|
||||
s_logger.error("DestroyVM remove volume - failed to detach and delete volume " + volume.getInstanceId() + " from instance " + volume.getId());
|
||||
|
|
|
|||
Loading…
Reference in New Issue