mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Allow for arbitrary disk offering details to be saved/displayed (#6474)
* Allow for arbitrary disk offering details to be saved/displayed Similar to service offering details, allow details to be provided and displayed. Can be used for classification of offerings, etc. Signed-off-by: Marcus Sorensen <mls@apple.com> * Update server/src/main/java/com/cloud/configuration/ConfigurationManagerImpl.java Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com> Co-authored-by: Daniel Augusto Veronezi Salvador <38945620+GutoVeronezi@users.noreply.github.com>
This commit is contained in:
parent
ff7831d751
commit
7b0ebe2e37
@ -17,6 +17,7 @@
|
||||
package org.apache.cloudstack.api.response;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.BaseResponseWithAnnotations;
|
||||
@ -159,6 +160,10 @@ public class DiskOfferingResponse extends BaseResponseWithAnnotations {
|
||||
@Param(description = "To allow or disallow the resize operation on the disks created from this disk offering, if the flag is true then resize is not allowed", since = "4.17")
|
||||
private Boolean diskSizeStrictness;
|
||||
|
||||
@SerializedName(ApiConstants.DETAILS)
|
||||
@Param(description = "additional key/value details tied with this disk offering", since = "4.17")
|
||||
private Map<String, String> details;
|
||||
|
||||
public Boolean getDisplayOffering() {
|
||||
return displayOffering;
|
||||
}
|
||||
@ -375,4 +380,8 @@ public class DiskOfferingResponse extends BaseResponseWithAnnotations {
|
||||
public void setDiskSizeStrictness(Boolean diskSizeStrictness) {
|
||||
this.diskSizeStrictness = diskSizeStrictness;
|
||||
}
|
||||
|
||||
public void setDetails(Map<String, String> details) {
|
||||
this.details = details;
|
||||
}
|
||||
}
|
||||
|
||||
@ -131,6 +131,7 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
||||
diskOfferingResponse.setCacheMode(offering.getCacheMode());
|
||||
diskOfferingResponse.setObjectName("diskoffering");
|
||||
Map<String, String> offeringDetails = ApiDBUtils.getResourceDetails(offering.getId(), ResourceTag.ResourceObjectType.DiskOffering);
|
||||
diskOfferingResponse.setDetails(offeringDetails);
|
||||
if (offeringDetails != null && !offeringDetails.isEmpty()) {
|
||||
String vsphereStoragePolicyId = offeringDetails.get(ApiConstants.STORAGE_POLICY);
|
||||
if (vsphereStoragePolicyId != null) {
|
||||
|
||||
@ -3535,14 +3535,11 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), ApiConstants.ZONE_ID, String.valueOf(zoneId), false));
|
||||
}
|
||||
}
|
||||
if (details != null && !details.isEmpty()) {
|
||||
// Support disk offering details for below parameters
|
||||
if (details.containsKey(Volume.BANDWIDTH_LIMIT_IN_MBPS)) {
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), Volume.BANDWIDTH_LIMIT_IN_MBPS, details.get(Volume.BANDWIDTH_LIMIT_IN_MBPS), false));
|
||||
}
|
||||
if (details.containsKey(Volume.IOPS_LIMIT)) {
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), Volume.IOPS_LIMIT, details.get(Volume.IOPS_LIMIT), false));
|
||||
}
|
||||
if (MapUtils.isNotEmpty(details)) {
|
||||
details.forEach((key, value) -> {
|
||||
boolean displayDetail = !StringUtils.equalsAny(key, Volume.BANDWIDTH_LIMIT_IN_MBPS, Volume.IOPS_LIMIT);
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), key, value, displayDetail));
|
||||
});
|
||||
}
|
||||
if (storagePolicyID != null) {
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), ApiConstants.STORAGE_POLICY, String.valueOf(storagePolicyID), false));
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user