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.ServerApiException; | ||||||
| import org.apache.cloudstack.api.response.DiskOfferingResponse; | import org.apache.cloudstack.api.response.DiskOfferingResponse; | ||||||
| import org.apache.cloudstack.api.response.DomainResponse; | import org.apache.cloudstack.api.response.DomainResponse; | ||||||
|  | import org.apache.cloudstack.api.response.ImportVsphereStoragePoliciesResponse; | ||||||
| import org.apache.cloudstack.api.response.ZoneResponse; | import org.apache.cloudstack.api.response.ZoneResponse; | ||||||
| import org.apache.commons.collections.CollectionUtils; | import org.apache.commons.collections.CollectionUtils; | ||||||
| import org.apache.log4j.Logger; | import org.apache.log4j.Logger; | ||||||
| @ -151,6 +152,9 @@ public class CreateDiskOfferingCmd extends BaseCmd { | |||||||
|             since = "4.14") |             since = "4.14") | ||||||
|     private String cacheMode; |     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 /////////////////////// |     /////////////////// Accessors /////////////////////// | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
| @ -273,6 +277,9 @@ public class CreateDiskOfferingCmd extends BaseCmd { | |||||||
|         return cacheMode; |         return cacheMode; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |     public Long getStoragePolicy() { | ||||||
|  |         return storagePolicy; | ||||||
|  |     } | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
|     /////////////// API Implementation/////////////////// |     /////////////// API Implementation/////////////////// | ||||||
|     ///////////////////////////////////////////////////// |     ///////////////////////////////////////////////////// | ||||||
|  | |||||||
| @ -39,7 +39,7 @@ import java.util.UUID; | |||||||
| import javax.inject.Inject; | import javax.inject.Inject; | ||||||
| import javax.naming.ConfigurationException; | 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.acl.SecurityChecker; | ||||||
| import org.apache.cloudstack.affinity.AffinityGroup; | import org.apache.cloudstack.affinity.AffinityGroup; | ||||||
| import org.apache.cloudstack.affinity.AffinityGroupService; | 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.user.dao.UserDao; | ||||||
| import com.cloud.utils.NumbersUtil; | import com.cloud.utils.NumbersUtil; | ||||||
| import com.cloud.utils.Pair; | import com.cloud.utils.Pair; | ||||||
|  | import com.cloud.utils.StringUtils; | ||||||
| import com.cloud.utils.UriUtils; | import com.cloud.utils.UriUtils; | ||||||
| import com.cloud.utils.component.ManagerBase; | import com.cloud.utils.component.ManagerBase; | ||||||
| import com.cloud.utils.db.DB; | import com.cloud.utils.db.DB; | ||||||
| @ -387,6 +388,9 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|     IndirectAgentLB _indirectAgentLB; |     IndirectAgentLB _indirectAgentLB; | ||||||
|     @Inject |     @Inject | ||||||
|     private VMTemplateZoneDao templateZoneDao; |     private VMTemplateZoneDao templateZoneDao; | ||||||
|  |     @Inject | ||||||
|  |     VsphereStoragePolicyDao vsphereStoragePolicyDao; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|     // FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao? |     // FIXME - why don't we have interface for DataCenterLinkLocalIpAddressDao? | ||||||
|     @Inject |     @Inject | ||||||
| @ -2827,7 +2831,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|                                                 Long bytesWriteRate, Long bytesWriteRateMax, Long bytesWriteRateMaxLength, |                                                 Long bytesWriteRate, Long bytesWriteRateMax, Long bytesWriteRateMaxLength, | ||||||
|                                                 Long iopsReadRate, Long iopsReadRateMax, Long iopsReadRateMaxLength, |                                                 Long iopsReadRate, Long iopsReadRateMax, Long iopsReadRateMaxLength, | ||||||
|                                                 Long iopsWriteRate, Long iopsWriteRateMax, Long iopsWriteRateMaxLength, |                                                 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 |         long diskSize = 0;// special case for custom disk offerings | ||||||
|         if (numGibibytes != null && numGibibytes <= 0) { |         if (numGibibytes != null && numGibibytes <= 0) { | ||||||
|             throw new InvalidParameterValueException("Please specify a disk size of at least 1 Gb."); |             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)); |                     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()) { |             if (!detailsVO.isEmpty()) { | ||||||
|                 diskOfferingDetailsDao.saveDetails(detailsVO); |                 diskOfferingDetailsDao.saveDetails(detailsVO); | ||||||
|             } |             } | ||||||
| @ -2976,6 +2983,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|         final String tags = cmd.getTags(); |         final String tags = cmd.getTags(); | ||||||
|         final List<Long> domainIds = cmd.getDomainIds(); |         final List<Long> domainIds = cmd.getDomainIds(); | ||||||
|         final List<Long> zoneIds = cmd.getZoneIds(); |         final List<Long> zoneIds = cmd.getZoneIds(); | ||||||
|  |         final Long storagePolicyId = cmd.getStoragePolicy(); | ||||||
| 
 | 
 | ||||||
|         // check if valid domain |         // check if valid domain | ||||||
|         if (CollectionUtils.isNotEmpty(domainIds)) { |         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 Boolean isCustomizedIops = cmd.isCustomizedIops(); | ||||||
|         final Long minIops = cmd.getMinIops(); |         final Long minIops = cmd.getMinIops(); | ||||||
|         final Long maxIops = cmd.getMaxIops(); |         final Long maxIops = cmd.getMaxIops(); | ||||||
| @ -3045,7 +3059,7 @@ public class ConfigurationManagerImpl extends ManagerBase implements Configurati | |||||||
|                 localStorageRequired, isDisplayOfferingEnabled, isCustomizedIops, minIops, |                 localStorageRequired, isDisplayOfferingEnabled, isCustomizedIops, minIops, | ||||||
|                 maxIops, bytesReadRate, bytesReadRateMax, bytesReadRateMaxLength, bytesWriteRate, bytesWriteRateMax, bytesWriteRateMaxLength, |                 maxIops, bytesReadRate, bytesReadRateMax, bytesReadRateMaxLength, bytesWriteRate, bytesWriteRateMax, bytesWriteRateMaxLength, | ||||||
|                 iopsReadRate, iopsReadRateMax, iopsReadRateMaxLength, iopsWriteRate, iopsWriteRateMax, iopsWriteRateMaxLength, |                 iopsReadRate, iopsReadRateMax, iopsReadRateMaxLength, iopsWriteRate, iopsWriteRateMax, iopsWriteRateMaxLength, | ||||||
|                 hypervisorSnapshotReserve, cacheMode); |                 hypervisorSnapshotReserve, cacheMode, storagePolicyId); | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     /** |     /** | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user