mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-4227
This commit is contained in:
parent
798d8f1e4b
commit
d39408cd0c
@ -81,6 +81,7 @@ import org.apache.cloudstack.storage.datastore.db.ImageStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.SnapshotDataStoreVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
|
||||
@ -207,6 +208,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
@Inject
|
||||
protected PrimaryDataStoreDao _storagePoolDao = null;
|
||||
@Inject
|
||||
protected StoragePoolDetailsDao _storagePoolDetailsDao;
|
||||
@Inject
|
||||
protected ImageStoreDao _imageStoreDao = null;
|
||||
@Inject
|
||||
protected ImageStoreDetailsDao _imageStoreDetailsDao = null;
|
||||
@ -778,6 +781,19 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
}
|
||||
|
||||
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();
|
||||
@ -786,6 +802,18 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
_storagePoolDao.updateDetails(id, details);
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user