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

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


The following commit(s) were added to refs/heads/main by this push:
     new 940733cedfb UI: Fix user role login due to missing API access on 
custom hypervisor name (#7939)
940733cedfb is described below

commit 940733cedfb1b46930d280c76a5f436d9c01f553
Author: Nicolas Vazquez <[email protected]>
AuthorDate: Mon Sep 11 05:38:05 2023 -0300

    UI: Fix user role login due to missing API access on custom hypervisor name 
(#7939)
    
    * UI: Fix user role login due to missing API access on custom hypervisor 
name
    
    * Refactor to include the custom HW display name as part of the response of 
listCapabilities API
    
    * Add since parameter
---
 .../api/command/user/config/ListCapabilitiesCmd.java         |  1 +
 .../apache/cloudstack/api/response/CapabilitiesResponse.java |  8 ++++++++
 .../src/main/java/com/cloud/server/ManagementServerImpl.java |  2 ++
 ui/src/store/modules/user.js                                 | 12 +++---------
 4 files changed, 14 insertions(+), 9 deletions(-)

diff --git 
a/api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
 
b/api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
index 4a2711e2092..65920a97c98 100644
--- 
a/api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
+++ 
b/api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java
@@ -59,6 +59,7 @@ public class ListCapabilitiesCmd extends BaseCmd {
         
response.setAllowUserViewAllDomainAccounts((Boolean)capabilities.get("allowUserViewAllDomainAccounts"));
         
response.setKubernetesServiceEnabled((Boolean)capabilities.get("kubernetesServiceEnabled"));
         
response.setKubernetesClusterExperimentalFeaturesEnabled((Boolean)capabilities.get("kubernetesClusterExperimentalFeaturesEnabled"));
+        response.setCustomHypervisorDisplayName((String) 
capabilities.get("customHypervisorDisplayName"));
         if (capabilities.containsKey("apiLimitInterval")) {
             
response.setApiLimitInterval((Integer)capabilities.get("apiLimitInterval"));
         }
diff --git 
a/api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java
 
b/api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java
index d2f7c6b00d0..e4224c85e97 100644
--- 
a/api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java
+++ 
b/api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java
@@ -100,6 +100,10 @@ public class CapabilitiesResponse extends BaseResponse {
     @Param(description = "true if experimental features for Kubernetes cluster 
such as Docker private registry are enabled, false otherwise")
     private boolean kubernetesClusterExperimentalFeaturesEnabled;
 
+    @SerializedName("customhypervisordisplayname")
+    @Param(description = "Display name for custom hypervisor", since = 
"4.19.0")
+    private String customHypervisorDisplayName;
+
     @SerializedName("defaultuipagesize")
     @Param(description = "default page size in the UI for various views, value 
set in the configurations", since = "4.15.2")
     private Long defaultUiPageSize;
@@ -215,4 +219,8 @@ public class CapabilitiesResponse extends BaseResponse {
     public void setInstancesDisksStatsRetentionTime(Integer 
instancesDisksStatsRetentionTime) {
         this.instancesDisksStatsRetentionTime = 
instancesDisksStatsRetentionTime;
     }
+
+    public void setCustomHypervisorDisplayName(String 
customHypervisorDisplayName) {
+        this.customHypervisorDisplayName = customHypervisorDisplayName;
+    }
 }
diff --git a/server/src/main/java/com/cloud/server/ManagementServerImpl.java 
b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
index 5a6fd617899..77a652d7690 100644
--- a/server/src/main/java/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/main/java/com/cloud/server/ManagementServerImpl.java
@@ -43,6 +43,7 @@ import javax.crypto.spec.SecretKeySpec;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import com.cloud.hypervisor.HypervisorGuru;
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.SecurityChecker;
 import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -4326,6 +4327,7 @@ public class ManagementServerImpl extends ManagerBase 
implements ManagementServe
         capabilities.put("allowUserViewAllDomainAccounts", 
allowUserViewAllDomainAccounts);
         capabilities.put("kubernetesServiceEnabled", kubernetesServiceEnabled);
         capabilities.put("kubernetesClusterExperimentalFeaturesEnabled", 
kubernetesClusterExperimentalFeaturesEnabled);
+        capabilities.put("customHypervisorDisplayName", 
HypervisorGuru.HypervisorCustomDisplayName.value());
         capabilities.put(ApiServiceConfiguration.DefaultUIPageSize.key(), 
ApiServiceConfiguration.DefaultUIPageSize.value());
         capabilities.put(ApiConstants.INSTANCES_STATS_RETENTION_TIME, 
StatsCollector.vmStatsMaxRetentionTime.value());
         capabilities.put(ApiConstants.INSTANCES_STATS_USER_ONLY, 
StatsCollector.vmStatsCollectUserVMOnly.value());
diff --git a/ui/src/store/modules/user.js b/ui/src/store/modules/user.js
index beddb10edf0..6a3ba217baf 100644
--- a/ui/src/store/modules/user.js
+++ b/ui/src/store/modules/user.js
@@ -286,6 +286,9 @@ const user = {
           if (result && result.defaultuipagesize) {
             commit('SET_DEFAULT_LISTVIEW_PAGE_SIZE', result.defaultuipagesize)
           }
+          if (result && result.customhypervisordisplayname) {
+            commit('SET_CUSTOM_HYPERVISOR_NAME', 
result.customhypervisordisplayname)
+          }
         }).catch(error => {
           reject(error)
         })
@@ -302,15 +305,6 @@ const user = {
           commit('SET_CLOUDIAN', cloudian)
         }).catch(ignored => {
         })
-
-        api('listConfigurations', { name: 'hypervisor.custom.display.name' 
}).then(json => {
-          if (json.listconfigurationsresponse.configuration !== null) {
-            const config = json.listconfigurationsresponse.configuration[0]
-            commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
-          }
-        }).catch(error => {
-          reject(error)
-        })
       })
     },
 

Reply via email to