|
31 | 31 | import java.util.List; |
32 | 32 | import java.util.Map; |
33 | 33 | import java.util.Random; |
34 | | -import java.util.Set; |
35 | 34 | import java.util.concurrent.ExecutionException; |
36 | 35 | import java.util.concurrent.Executors; |
37 | 36 | import java.util.concurrent.ScheduledExecutorService; |
|
157 | 156 | import com.cloud.storage.dao.DiskOfferingDao; |
158 | 157 | import com.cloud.storage.dao.SnapshotDao; |
159 | 158 | import com.cloud.storage.dao.StoragePoolHostDao; |
| 159 | +import com.cloud.storage.dao.StoragePoolTagsDao; |
160 | 160 | import com.cloud.storage.dao.StoragePoolWorkDao; |
161 | 161 | import com.cloud.storage.dao.VMTemplateDao; |
162 | 162 | import com.cloud.storage.dao.VMTemplatePoolDao; |
@@ -290,6 +290,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C |
290 | 290 | ResourceLimitService _resourceLimitMgr; |
291 | 291 | @Inject |
292 | 292 | EntityManager _entityMgr; |
| 293 | + @Inject |
| 294 | + StoragePoolTagsDao _storagePoolTagsDao; |
293 | 295 |
|
294 | 296 | protected List<StoragePoolDiscoverer> _discoverers; |
295 | 297 |
|
@@ -776,51 +778,18 @@ private void enablePrimaryStoragePool(StoragePoolVO primaryStorage) { |
776 | 778 | public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws IllegalArgumentException { |
777 | 779 | // Input validation |
778 | 780 | Long id = cmd.getId(); |
779 | | - List<String> tags = cmd.getTags(); |
780 | 781 |
|
781 | 782 | StoragePoolVO pool = _storagePoolDao.findById(id); |
782 | 783 | if (pool == null) { |
783 | 784 | throw new IllegalArgumentException("Unable to find storage pool with ID: " + id); |
784 | 785 | } |
785 | 786 |
|
786 | | - Map<String, String> updatedDetails = new HashMap<String, String>(); |
787 | | - |
788 | | - if (tags != null) { |
789 | | - Map<String, String> existingDetails = _storagePoolDetailsDao.listDetailsKeyPairs(id); |
790 | | - Set<String> existingKeys = existingDetails.keySet(); |
791 | | - |
792 | | - Map<String, String> existingDetailsToKeep = new HashMap<String, String>(); |
793 | | - |
794 | | - for (String existingKey : existingKeys) { |
795 | | - String existingValue = existingDetails.get(existingKey); |
796 | | - |
797 | | - if (!Boolean.TRUE.toString().equalsIgnoreCase(existingValue)) { |
798 | | - existingDetailsToKeep.put(existingKey, existingValue); |
799 | | - } |
800 | | - } |
801 | | - |
802 | | - Map<String, String> details = new HashMap<String, String>(); |
803 | | - for (String tag : tags) { |
804 | | - tag = tag.trim(); |
805 | | - if (tag.length() > 0 && !details.containsKey(tag)) { |
806 | | - details.put(tag, "true"); |
807 | | - } |
808 | | - } |
809 | | - |
810 | | - Set<String> existingKeysToKeep = existingDetailsToKeep.keySet(); |
811 | | - |
812 | | - for (String existingKeyToKeep : existingKeysToKeep) { |
813 | | - String existingValueToKeep = existingDetailsToKeep.get(existingKeyToKeep); |
814 | | - |
815 | | - if (details.containsKey(existingKeyToKeep)) { |
816 | | - throw new CloudRuntimeException("Storage tag '" + existingKeyToKeep + |
817 | | - "' conflicts with a stored property of this primary storage. No changes were made."); |
818 | | - } |
819 | | - |
820 | | - details.put(existingKeyToKeep, existingValueToKeep); |
| 787 | + final List<String> storagePoolTags = cmd.getTags(); |
| 788 | + if (storagePoolTags != null) { |
| 789 | + if (s_logger.isDebugEnabled()) { |
| 790 | + s_logger.debug("Updating Storage Pool Tags to :" + storagePoolTags); |
821 | 791 | } |
822 | | - |
823 | | - updatedDetails.putAll(details); |
| 792 | + _storagePoolTagsDao.persist(pool.getId(), storagePoolTags); |
824 | 793 | } |
825 | 794 |
|
826 | 795 | Long updatedCapacityBytes = null; |
@@ -863,8 +832,6 @@ public PrimaryDataStoreInfo updateStoragePool(UpdateStoragePoolCmd cmd) throws I |
863 | 832 | } else { |
864 | 833 | disablePrimaryStoragePool(pool); |
865 | 834 | } |
866 | | - } else if (updatedDetails.size() >= 0) { |
867 | | - _storagePoolDao.updateDetails(id, updatedDetails); |
868 | 835 | } |
869 | 836 |
|
870 | 837 | if (updatedCapacityBytes != null) { |
|
0 commit comments