cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mtutkow...@apache.org
Subject git commit: updated refs/heads/master to d39408c
Date Sat, 10 Aug 2013 23:43:39 GMT
Updated Branches:
  refs/heads/master 798d8f1e4 -> d39408cd0


CLOUDSTACK-4227

Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/d39408cd
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/d39408cd
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/d39408cd

Branch: refs/heads/master
Commit: d39408cd0cb86680d2113cb3e14899034cb02df9
Parents: 798d8f1
Author: Mike Tutkowski <mike.tutkowski@solidfire.com>
Authored: Sat Aug 10 17:43:15 2013 -0600
Committer: Mike Tutkowski <mike.tutkowski@solidfire.com>
Committed: Sat Aug 10 17:43:15 2013 -0600

----------------------------------------------------------------------
 .../com/cloud/storage/StorageManagerImpl.java   | 28 ++++++++++++++++++++
 1 file changed, 28 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d39408cd/server/src/com/cloud/storage/StorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java
index 9f720d6..df0832a 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -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);
         }
 


Mime
View raw message