Skip to content

Commit af256b7

Browse files
committed
fix for resource events
Signed-off-by: Abhishek Kumar <abhishek.mrt22@gmail.com>
1 parent bfaf987 commit af256b7

1 file changed

Lines changed: 22 additions & 5 deletions

File tree

  • plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/adapter

plugins/integrations/veeam-control-service/src/main/java/org/apache/cloudstack/veeam/adapter/ServerAdapter.java

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
import org.apache.cloudstack.acl.SecurityChecker;
3939
import org.apache.cloudstack.affinity.AffinityGroupVO;
4040
import org.apache.cloudstack.affinity.dao.AffinityGroupDao;
41+
import org.apache.cloudstack.api.ApiCommandResourceType;
4142
import org.apache.cloudstack.api.ApiConstants;
4243
import org.apache.cloudstack.api.ApiServerService;
4344
import org.apache.cloudstack.api.BaseAsyncCmd;
@@ -1552,6 +1553,10 @@ public DiskAttachment attachInstanceDisk(final String vmUuid, final DiskAttachme
15521553
if (Boolean.parseBoolean(request.getBootable()) || Volume.Type.ROOT.equals(volumeVO.getVolumeType())) {
15531554
deviceId = 0L;
15541555
}
1556+
CallContext context = CallContext.current();
1557+
context.setEventDetails("Volume Id: " + volumeVO.getUuid() + " VmId: " + vmVo.getUuid());
1558+
context.setEventResourceType(ApiCommandResourceType.Volume);
1559+
context.setEventResourceId(volumeVO.getId());
15551560
Volume volume = volumeApiService.attachVolumeToVM(vmVo.getId(), volumeVO.getId(), deviceId, true);
15561561
processInstanceRestoreConfigIfNeeded(vmVo, volume);
15571562
VolumeJoinVO attachedVolumeVO = volumeJoinDao.findById(volume.getId());
@@ -1569,16 +1574,20 @@ public void detachInstanceDisk(final String vmUuid, final String volumeUuid) {
15691574
}
15701575
accountService.checkAccess(CallContext.current().getCallingAccount(), SecurityChecker.AccessType.OperateEntry,
15711576
false, vmVo);
1572-
VolumeVO volumeVo = volumeDao.findByUuid(volumeUuid);
1573-
if (volumeVo == null) {
1577+
VolumeVO volumeVO = volumeDao.findByUuid(volumeUuid);
1578+
if (volumeVO == null) {
15741579
throw new InvalidParameterValueException("Volume with ID " + volumeUuid + " not found");
15751580
}
1576-
if (volumeVo.getInstanceId() != vmVo.getId()) {
1581+
if (volumeVO.getInstanceId() != vmVo.getId()) {
15771582
throw new InvalidParameterValueException("Volume with ID " + volumeUuid + " is not attached to VM with ID " + vmUuid);
15781583
}
1584+
CallContext context = CallContext.current();
1585+
context.setEventDetails("Volume Id: " + volumeVO.getUuid() + " VmId: " + vmVo.getUuid());
1586+
context.setEventResourceType(ApiCommandResourceType.Volume);
1587+
context.setEventResourceId(volumeVO.getId());
15791588
DetachVolumeCmd cmd = new DetachVolumeCmd();
15801589
ComponentContext.inject(cmd);
1581-
cmd.setId(volumeVo.getId());
1590+
cmd.setId(volumeVO.getId());
15821591
volumeApiService.detachVolumeFromVM(cmd);
15831592
}
15841593

@@ -1629,7 +1638,11 @@ public void deleteDisk(String uuid) {
16291638
if (vo == null) {
16301639
throw new InvalidParameterValueException("Disk with ID " + uuid + " not found");
16311640
}
1632-
volumeApiService.deleteVolume(vo.getId(), accountService.getSystemAccount());
1641+
CallContext context = CallContext.current();
1642+
context.setEventDetails("Volume Id: " + vo.getUuid());
1643+
context.setEventResourceType(ApiCommandResourceType.Volume);
1644+
context.setEventResourceId(vo.getId());
1645+
volumeApiService.destroyVolume(vo.getId(), CallContext.current().getCallingAccount(), true, false);
16331646
}
16341647

16351648
@ApiAccess(command = UpdateVolumeCmd.class)
@@ -1694,6 +1707,10 @@ public Nic attachInstanceNic(final String vmUuid, final Nic request) {
16941707
nicDetails = new Pair<>(null, workerVmIp);
16951708
removeInstanceWorkerVmIp(vmVo);
16961709
}
1710+
CallContext context = CallContext.current();
1711+
context.setEventResourceType(ApiCommandResourceType.VirtualMachine);
1712+
context.setEventResourceId(vmVo.getId());
1713+
CallContext.current().setEventDetails("Vm Id: " + vmVo.getUuid() + " Network Id: " + networkVO.getUuid());
16971714
AddNicToVMCmd cmd = new AddNicToVMCmd();
16981715
ComponentContext.inject(cmd);
16991716
cmd.setVmId(vmVo.getId());

0 commit comments

Comments
 (0)