public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException {
// Input validation
Long id = cmd.getId();
List<String> tags = cmd.getTags();
StoragePoolVO pool = _storagePoolDao.findById(id);
if (pool == null) {
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();
Map<String, String> existingDetailsToKeep = new HashMap<String, String>();
for (String existingKey : existingKeys) {
String existingValue = existingDetails.get(existingKey);
if (!Boolean.TRUE.toString().equalsIgnoreCase(existingValue)) {
existingDetailsToKeep.put(existingKey, existingValue);
}
}
Map<String, String> details = new HashMap<String, String>();
for (String tag : tags) {
tag = tag.trim();
if (tag.length() > 0 && !details.containsKey(tag)) {
details.put(tag, "true");
}
}
Set<String> existingKeysToKeep = existingDetailsToKeep.keySet();
for (String existingKeyToKeep : existingKeysToKeep) {
String existingValueToKeep = existingDetailsToKeep.get(existingKeyToKeep);
if (details.containsKey(existingKeyToKeep)) {
throw new CloudRuntimeException("Storage tag '" + existingKeyToKeep + "' conflicts with a stored property of this primary storage. No changes were made.");
}
details.put(existingKeyToKeep, existingValueToKeep);
}
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);
}