Skip to content

Commit c8fad18

Browse files
Issue-522: Added ListStorageAccessGroups API and storageaccessgroup parameter in list APIs (FR79 Issue) (apache#524)
This adds listStorageAccessGroups API and storageaccessgroup parameter in list hosts/pods/clusters/zones/storagepools APIs This PR addresses apache#522
1 parent 2b63e6a commit c8fad18

Some content is hidden

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

41 files changed

+974
-29
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,7 @@ public class ApiConstants {
435435
public static final String TAGS = "tags";
436436
public static final String STORAGE_TAGS = "storagetags";
437437
public static final String STORAGE_ACCESS_GROUPS = "storageaccessgroups";
438+
public static final String STORAGE_ACCESS_GROUP = "storageaccessgroup";
438439
public static final String TARGET_IQN = "targetiqn";
439440
public static final String TEMPLATE_FILTER = "templatefilter";
440441
public static final String TEMPLATE_ID = "templateid";

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ public interface ResponseGenerator {
290290

291291
PodResponse createPodResponse(Pod pod, Boolean showCapacities);
292292

293+
PodResponse createMinimalPodResponse(Pod pod);
294+
293295
ZoneResponse createZoneResponse(ResponseView view, DataCenter dataCenter, Boolean showCapacities, Boolean showResourceIcon);
294296

295297
DataCenterGuestIpv6PrefixResponse createDataCenterGuestIpv6PrefixResponse(DataCenterGuestIpv6Prefix prefix);
@@ -304,6 +306,8 @@ public interface ResponseGenerator {
304306

305307
ClusterResponse createClusterResponse(Cluster cluster, Boolean showCapacities);
306308

309+
ClusterResponse createMinimalClusterResponse(Cluster cluster);
310+
307311
FirewallRuleResponse createPortForwardingRuleResponse(PortForwardingRule fwRule);
308312

309313
IpForwardingRuleResponse createIpForwardingRuleResponse(StaticNatRule fwRule);

api/src/main/java/org/apache/cloudstack/api/command/admin/cluster/ListClustersCmd.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ public class ListClustersCmd extends BaseListCmd {
7070
@Parameter(name = ApiConstants.SHOW_CAPACITIES, type = CommandType.BOOLEAN, description = "flag to display the capacity of the clusters")
7171
private Boolean showCapacities;
7272

73+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING, description = "the name of the storage access group")
74+
private String storageAccessGroup;
75+
7376
/////////////////////////////////////////////////////
7477
/////////////////// Accessors ///////////////////////
7578
/////////////////////////////////////////////////////
@@ -114,6 +117,18 @@ public Boolean getShowCapacities() {
114117
return showCapacities;
115118
}
116119

120+
public String getStorageAccessGroup() {
121+
return storageAccessGroup;
122+
}
123+
124+
public ListClustersCmd() {
125+
126+
}
127+
128+
public ListClustersCmd(String storageAccessGroup) {
129+
this.storageAccessGroup = storageAccessGroup;
130+
}
131+
117132
/////////////////////////////////////////////////////
118133
/////////////// API Implementation///////////////////
119134
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/host/ListHostsCmd.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ public class ListHostsCmd extends BaseListCmd {
111111
@Parameter(name = ApiConstants.MANAGEMENT_SERVER_ID, type = CommandType.UUID, entityType = ManagementServerResponse.class, description = "the id of the management server", since="4.18.1")
112112
private Long managementServerId;
113113

114+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING, description = "the name of the storage access group")
115+
private String storageAccessGroup;
116+
114117
/////////////////////////////////////////////////////
115118
/////////////////// Accessors ///////////////////////
116119
/////////////////////////////////////////////////////
@@ -194,6 +197,18 @@ public Long getManagementServerId() {
194197
return managementServerId;
195198
}
196199

200+
public String getStorageAccessGroup() {
201+
return storageAccessGroup;
202+
}
203+
204+
public ListHostsCmd() {
205+
206+
}
207+
208+
public ListHostsCmd(String storageAccessGroup) {
209+
this.storageAccessGroup = storageAccessGroup;
210+
}
211+
197212
/////////////////////////////////////////////////////
198213
/////////////// API Implementation///////////////////
199214
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/admin/pod/ListPodsByCmd.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ public class ListPodsByCmd extends BaseListCmd {
5757
@Parameter(name = ApiConstants.SHOW_CAPACITIES, type = CommandType.BOOLEAN, description = "flag to display the capacity of the pods")
5858
private Boolean showCapacities;
5959

60+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING, description = "the name of the storage access group")
61+
private String storageAccessGroup;
62+
6063
/////////////////////////////////////////////////////
6164
/////////////////// Accessors ///////////////////////
6265
/////////////////////////////////////////////////////
@@ -81,6 +84,18 @@ public Boolean getShowCapacities() {
8184
return showCapacities;
8285
}
8386

87+
public String getStorageAccessGroup() {
88+
return storageAccessGroup;
89+
}
90+
91+
public ListPodsByCmd() {
92+
93+
}
94+
95+
public ListPodsByCmd(String storageAccessGroup) {
96+
this.storageAccessGroup = storageAccessGroup;
97+
}
98+
8499
/////////////////////////////////////////////////////
85100
/////////////// API Implementation///////////////////
86101
/////////////////////////////////////////////////////
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.apache.cloudstack.api.command.admin.storage;
20+
21+
import org.apache.cloudstack.api.ApiConstants;
22+
import org.apache.cloudstack.api.BaseCmd;
23+
import org.apache.cloudstack.api.Parameter;
24+
import org.apache.cloudstack.api.response.StorageAccessGroupResponse;
25+
import org.apache.log4j.Logger;
26+
import org.apache.cloudstack.api.APICommand;
27+
import org.apache.cloudstack.api.ApiCommandResourceType;
28+
import org.apache.cloudstack.api.BaseListCmd;
29+
import org.apache.cloudstack.api.response.ListResponse;
30+
31+
@APICommand(name = "listStorageAccessGroups", description = "Lists storage access groups", responseObject = StorageAccessGroupResponse.class, since = "4.18.1", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false)
32+
public class ListStorageAccessGroupsCmd extends BaseListCmd {
33+
public static final Logger s_logger = Logger.getLogger(ListStorageAccessGroupsCmd.class.getName());
34+
35+
// ///////////////////////////////////////////////////
36+
// ////////////// API parameters /////////////////////
37+
// ///////////////////////////////////////////////////
38+
39+
@Parameter(name = ApiConstants.NAME, type = BaseCmd.CommandType.STRING, description = "Name of the Storage access group")
40+
private String name;
41+
42+
// ///////////////////////////////////////////////////
43+
// ///////////////// Accessors ///////////////////////
44+
// ///////////////////////////////////////////////////
45+
46+
public String getName() {
47+
return name;
48+
}
49+
50+
// ///////////////////////////////////////////////////
51+
// ///////////// API Implementation///////////////////
52+
// ///////////////////////////////////////////////////
53+
54+
@Override
55+
public ApiCommandResourceType getApiResourceType() {
56+
return ApiCommandResourceType.StoragePool;
57+
}
58+
59+
@Override
60+
public void execute() {
61+
ListResponse<StorageAccessGroupResponse> response = _queryService.searchForStorageAccessGroups(this);
62+
63+
response.setResponseName(getCommandName());
64+
65+
setResponseObject(response);
66+
}
67+
}

api/src/main/java/org/apache/cloudstack/api/command/admin/storage/ListStoragePoolsCmd.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public class ListStoragePoolsCmd extends BaseListCmd {
7575

7676
@Parameter(name = ApiConstants.STORAGE_CUSTOM_STATS, type = CommandType.BOOLEAN, description = "If true, lists the custom stats of the storage pool", since = "4.18.1")
7777
private Boolean customStats;
78+
79+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING, description = "the name of the storage access group")
80+
private String storageAccessGroup;
81+
7882
/////////////////////////////////////////////////////
7983
/////////////////// Accessors ///////////////////////
8084
/////////////////////////////////////////////////////
@@ -122,6 +126,19 @@ public void setId(Long id) {
122126
public Boolean getCustomStats() {
123127
return customStats != null && customStats;
124128
}
129+
130+
public String getStorageAccessGroup() {
131+
return storageAccessGroup;
132+
}
133+
134+
public ListStoragePoolsCmd() {
135+
136+
}
137+
138+
public ListStoragePoolsCmd(String storageAccessGroup) {
139+
this.storageAccessGroup = storageAccessGroup;
140+
}
141+
125142
/////////////////////////////////////////////////////
126143
/////////////// API Implementation///////////////////
127144
/////////////////////////////////////////////////////

api/src/main/java/org/apache/cloudstack/api/command/user/zone/ListZonesCmd.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ public class ListZonesCmd extends BaseListCmd implements UserCmd {
6868
@Parameter(name = ApiConstants.SHOW_RESOURCE_ICON, type = CommandType.BOOLEAN, description = "flag to display the resource image for the zones")
6969
private Boolean showIcon;
7070

71+
@Parameter(name = ApiConstants.STORAGE_ACCESS_GROUP, type = CommandType.STRING, description = "the name of the storage access group")
72+
private String storageAccessGroup;
73+
7174
/////////////////////////////////////////////////////
7275
/////////////////// Accessors ///////////////////////
7376
/////////////////////////////////////////////////////
@@ -104,6 +107,18 @@ public Boolean getShowIcon () {
104107
return showIcon != null ? showIcon : false;
105108
}
106109

110+
public String getStorageAccessGroup() {
111+
return storageAccessGroup;
112+
}
113+
114+
public ListZonesCmd() {
115+
116+
}
117+
118+
public ListZonesCmd(String storageAccessGroup) {
119+
this.storageAccessGroup = storageAccessGroup;
120+
}
121+
107122
/////////////////////////////////////////////////////
108123
/////////////// API Implementation///////////////////
109124
/////////////////////////////////////////////////////

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ public class HostResponse extends BaseResponseWithAnnotations {
151151
@Deprecated
152152
@SerializedName("memoryallocated")
153153
@Param(description = "the amount of the host's memory currently allocated")
154-
private long memoryAllocated;
154+
private Long memoryAllocated;
155155

156156
@SerializedName("memoryallocatedpercentage")
157157
@Param(description = "the amount of the host's memory currently allocated in percentage")
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
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 com.google.gson.annotations.SerializedName;
20+
import org.apache.cloudstack.api.ApiConstants;
21+
import org.apache.cloudstack.api.BaseResponse;
22+
import com.cloud.serializer.Param;
23+
24+
public class StorageAccessGroupResponse extends BaseResponse {
25+
@SerializedName(ApiConstants.ID)
26+
@Param(description = "the ID of the storage access group")
27+
private String id;
28+
29+
@SerializedName(ApiConstants.NAME)
30+
@Param(description = "the name of the storage access group")
31+
private String name;
32+
33+
@SerializedName("hosts")
34+
@Param(description = "List of Hosts in the Storage Access Group")
35+
private ListResponse<HostResponse> hostResponseList;
36+
37+
@SerializedName("clusters")
38+
@Param(description = "List of Clusters in the Storage Access Group")
39+
private ListResponse<ClusterResponse> clusterResponseList;
40+
41+
@SerializedName("pods")
42+
@Param(description = "List of Pods in the Storage Access Group")
43+
private ListResponse<PodResponse> podResponseList;
44+
45+
@SerializedName("zones")
46+
@Param(description = "List of Zones in the Storage Access Group")
47+
private ListResponse<ZoneResponse> zoneResponseList;
48+
49+
@SerializedName("storagepools")
50+
@Param(description = "List of Storage Pools in the Storage Access Group")
51+
private ListResponse<StoragePoolResponse> storagePoolResponseList;
52+
53+
public String getId() {
54+
return id;
55+
}
56+
57+
public void setId(String id) {
58+
this.id = id;
59+
}
60+
61+
public String getName() {
62+
return name;
63+
}
64+
65+
public void setName(String name) {
66+
this.name = name;
67+
}
68+
69+
public ListResponse<HostResponse> getHostResponseList() {
70+
return hostResponseList;
71+
}
72+
73+
public void setHostResponseList(ListResponse<HostResponse> hostResponseList) {
74+
this.hostResponseList = hostResponseList;
75+
}
76+
77+
public ListResponse<ClusterResponse> getClusterResponseList() {
78+
return clusterResponseList;
79+
}
80+
81+
public void setClusterResponseList(ListResponse<ClusterResponse> clusterResponseList) {
82+
this.clusterResponseList = clusterResponseList;
83+
}
84+
85+
public ListResponse<PodResponse> getPodResponseList() {
86+
return podResponseList;
87+
}
88+
89+
public void setPodResponseList(ListResponse<PodResponse> podResponseList) {
90+
this.podResponseList = podResponseList;
91+
}
92+
93+
public ListResponse<ZoneResponse> getZoneResponseList() {
94+
return zoneResponseList;
95+
}
96+
97+
public void setZoneResponseList(ListResponse<ZoneResponse> zoneResponseList) {
98+
this.zoneResponseList = zoneResponseList;
99+
}
100+
101+
public ListResponse<StoragePoolResponse> getStoragePoolResponseList() {
102+
return storagePoolResponseList;
103+
}
104+
105+
public void setStoragePoolResponseList(ListResponse<StoragePoolResponse> storagePoolResponseList) {
106+
this.storagePoolResponseList = storagePoolResponseList;
107+
}
108+
}

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
9595

9696
@SerializedName("securitygroupsenabled")
9797
@Param(description = "true if security groups support is enabled, false otherwise")
98-
private boolean securityGroupsEnabled;
98+
private Boolean securityGroupsEnabled;
9999

100100
@SerializedName("allocationstate")
101101
@Param(description = "the allocation state of the cluster")
@@ -115,7 +115,7 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
115115

116116
@SerializedName(ApiConstants.LOCAL_STORAGE_ENABLED)
117117
@Param(description = "true if local storage offering enabled, false otherwise")
118-
private boolean localStorageEnabled;
118+
private Boolean localStorageEnabled;
119119

120120
@SerializedName(ApiConstants.TAGS)
121121
@Param(description = "the list of resource tags associated with zone.", responseObject = ResourceTagResponse.class, since = "4.3")
@@ -131,7 +131,7 @@ public class ZoneResponse extends BaseResponseWithAnnotations implements SetReso
131131

132132
@SerializedName(ApiConstants.ALLOW_USER_SPECIFY_VR_MTU)
133133
@Param(description = "Allow end users to specify VR MTU", since = "4.18.0")
134-
private boolean allowUserSpecifyVRMtu;
134+
private Boolean allowUserSpecifyVRMtu;
135135

136136
@SerializedName(ApiConstants.ROUTER_PRIVATE_INTERFACE_MAX_MTU)
137137
@Param(description = "The maximum value the MTU can have on the VR's private interfaces", since = "4.18.0")
@@ -153,6 +153,10 @@ public ZoneResponse() {
153153
tags = new LinkedHashSet<ResourceTagResponse>();
154154
}
155155

156+
public ZoneResponse(Set<ResourceTagResponse> tags) {
157+
this.tags = tags;
158+
}
159+
156160
public void setId(String id) {
157161
this.id = id;
158162
}

0 commit comments

Comments
 (0)