Skip to content

Commit 1c130a5

Browse files
Pearl1594yadvr
andauthored
api: metrics API response is not super-set of resources response keys (#3834)
The metrics API has few properties missing that are present in the corresponding resource. Fixes #3831 Signed-off-by: Rohit Yadav <rohit.yadav@shapeblue.com> Co-authored-by: Rohit Yadav <rohit@apache.org>
1 parent 521217c commit 1c130a5

6 files changed

Lines changed: 46 additions & 37 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@
2121
import java.util.List;
2222
import java.util.Map;
2323

24-
import com.google.gson.annotations.SerializedName;
25-
2624
import org.apache.cloudstack.api.ApiConstants;
2725
import org.apache.cloudstack.api.BaseResponse;
2826
import org.apache.cloudstack.api.EntityReference;
2927

3028
import com.cloud.org.Cluster;
3129
import com.cloud.serializer.Param;
30+
import com.google.gson.annotations.SerializedName;
3231

3332
@EntityReference(value = Cluster.class)
3433
public class ClusterResponse extends BaseResponse {
@@ -216,4 +215,8 @@ public void setResourceDetails(Map<String, String> details) {
216215
resourceDetails.remove("password");
217216
}
218217
}
218+
219+
public Map<String, String> getResourceDetails() {
220+
return resourceDetails;
221+
}
219222
}

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

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,22 @@
1616
// under the License.
1717
package org.apache.cloudstack.api.response;
1818

19-
import com.cloud.host.Host;
20-
import com.cloud.host.Status;
21-
import com.cloud.hypervisor.Hypervisor.HypervisorType;
22-
import com.cloud.serializer.Param;
23-
import com.google.gson.annotations.SerializedName;
19+
import java.util.Date;
20+
import java.util.HashMap;
21+
import java.util.List;
22+
import java.util.Map;
23+
2424
import org.apache.cloudstack.api.ApiConstants;
2525
import org.apache.cloudstack.api.BaseResponse;
2626
import org.apache.cloudstack.api.EntityReference;
2727
import org.apache.cloudstack.ha.HAConfig;
2828
import org.apache.cloudstack.outofbandmanagement.OutOfBandManagement;
2929

30-
import java.util.Date;
31-
import java.util.HashMap;
32-
import java.util.List;
33-
import java.util.Map;
30+
import com.cloud.host.Host;
31+
import com.cloud.host.Status;
32+
import com.cloud.hypervisor.Hypervisor.HypervisorType;
33+
import com.cloud.serializer.Param;
34+
import com.google.gson.annotations.SerializedName;
3435

