Updated Branches: refs/heads/master da6177611 -> 0f60b5d41
CLOUDSTACK-4331 - Enable more capacity from a managed storage device to be given to CloudStack Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/0f60b5d4 Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/0f60b5d4 Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/0f60b5d4 Branch: refs/heads/master Commit: 0f60b5d41cc1db8d29ff72de1a8c38f96a44915e Parents: da61776 Author: Mike Tutkowski <[email protected]> Authored: Wed Aug 14 15:02:57 2013 -0600 Committer: Mike Tutkowski <[email protected]> Committed: Wed Aug 14 15:02:57 2013 -0600 ---------------------------------------------------------------------- .../admin/storage/UpdateStoragePoolCmd.java | 15 +++++++ .../datastore/db/PrimaryDataStoreDao.java | 15 +++---- .../datastore/db/PrimaryDataStoreDaoImpl.java | 9 ++--- .../com/cloud/storage/StorageManagerImpl.java | 42 +++++++++++++++++++- 4 files changed, 65 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f60b5d4/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java ---------------------------------------------------------------------- diff --git a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java index 2ecb90f..f04ecbc 100644 --- a/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java +++ b/api/src/org/apache/cloudstack/api/command/admin/storage/UpdateStoragePoolCmd.java @@ -47,6 +47,13 @@ public class UpdateStoragePoolCmd extends BaseCmd { @Parameter(name=ApiConstants.TAGS, type=CommandType.LIST, collectionType=CommandType.STRING, description="comma-separated list of tags for the storage pool") private List<String> tags; + @Parameter(name=ApiConstants.CAPACITY_IOPS, type=CommandType.LONG, + required=false, description="IOPS CloudStack can provision from this storage pool") + private Long capacityIops; + + @Parameter(name=ApiConstants.CAPACITY_BYTES, type=CommandType.LONG, + required=false, description="bytes CloudStack can provision from this storage pool") + private Long capacityBytes; ///////////////////////////////////////////////////// /////////////////// Accessors /////////////////////// @@ -60,6 +67,14 @@ public class UpdateStoragePoolCmd extends BaseCmd { return tags; } + public Long getCapacityIops() { + return capacityIops; + } + + public Long getCapacityBytes() { + return capacityBytes; + } + ///////////////////////////////////////////////////// /////////////// API Implementation/////////////////// ///////////////////////////////////////////////////// http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f60b5d4/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java index 669dd25..59c338e 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java @@ -42,19 +42,16 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> { /** * Set capacity of storage pool in bytes * @param id pool id. - * @param capacity capacity in bytes + * @param capacityBytes capacity in bytes */ - void updateCapacity(long id, long capacity); + void updateCapacityBytes(long id, long capacityBytes); /** - * Set available bytes of storage pool in bytes - * - * @param id - * pool id. - * @param available - * available capacity in bytes + * Set iops capacity of storage pool + * @param id pool id. + * @param capacityIops iops capacity */ - void updateAvailable(long id, long available); + void updateCapacityIops(long id, long capacityIops); StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details); http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f60b5d4/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java ---------------------------------------------------------------------- diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index 1032526..b39f844 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -140,18 +140,17 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> } @Override - public void updateAvailable(long id, long available) { + public void updateCapacityBytes(long id, long capacityBytes) { StoragePoolVO pool = createForUpdate(id); - pool.setUsedBytes(available); + pool.setCapacityBytes(capacityBytes); update(id, pool); } @Override - public void updateCapacity(long id, long capacity) { + public void updateCapacityIops(long id, long capacityIops) { StoragePoolVO pool = createForUpdate(id); - pool.setCapacityBytes(capacity); + pool.setCapacityIops(capacityIops); update(id, pool); - } @Override http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f60b5d4/server/src/com/cloud/storage/StorageManagerImpl.java ---------------------------------------------------------------------- diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 23e713e..b5d6ff9 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -733,6 +733,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C throw new IllegalArgumentException("Unable to find storage pool with ID: " + id); } + Map<String, String> updatedDetails = new HashMap<String, String>(); + if (tags != null) { Map<String, String> existingDetails = _storagePoolDetailsDao.getDetails(id); Set<String> existingKeys = existingDetails.keySet(); @@ -767,10 +769,46 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C details.put(existingKeyToKeep, existingValueToKeep); } - _storagePoolDao.updateDetails(id, details); + updatedDetails.putAll(details); + } + + Long updatedCapacityBytes = null; + Long capacityBytes = cmd.getCapacityBytes(); + + if (capacityBytes != null) { + if (capacityBytes > pool.getCapacityBytes()) { + updatedCapacityBytes = capacityBytes; + } + else if (capacityBytes < pool.getCapacityBytes()) { + throw new CloudRuntimeException("The value of 'Capacity bytes' cannot be reduced in this version."); + } + } + + Long updatedCapacityIops = null; + Long capacityIops = cmd.getCapacityIops(); + + if (capacityIops != null) { + if (capacityIops > pool.getCapacityIops()) { + updatedCapacityIops = capacityIops; + } + else if (capacityIops < pool.getCapacityIops()) { + throw new CloudRuntimeException("The value of 'Capacity IOPS' cannot be reduced in this version."); + } + } + + if (updatedDetails.size() > 0) { + _storagePoolDao.updateDetails(id, updatedDetails); + } + + if (updatedCapacityBytes != null) { + _storagePoolDao.updateCapacityBytes(id, capacityBytes); + } + + if (updatedCapacityIops != null) { + _storagePoolDao.updateCapacityIops(id, capacityIops); } - return (PrimaryDataStoreInfo) dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); + return (PrimaryDataStoreInfo)dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary); } @Override
