This is an automated email from the ASF dual-hosted git repository.

nvazquez pushed a commit to branch 4.18
in repository https://gitbox.apache.org/repos/asf/cloudstack.git


The following commit(s) were added to refs/heads/4.18 by this push:
     new 7a9bb835bc7 Fix Template and ISO upload events (#9545)
7a9bb835bc7 is described below

commit 7a9bb835bc78e4c584ca1dce520152428091fb1b
Author: Nicolas Vazquez <nicovazque...@gmail.com>
AuthorDate: Tue Aug 20 11:23:07 2024 -0300

    Fix Template and ISO upload events (#9545)
---
 .../java/com/cloud/template/HypervisorTemplateAdapter.java   | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git 
a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java 
b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
index 2a536fa7a79..7fdabf3a8cd 100644
--- a/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/main/java/com/cloud/template/HypervisorTemplateAdapter.java
@@ -35,12 +35,14 @@ import 
org.apache.cloudstack.agent.directdownload.CheckUrlAnswer;
 import org.apache.cloudstack.agent.directdownload.CheckUrlCommand;
 import org.apache.cloudstack.annotation.AnnotationService;
 import org.apache.cloudstack.annotation.dao.AnnotationDao;
+import org.apache.cloudstack.api.ApiCommandResourceType;
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.GetUploadParamsForIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
 import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
 import 
org.apache.cloudstack.api.command.user.template.GetUploadParamsForTemplateCmd;
 import org.apache.cloudstack.api.command.user.template.RegisterTemplateCmd;
+import org.apache.cloudstack.context.CallContext;
 import org.apache.cloudstack.direct.download.DirectDownloadManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataObject;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStore;
@@ -359,6 +361,16 @@ public class HypervisorTemplateAdapter extends 
TemplateAdapterBase {
                     throw new CloudRuntimeException("Unable to persist the 
template " + profile.getTemplate());
                 }
 
+                // Set Event Details for Template/ISO Upload
+                String eventType = 
template.getFormat().equals(ImageFormat.ISO) ? "Iso" : "Template";
+                String eventResourceId = template.getUuid();
+                CallContext.current().setEventDetails(String.format("%s Id: 
%s", eventType, eventResourceId));
+                
CallContext.current().putContextParameter(eventType.equals("Iso") ? eventType : 
VirtualMachineTemplate.class, eventResourceId);
+                if (template.getFormat().equals(ImageFormat.ISO)) {
+                    
CallContext.current().setEventResourceType(ApiCommandResourceType.Iso);
+                    CallContext.current().setEventResourceId(template.getId());
+                }
+
                 if (profile.getZoneIdList() != null && 
profile.getZoneIdList().size() > 1)
                     throw new CloudRuntimeException("Operation is not 
supported for more than one zone id at a time");
 

Reply via email to