mirror of
https://github.com/apache/cloudstack.git
synced 2025-11-02 20:02:29 +01:00
Disk offering response: added vsphere storage policy to response if exists
This commit is contained in:
parent
a54436b790
commit
1e4e5cf4c0
@ -151,6 +151,10 @@ public class DiskOfferingResponse extends BaseResponse {
|
||||
@Param(description = "whether to display the offering to the end user or not.")
|
||||
private Boolean displayOffering;
|
||||
|
||||
@SerializedName("vspherestoragepolicy")
|
||||
@Param(description = "the vsphere storage policy tagged to the disk offering in case of VMware", since = "4.15")
|
||||
private String vsphereStoragePolicy;
|
||||
|
||||
public Boolean getDisplayOffering() {
|
||||
return displayOffering;
|
||||
}
|
||||
@ -351,4 +355,12 @@ public class DiskOfferingResponse extends BaseResponse {
|
||||
public void setIopsWriteRateMaxLength(Long iopsWriteRateMaxLength) {
|
||||
this.iopsWriteRateMaxLength = iopsWriteRateMaxLength;
|
||||
}
|
||||
|
||||
public String getVsphereStoragePolicy() {
|
||||
return vsphereStoragePolicy;
|
||||
}
|
||||
|
||||
public void setVsphereStoragePolicy(String vsphereStoragePolicy) {
|
||||
this.vsphereStoragePolicy = vsphereStoragePolicy;
|
||||
}
|
||||
}
|
||||
|
||||
@ -459,6 +459,69 @@ CREATE VIEW `cloud`.`service_offering_view` AS
|
||||
GROUP BY
|
||||
`service_offering`.`id`;
|
||||
|
||||
DROP VIEW IF EXISTS `cloud`.`disk_offering_view`;
|
||||
CREATE VIEW `cloud`.`disk_offering_view` AS
|
||||
SELECT
|
||||
`disk_offering`.`id` AS `id`,
|
||||
`disk_offering`.`uuid` AS `uuid`,
|
||||
`disk_offering`.`name` AS `name`,
|
||||
`disk_offering`.`display_text` AS `display_text`,
|
||||
`disk_offering`.`provisioning_type` AS `provisioning_type`,
|
||||
`disk_offering`.`disk_size` AS `disk_size`,
|
||||
`disk_offering`.`min_iops` AS `min_iops`,
|
||||
`disk_offering`.`max_iops` AS `max_iops`,
|
||||
`disk_offering`.`created` AS `created`,
|
||||
`disk_offering`.`tags` AS `tags`,
|
||||
`disk_offering`.`customized` AS `customized`,
|
||||
`disk_offering`.`customized_iops` AS `customized_iops`,
|
||||
`disk_offering`.`removed` AS `removed`,
|
||||
`disk_offering`.`use_local_storage` AS `use_local_storage`,
|
||||
`disk_offering`.`system_use` AS `system_use`,
|
||||
`disk_offering`.`hv_ss_reserve` AS `hv_ss_reserve`,
|
||||
`disk_offering`.`bytes_read_rate` AS `bytes_read_rate`,
|
||||
`disk_offering`.`bytes_read_rate_max` AS `bytes_read_rate_max`,
|
||||
`disk_offering`.`bytes_read_rate_max_length` AS `bytes_read_rate_max_length`,
|
||||
`disk_offering`.`bytes_write_rate` AS `bytes_write_rate`,
|
||||
`disk_offering`.`bytes_write_rate_max` AS `bytes_write_rate_max`,
|
||||
`disk_offering`.`bytes_write_rate_max_length` AS `bytes_write_rate_max_length`,
|
||||
`disk_offering`.`iops_read_rate` AS `iops_read_rate`,
|
||||
`disk_offering`.`iops_read_rate_max` AS `iops_read_rate_max`,
|
||||
`disk_offering`.`iops_read_rate_max_length` AS `iops_read_rate_max_length`,
|
||||
`disk_offering`.`iops_write_rate` AS `iops_write_rate`,
|
||||
`disk_offering`.`iops_write_rate_max` AS `iops_write_rate_max`,
|
||||
`disk_offering`.`iops_write_rate_max_length` AS `iops_write_rate_max_length`,
|
||||
`disk_offering`.`cache_mode` AS `cache_mode`,
|
||||
`disk_offering`.`sort_key` AS `sort_key`,
|
||||
`disk_offering`.`type` AS `type`,
|
||||
`disk_offering`.`display_offering` AS `display_offering`,
|
||||
`disk_offering`.`state` AS `state`,
|
||||
`vsphere_storage_policy`.`value` AS `vsphere_storage_policy`,
|
||||
GROUP_CONCAT(DISTINCT(domain.id)) AS domain_id,
|
||||
GROUP_CONCAT(DISTINCT(domain.uuid)) AS domain_uuid,
|
||||
GROUP_CONCAT(DISTINCT(domain.name)) AS domain_name,
|
||||
GROUP_CONCAT(DISTINCT(domain.path)) AS domain_path,
|
||||
GROUP_CONCAT(DISTINCT(zone.id)) AS zone_id,
|
||||
GROUP_CONCAT(DISTINCT(zone.uuid)) AS zone_uuid,
|
||||
GROUP_CONCAT(DISTINCT(zone.name)) AS zone_name
|
||||
FROM
|
||||
`cloud`.`disk_offering`
|
||||
LEFT JOIN
|
||||
`cloud`.`disk_offering_details` AS `domain_details` ON `domain_details`.`offering_id` = `disk_offering`.`id` AND `domain_details`.`name`='domainid'
|
||||
LEFT JOIN
|
||||
`cloud`.`domain` AS `domain` ON FIND_IN_SET(`domain`.`id`, `domain_details`.`value`)
|
||||
LEFT JOIN
|
||||
`cloud`.`disk_offering_details` AS `zone_details` ON `zone_details`.`offering_id` = `disk_offering`.`id` AND `zone_details`.`name`='zoneid'
|
||||
LEFT JOIN
|
||||
`cloud`.`data_center` AS `zone` ON FIND_IN_SET(`zone`.`id`, `zone_details`.`value`)
|
||||
LEFT JOIN
|
||||
`cloud`.`disk_offering_details` AS `vsphere_storage_policy` ON `vsphere_storage_policy`.`offering_id` = `disk_offering`.`id`
|
||||
AND `vsphere_storage_policy`.`name` = 'storagepolicy'
|
||||
|
||||
WHERE
|
||||
`disk_offering`.`state`='Active'
|
||||
GROUP BY
|
||||
`disk_offering`.`id`;
|
||||
|
||||
ALTER TABLE `cloud`.`template_spool_ref`
|
||||
DROP FOREIGN KEY `fk_template_spool_ref__template_id`;
|
||||
|
||||
|
||||
@ -17,7 +17,13 @@
|
||||
package com.cloud.api.query.dao;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.api.ApiDBUtils;
|
||||
import com.cloud.dc.VsphereStoragePolicyVO;
|
||||
import com.cloud.dc.dao.VsphereStoragePolicyDao;
|
||||
import com.cloud.server.ResourceTag;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.stereotype.Component;
|
||||
@ -30,10 +36,15 @@ import com.cloud.utils.db.GenericDaoBase;
|
||||
import com.cloud.utils.db.SearchBuilder;
|
||||
import com.cloud.utils.db.SearchCriteria;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Component
|
||||
public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO, Long> implements DiskOfferingJoinDao {
|
||||
public static final Logger s_logger = Logger.getLogger(DiskOfferingJoinDaoImpl.class);
|
||||
|
||||
@Inject
|
||||
VsphereStoragePolicyDao _vsphereStoragePolicyDao;
|
||||
|
||||
private final SearchBuilder<DiskOfferingJoinVO> dofIdSearch;
|
||||
private final Attribute _typeAttr;
|
||||
|
||||
@ -108,6 +119,15 @@ public class DiskOfferingJoinDaoImpl extends GenericDaoBase<DiskOfferingJoinVO,
|
||||
diskOfferingResponse.setIopsWriteRateMaxLength(offering.getIopsWriteRateMaxLength());
|
||||
diskOfferingResponse.setCacheMode(offering.getCacheMode());
|
||||
diskOfferingResponse.setObjectName("diskoffering");
|
||||
Map<String, String> offeringDetails = ApiDBUtils.getResourceDetails(offering.getId(), ResourceTag.ResourceObjectType.DiskOffering);
|
||||
if (offeringDetails != null && !offeringDetails.isEmpty()) {
|
||||
String vsphereStoragePolicyId = offeringDetails.get(ApiConstants.STORAGE_POLICY);
|
||||
if (vsphereStoragePolicyId != null) {
|
||||
VsphereStoragePolicyVO vsphereStoragePolicyVO = _vsphereStoragePolicyDao.findById(Long.parseLong(vsphereStoragePolicyId));
|
||||
if (vsphereStoragePolicyVO != null)
|
||||
diskOfferingResponse.setVsphereStoragePolicy(vsphereStoragePolicyVO.getName());
|
||||
}
|
||||
}
|
||||
|
||||
return diskOfferingResponse;
|
||||
}
|
||||
|
||||
@ -159,6 +159,9 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
|
||||
@Column(name = "state")
|
||||
DiskOffering.State state;
|
||||
|
||||
@Column(name = "vsphere_storage_policy")
|
||||
String vsphereStoragePolicy;
|
||||
|
||||
public DiskOfferingJoinVO() {
|
||||
}
|
||||
|
||||
@ -343,4 +346,8 @@ public class DiskOfferingJoinVO extends BaseViewVO implements InternalIdentity,
|
||||
public void setState(DiskOffering.State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public String getVsphereStoragePolicy() {
|
||||
return vsphereStoragePolicy;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user