From 08d7b46be748794773df1f549d3b3dc98068861f Mon Sep 17 00:00:00 2001 From: Mike Tutkowski Date: Fri, 18 Jul 2014 12:02:52 -0600 Subject: [PATCH] Update to volume-resize logic --- .../SolidFirePrimaryDataStoreDriver.java | 2 +- .../cloud/storage/VolumeApiServiceImpl.java | 24 +++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) diff --git a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java index 5a23fcf3991..2228c59f725 100644 --- a/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java +++ b/plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidFirePrimaryDataStoreDriver.java @@ -423,7 +423,7 @@ public class SolidFirePrimaryDataStoreDriver implements PrimaryDataStoreDriver { SolidFireUtil.modifySolidFireVolume(sfConnection, sfVolumeId, sfVolume.getTotalSize(), payload.newMinIops, payload.newMaxIops, getDefaultBurstIops(storagePoolId, payload.newMaxIops)); - VolumeVO volume = _volumeDao.findById(sfVolumeId); + VolumeVO volume = _volumeDao.findById(volumeInfo.getId()); volume.setMinIops(payload.newMinIops); volume.setMaxIops(payload.newMaxIops); diff --git a/server/src/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/com/cloud/storage/VolumeApiServiceImpl.java index 49cb520cda0..64d6bc0bd1b 100644 --- a/server/src/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/com/cloud/storage/VolumeApiServiceImpl.java @@ -733,12 +733,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic DiskOfferingVO diskOffering = _diskOfferingDao.findById(volume.getDiskOfferingId()); DiskOfferingVO newDiskOffering = _diskOfferingDao.findById(cmd.getNewDiskOfferingId()); - /* Only works for KVM/XenServer/VMware for now, and volumes with 'None' since they're just allocated in DB */ + /* Only works for KVM/XenServer/VMware (or "Any") for now, and volumes with 'None' since they're just allocated in DB */ HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId()); if (hypervisorType != HypervisorType.KVM && hypervisorType != HypervisorType.XenServer && - hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.None) { + hypervisorType != HypervisorType.VMware && hypervisorType != HypervisorType.Any && hypervisorType != HypervisorType.None) { throw new InvalidParameterValueException("CloudStack currently only supports volumes marked as the KVM, VMware, or XenServer hypervisor type for resize."); } @@ -808,6 +808,10 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic throw new InvalidParameterValueException("There are no tags on the current disk offering. The new disk offering needs to have no tags, as well."); } + if (!areIntegersEqual(diskOffering.getHypervisorSnapshotReserve(), newDiskOffering.getHypervisorSnapshotReserve())) { + throw new InvalidParameterValueException("The hypervisor snapshot reverse on the new and old disk offerings must be equal."); + } + if (newDiskOffering.getDomainId() != null) { // not a public offering; check access _configMgr.checkDiskOfferingAccess(CallContext.current().getCallingAccount(), newDiskOffering); @@ -945,6 +949,18 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic newDiskOffering != null ? cmd.getNewDiskOfferingId() : null, shrinkOk); } + private static boolean areIntegersEqual(Integer i1, Integer i2) { + if (i1 == null) { + i1 = 0; + } + + if (i2 == null) { + i2 = 0; + } + + return i1.equals(i2); + } + private void validateIops(Long minIops, Long maxIops) { if ((minIops == null && maxIops != null) || (minIops != null && maxIops == null)) { throw new InvalidParameterValueException("Either 'miniops' and 'maxiops' must both be provided or neither must be provided."); @@ -999,14 +1015,12 @@ public class VolumeApiServiceImpl extends ManagerBase implements VolumeApiServic StoragePoolVO storagePool = _storagePoolDao.findById(vol.getPoolId()); - if (storagePool.isManaged()) { + if (currentSize != newSize && storagePool.isManaged()) { if (hosts.length > 0) { volService.resizeVolumeOnHypervisor(volumeId, newSize, hosts[0], instanceName); } volume.setSize(newSize); - - /** @todo let the storage driver know the CloudStack volume within the storage volume in question has a new size */ } if (newDiskOfferingId != null) {