Search in sources :

Example 1 with UpdateTsmStorageCmdResponse

use of org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmStorageCmdResponse in project cloudstack by apache.

the class ElastistorPrimaryDataStoreLifeCycle method updateStoragePool.

@Override
public void updateStoragePool(StoragePool storagePool, Map<String, String> details) {
    String capacityBytes = details.get(PrimaryDataStoreLifeCycle.CAPACITY_BYTES);
    String capacityIops = details.get(PrimaryDataStoreLifeCycle.CAPACITY_IOPS);
    StoragePoolVO storagePoolVO = _storagePoolDao.findById(storagePool.getId());
    try {
        if (capacityBytes != null) {
            long usedBytes = _capacityMgr.getUsedBytes(storagePoolVO);
            if (Long.parseLong(capacityBytes) < usedBytes) {
                throw new CloudRuntimeException("Cannot reduce the number of bytes for this storage pool as it would lead to an insufficient number of bytes");
            }
            UpdateTsmStorageCmdResponse updateTsmStorageCmdResponse = ElastistorUtil.updateElastistorTsmStorage(capacityBytes, storagePool.getUuid());
            if (updateTsmStorageCmdResponse.getStorage().getId() != null) {
                // update the cloudstack db
                _storagePoolDao.updateCapacityBytes(storagePool.getId(), Long.parseLong(capacityBytes));
                s_logger.info("elastistor TSM storage successfully updated");
            } else {
                throw new CloudRuntimeException("Failed to update the storage of Elastistor TSM" + updateTsmStorageCmdResponse.toString());
            }
        }
        if (capacityIops != null) {
            long usedIops = _capacityMgr.getUsedIops(storagePoolVO);
            long capacity = Long.parseLong(capacityIops);
            if (capacity < usedIops) {
                throw new CloudRuntimeException("Cannot reduce the number of IOPS for this storage pool as it would lead to an insufficient number of IOPS");
            }
            UpdateTsmCmdResponse updateTsmCmdResponse = ElastistorUtil.updateElastistorTsmIOPS(capacityIops, storagePool.getUuid());
            if (updateTsmCmdResponse.getTsm(0).getUuid() != null) {
                // update the cloudstack db
                _storagePoolDao.updateCapacityIops(storagePool.getId(), capacity);
                s_logger.info("elastistor TSM IOPS successfully updated");
            } else {
                throw new CloudRuntimeException("Failed to update the IOPS of Elastistor TSM" + updateTsmCmdResponse.toString());
            }
        }
    } catch (Throwable e) {
        throw new CloudRuntimeException("Failed to update the storage pool" + e);
    }
}
Also used : CloudRuntimeException(com.cloud.utils.exception.CloudRuntimeException) StoragePoolVO(org.apache.cloudstack.storage.datastore.db.StoragePoolVO) UpdateTsmStorageCmdResponse(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmStorageCmdResponse) UpdateTsmCmdResponse(org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmCmdResponse)

Aggregations

CloudRuntimeException (com.cloud.utils.exception.CloudRuntimeException)1 StoragePoolVO (org.apache.cloudstack.storage.datastore.db.StoragePoolVO)1 UpdateTsmCmdResponse (org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmCmdResponse)1 UpdateTsmStorageCmdResponse (org.apache.cloudstack.storage.datastore.util.ElastistorUtil.UpdateTsmStorageCmdResponse)1