Skip to content

Commit 8f503c7

Browse files
author
Mike Tutkowski
committed
CLOUDSTACK-4227
1 parent 48cf866 commit 8f503c7

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎server/src/com/cloud/storage/StorageManagerImpl.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@
141141
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
142142
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
143143
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
144+
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
144145
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
145146
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
146147
import org.apache.cloudstack.storage.datastore.db.VolumeDataStoreDao;
@@ -206,6 +207,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
206207
@Inject
207208
protected PrimaryDataStoreDao _storagePoolDao = null;
208209
@Inject
210+
protected StoragePoolDetailsDao _storagePoolDetailsDao;
211+
@Inject
209212
protected ImageStoreDao _imageStoreDao = null;
210213
@Inject
211214
protected ImageStoreDetailsDao _imageStoreDetailsDao = null;
@@ -789,6 +792,19 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
789792
}
790793

791794
if (tags != null) {
795+
Map<String, String> existingDetails = _storagePoolDetailsDao.getDetails(id);
796+
Set<String> existingKeys = existingDetails.keySet();
797+
798+
Map<String, String> existingDetailsToKeep = new HashMap<String, String>();
799+
800+
for (String existingKey : existingKeys) {
801+
String existingValue = existingDetails.get(existingKey);
802+
803+
if (!Boolean.TRUE.toString().equalsIgnoreCase(existingValue)) {
804+
existingDetailsToKeep.put(existingKey, existingValue);
805+
}
806+
}
807+
792808
Map<String, String> details = new HashMap<String, String>();
793809
for (String tag : tags) {
794810
tag = tag.trim();
@@ -797,6 +813,18 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I
797813
}
798814
}
799815

816+
Set<String> existingKeysToKeep = existingDetailsToKeep.keySet();
817+
818+
for (String existingKeyToKeep : existingKeysToKeep) {
819+
String existingValueToKeep = existingDetailsToKeep.get(existingKeyToKeep);
820+
821+
if (details.containsKey(existingKeyToKeep)) {
822+
throw new CloudRuntimeException("Storage tag '" + existingKeyToKeep + "' conflicts with a stored property of this primary storage. No changes were made.");
823+
}
824+
825+
details.put(existingKeyToKeep, existingValueToKeep);
826+
}
827+
800828
_storagePoolDao.updateDetails(id, details);
801829
}
802830

0 commit comments

Comments
 (0)