CLOUDSTACK-4331 - Enable more capacity from a managed storage device to be given to CloudStack

This commit is contained in:
Mike Tutkowski 2013-08-14 15:02:57 -06:00
parent da61776111
commit 0f60b5d41c
4 changed files with 65 additions and 16 deletions

View File

@ -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///////////////////
/////////////////////////////////////////////////////

View File

@ -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);

View File

@ -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

View File

@ -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);
}
return (PrimaryDataStoreInfo) dataStoreMgr.getDataStore(pool.getId(), DataStoreRole.Primary);
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);
}
@Override