Skip to content

Commit 7a9bb83

Browse files
authored
Fix Template and ISO upload events (#9545)
1 parent 27f23f4 commit 7a9bb83

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,14 @@
3535
import org.apache.cloudstack.agent.directdownload.CheckUrlCommand;
3636
import org.apache.cloudstack.annotation.AnnotationService;
3737
import org.apache.cloudstack.annotation.dao.AnnotationDao;
38+
import org.apache.cloudstack.api.ApiCommandResourceType;
3839
import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
3940
import org.apache.cloudstack.api.command.user.iso.GetUploadParamsForIsoCmd;
4041
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
4142
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
4243
import org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd;
4344
import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
45+
import org.apache.cloudstack.context.CallContext;
4446
import org.apache.cloudstack.direct.download.DirectDownloadManager;
4547
import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
4648
import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@@ -359,6 +361,16 @@ public List<TemplateOrVolumePostUploadCommand> doInTransaction(TransactionStatus
359361
throw new CloudRuntimeException("Unable to persist the template " + profile.getTemplate());
360362
}
361363

364+
// Set Event Details for Template/ISO Upload
365+
String eventType = template.getFormat().equals(ImageFormat.ISO) ? "Iso" : "Template";
366+
String eventResourceId = template.getUuid();
367+
CallContext.current().setEventDetails(String.format("%s Id: %s", eventType, eventResourceId));
368+
CallContext.current().putContextParameter(eventType.equals("Iso") ? eventType : VirtualMachineTemplate.class, eventResourceId);
369+
if (template.getFormat().equals(ImageFormat.ISO)) {
370+
CallContext.current().setEventResourceType(ApiCommandResourceType.Iso);
371+
CallContext.current().setEventResourceId(template.getId());
372+
}
373+
362374
if (profile.getZoneIdList() != null && profile.getZoneIdList().size() > 1)
363375
throw new CloudRuntimeException("Operation is not supported for more than one zone id at a time");
364376

0 commit comments

Comments
 (0)