You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ha...@apache.org on 2022/12/30 07:46:36 UTC
[cloudstack] 06/07: UI changes for adding guest os and mappings
This is an automated email from the ASF dual-hosted git repository.
harikrishna pushed a commit to branch guest-os-mappings-improvements
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
commit 618946a6bfb5838e24689bdd9c050651e8099dd7
Author: Harikrishna Patnala <ha...@gmail.com>
AuthorDate: Fri Dec 30 11:31:05 2022 +0530
UI changes for adding guest os and mappings
---
.../org/apache/cloudstack/api/ApiConstants.java | 1 +
.../command/admin/guest/ListGuestOsMappingCmd.java | 7 +++
.../api/command/admin/guest/UpdateGuestOsCmd.java | 2 +-
.../cloudstack/api/response/GuestOSResponse.java | 14 +++---
.../main/java/com/cloud/api/ApiResponseHelper.java | 2 +-
.../com/cloud/server/ManagementServerImpl.java | 5 +++
ui/public/locales/en.json | 10 ++++-
ui/src/components/view/InfoCard.vue | 2 +-
ui/src/components/view/ListView.vue | 7 ++-
ui/src/components/widgets/Breadcrumb.vue | 2 +-
ui/src/config/section/config.js | 51 +++++++++++++++++++---
ui/src/views/AutogenView.vue | 2 +-
12 files changed, 85 insertions(+), 20 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 ae97c2ef903..b6216124a25 100644
--- a/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/main/java/org/apache/cloudstack/api/ApiConstants.java
@@ -297,6 +297,7 @@ public class ApiConstants {
public static final String OP = "op";
public static final String OS_CATEGORY_ID = "oscategoryid";
public static final String OS_CATEGORY_NAME = "oscategoryname";
+ public static final String OS_NAME = "osname";
public static final String OS_ID = "osid";
public static final String OS_TYPE_ID = "ostypeid";
public static final String OS_DISPLAY_NAME = "osdisplayname";
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java
index a7fc9e0decd..da5b6b9dd8d 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/ListGuestOsMappingCmd.java
@@ -49,6 +49,9 @@ public class ListGuestOsMappingCmd extends BaseListCmd {
@Parameter(name = ApiConstants.OS_TYPE_ID, type = CommandType.UUID, entityType = GuestOSResponse.class, required = false, description = "list mapping by Guest OS Type UUID")
private Long osTypeId;
+ @Parameter(name = ApiConstants.OS_DISPLAY_NAME, type = CommandType.STRING, required = false, description = "list Guest OS mapping by OS display name")
+ private String osDisplayName;
+
@Parameter(name = ApiConstants.HYPERVISOR, type = CommandType.STRING, required = false, description = "list Guest OS mapping by hypervisor")
private String hypervisor;
@@ -67,6 +70,10 @@ public class ListGuestOsMappingCmd extends BaseListCmd {
return osTypeId;
}
+ public String getOsDisplayName() {
+ return osDisplayName;
+ }
+
public String getHypervisor() {
return hypervisor;
}
diff --git a/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java b/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java
index d67ffc66e95..55007870add 100644
--- a/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java
+++ b/api/src/main/java/org/apache/cloudstack/api/command/admin/guest/UpdateGuestOsCmd.java
@@ -54,7 +54,7 @@ public class UpdateGuestOsCmd extends BaseAsyncCmd {
@Parameter(name = ApiConstants.OS_DISPLAY_NAME, type = CommandType.STRING, required = true, description = "Unique display name for Guest OS")
private String osDisplayName;
- @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = true, description = "Map of (key/value pairs)")
+ @Parameter(name = ApiConstants.DETAILS, type = CommandType.MAP, required = false, description = "Map of (key/value pairs)")
private Map details;
diff --git a/api/src/main/java/org/apache/cloudstack/api/response/GuestOSResponse.java b/api/src/main/java/org/apache/cloudstack/api/response/GuestOSResponse.java
index 784a5297cc6..319d44bec8e 100644
--- a/api/src/main/java/org/apache/cloudstack/api/response/GuestOSResponse.java
+++ b/api/src/main/java/org/apache/cloudstack/api/response/GuestOSResponse.java
@@ -39,9 +39,9 @@ public class GuestOSResponse extends BaseResponse {
@Param(description = "the name of the OS category")
private String osCategoryName;
- @SerializedName(ApiConstants.DESCRIPTION)
- @Param(description = "the name/description of the OS type")
- private String description;
+ @SerializedName(ApiConstants.OS_NAME)
+ @Param(description = "the name of the OS type")
+ private String osName;
@SerializedName(ApiConstants.IS_USER_DEFINED)
@Param(description = "is the guest OS user defined")
@@ -71,12 +71,12 @@ public class GuestOSResponse extends BaseResponse {
this.osCategoryName = osCategoryName;
}
- public String getDescription() {
- return description;
+ public String getOsName() {
+ return osName;
}
- public void setDescription(String description) {
- this.description = description;
+ public void setOsName(String osName) {
+ this.osName = osName;
}
public String getIsUserDefined() {
diff --git a/server/src/main/java/com/cloud/api/ApiResponseHelper.java b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
index 8fb5e3dc2d6..744d9419bc0 100644
--- a/server/src/main/java/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/main/java/com/cloud/api/ApiResponseHelper.java
@@ -3583,7 +3583,7 @@ public class ApiResponseHelper implements ResponseGenerator {
@Override
public GuestOSResponse createGuestOSResponse(GuestOS guestOS) {
GuestOSResponse response = new GuestOSResponse();
- response.setDescription(guestOS.getDisplayName());
+ response.setOsName(guestOS.getDisplayName());
response.setId(guestOS.getUuid());
response.setIsUserDefined(String.valueOf(guestOS.getIsUserDefined()));
GuestOSCategoryVO category = ApiDBUtils.findGuestOsCategoryById(guestOS.getCategoryId());
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index a36fb654b5c..5dc6f36e769 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -2609,6 +2609,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
searchFilter.addOrderBy(GuestOSHypervisorVO.class, "created", false);
final Long id = cmd.getId();
final Long osTypeId = cmd.getOsTypeId();
+ final String osDisplayName = cmd.getOsDisplayName();
final String hypervisor = cmd.getHypervisor();
final String hypervisorVersion = cmd.getHypervisorVersion();
@@ -2627,6 +2628,10 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
sc.addAnd("guestOsId", SearchCriteria.Op.EQ, osTypeId);
}
+ if (osDisplayName != null) {
+ sc.addAnd("guestOsName", SearchCriteria.Op.LIKE, "%" + osDisplayName + "%");
+ }
+
if (hypervisor != null) {
sc.addAnd("hypervisorType", SearchCriteria.Op.EQ, hypervisor);
}
diff --git a/ui/public/locales/en.json b/ui/public/locales/en.json
index b36fb54c8e5..87510c5b4e3 100644
--- a/ui/public/locales/en.json
+++ b/ui/public/locales/en.json
@@ -68,6 +68,8 @@
"label.action.delete.domain": "Delete domain",
"label.action.delete.egress.firewall": "Delete egress firewall rule",
"label.action.delete.firewall": "Delete firewall rule",
+"label.action.delete.guest.os": "Delete guest os",
+"label.action.delete.guest.os.hypervisor.mapping": "Delete guest os hypervisor mapping",
"label.action.delete.ip.range": "Delete IP range",
"label.action.delete.iso": "Delete ISO",
"label.action.delete.load.balancer": "Delete load balancer rule",
@@ -195,6 +197,8 @@
"label.add.f5.device": "Add F5 device",
"label.add.firewall": "Add firewall rule",
"label.add.guest.network": "Add guest network",
+"label.add.guest.os": "Add guest os",
+"label.add.guest.os.hypervisor.mapping": "Add guest os hypervisor mapping",
"label.add.host": "Add host",
"label.add.ingress.rule": "Add ingress rule",
"label.add.intermediate.certificate": "Add intermediate certificate",
@@ -786,7 +790,7 @@
"label.guest.netmask": "Guest netmask",
"label.guest.networks": "Guest networks",
"label.guest.os": "Guest OS",
-"label.guest.os.mappings": "Guest OS mappings",
+"label.guest.os.hypervisor.mappings": "Guest OS Hypervisor mappings",
"label.guest.start.ip": "Guest start IP",
"label.guest.traffic": "Guest traffic",
"label.guestcidraddress": "Guest CIDR",
@@ -1248,7 +1252,9 @@
"label.order": "Order",
"label.oscategoryid": "OS preference",
"label.oscategoryname": "OS category name",
+"label.osname": "OS name",
"label.osdisplayname": "OS name",
+"label.osmappingcheckenabled": "Check OS name with hypervisor",
"label.osnameforhypervisor": "Hypervisor mapping name",
"label.ostypeid": "OS type",
"label.osdistribution": "OS distribution",
@@ -2002,6 +2008,8 @@
"message.action.delete.backup.offering": "Please confirm that you want to delete this backup offering?",
"message.action.delete.cluster": "Please confirm that you want to delete this cluster.",
"message.action.delete.disk.offering": "Please confirm that you want to delete this disk offering.",
+"message.action.delete.guest.os": "Please confirm that you want to delete this guest os. System defined entry cannot be deleted.",
+"message.action.delete.guest.os.hypervisor.mapping": "Please confirm that you want to delete this guest os hypervisor mapping. System defined entry cannot be deleted.",
"message.action.delete.instance.group": "Please confirm that you want to delete the instance group.",
"message.action.delete.iso": "Please confirm that you want to delete this ISO.",
"message.action.delete.network": "Please confirm that you want to delete this network.",
diff --git a/ui/src/components/view/InfoCard.vue b/ui/src/components/view/InfoCard.vue
index 32ac7aad91b..b6aa4855792 100644
--- a/ui/src/components/view/InfoCard.vue
+++ b/ui/src/components/view/InfoCard.vue
@@ -834,7 +834,7 @@ export default {
},
name () {
return this.resource.displayname || this.resource.name || this.resource.displaytext || this.resource.username ||
- this.resource.ipaddress || this.resource.virtualmachinename || this.resource.templatetype
+ this.resource.ipaddress || this.resource.virtualmachinename || this.resource.osname || this.resource.osdisplayname || this.resource.templatetype
},
keypairs () {
if (!this.resource.keypairs) {
diff --git a/ui/src/components/view/ListView.vue b/ui/src/components/view/ListView.vue
index a7f0be697c7..f5596203164 100644
--- a/ui/src/components/view/ListView.vue
+++ b/ui/src/components/view/ListView.vue
@@ -178,10 +178,13 @@
<span v-if="$route.name === 'hypervisorcapability'">
<router-link :to="{ path: $route.path + '/' + record.id }">{{ text }}</router-link>
</span>
- <span v-else-if="$route.name === 'guestos'">
+ <span v-else-if="$route.name === 'guestoshypervisormapping'">
<router-link :to="{ path: $route.path + '/' + record.id }">{{ text }}</router-link>
</span>
- <span v-else-if="$route.name === 'guestoshypervisormapping'">
+ <span v-else>{{ text }}</span>
+ </template>
+ <template #osname="{ text, record }">
+ <span v-if="$route.name === 'guestos'">
<router-link :to="{ path: $route.path + '/' + record.id }">{{ text }}</router-link>
</span>
<span v-else>{{ text }}</span>
diff --git a/ui/src/components/widgets/Breadcrumb.vue b/ui/src/components/widgets/Breadcrumb.vue
index 68004605334..054f49f111e 100644
--- a/ui/src/components/widgets/Breadcrumb.vue
+++ b/ui/src/components/widgets/Breadcrumb.vue
@@ -34,7 +34,7 @@
</span>
</label>
<label v-else>
- {{ resource.displayname || resource.name || resource.displaytext || resource.hostname || resource.username || resource.ipaddress || $route.params.id }}
+ {{ resource.displayname || resource.name || resource.displaytext || resource.hostname || resource.username || resource.ipaddress || resource.osname || resource.osdisplayname || $route.params.id }}
</label>
</span>
<span v-else>
diff --git a/ui/src/config/section/config.js b/ui/src/config/section/config.js
index fdb9ad99fef..eafd1434e39 100644
--- a/ui/src/config/section/config.js
+++ b/ui/src/config/section/config.js
@@ -86,24 +86,48 @@ export default {
{
name: 'guestos',
title: 'label.guest.os',
+ docHelp: 'adminguide/service_offerings.html#compute-and-disk-service-offerings',
icon: 'database-outlined',
permission: ['listOsTypes'],
- columns: ['description', 'oscategoryname', 'isuserdefined'],
- details: ['description', 'oscategoryname', 'isuserdefined'],
- searchFilters: ['description'],
+ columns: ['osname', 'oscategoryname', 'isuserdefined'],
+ details: ['osname', 'oscategoryname', 'isuserdefined'],
+ related: [{
+ name: 'guestoshypervisormapping',
+ title: 'label.guest.os.hypervisor.mappings',
+ param: 'ostypeid'
+ }],
+ searchFilters: ['osname'],
actions: [
+ {
+ api: 'addGuestOs',
+ icon: 'plus-outlined',
+ label: 'label.add.guest.os',
+ listView: true,
+ dataView: false,
+ args: ['osdisplayname', 'oscategoryid']
+ },
{
api: 'updateGuestOs',
icon: 'edit-outlined',
label: 'label.edit',
dataView: true,
args: ['osdisplayname']
+ },
+ {
+ api: 'removeGuestOs',
+ icon: 'delete-outlined',
+ label: 'label.action.delete.guest.os',
+ message: 'message.action.delete.guest.os',
+ docHelp: 'adminguide/service_offerings.html#modifying-or-deleting-a-service-offering',
+ dataView: true,
+ popup: true
}
]
},
{
name: 'guestoshypervisormapping',
- title: 'label.guest.os.mappings',
+ title: 'label.guest.os.hypervisor.mappings',
+ docHelp: 'adminguide/service_offerings.html#compute-and-disk-service-offerings',
icon: 'database-outlined',
permission: ['listGuestOsMapping'],
columns: ['hypervisor', 'hypervisorversion', 'osdisplayname', 'osnameforhypervisor'],
@@ -111,12 +135,29 @@ export default {
filters: ['all', 'kvm', 'vmware', 'xenserver', 'lxc', 'ovm3'],
searchFilters: ['osdisplayname', 'hypervisor', 'hypervisorversion'],
actions: [
+ {
+ api: 'addGuestOsMapping',
+ icon: 'plus-outlined',
+ label: 'label.add.guest.os.hypervisor.mapping',
+ listView: true,
+ dataView: false,
+ args: ['ostypeid', 'osdisplayname', 'hypervisor', 'hypervisorversion', 'osnameforhypervisor', 'osmappingcheckenabled', 'forced']
+ },
{
api: 'updateGuestOsMapping',
icon: 'edit-outlined',
label: 'label.edit',
dataView: true,
- args: ['osnameforhypervisor']
+ args: ['osnameforhypervisor', 'osmappingcheckenabled']
+ },
+ {
+ api: 'removeGuestOsMapping',
+ icon: 'delete-outlined',
+ label: 'label.action.delete.guest.os.hypervisor.mapping',
+ message: 'message.action.delete.guest.os.hypervisor.mapping',
+ docHelp: 'adminguide/service_offerings.html#modifying-or-deleting-a-service-offering',
+ dataView: true,
+ popup: true
}
]
}
diff --git a/ui/src/views/AutogenView.vue b/ui/src/views/AutogenView.vue
index 59f2c63165c..98074b5c94a 100644
--- a/ui/src/views/AutogenView.vue
+++ b/ui/src/views/AutogenView.vue
@@ -56,7 +56,7 @@
:value="$route.query.filter || (projectView && $route.name === 'vm' ||
['Admin', 'DomainAdmin'].includes($store.getters.userInfo.roletype) && ['vm', 'iso', 'template'].includes($route.name)
? 'all' : ['publicip'].includes($route.name)
- ? 'allocated' : ['guestnetwork', 'guestvlans'].includes($route.name) ? 'all' : 'self')"
+ ? 'allocated' : ['guestnetwork', 'guestvlans', 'guestos', 'guestoshypervisormapping'].includes($route.name) ? 'all' : 'self')"
style="min-width: 120px; margin-left: 10px"
@change="changeFilter"
showSearch