mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Add download link of volumes, templates and ISOs to the download event details (#10564)
This commit is contained in:
parent
53001417a0
commit
6de084ca97
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.api.command.user.iso;
|
||||
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
import org.apache.cloudstack.api.ApiCommandResourceType;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
@ -101,7 +102,15 @@ public class ExtractIsoCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "extracting ISO: " + getId() + " from zone: " + getZoneId();
|
||||
String isoId = this._uuidMgr.getUuid(VirtualMachineTemplate.class, getId());
|
||||
String baseDescription = String.format("Extracting ISO: %s", isoId);
|
||||
|
||||
Long zoneId = getZoneId();
|
||||
if (zoneId == null) {
|
||||
return baseDescription;
|
||||
}
|
||||
|
||||
return String.format("%s from zone: %s", baseDescription, this._uuidMgr.getUuid(DataCenter.class, zoneId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -101,7 +101,15 @@ public class ExtractTemplateCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "extracting template: " + this._uuidMgr.getUuid(VirtualMachineTemplate.class, getId()) + ((getZoneId() != null) ? " from zone: " + this._uuidMgr.getUuid(DataCenter.class, getZoneId()) : "");
|
||||
String templateId = this._uuidMgr.getUuid(VirtualMachineTemplate.class, getId());
|
||||
String baseDescription = String.format("Extracting template: %s", templateId);
|
||||
|
||||
Long zoneId = getZoneId();
|
||||
if (zoneId == null) {
|
||||
return baseDescription;
|
||||
}
|
||||
|
||||
return String.format("%s from zone: %s", baseDescription, this._uuidMgr.getUuid(DataCenter.class, zoneId));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.api.command.user.volume;
|
||||
|
||||
|
||||
import com.cloud.dc.DataCenter;
|
||||
import org.apache.cloudstack.acl.SecurityChecker.AccessType;
|
||||
import org.apache.cloudstack.api.ACL;
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
@ -114,12 +115,15 @@ public class ExtractVolumeCmd extends BaseAsyncCmd {
|
||||
|
||||
@Override
|
||||
public String getEventDescription() {
|
||||
return "Extraction job";
|
||||
String volumeId = this._uuidMgr.getUuid(Volume.class, getId());
|
||||
String zoneId = this._uuidMgr.getUuid(DataCenter.class, getZoneId());
|
||||
|
||||
return String.format("Extracting volume: %s from zone: %s", volumeId, zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
CallContext.current().setEventDetails("Volume Id: " + this._uuidMgr.getUuid(Volume.class, getId()));
|
||||
CallContext.current().setEventDetails(getEventDescription());
|
||||
String uploadUrl = _volumeService.extractVolume(this);
|
||||
if (uploadUrl != null) {
|
||||
ExtractResponse response = _responseGenerator.createVolumeExtractResponse(id, zoneId, getEntityOwnerId(), mode, uploadUrl);
|
||||
|
||||
@ -4115,7 +4115,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
|
||||
Optional<String> extractUrl = setExtractVolumeSearchCriteria(sc, volume);
|
||||
if (extractUrl.isPresent()) {
|
||||
return extractUrl.get();
|
||||
String url = extractUrl.get();
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, volume ID: %s", url, volume.getUuid()));
|
||||
return url;
|
||||
}
|
||||
|
||||
VMInstanceVO vm = null;
|
||||
@ -4132,7 +4134,9 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
VmWorkJobVO placeHolder = null;
|
||||
placeHolder = createPlaceHolderWork(vm.getId());
|
||||
try {
|
||||
return orchestrateExtractVolume(volume.getId(), zoneId);
|
||||
String url = orchestrateExtractVolume(volume.getId(), zoneId);
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, volume ID: %s", url, volume.getUuid()));
|
||||
return url;
|
||||
} finally {
|
||||
_workJobDao.expunge(placeHolder.getId());
|
||||
}
|
||||
@ -4161,13 +4165,17 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic
|
||||
|
||||
// retrieve the entity url from job result
|
||||
if (jobResult != null && jobResult instanceof String) {
|
||||
return (String)jobResult;
|
||||
String url = (String) jobResult;
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, volume ID: %s", url, volume.getUuid()));
|
||||
return url;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return orchestrateExtractVolume(volume.getId(), zoneId);
|
||||
String url = orchestrateExtractVolume(volume.getId(), zoneId);
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, volume ID: %s", url, volume.getUuid()));
|
||||
return url;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -488,7 +488,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
String mode = cmd.getMode();
|
||||
Long eventId = cmd.getStartEventId();
|
||||
|
||||
return extract(account, templateId, url, zoneId, mode, eventId, true);
|
||||
String extractUrl = extract(account, templateId, url, zoneId, mode, eventId, true);
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, ISO ID: %s", extractUrl, _tmpltDao.findById(templateId).getUuid()));
|
||||
return extractUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -506,7 +508,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
throw new InvalidParameterValueException("unable to find template with id " + templateId);
|
||||
}
|
||||
|
||||
return extract(caller, templateId, url, zoneId, mode, eventId, false);
|
||||
String extractUrl = extract(caller, templateId, url, zoneId, mode, eventId, false);
|
||||
CallContext.current().setEventDetails(String.format("Download URL: %s, template ID: %s", extractUrl, template.getUuid()));
|
||||
return extractUrl;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user