3536
@EntityReference(value = Host.class)
3637
public class HostResponse extends BaseResponse {
@@ -243,11 +244,6 @@ public class HostResponse extends BaseResponse {
243244
@Param(description = "the admin that annotated this host", since = "4.11")
244245
private String username;
245246

246-
// Default visibility to support accessing the details from unit tests
247-
Map getDetails() {
248-
return details;
249-
}
250-
251247
@Override
252248
public String getObjectId() {
253249
return this.getId();
@@ -361,7 +357,7 @@ public void setMemoryUsed(Long memoryUsed) {
361357
this.memoryUsed = memoryUsed;
362358
}
363359

364-
public void setGpuGroups(List<GpuResponse> gpuGroup) {
360+
public void setGpuGroup(List<GpuResponse> gpuGroup) {
365361
this.gpuGroup = gpuGroup;
366362
}
367363

@@ -437,6 +433,10 @@ public void setHostHAResponse(final HAConfig config) {
437433
this.hostHAResponse = new HostHAResponse(config);
438434
}
439435

436+
public void setHostHAResponse(HostHAResponse hostHAResponse) {
437+
this.hostHAResponse = hostHAResponse;
438+
}
439+
440440
public OutOfBandManagementResponse getOutOfBandManagementResponse() {
441441
return outOfBandManagementResponse;
442442
}
@@ -445,6 +445,10 @@ public void setOutOfBandManagementResponse(final OutOfBandManagement outOfBandMa
445445
this.outOfBandManagementResponse = new OutOfBandManagementResponse(outOfBandManagementConfig);
446446
}
447447

448+
public void setOutOfBandManagementResponse(OutOfBandManagementResponse outOfBandManagementResponse) {
449+
this.outOfBandManagementResponse = outOfBandManagementResponse;
450+
}
451+
448452
public String getResourceState() {
449453
return resourceState;
450454
}
@@ -496,7 +500,10 @@ public void setDetails(Map details) {
496500
detailsCopy.remove("password");
497501

498502
this.details = detailsCopy;
503+
}
499504

505+
public Map getDetails() {
506+
return details;
500507
}
501508

502509
public void setMemoryTotal(Long memoryTotal) {

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

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -262,19 +262,19 @@ public class VolumeResponse extends BaseResponseWithTagInformation implements Co
262262

263263
@SerializedName(ApiConstants.CLUSTER_ID)
264264
@Param(description = "cluster id of the volume")
265-
private String clusterid;
265+
private String clusterId;
266266

267267
@SerializedName(ApiConstants.CLUSTER_NAME)
268268
@Param(description = "cluster name where the volume is allocated")
269-
private String clustername;
269+
private String clusterName;
270270

271271
@SerializedName(ApiConstants.POD_ID)
272272
@Param(description = "pod id of the volume")
273-
private String podid;
273+
private String podId;
274274

275275
@SerializedName(ApiConstants.POD_NAME)
276276
@Param(description = "pod name of the volume")
277-
private String podname;
277+
private String podName;
278278

279279
public String getPath() {
280280
return path;
@@ -751,35 +751,34 @@ public void setUtilization(String utilization) {
751751
}
752752

753753
public String getClusterId() {
754-
return clusterid;
754+
return clusterId;
755755
}
756756

757-
public void setClusterId(String clusterid) {
758-
this.clusterid = clusterid;
757+
public void setClusterId(String clusterId) {
758+
this.clusterId = clusterId;
759759
}
760760

761761
public String getClusterName() {
762-
return clustername;
762+
return clusterName;
763763
}
764764

765-
public void setClusterName(String clustername) {
766-
this.clustername = clustername;
765+
public void setClusterName(String clusterName) {
766+
this.clusterName = clusterName;
767767
}
768768

769769
public String getPodId() {
770-
return podid;
770+
return podId;
771771
}
772772

773-
public void setPodId(String podid) {
774-
this.podid = podid;
773+
public void setPodId(String podId) {
774+
this.podId = podId;
775775
}
776776

777777
public String getPodName() {
778-
return podname;
778+
return podName;
779779
}
780780

781-
public void setPodName(String podname) {
782-
this.podname = podname;
781+
public void setPodName(String podName) {
782+
this.podName = podName;
783783
}
784-
785784
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ public void setDomainId(String domainId) {
173173
this.domainId = domainId;
174174
}
175175

176-
public void setType(String networkType) {
176+
public void setNetworkType(String networkType) {
177177
this.networkType = networkType;
178178
}
179179

server/src/main/java/com/cloud/api/query/dao/DataCenterJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public ZoneResponse newDataCenterResponse(ResponseView view, DataCenterJoinVO da
9090
zoneResponse.setDomainId(dataCenter.getDomainUuid());
9191
zoneResponse.setDomainName(dataCenter.getDomainName());
9292

93-
zoneResponse.setType(dataCenter.getNetworkType().toString());
93+
zoneResponse.setNetworkType(dataCenter.getNetworkType().toString());
9494
zoneResponse.setAllocationState(dataCenter.getAllocationState().toString());
9595
zoneResponse.setZoneToken(dataCenter.getZoneToken());
9696
zoneResponse.setDhcpProvider(dataCenter.getDhcpProvider());

server/src/main/java/com/cloud/api/query/dao/HostJoinDaoImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ public HostResponse newHostResponse(HostJoinVO host, EnumSet<HostDetails> detail
138138
}
139139
gpus.add(gpuResponse);
140140
}
141-
hostResponse.setGpuGroups(gpus);
141+
hostResponse.setGpuGroup(gpus);
142142
}
143143
if (details.contains(HostDetails.all) || details.contains(HostDetails.capacity) || details.contains(HostDetails.stats) || details.contains(HostDetails.events)) {
144144

0 commit comments

Comments
 (0)