mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Added Storagepolicy while creating diskoffering. CreateDiskOffering API now takes storagepolicy as a parameter with UUID value
This commit is contained in:
parent
fb0a96e7fb
commit
487bb03c4d
@ -28,6 +28,7 @@ import org.apache.cloudstack.api.Parameter;
|
||||
import org.apache.cloudstack.api.ServerApiException;
|
||||
import org.apache.cloudstack.api.response.DiskOfferingResponse;
|
||||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ImportVsphereStoragePoliciesResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
@ -151,6 +152,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||
since = "4.14")
|
||||
private String cacheMode;
|
||||
|
||||
@Parameter(name = ApiConstants.STORAGE_POLICY, type = CommandType.UUID, entityType = ImportVsphereStoragePoliciesResponse.class,required = false, description = "Name of the storage policy defined at vCenter, this is applicable only for VMware")
|
||||
private Long storagePolicy;
|
||||
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////////// Accessors ///////////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
@ -273,6 +277,9 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
||||
return cacheMode;
|
||||
}
|
||||
|
||||
public Long getStoragePolicy() {
|
||||
return storagePolicy;
|
||||
}
|
||||
/////////////////////////////////////////////////////
|
||||
/////////////// API Implementation///////////////////
|
||||
/////////////////////////////////////////////////////
|
||||
|
||||
@ -39,7 +39,7 @@ import java.util.UUID;
|
||||
import javax.inject.Inject;
|
||||
import javax.naming.ConfigurationException;
|
||||
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.dc.dao.VsphereStoragePolicyDao;
|
||||
import org.apache.cloudstack.acl.SecurityChecker;
|
||||
import org.apache.cloudstack.affinity.AffinityGroup;
|
||||
import org.apache.cloudstack.affinity.AffinityGroupService;
|
||||
@ -223,6 +223,7 @@ import com.cloud.user.dao.AccountDao;
|
||||
import com.cloud.user.dao.UserDao;
|
||||
import com.cloud.utils.NumbersUtil;
|
||||
import com.cloud.utils.Pair;
|
||||
import com.cloud.utils.StringUtils;
|
||||
import com.cloud.utils.UriUtils;
|
||||
import com.cloud.utils.component.ManagerBase;
|
||||
import com.cloud.utils.db.DB;
|
||||
@ -387,6 +388,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
IndirectAgentLB _indirectAgentLB;
|
||||
@Inject
|
||||
private VMTemplateZoneDao templateZoneDao;
|
||||
@Inject
|
||||
VsphereStoragePolicyDao vsphereStoragePolicyDao;
|
||||
|
||||
|
||||
// FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao?
|
||||
@Inject
|
||||
@ -2827,7 +2831,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
Long bytesWriteRate, Long bytesWriteRateMax, Long bytesWriteRateMaxLength,
|
||||
Long iopsReadRate, Long iopsReadRateMax, Long iopsReadRateMaxLength,
|
||||
Long iopsWriteRate, Long iopsWriteRateMax, Long iopsWriteRateMaxLength,
|
||||
final Integer hypervisorSnapshotReserve, String cacheMode) {
|
||||
final Integer hypervisorSnapshotReserve, String cacheMode, final Long storagePolicyID) {
|
||||
long diskSize = 0;// special case for custom disk offerings
|
||||
if (numGibibytes != null && numGibibytes <= 0) {
|
||||
throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb.");
|
||||
@ -2955,6 +2959,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), ApiConstants.ZONE_ID, String.valueOf(zoneId), false));
|
||||
}
|
||||
}
|
||||
if (storagePolicyID != null) {
|
||||
detailsVO.add(new DiskOfferingDetailVO(offering.getId(), ApiConstants.STORAGE_POLICY, String.valueOf(storagePolicyID), false));
|
||||
}
|
||||
if (!detailsVO.isEmpty()) {
|
||||
diskOfferingDetailsDao.saveDetails(detailsVO);
|
||||
}
|
||||
@ -2976,6 +2983,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
final String tags = cmd.getTags();
|
||||
final List<Long> domainIds = cmd.getDomainIds();
|
||||
final List<Long> zoneIds = cmd.getZoneIds();
|
||||
final Long storagePolicyId = cmd.getStoragePolicy();
|
||||
|
||||
// check if valid domain
|
||||
if (CollectionUtils.isNotEmpty(domainIds)) {
|
||||
@ -3015,6 +3023,12 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
}
|
||||
}
|
||||
|
||||
if (storagePolicyId != null) {
|
||||
if (vsphereStoragePolicyDao.findById(storagePolicyId) == null) {
|
||||
throw new InvalidParameterValueException("Please specify a valid vSphere storage policy id");
|
||||
}
|
||||
}
|
||||
|
||||
final Boolean isCustomizedIops = cmd.isCustomizedIops();
|
||||
final Long minIops = cmd.getMinIops();
|
||||
final Long maxIops = cmd.getMaxIops();
|
||||
@ -3045,7 +3059,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati
|
||||
localStorageRequired, isDisplayOfferingEnabled, isCustomizedIops, minIops,
|
||||
maxIops, bytesReadRate, bytesReadRateMax, bytesReadRateMaxLength, bytesWriteRate, bytesWriteRateMax, bytesWriteRateMaxLength,
|
||||
iopsReadRate, iopsReadRateMax, iopsReadRateMaxLength, iopsWriteRate, iopsWriteRateMax, iopsWriteRateMaxLength,
|
||||
hypervisorSnapshotReserve, cacheMode);
|
||||
hypervisorSnapshotReserve, cacheMode, storagePolicyId);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user