Skip to content

Commit 940733c

Browse files
authored
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
1 parent 710f34e commit 940733c

4 files changed

Lines changed: 14 additions & 9 deletions

File tree

api/src/main/java/org/apache/cloudstack/api/command/user/config/ListCapabilitiesCmd.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ public void execute() {
5959
response.setAllowUserViewAllDomainAccounts((Boolean)capabilities.get("allowUserViewAllDomainAccounts"));
6060
response.setKubernetesServiceEnabled((Boolean)capabilities.get("kubernetesServiceEnabled"));
6161
response.setKubernetesClusterExperimentalFeaturesEnabled((Boolean)capabilities.get("kubernetesClusterExperimentalFeaturesEnabled"));
62+
response.setCustomHypervisorDisplayName((String) capabilities.get("customHypervisorDisplayName"));
6263
if (capabilities.containsKey("apiLimitInterval")) {
6364
response.setApiLimitInterval((Integer)capabilities.get("apiLimitInterval"));
6465
}

api/src/main/java/org/apache/cloudstack/api/response/CapabilitiesResponse.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ public class CapabilitiesResponse extends BaseResponse {
100100
@Param(description = "true if experimental features for Kubernetes cluster such as Docker private registry are enabled, false otherwise")
101101
private boolean kubernetesClusterExperimentalFeaturesEnabled;
102102

103+
@SerializedName("customhypervisordisplayname")
104+
@Param(description = "Display name for custom hypervisor", since = "4.19.0")
105+
private String customHypervisorDisplayName;
106+
103107
@SerializedName("defaultuipagesize")
104108
@Param(description = "default page size in the UI for various views, value set in the configurations", since = "4.15.2")
105109
private Long defaultUiPageSize;
@@ -215,4 +219,8 @@ public void setInstancesDisksStatsRetentionEnabled(Boolean instancesDisksStatsRe
215219
public void setInstancesDisksStatsRetentionTime(Integer instancesDisksStatsRetentionTime) {
216220
this.instancesDisksStatsRetentionTime = instancesDisksStatsRetentionTime;
217221
}
222+
223+
public void setCustomHypervisorDisplayName(String customHypervisorDisplayName) {
224+
this.customHypervisorDisplayName = customHypervisorDisplayName;
225+
}
218226
}

server/src/main/java/com/cloud/server/ManagementServerImpl.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import javax.inject.Inject;
4444
import javax.naming.ConfigurationException;
4545

46+
import com.cloud.hypervisor.HypervisorGuru;
4647
import org.apache.cloudstack.acl.ControlledEntity;
4748
import org.apache.cloudstack.acl.SecurityChecker;
4849
import org.apache.cloudstack.affinity.AffinityGroupProcessor;
@@ -4326,6 +4327,7 @@ public Map<String, Object> listCapabilities(final ListCapabilitiesCmd cmd) {
43264327
capabilities.put("allowUserViewAllDomainAccounts", allowUserViewAllDomainAccounts);
43274328
capabilities.put("kubernetesServiceEnabled", kubernetesServiceEnabled);
43284329
capabilities.put("kubernetesClusterExperimentalFeaturesEnabled", kubernetesClusterExperimentalFeaturesEnabled);
4330+
capabilities.put("customHypervisorDisplayName", HypervisorGuru.HypervisorCustomDisplayName.value());
43294331
capabilities.put(ApiServiceConfiguration.DefaultUIPageSize.key(), ApiServiceConfiguration.DefaultUIPageSize.value());
43304332
capabilities.put(ApiConstants.INSTANCES_STATS_RETENTION_TIME, StatsCollector.vmStatsMaxRetentionTime.value());
43314333
capabilities.put(ApiConstants.INSTANCES_STATS_USER_ONLY, StatsCollector.vmStatsCollectUserVMOnly.value());

ui/src/store/modules/user.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,9 @@ const user = {
286286
if (result && result.defaultuipagesize) {
287287
commit('SET_DEFAULT_LISTVIEW_PAGE_SIZE', result.defaultuipagesize)
288288
}
289+
if (result && result.customhypervisordisplayname) {
290+
commit('SET_CUSTOM_HYPERVISOR_NAME', result.customhypervisordisplayname)
291+
}
289292
}).catch(error => {
290293
reject(error)
291294
})
@@ -302,15 +305,6 @@ const user = {
302305
commit('SET_CLOUDIAN', cloudian)
303306
}).catch(ignored => {
304307
})
305-
306-
api('listConfigurations', { name: 'hypervisor.custom.display.name' }).then(json => {
307-
if (json.listconfigurationsresponse.configuration !== null) {
308-
const config = json.listconfigurationsresponse.configuration[0]
309-
commit('SET_CUSTOM_HYPERVISOR_NAME', config.value)
310-
}
311-
}).catch(error => {
312-
reject(error)
313-
})
314308
})
315309
},
316310

0 commit comments

Comments
 (0)