From daf6b9d1030188bb129e44e2cdd7a4f65a2bbb0f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 24 May 2024 21:09:52 +0530 Subject: [PATCH] api,ui: vm template format, fix vm info link (#9094) --- .../apache/cloudstack/api/ApiConstants.java | 1 + .../api/response/UserVmResponse.java | 12 ++++++ .../META-INF/db/views/cloud.user_vm_view.sql | 1 + .../api/query/dao/UserVmJoinDaoImpl.java | 1 + .../com/cloud/api/query/vo/UserVmJoinVO.java | 8 ++++ .../api/query/dao/UserVmJoinDaoImplTest.java | 38 ++++++++++--------- ui/src/components/view/InfoCard.vue | 2 +- 7 files changed, 44 insertions(+), 19 deletions(-) diff --git a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java index b5fab14ccb6..7565b679e58 100644 --- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java +++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java @@ -448,6 +448,7 @@ public class ApiConstants { public static final String TEMPLATE_IDS = "templateids"; public static final String TEMPLATE_NAME = "templatename"; public static final String TEMPLATE_TYPE = "templatetype"; + public static final String TEMPLATE_FORMAT = "templateformat"; public static final String TIMEOUT = "timeout"; public static final String TIMEZONE = "timezone"; public static final String TIMEZONEOFFSET = "timezoneoffset"; diff --git a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java index 763265e109d..5a0ea77a4e7 100644 --- a/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java +++ b/api/src/main/java/org/apache/cloudstack/api/response/UserVmResponse.java @@ -137,6 +137,10 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co @Param(description = "the type of the template for the virtual machine", since = "4.19.0") private String templateType; + @SerializedName(ApiConstants.TEMPLATE_FORMAT) + @Param(description = "the format of the template for the virtual machine", since = "4.19.1") + private String templateFormat; + @SerializedName("templatedisplaytext") @Param(description = " an alternate display text of the template for the virtual machine") private String templateDisplayText; @@ -1076,6 +1080,14 @@ public class UserVmResponse extends BaseResponseWithTagInformation implements Co this.templateType = templateType; } + public String getTemplateFormat() { + return templateFormat; + } + + public void setTemplateFormat(String templateFormat) { + this.templateFormat = templateFormat; + } + public List getVnfNics() { return vnfNics; } diff --git a/engine/schema/src/main/resources/META-INF/db/views/cloud.user_vm_view.sql b/engine/schema/src/main/resources/META-INF/db/views/cloud.user_vm_view.sql index 7a057dc0330..25f95709721 100644 --- a/engine/schema/src/main/resources/META-INF/db/views/cloud.user_vm_view.sql +++ b/engine/schema/src/main/resources/META-INF/db/views/cloud.user_vm_view.sql @@ -74,6 +74,7 @@ SELECT `vm_template`.`uuid` AS `template_uuid`, `vm_template`.`name` AS `template_name`, `vm_template`.`type` AS `template_type`, + `vm_template`.`format` AS `template_format`, `vm_template`.`display_text` AS `template_display_text`, `vm_template`.`enable_password` AS `password_enabled`, `iso`.`id` AS `iso_id`, diff --git a/server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java b/server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java index e5cc9ee7234..828cafd7d50 100644 --- a/server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java +++ b/server/src/main/java/com/cloud/api/query/dao/UserVmJoinDaoImpl.java @@ -198,6 +198,7 @@ public class UserVmJoinDaoImpl extends GenericDaoBaseWithTagInformation { @@ -109,6 +110,7 @@ public class UserVmJoinDaoImplTest extends GenericDaoBaseWithTagInformationBaseT Mockito.when(userVmMock.getId()).thenReturn(vmId); Mockito.when(userVmMock.getTemplateId()).thenReturn(templateId); Mockito.when(userVmMock.getTemplateType()).thenReturn(Storage.TemplateType.VNF); + Mockito.when(userVmMock.getTemplateFormat()).thenReturn(Storage.ImageFormat.OVA); Mockito.when(caller.getId()).thenReturn(2L); Mockito.when(accountMgr.isRootAdmin(nullable(Long.class))).thenReturn(true); diff --git a/ui/src/components/view/InfoCard.vue b/ui/src/components/view/InfoCard.vue index 66c878da0f8..a4fa1191d13 100644 --- a/ui/src/components/view/InfoCard.vue +++ b/ui/src/components/view/InfoCard.vue @@ -524,7 +524,7 @@
- {{ resource.templatedisplaytext || resource.templatename || resource.templateid }} + {{ resource.templatedisplaytext || resource.templatename || resource.templateid }}