Skip to content

Commit 703e618

Browse files
Improve global settings in the UI to be more intuitive/logical
1 parent 9162a9b commit 703e618

File tree

44 files changed

+2665
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+2665
-9
lines changed

api/src/main/java/com/cloud/server/ManagementService.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.Map;
2222

2323
import org.apache.cloudstack.api.command.admin.cluster.ListClustersCmd;
24+
import org.apache.cloudstack.api.command.admin.config.ListCfgGroupsByCmd;
2425
import org.apache.cloudstack.api.command.admin.config.ListCfgsByCmd;
2526
import org.apache.cloudstack.api.command.admin.config.UpdateHypervisorCapabilitiesCmd;
2627
import org.apache.cloudstack.api.command.admin.guest.AddGuestOsCmd;
@@ -58,6 +59,7 @@
5859
import org.apache.cloudstack.api.command.user.vm.GetVMPasswordCmd;
5960
import org.apache.cloudstack.api.command.user.vmgroup.UpdateVMGroupCmd;
6061
import org.apache.cloudstack.config.Configuration;
62+
import org.apache.cloudstack.config.ConfigurationGroup;
6163

6264
import com.cloud.alert.Alert;
6365
import com.cloud.capacity.Capacity;
@@ -97,6 +99,13 @@ public interface ManagementService {
9799
*/
98100
Pair<List<? extends Configuration>, Integer> searchForConfigurations(ListCfgsByCmd c);
99101

102+
/**
103+
* returns the the configuration groups
104+
*
105+
* @return list of configuration groups
106+
*/
107+
Pair<List<? extends ConfigurationGroup>, Integer> listConfigurationGroups(ListCfgGroupsByCmd cmd);
108+
100109
/**
101110
* Searches for Clusters by the specified search criteria
102111
*

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ public class ApiConstants {
171171
public static final String GATEWAY = "gateway";
172172
public static final String IP6_GATEWAY = "ip6gateway";
173173
public static final String GROUP = "group";
174+
public static final String SUBGROUP = "subgroup";
174175
public static final String GROUP_ID = "groupid";
175176
public static final String GSLB_LB_METHOD = "gslblbmethod";
176177
public static final String GSLB_SERVICE_DOMAIN_NAME = "gslbdomainname";
@@ -277,6 +278,7 @@ public class ApiConstants {
277278
public static final String OUTPUT = "output";
278279
public static final String PROPERTIES = "properties";
279280
public static final String PARAMS = "params";
281+
public static final String PARENT = "parent";
280282
public static final String PARENT_ID = "parentid";
281283
public static final String PARENT_DOMAIN_ID = "parentdomainid";
282284
public static final String PARENT_TEMPLATE_ID = "parenttemplateid";
@@ -298,6 +300,7 @@ public class ApiConstants {
298300
public static final String POSITION = "position";
299301
public static final String POST_URL = "postURL";
300302
public static final String POWER_STATE = "powerstate";
303+
public static final String PRECEDENCE = "precedence";
301304
public static final String PRIVATE_INTERFACE = "privateinterface";
302305
public static final String PRIVATE_IP = "privateip";
303306
public static final String PRIVATE_PORT = "privateport";

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,13 @@
2323
import java.util.Set;
2424

2525
import com.cloud.server.ResourceIcon;
26+
27+
import org.apache.cloudstack.api.response.ConfigurationGroupResponse;
2628
import org.apache.cloudstack.api.response.ResourceIconResponse;
2729
import org.apache.cloudstack.api.response.RouterHealthCheckResultResponse;
2830
import com.cloud.resource.RollingMaintenanceManager;
2931
import org.apache.cloudstack.api.response.RollingMaintenanceResponse;
32+
import org.apache.cloudstack.config.ConfigurationGroup;
3033
import org.apache.cloudstack.management.ManagementServerHost;
3134
import org.apache.cloudstack.affinity.AffinityGroup;
3235
import org.apache.cloudstack.affinity.AffinityGroupResponse;
@@ -230,6 +233,8 @@ public interface ResponseGenerator {
230233

231234
ConfigurationResponse createConfigurationResponse(Configuration cfg);
232235

236+
ConfigurationGroupResponse createConfigurationGroupResponse(ConfigurationGroup cfgGroup);
237+
233238
SnapshotResponse createSnapshotResponse(Snapshot snapshot);
234239

235240
SnapshotPolicyResponse createSnapshotPolicyResponse(SnapshotPolicy policy);
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.command.admin.config;
18+
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
22+
import org.apache.cloudstack.api.APICommand;
23+
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.BaseCmd;
25+
import org.apache.cloudstack.api.BaseListCmd;
26+
import org.apache.cloudstack.api.Parameter;
27+
import org.apache.cloudstack.api.response.ConfigurationGroupResponse;
28+
import org.apache.cloudstack.api.response.ListResponse;
29+
import org.apache.cloudstack.config.ConfigurationGroup;
30+
import org.apache.log4j.Logger;
31+
32+
import com.cloud.utils.Pair;
33+
34+
@APICommand(name = ListCfgGroupsByCmd.APINAME, description = "Lists all configuration groups.", responseObject = ConfigurationGroupResponse.class,
35+
requestHasSensitiveInfo = false, responseHasSensitiveInfo = false, since = "4.17.0")
36+
public class ListCfgGroupsByCmd extends BaseListCmd {
37+
public static final Logger s_logger = Logger.getLogger(ListCfgGroupsByCmd.class.getName());
38+
39+
public static final String APINAME = "listConfigurationGroups";
40+
41+
// ///////////////////////////////////////////////////
42+
// ////////////// API parameters /////////////////////
43+
// ///////////////////////////////////////////////////
44+
45+
@Parameter(name = ApiConstants.GROUP, type = CommandType.STRING, description = "lists configuration group by group name")
46+
private String groupName;
47+
48+
// ///////////////////////////////////////////////////
49+
// ///////////////// Accessors ///////////////////////
50+
// ///////////////////////////////////////////////////
51+
52+
public String getGroupName() {
53+
return groupName;
54+
}
55+
56+
// ///////////////////////////////////////////////////
57+
// ///////////// API Implementation///////////////////
58+
// ///////////////////////////////////////////////////
59+
60+
@Override
61+
public String getCommandName() {
62+
return APINAME.toLowerCase() + BaseCmd.RESPONSE_SUFFIX;
63+
}
64+
65+
@Override
66+
public void execute() {
67+
Pair<List<? extends ConfigurationGroup>, Integer> result = _mgr.listConfigurationGroups(this);
68+
ListResponse<ConfigurationGroupResponse> response = new ListResponse<ConfigurationGroupResponse>();
69+
List<ConfigurationGroupResponse> configGroupResponses = new ArrayList<ConfigurationGroupResponse>();
70+
for (ConfigurationGroup cfgGroup : result.first()) {
71+
ConfigurationGroupResponse cfgGroupResponse = _responseGenerator.createConfigurationGroupResponse(cfgGroup);
72+
cfgGroupResponse.setObjectName("configurationgroup");
73+
configGroupResponses.add(cfgGroupResponse);
74+
}
75+
76+
response.setResponses(configGroupResponses, result.second());
77+
response.setResponseName(getCommandName());
78+
setResponseObject(response);
79+
}
80+
}

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", since = "4.17.0")
97+
private String groupName;
98+
99+
@Parameter(name = ApiConstants.SUBGROUP, type = CommandType.STRING, description = "lists configuration by subgroup name", since = "4.17.0")
100+
private String subGroupName;
101+
102+
@Parameter(name = ApiConstants.PARENT, type = CommandType.STRING, description = "lists configuration by parent name", since = "4.17.0")
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+
validateParameters();
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 validateParameters() {
227+
if (StringUtils.isNotEmpty(getSubGroupName()) && StringUtils.isEmpty(getGroupName())) {
228+
throw new ServerApiException(ApiErrorCode.PARAM_ERROR, "Configuration 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
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.api.response;
18+
19+
import java.util.List;
20+
21+
import com.google.gson.annotations.SerializedName;
22+
23+
import org.apache.cloudstack.api.ApiConstants;
24+
import org.apache.cloudstack.api.BaseResponse;
25+
26+
import com.cloud.serializer.Param;
27+
28+
public class ConfigurationGroupResponse extends BaseResponse {
29+
@SerializedName(ApiConstants.NAME)
30+
@Param(description = "the name of the configuration group")
31+
private String groupName;
32+
33+
@SerializedName(ApiConstants.SUBGROUP)
34+
@Param(description = "the subgroups of the configuration group", responseObject = ConfigurationSubGroupResponse.class)
35+
private List<ConfigurationSubGroupResponse> subGroups;
36+
37+
@SerializedName(ApiConstants.DESCRIPTION)
38+
@Param(description = "the description of the configuration group")
39+
private String description;
40+
41+
@SerializedName(ApiConstants.PRECEDENCE)
42+
@Param(description = "the precedence of the configuration group")
43+
private Long precedence;
44+
45+
public String getGroupName() {
46+
return groupName;
47+
}
48+
49+
public void setGroupName(String groupName) {
50+
this.groupName = groupName;
51+
}
52+
53+
public List<ConfigurationSubGroupResponse> getSubGroups() {
54+
return subGroups;
55+
}
56+
57+
public void setSubGroups(List<ConfigurationSubGroupResponse> subGroups) {
58+
this.subGroups = subGroups;
59+
}
60+
61+
public String getDescription() {
62+
return description;
63+
}
64+
65+
public void setDescription(String description) {
66+
this.description = description;
67+
}
68+
69+
public Long getPrecedence() {
70+
return precedence;
71+
}
72+
73+
public void setPrecedence(Long precedence) {
74+
this.precedence = precedence;
75+
}
76+
}

0 commit comments

Comments
 (0)