From 968dc0616f88088005ea204ff8d7ecc7aecc1e9f Mon Sep 17 00:00:00 2001 From: abhishek Date: Thu, 11 Nov 2010 15:44:02 -0800 Subject: [PATCH] bug 7021: data disk wasn't being created for custom sizes. Also, we were having max size checks in GB, whereas disk offerings are in MB. Made the change there as well.The storage allocators were commented out in master, uncommented them. Status 7021: resolved fixed --- client/tomcatconf/components.xml.in | 4 ++-- .../hypervisor/xen/resource/CitrixResourceBase.java | 2 +- server/src/com/cloud/configuration/Config.java | 2 +- .../src/com/cloud/server/ManagementServerImpl.java | 12 ++++++------ server/src/com/cloud/storage/StorageManagerImpl.java | 5 ++++- 5 files changed, 14 insertions(+), 11 deletions(-) diff --git a/client/tomcatconf/components.xml.in b/client/tomcatconf/components.xml.in index 3119a71cda9..87f9dcaf4f4 100755 --- a/client/tomcatconf/components.xml.in +++ b/client/tomcatconf/components.xml.in @@ -123,8 +123,8 @@ - - + < adapter name="Storage" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator"/ > + diff --git a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java index 89f97e00f46..114de0e504a 100644 --- a/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java +++ b/core/src/com/cloud/hypervisor/xen/resource/CitrixResourceBase.java @@ -4692,7 +4692,7 @@ public abstract class CitrixResourceBase implements StoragePoolResource, ServerR vdir.type = Types.VdiType.USER; if(cmd.getSize()!=0) - vdir.virtualSize = cmd.getSize(); + vdir.virtualSize = (cmd.getSize()*1024*1024*1L); else vdir.virtualSize = dskch.getSize(); vdi = VDI.create(conn, vdir); diff --git a/server/src/com/cloud/configuration/Config.java b/server/src/com/cloud/configuration/Config.java index f4daf1068b8..55e279909fd 100644 --- a/server/src/com/cloud/configuration/Config.java +++ b/server/src/com/cloud/configuration/Config.java @@ -48,7 +48,7 @@ public enum Config { StorageOverprovisioningFactor("Storage", StoragePoolAllocator.class, String.class, "storage.overprovisioning.factor", "2", "Used for storage overprovisioning calculation; available storage will be (actualStorageSize * storage.overprovisioning.factor)", null), StorageStatsInterval("Storage", ManagementServer.class, String.class, "storage.stats.interval", "60000", "The interval in milliseconds when storage stats (per host) are retrieved from agents.", null), - MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "max.volume.size.gb", "2000", "The maximum size for a volume in gigabytes.", null), + MaxVolumeSize("Storage", ManagementServer.class, Integer.class, "max.volume.size.mb", "1024000", "The maximum size for a volume in megabytes.", null), TotalRetries("Storage", AgentManager.class, Integer.class, "total.retries", "4", "The number of times each command sent to a host should be retried in case of failure.", null), // Network diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 79be06e07ee..4352700eea1 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -393,7 +393,7 @@ public class ManagementServerImpl implements ManagementServer { private final int _routerRamSize; private final int _proxyRamSize; private final int _ssRamSize; - private int _maxVolumeSizeInGb; + private int _maxVolumeSizeInMb; private final Map _availableIdsMap; @@ -512,9 +512,9 @@ public class ManagementServerImpl implements ManagementServer { _networkGroupsEnabled = true; } - String maxVolumeSizeInGbString = _configDao.getValue("max.volume.size.gb"); - int maxVolumeSizeGb = NumbersUtil.parseInt(maxVolumeSizeInGbString, 2000); - _maxVolumeSizeInGb = maxVolumeSizeGb; + String maxVolumeSizeInMbString = _configDao.getValue("max.volume.size.gb"); + int maxVolumeSizeMb = NumbersUtil.parseInt(maxVolumeSizeInMbString, (2000*1024));//2000 gb + _maxVolumeSizeInMb = maxVolumeSizeMb; } protected Map getConfigs() { @@ -1216,8 +1216,8 @@ public class ManagementServerImpl implements ManagementServer { throw new InvalidParameterValueException("Please specify a valid disk size for VM creation; custom disk offering has no size set"); } - if(diskOffering != null && diskOffering.isCustomized() && size > _maxVolumeSizeInGb){ - throw new InvalidParameterValueException("Please specify a valid disk size for VM creation; custom disk offering max size is:"+_maxVolumeSizeInGb); + if(diskOffering != null && diskOffering.isCustomized() && size > _maxVolumeSizeInMb){ + throw new InvalidParameterValueException("Please specify a valid disk size for VM creation; custom disk offering max size is:"+_maxVolumeSizeInMb); } // validate that the template is usable by the account diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index c3aeb3b82b9..b2f641a3737 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -716,6 +716,9 @@ public class StorageManagerImpl implements StorageManager { StoragePoolVO pool = null; final HashSet avoidPools = new HashSet(avoids); + if(diskOffering != null && diskOffering.isCustomized()){ + diskOffering.setDiskSize(size); + } DiskProfile dskCh = null; if (volume.getVolumeType() == VolumeType.ROOT && Storage.ImageFormat.ISO != template.getFormat()) { dskCh = createDiskCharacteristics(volume, template, dc, offering); @@ -842,7 +845,7 @@ public class StorageManagerImpl implements StorageManager { rootVol.setDeviceId(0l); rootVol = _volsDao.persist(rootVol); - if (diskOffering != null && diskOffering.getDiskSizeInBytes() > 0) { + if ((diskOffering != null && diskOffering.getDiskSizeInBytes() > 0)) { dataVol = new VolumeVO(VolumeType.DATADISK, vm.getId(), vm.getInstanceName() + "-DATA", dc.getId(), pod.getId(), account.getId(), account.getDomainId(), (size>0)? size : diskOffering.getDiskSizeInBytes()); createStartedEvent(account, dataVol);