mirror of
				https://github.com/apache/cloudstack.git
				synced 2025-10-26 08:42:29 +01:00 
			
		
		
		
	Merge remote-tracking branch 'origin/4.18'
This commit is contained in:
		
						commit
						7362e5338c
					
				| @ -323,8 +323,8 @@ public class DeployVMCmd extends BaseAsyncCreateCustomIdCmd implements SecurityG | ||||
|             customparameterMap.put(getBootType().toString(), getBootMode().toString()); | ||||
|         } | ||||
| 
 | ||||
|         if (rootdisksize != null && !customparameterMap.containsKey("rootdisksize")) { | ||||
|             customparameterMap.put("rootdisksize", rootdisksize.toString()); | ||||
|         if (rootdisksize != null && !customparameterMap.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) { | ||||
|             customparameterMap.put(VmDetailConstants.ROOT_DISK_SIZE, rootdisksize.toString()); | ||||
|         } | ||||
| 
 | ||||
|         IoDriverPolicy ioPolicy = getIoDriverPolicy(); | ||||
|  | ||||
| @ -509,13 +509,12 @@ public class SystemVmTemplateRegistration { | ||||
|         } | ||||
|     } | ||||
| 
 | ||||
|     public void updateTemplateDetails(SystemVMTemplateDetails details, boolean updateTemplateDetails) { | ||||
|     public void updateTemplateDetails(SystemVMTemplateDetails details) { | ||||
|         VMTemplateVO template = vmTemplateDao.findById(details.getId()); | ||||
|         if (updateTemplateDetails) { | ||||
|             template.setSize(details.getSize()); | ||||
|             template.setState(VirtualMachineTemplate.State.Active); | ||||
|             vmTemplateDao.update(template.getId(), template); | ||||
|         } | ||||
|         template.setSize(details.getSize()); | ||||
|         template.setState(VirtualMachineTemplate.State.Active); | ||||
|         vmTemplateDao.update(template.getId(), template); | ||||
| 
 | ||||
|         TemplateDataStoreVO templateDataStoreVO = templateDataStoreDao.findByStoreTemplate(details.getStoreId(), template.getId()); | ||||
|         templateDataStoreVO.setSize(details.getSize()); | ||||
|         templateDataStoreVO.setPhysicalSize(details.getPhysicalSize()); | ||||
| @ -613,7 +612,7 @@ public class SystemVmTemplateRegistration { | ||||
| 
 | ||||
|     private Long performTemplateRegistrationOperations(Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName, | ||||
|                                                        String url, String checksum, ImageFormat format, long guestOsId, | ||||
|                                                        Long storeId, Long templateId, String filePath, boolean updateTmpltDetails) { | ||||
|                                                        Long storeId, Long templateId, String filePath, TemplateDataStoreVO templateDataStoreVO) { | ||||
|         Hypervisor.HypervisorType hypervisor = hypervisorAndTemplateName.first(); | ||||
|         String templateName = UUID.randomUUID().toString(); | ||||
|         Date created = new Date(DateUtil.currentGMTTime().getTime()); | ||||
| @ -631,21 +630,24 @@ public class SystemVmTemplateRegistration { | ||||
|         String destTempFolderName = String.valueOf(templateId); | ||||
|         String destTempFolder = filePath + PARTIAL_TEMPLATE_FOLDER + destTempFolderName; | ||||
|         details.setInstallPath(PARTIAL_TEMPLATE_FOLDER + destTempFolderName + File.separator + templateName + "." + hypervisorImageFormat.get(hypervisor).getFileExtension()); | ||||
|         createTemplateStoreRefEntry(details); | ||||
|         if (templateDataStoreVO == null) { | ||||
|             createTemplateStoreRefEntry(details); | ||||
|         } | ||||
|         setupTemplate(templateName, hypervisorAndTemplateName, destTempFolder); | ||||
|         readTemplateProperties(destTempFolder + "/template.properties", details); | ||||
|         details.setUpdated(new Date(DateUtil.currentGMTTime().getTime())); | ||||
|         updateTemplateDetails(details, updateTmpltDetails); | ||||
|         updateTemplateDetails(details); | ||||
|         return templateId; | ||||
|     } | ||||
| 
 | ||||
|     public void registerTemplate(Pair<Hypervisor.HypervisorType, String> hypervisorAndTemplateName, | ||||
|                                  Pair<String, Long> storeUrlAndId, VMTemplateVO templateVO, String filePath) { | ||||
|                                  Pair<String, Long> storeUrlAndId, VMTemplateVO templateVO, | ||||
|                                  TemplateDataStoreVO templateDataStoreVO, String filePath) { | ||||
|         Long templateId = null; | ||||
|         try { | ||||
|             templateId = templateVO.getId(); | ||||
|             performTemplateRegistrationOperations(hypervisorAndTemplateName, templateVO.getUrl(), templateVO.getChecksum(), | ||||
|                     templateVO.getFormat(), templateVO.getGuestOSId(), storeUrlAndId.second(), templateId, filePath, false); | ||||
|                     templateVO.getFormat(), templateVO.getGuestOSId(), storeUrlAndId.second(), templateId, filePath, templateDataStoreVO); | ||||
|         } catch (Exception e) { | ||||
|             String errMsg = String.format("Failed to register template for hypervisor: %s", hypervisorAndTemplateName.first()); | ||||
|             LOGGER.error(errMsg, e); | ||||
| @ -662,7 +664,7 @@ public class SystemVmTemplateRegistration { | ||||
|         try { | ||||
|             Hypervisor.HypervisorType hypervisor = hypervisorAndTemplateName.first(); | ||||
|             templateId = performTemplateRegistrationOperations(hypervisorAndTemplateName, NewTemplateUrl.get(hypervisor), NewTemplateChecksum.get(hypervisor), | ||||
|                     hypervisorImageFormat.get(hypervisor), hypervisorGuestOsMap.get(hypervisor), storeUrlAndId.second(), null, filePath, true); | ||||
|                     hypervisorImageFormat.get(hypervisor), hypervisorGuestOsMap.get(hypervisor), storeUrlAndId.second(), null, filePath, null); | ||||
|             Map<String, String> configParams = new HashMap<>(); | ||||
|             configParams.put(RouterTemplateConfigurationNames.get(hypervisorAndTemplateName.first()), hypervisorAndTemplateName.second()); | ||||
|             configParams.put("minreq.sysvmtemplate.version", getSystemVmTemplateVersion()); | ||||
| @ -783,7 +785,7 @@ public class SystemVmTemplateRegistration { | ||||
|                                         if (validateIfSeeded(storeUrlAndId.first(), installPath)) { | ||||
|                                             continue; | ||||
|                                         } else if (templateVO != null) { | ||||
|                                             registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, filePath); | ||||
|                                             registerTemplate(hypervisorAndTemplateName, storeUrlAndId, templateVO, templateDataStoreVO, filePath); | ||||
|                                             continue; | ||||
|                                         } | ||||
|                                     } | ||||
|  | ||||
| @ -2917,7 +2917,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C | ||||
|                                     } | ||||
|                                     SystemVmTemplateRegistration.mountStore(storeUrlAndId.first(), filePath); | ||||
|                                     if (templateVO != null && vmTemplateVO != null) { | ||||
|                                         systemVmTemplateRegistration.registerTemplate(hypervisorAndTemplateName, storeUrlAndId, vmTemplateVO, filePath); | ||||
|                                         systemVmTemplateRegistration.registerTemplate(hypervisorAndTemplateName, storeUrlAndId, vmTemplateVO, templateVO, filePath); | ||||
|                                     } else { | ||||
|                                         systemVmTemplateRegistration.registerTemplate(hypervisorAndTemplateName, storeUrlAndId, filePath); | ||||
|                                     } | ||||
|  | ||||
| @ -3949,7 +3949,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|                 rootDiskOfferingId = diskOfferingId; | ||||
|                 diskOfferingId = null; | ||||
|             } | ||||
|             if (!customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) { | ||||
|             if (!customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE) && diskSize != null) { | ||||
|                 customParameters.put(VmDetailConstants.ROOT_DISK_SIZE, String.valueOf(diskSize)); | ||||
|             } | ||||
|         } | ||||
| @ -4336,7 +4336,14 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|      */ | ||||
|     protected long configureCustomRootDiskSize(Map<String, String> customParameters, VMTemplateVO template, HypervisorType hypervisorType, DiskOfferingVO rootDiskOffering) { | ||||
|         verifyIfHypervisorSupportsRootdiskSizeOverride(hypervisorType); | ||||
|         long rootDiskSizeInBytes = verifyAndGetDiskSize(rootDiskOffering, NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1)); | ||||
|         Long rootDiskSizeCustomParam = null; | ||||
|         if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) { | ||||
|             rootDiskSizeCustomParam = NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1); | ||||
|             if (rootDiskSizeCustomParam <= 0) { | ||||
|                 throw new InvalidParameterValueException("Root disk size should be a positive number."); | ||||
|             } | ||||
|         } | ||||
|         long rootDiskSizeInBytes = verifyAndGetDiskSize(rootDiskOffering, rootDiskSizeCustomParam); | ||||
|         if (rootDiskSizeInBytes > 0) { //if the size at DiskOffering is not zero then the Service Offering had it configured, it holds priority over the User custom size | ||||
|             _volumeService.validateVolumeSizeInBytes(rootDiskSizeInBytes); | ||||
|             long rootDiskSizeInGiB = rootDiskSizeInBytes / GiB_TO_BYTES; | ||||
| @ -4345,11 +4352,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir | ||||
|         } | ||||
| 
 | ||||
|         if (customParameters.containsKey(VmDetailConstants.ROOT_DISK_SIZE)) { | ||||
|             Long rootDiskSize = NumbersUtil.parseLong(customParameters.get(VmDetailConstants.ROOT_DISK_SIZE), -1); | ||||
|             if (rootDiskSize <= 0) { | ||||
|                 throw new InvalidParameterValueException("Root disk size should be a positive number."); | ||||
|             } | ||||
|             rootDiskSize *= GiB_TO_BYTES; | ||||
|             Long rootDiskSize = rootDiskSizeCustomParam * GiB_TO_BYTES; | ||||
|             _volumeService.validateVolumeSizeInBytes(rootDiskSize); | ||||
|             return rootDiskSize; | ||||
|         } else { | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user