Skip to content

Commit 6689f01

Browse files
Improve global settings in the UI to be more intuitive/logical
1 parent 30ae9ee commit 6689f01

File tree

39 files changed

+1568
-12
lines changed

39 files changed

+1568
-12
lines changed

api/src/main/java/org/apache/cloudstack/api/ApiConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ public class ApiConstants {
168168
public static final String GATEWAY = "gateway";
169169
public static final String IP6_GATEWAY = "ip6gateway";
170170
public static final String GROUP = "group";
171+
public static final String SUBGROUP = "subgroup";
171172
public static final String GROUP_ID = "groupid";
172173
public static final String GSLB_LB_METHOD = "gslblbmethod";
173174
public static final String GSLB_SERVICE_DOMAIN_NAME = "gslbdomainname";
@@ -274,6 +275,7 @@ public class ApiConstants {
274275
public static final String OUTPUT = "output";
275276
public static final String PROPERTIES = "properties";
276277
public static final String PARAMS = "params";
278+
public static final String PARENT = "parent";
277279
public static final String PARENT_ID = "parentid";
278280
public static final String PARENT_DOMAIN_ID = "parentdomainid";
279281
public static final String PARENT_TEMPLATE_ID = "parenttemplateid";

api/src/main/java/org/apache/cloudstack/api/command/admin/config/ListCfgsByCmd.java

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121

22+
import org.apache.cloudstack.api.ApiErrorCode;
23+
import org.apache.cloudstack.api.ServerApiException;
2224
import org.apache.cloudstack.api.response.DomainResponse;
25+
import org.apache.commons.lang3.StringUtils;
2326
import org.apache.log4j.Logger;
2427

2528
import org.apache.cloudstack.api.APICommand;
@@ -90,6 +93,15 @@ public class ListCfgsByCmd extends BaseListCmd {
9093
description = "the ID of the Image Store to update the parameter value for corresponding image store")
9194
private Long imageStoreId;
9295

96+
@Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "lists configuration by group name")
97+
private String groupName;
98+
99+
@Parameter(name = ApiConstants.SUBGROUP, type = CommandType.STRING, description = "lists configuration by subgroup name")
100+
private String subGroupName;
101+
102+
@Parameter(name = ApiConstants.PARENT, type = CommandType.STRING, description = "lists configuration by parent name")
103+
private String parentName;
104+
93105
// ///////////////////////////////////////////////////
94106
// ///////////////// Accessors ///////////////////////
95107
// ///////////////////////////////////////////////////
@@ -126,6 +138,26 @@ public Long getImageStoreId() {
126138
return imageStoreId;
127139
}
128140

141+
public String getGroupName() {
142+
return groupName;
143+
}
144+
145+
public String getSubGroupName() {
146+
return subGroupName;
147+
}
148+
149+
public String getParentName() {
150+
return parentName;
151+
}
152+
153+
@Override
154+
public Integer getPageSize() {
155+
if (StringUtils.isNotEmpty(getGroupName())) {
156+
return Integer.valueOf(s_pageSizeUnlimited.intValue());
157+
}
158+
return super.getPageSize();
159+
}
160+
129161
@Override
130162
public Long getPageSizeVal() {
131163
Long defaultPageSize = 500L;
@@ -151,11 +183,15 @@ public String getCommandName() {
151183

152184
@Override
153185
public void execute() {
186+
validParameters();
154187
Pair<List<? extends Configuration>, Integer> result = _mgr.searchForConfigurations(this);
155188
ListResponse<ConfigurationResponse> response = new ListResponse<ConfigurationResponse>();
156189
List<ConfigurationResponse> configResponses = new ArrayList<ConfigurationResponse>();
157190
for (Configuration cfg : result.first()) {
158191
ConfigurationResponse cfgResponse = _responseGenerator.createConfigurationResponse(cfg);
192+
if (!matchesConfigurationGroup(cfgResponse)) {
193+
continue;
194+
}
159195
cfgResponse.setObjectName("configuration");
160196
if (getZoneId() != null) {
161197
cfgResponse.setScope("zone");
@@ -178,8 +214,32 @@ public void execute() {
178214
configResponses.add(cfgResponse);
179215
}
180216

181-
response.setResponses(configResponses, result.second());
217+
if (StringUtils.isNotEmpty(getGroupName())) {
218+
response.setResponses(configResponses, configResponses.size());
219+
} else {
220+
response.setResponses(configResponses, result.second());
221+
}
182222
response.setResponseName(getCommandName());
183223
setResponseObject(response);
184224
}
225+
226+
private void validParameters() {
227+
if (StringUtils.isNotEmpty(getSubGroupName())&& StringUtils.isEmpty(getGroupName())) {
228+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Group name must be specified with the subgroup name");
229+
}
230+
}
231+
232+
private boolean matchesConfigurationGroup(ConfigurationResponse cfgResponse) {
233+
if (StringUtils.isNotEmpty(getGroupName())) {
234+
if (!(getGroupName().equalsIgnoreCase(cfgResponse.getGroup()))) {
235+
return false;
236+
}
237+
if (StringUtils.isNotEmpty(getSubGroupName())) {
238+
if (!(getSubGroupName().equalsIgnoreCase(cfgResponse.getSubGroup()))) {
239+
return false;
240+
}
241+
}
242+
}
243+
return true;
244+
}
185245
}

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

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,14 @@ public class ConfigurationResponse extends BaseResponse {
2828
@Param(description = "the category of the configuration")
2929
private String category;
3030

31+
@SerializedName(ApiConstants.GROUP)
32+
@Param(description = "the group of the configuration")
33+
private String group;
34+
35+
@SerializedName(ApiConstants.SUBGROUP)
36+
@Param(description = "the subgroup of the configuration")
37+
private String subGroup;
38+
3139
@SerializedName(ApiConstants.NAME)
3240
@Param(description = "the name of the configuration")
3341
private String name;
@@ -52,6 +60,22 @@ public class ConfigurationResponse extends BaseResponse {
5260
@Param(description = "true if the configuration is dynamic")
5361
private boolean isDynamic;
5462

63+
@SerializedName(ApiConstants.COMPONENT)
64+
@Param(description = "the component of the configuration", since = "4.17.0")
65+
private String component;
66+
67+
@SerializedName("parent")
68+
@Param(description = "the name of the parent configuration", since = "4.17.0")
69+
private String parent;
70+
71+
@SerializedName(ApiConstants.DISPLAY_TEXT)
72+
@Param(description = "the display text of the configuration", since = "4.17.0")
73+
private String displayText;
74+
75+
@SerializedName(ApiConstants.TYPE)
76+
@Param(description = "the type of the configuration value", since = "4.17.0")
77+
private String type;
78+
5579
public String getCategory() {
5680
return category;
5781
}
@@ -60,6 +84,22 @@ public void setCategory(String category) {
6084
this.category = category;
6185
}
6286

87+
public String getGroup() {
88+
return group;
89+
}
90+
91+
public void setGroup(String group) {
92+
this.group = group;
93+
}
94+
95+
public String getSubGroup() {
96+
return subGroup;
97+
}
98+
99+
public void setSubGroup(String subGroup) {
100+
this.subGroup = subGroup;
101+
}
102+
63103
public String getName() {
64104
return name;
65105
}
@@ -100,4 +140,35 @@ public void setIsDynamic(boolean isDynamic) {
100140
this.isDynamic = isDynamic;
101141
}
102142

143+
public String getComponent() {
144+
return component;
145+
}
146+
147+
public void setComponent(String component) {
148+
this.component = component;
149+
}
150+
151+
public String getParent() {
152+
return parent;
153+
}
154+
155+
public void setParent(String parent) {
156+
this.parent = parent;
157+
}
158+
159+
public String getDisplayText() {
160+
return displayText;
161+
}
162+
163+
public void setDisplayText(String displayText) {
164+
this.displayText = displayText;
165+
}
166+
167+
public String getType() {
168+
return type;
169+
}
170+
171+
public void setType(String type) {
172+
this.type = type;
173+
}
103174
}

engine/components-api/src/main/java/com/cloud/configuration/ConfigurationManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import com.cloud.offerings.NetworkOfferingVO;
4343
import com.cloud.org.Grouping.AllocationState;
4444
import com.cloud.user.Account;
45+
import com.cloud.utils.Pair;
4546

4647
/**
4748
* ConfigurationManager handles adding pods/zones, changing IP ranges, enabling external firewalls, and editing
@@ -259,4 +260,8 @@ Vlan createVlanAndPublicIpRange(long zoneId, long networkId, long physicalNetwor
259260
AllocationState findPodAllocationState(HostPodVO pod);
260261

261262
AllocationState findClusterAllocationState(ClusterVO cluster);
263+
264+
String getConfigurationType(String configName); // Value type
265+
266+
Pair<String, String> getConfigurationGroup(String configName);
262267
}

0 commit comments

Comments
 (0)