cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [42/50] [abbrv] git commit: updated refs/heads/object_store_migration to 5ec2a44
Date Tue, 29 Oct 2013 03:53:32 GMT
Resource details (metadata) - added support for Storage pool details


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

Branch: refs/heads/object_store_migration
Commit: d0090a0c24bbbef2575207193f2e5bed83bdd242
Parents: 92f9724
Author: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Authored: Mon Oct 28 10:15:55 2013 -0700
Committer: Alena Prokharchyk <alena.prokharchyk@citrix.com>
Committed: Mon Oct 28 12:53:53 2013 -0700

----------------------------------------------------------------------
 api/src/com/cloud/server/ResourceTag.java       |  3 +-
 .../com/cloud/dc/dao/ResourceDetailDaoBase.java |  3 +
 .../dao/ServiceOfferingDetailsDaoImpl.java      |  4 +-
 .../storage/dao/StoragePoolDetailsDaoImpl.java  | 58 +-------------------
 .../storage/dao/VMTemplateDetailsDaoImpl.java   |  4 ++
 .../cloud/storage/dao/VolumeDetailsDaoImpl.java |  4 +-
 .../src/com/cloud/vm/dao/NicDetailDaoImpl.java  |  4 +-
 .../com/cloud/vm/dao/UserVmDetailsDaoImpl.java  |  4 +-
 .../datastore/db/PrimaryDataStoreDaoImpl.java   | 14 +++--
 .../datastore/db/PrimaryDataStoreDetailVO.java  | 34 +++++-------
 .../db/PrimaryDataStoreDetailsDao.java          | 10 +---
 .../datastore/db/StoragePoolDetailVO.java       | 38 +++++--------
 .../datastore/db/StoragePoolDetailsDao.java     | 11 +---
 .../db/PrimaryDataStoreDetailsDaoImpl.java      | 52 ++----------------
 .../configuration/ConfigurationManagerImpl.java | 10 +---
 .../metadata/ResourceMetaDataManagerImpl.java   | 13 +++++
 .../com/cloud/storage/StorageManagerImpl.java   |  2 +-
 .../cloud/tags/TaggedResourceManagerImpl.java   |  5 ++
 18 files changed, 93 insertions(+), 180 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/api/src/com/cloud/server/ResourceTag.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/server/ResourceTag.java b/api/src/com/cloud/server/ResourceTag.java
index f2bcd18..85bbcd0 100644
--- a/api/src/com/cloud/server/ResourceTag.java
+++ b/api/src/com/cloud/server/ResourceTag.java
@@ -43,7 +43,8 @@ public interface ResourceTag extends ControlledEntity, Identity, InternalIdentit
         VMSnapshot (true, false),
         RemoteAccessVpn (true, false),
         Zone (false, true),
-        ServiceOffering (false, true);
+        ServiceOffering (false, true),
+        Storage(false, true);
         
         ResourceObjectType(boolean resourceTagsSupport, boolean resourceMetadataSupport)
{
             this.resourceTagsSupport = resourceTagsSupport;

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/dc/dao/ResourceDetailDaoBase.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/dc/dao/ResourceDetailDaoBase.java b/engine/schema/src/com/cloud/dc/dao/ResourceDetailDaoBase.java
index ea8f85a..9102a62 100644
--- a/engine/schema/src/com/cloud/dc/dao/ResourceDetailDaoBase.java
+++ b/engine/schema/src/com/cloud/dc/dao/ResourceDetailDaoBase.java
@@ -103,6 +103,9 @@ public abstract class ResourceDetailDaoBase<R extends ResourceDetail>
extends Ge
     
 
     public void addDetail(R detail) {
+        if (detail == null) {
+            return;
+        }
         R existingDetail = findDetail(detail.getResourceId(), detail.getName());
         if (existingDetail != null) {
             remove(existingDetail.getId());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
index eed8a13..6cac9da 100644
--- a/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/service/dao/ServiceOfferingDetailsDaoImpl.java
@@ -27,5 +27,7 @@ import com.cloud.service.ServiceOfferingDetailsVO;
 @Local(value=ServiceOfferingDetailsDao.class)
 public class ServiceOfferingDetailsDaoImpl extends ResourceDetailDaoBase<ServiceOfferingDetailsVO>
         implements ServiceOfferingDetailsDao {
-    
+    public ServiceOfferingDetailsDaoImpl() {
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
index 7859ca7..6d7991f 100644
--- a/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
@@ -16,10 +16,6 @@
 // under the License.
 package com.cloud.storage.dao;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import javax.ejb.Local;
 
 import org.apache.cloudstack.framework.config.ConfigKey;
@@ -28,60 +24,12 @@ import org.apache.cloudstack.framework.config.ScopedConfigStorage;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.dc.dao.ResourceDetailDaoBase;
 
 @Local(value = StoragePoolDetailsDao.class)
-public class StoragePoolDetailsDaoImpl extends GenericDaoBase<StoragePoolDetailVO, Long>
implements StoragePoolDetailsDao, ScopedConfigStorage {
-
-    protected final SearchBuilder<StoragePoolDetailVO> PoolSearch;
-
-    protected StoragePoolDetailsDaoImpl() {
-        super();
-        PoolSearch = createSearchBuilder();
-        PoolSearch.and("pool", PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
-        PoolSearch.and("name", PoolSearch.entity().getName(), SearchCriteria.Op.EQ);
-        PoolSearch.done();
-    }
-
-    @Override
-    public void update(long poolId, Map<String, String> details) {
-        TransactionLegacy txn = TransactionLegacy.currentTxn();
-        SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-
-        txn.start();
-        expunge(sc);
-        for (Map.Entry<String, String> entry : details.entrySet()) {
-            StoragePoolDetailVO detail = new StoragePoolDetailVO(poolId, entry.getKey(),
entry.getValue());
-            persist(detail);
-        }
-        txn.commit();
-    }
-
-    @Override
-    public Map<String, String> getDetails(long poolId) {
-        SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-
-        List<StoragePoolDetailVO> details = listBy(sc);
-        Map<String, String> detailsMap = new HashMap<String, String>();
-        for (StoragePoolDetailVO detail : details) {
-            detailsMap.put(detail.getName(), detail.getValue());
-        }
-
-        return detailsMap;
-    }
-
-    @Override
-    public StoragePoolDetailVO findDetail(long poolId, String name) {
-        SearchCriteria<StoragePoolDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-        sc.setParameters("name", name);
+public class StoragePoolDetailsDaoImpl extends ResourceDetailDaoBase<StoragePoolDetailVO>
implements StoragePoolDetailsDao, ScopedConfigStorage {
 
-        return findOneIncludingRemovedBy(sc);
+    public StoragePoolDetailsDaoImpl() {
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
index 4b9bfb5..384b2d6 100644
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDetailsDaoImpl.java
@@ -26,4 +26,8 @@ import com.cloud.storage.VMTemplateDetailVO;
 @Component
 @Local(value = VMTemplateDetailsDao.class)
 public class VMTemplateDetailsDaoImpl extends ResourceDetailDaoBase<VMTemplateDetailVO>
implements VMTemplateDetailsDao {
+    public VMTemplateDetailsDaoImpl(){
+        
+    }
+    
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
index 9df6ee1..c62b66a 100644
--- a/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VolumeDetailsDaoImpl.java
@@ -26,5 +26,7 @@ import com.cloud.storage.VolumeDetailVO;
 @Component
 @Local(value=VolumeDetailsDao.class)
 public class VolumeDetailsDaoImpl extends ResourceDetailDaoBase<VolumeDetailVO> implements
VolumeDetailsDao {
-
+    public VolumeDetailsDaoImpl() {
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
index 6263cae..a009025 100644
--- a/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/NicDetailDaoImpl.java
@@ -26,5 +26,7 @@ import com.cloud.vm.NicDetailVO;
 @Component
 @Local (value={NicDetailDao.class})
 public class NicDetailDaoImpl extends ResourceDetailDaoBase<NicDetailVO> implements
NicDetailDao {
-    
+    public NicDetailDaoImpl() {
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
index b435381..ba72f25 100644
--- a/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
+++ b/engine/schema/src/com/cloud/vm/dao/UserVmDetailsDaoImpl.java
@@ -26,5 +26,7 @@ import com.cloud.vm.UserVmDetailVO;
 @Component
 @Local(value=UserVmDetailsDao.class)
 public class UserVmDetailsDaoImpl extends ResourceDetailDaoBase<UserVmDetailVO> implements
UserVmDetailsDao {
-
+    public UserVmDetailsDaoImpl() {
+        
+    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index 8ed84ef..bee76f5 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -28,6 +28,8 @@ import javax.ejb.Local;
 import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
+import org.springframework.stereotype.Component;
+
 import com.cloud.host.Status;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.storage.ScopeType;
@@ -43,6 +45,7 @@ import com.cloud.utils.db.SearchCriteria.Op;
 import com.cloud.utils.db.TransactionLegacy;
 import com.cloud.utils.exception.CloudRuntimeException;
 
+
 @Local(value = { PrimaryDataStoreDao.class })
 @DB()
 public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO, Long> implements
PrimaryDataStoreDao {
@@ -52,8 +55,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
     protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
 
-    @Inject
-    protected StoragePoolDetailsDao _detailsDao;
+    @Inject protected StoragePoolDetailsDao _detailsDao;
 
     private final String DetailsSqlPrefix = "SELECT storage_pool.* from storage_pool LEFT
JOIN storage_pool_details ON storage_pool.id = storage_pool_details.pool_id WHERE storage_pool.removed
is null and storage_pool.status = 'Up' and storage_pool.data_center_id = ? and (storage_pool.pod_id
= ? or storage_pool.pod_id is null) and storage_pool.scope = ? and (";
     private final String DetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id HAVING
COUNT(storage_pool_details.name) >= ?";
@@ -380,13 +382,17 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     @Override
     public void updateDetails(long poolId, Map<String, String> details) {
         if (details != null) {
-            _detailsDao.update(poolId, details);
+            List<StoragePoolDetailVO> detailsVO = new ArrayList<StoragePoolDetailVO>();
+            for (String key : details.keySet()) {
+                detailsVO.add(new StoragePoolDetailVO(poolId, key, details.get(key)));
+            }
+            _detailsDao.addDetails(detailsVO);
         }
     }
 
     @Override
     public Map<String, String> getDetails(long poolId) {
-        return _detailsDao.getDetails(poolId);
+        return _detailsDao.findDetails(poolId);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
index 0d9af4b..badb637 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailVO.java
@@ -23,16 +23,18 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.ResourceDetail;
+
 @Entity
 @Table(name = "storage_pool_details")
-public class PrimaryDataStoreDetailVO {
+public class PrimaryDataStoreDetailVO implements ResourceDetail{
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "id")
     long id;
 
     @Column(name = "pool_id")
-    long poolId;
+    long resourceId;
 
     @Column(name = "name")
     String name;
@@ -41,39 +43,31 @@ public class PrimaryDataStoreDetailVO {
     String value;
 
     public PrimaryDataStoreDetailVO(long poolId, String name, String value) {
-        this.poolId = poolId;
+        this.resourceId = poolId;
         this.name = name;
         this.value = value;
     }
+    
+    protected PrimaryDataStoreDetailVO() {
+    }
 
+    @Override
     public long getId() {
         return id;
     }
 
-    public long getPoolId() {
-        return poolId;
-    }
-
-    public void setPoolId(long poolId) {
-        this.poolId = poolId;
+    @Override
+    public long getResourceId() {
+        return resourceId;
     }
 
+    @Override
     public String getName() {
         return name;
     }
 
-    public void setName(String name) {
-        this.name = name;
-    }
-
+    @Override
     public String getValue() {
         return value;
     }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-    protected PrimaryDataStoreDetailVO() {
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
index 18e2f1c..8466107 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDetailsDao.java
@@ -16,13 +16,7 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.db;
 
-import java.util.Map;
+import com.cloud.dc.dao.ResourceDetailDao;
 
-import com.cloud.utils.db.GenericDao;
-
-public interface PrimaryDataStoreDetailsDao extends GenericDao<PrimaryDataStoreDetailVO,
Long> {
-
-    void update(long poolId, Map<String, String> details);
-
-    Map<String, String> getDetails(long poolId);
+public interface PrimaryDataStoreDetailsDao extends ResourceDetailDao<PrimaryDataStoreDetailVO>
{
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
index e51f3a3..9499df0 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailVO.java
@@ -16,8 +16,6 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.db;
 
-import org.apache.cloudstack.api.InternalIdentity;
-
 import javax.persistence.Column;
 import javax.persistence.Entity;
 import javax.persistence.GeneratedValue;
@@ -25,16 +23,18 @@ import javax.persistence.GenerationType;
 import javax.persistence.Id;
 import javax.persistence.Table;
 
+import org.apache.cloudstack.api.ResourceDetail;
+
 @Entity
 @Table(name = "storage_pool_details")
-public class StoragePoolDetailVO implements InternalIdentity {
+public class StoragePoolDetailVO implements ResourceDetail {
     @Id
     @GeneratedValue(strategy = GenerationType.IDENTITY)
     @Column(name = "id")
     long id;
 
     @Column(name = "pool_id")
-    long poolId;
+    long resourceId;
 
     @Column(name = "name")
     String name;
@@ -43,39 +43,31 @@ public class StoragePoolDetailVO implements InternalIdentity {
     String value;
 
     public StoragePoolDetailVO(long poolId, String name, String value) {
-        this.poolId = poolId;
+        this.resourceId = poolId;
         this.name = name;
         this.value = value;
     }
+    
+    public StoragePoolDetailVO() {
+    }
 
+    @Override
     public long getId() {
         return id;
     }
 
-    public long getPoolId() {
-        return poolId;
-    }
-
-    public void setPoolId(long poolId) {
-        this.poolId = poolId;
+    @Override
+    public long getResourceId() {
+        return resourceId;
     }
 
+    @Override
     public String getName() {
         return name;
     }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
+    
+    @Override
     public String getValue() {
         return value;
     }
-
-    public void setValue(String value) {
-        this.value = value;
-    }
-
-    protected StoragePoolDetailVO() {
-    }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
index 49f4f19..f7ef631 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/StoragePoolDetailsDao.java
@@ -16,15 +16,8 @@
 // under the License.
 package org.apache.cloudstack.storage.datastore.db;
 
-import java.util.Map;
-
+import com.cloud.dc.dao.ResourceDetailDao;
 import com.cloud.utils.db.GenericDao;
 
-public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long>
{
-
-    void update(long poolId, Map<String, String> details);
-
-    Map<String, String> getDetails(long poolId);
-
-    StoragePoolDetailVO findDetail(long poolId, String name);
+public interface StoragePoolDetailsDao extends GenericDao<StoragePoolDetailVO, Long>,
ResourceDetailDao<StoragePoolDetailVO> {
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
index be741da..13b19d0 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/volume/db/PrimaryDataStoreDetailsDaoImpl.java
@@ -16,59 +16,17 @@
 // under the License.
 package org.apache.cloudstack.storage.volume.db;
 
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDetailVO;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDetailsDao;
 import org.springframework.stereotype.Component;
 
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.TransactionLegacy;
+import com.cloud.dc.dao.ResourceDetailDaoBase;
 
 @Component
-public class PrimaryDataStoreDetailsDaoImpl extends GenericDaoBase<PrimaryDataStoreDetailVO,
Long> implements
+public class PrimaryDataStoreDetailsDaoImpl extends ResourceDetailDaoBase<PrimaryDataStoreDetailVO>
implements
         PrimaryDataStoreDetailsDao {
-
-    protected final SearchBuilder<PrimaryDataStoreDetailVO> PoolSearch = null;
-
-    protected PrimaryDataStoreDetailsDaoImpl() {
-        /*
-         * super(); PoolSearch = createSearchBuilder(); PoolSearch.and("pool",
-         * PoolSearch.entity().getPoolId(), SearchCriteria.Op.EQ);
-         * PoolSearch.done();
-         */
-    }
-
-    @Override
-    public void update(long poolId, Map<String, String> details) {
-        TransactionLegacy txn = TransactionLegacy.currentTxn();
-        SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-
-        txn.start();
-        expunge(sc);
-        for (Map.Entry<String, String> entry : details.entrySet()) {
-            PrimaryDataStoreDetailVO detail = new PrimaryDataStoreDetailVO(poolId, entry.getKey(),
entry.getValue());
-            persist(detail);
-        }
-        txn.commit();
-    }
-
-    @Override
-    public Map<String, String> getDetails(long poolId) {
-        SearchCriteria<PrimaryDataStoreDetailVO> sc = PoolSearch.create();
-        sc.setParameters("pool", poolId);
-
-        List<PrimaryDataStoreDetailVO> details = listBy(sc);
-        Map<String, String> detailsMap = new HashMap<String, String>();
-        for (PrimaryDataStoreDetailVO detail : details) {
-            detailsMap.put(detail.getName(), detail.getValue());
-        }
-
-        return detailsMap;
+    
+    public PrimaryDataStoreDetailsDaoImpl() {
+        
     }
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
index 6af50df..998e3ef 100755
--- a/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
+++ b/server/src/com/cloud/configuration/ConfigurationManagerImpl.java
@@ -475,14 +475,8 @@ public class ConfigurationManagerImpl extends ManagerBase implements
Configurati
                     throw new InvalidParameterValueException("unable to find storage pool
by id " + resourceId);
                 }
                 StoragePoolDetailVO storagePoolDetailVO = _storagePoolDetailsDao.findDetail(resourceId,
name);
-                if (storagePoolDetailVO == null) {
-                    storagePoolDetailVO = new StoragePoolDetailVO(resourceId, name, value);
-                    _storagePoolDetailsDao.persist(storagePoolDetailVO);
-
-                } else {
-                    storagePoolDetailVO.setValue(value);
-                    _storagePoolDetailsDao.update(storagePoolDetailVO.getId(), storagePoolDetailVO);
-                }
+                _storagePoolDetailsDao.addDetail(storagePoolDetailVO);
+                
                 break;
 
             case Account:

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
index 5bfe004..c94f32f 100644
--- a/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
+++ b/server/src/com/cloud/metadata/ResourceMetaDataManagerImpl.java
@@ -26,6 +26,8 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.ResourceDetail;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -77,6 +79,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
     VMTemplateDetailsDao _templateDetailsDao;
     @Inject
     ServiceOfferingDetailsDao _serviceOfferingDetailsDao;
+    @Inject
+    StoragePoolDetailsDao _storageDetailsDao;
     
     private static Map<ResourceObjectType, ResourceDetailDao<? extends ResourceDetail>>
_daoMap= 
             new HashMap<ResourceObjectType, ResourceDetailDao<? extends ResourceDetail>>();
@@ -91,6 +95,8 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
         _daoMap.put(ResourceObjectType.Nic, _nicDetailDao);
         _daoMap.put(ResourceObjectType.ServiceOffering, _serviceOfferingDetailsDao);
         _daoMap.put(ResourceObjectType.Zone, _dcDetailsDao);
+        _daoMap.put(ResourceObjectType.Storage, _storageDetailsDao);
+        
         return true;
     }
 
@@ -138,6 +144,10 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
                         detail = new VMTemplateDetailVO(id, key, value);
                     } else if (resourceType == ResourceObjectType.ServiceOffering) {
                         detail = new ServiceOfferingDetailsVO(id, key, value);
+                    } else if (resourceType == ResourceObjectType.Storage) {
+                        detail = new StoragePoolDetailVO(id, key, value);
+                    } else {
+                        throw new UnsupportedOperationException("ResourceType " + resourceType
+ " doesn't support metadata");
                     }
                     newDetailDaoHelper.addDetail(detail);
                         
@@ -174,6 +184,9 @@ public class ResourceMetaDataManagerImpl extends ManagerBase implements
Resource
         
         private void addDetail(ResourceDetail detail) {
             ResourceDetailDao<ResourceDetail> dao = (ResourceDetailDao<ResourceDetail>)_daoMap.get(resourceType);
+            if (dao == null) {
+                throw new UnsupportedOperationException("ResourceType " + resourceType +
" doesn't support metadata");
+            }
             dao.addDetail(detail);   
         }
         

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/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 75cedd0..fe7863b 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -706,7 +706,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
         Map<String, String> updatedDetails = new HashMap<String, String>();
 
         if (tags != null) {
-            Map<String, String> existingDetails = _storagePoolDetailsDao.getDetails(id);
+            Map<String, String> existingDetails = _storagePoolDetailsDao.findDetails(id);
             Set<String> existingKeys = existingDetails.keySet();
 
             Map<String, String> existingDetailsToKeep = new HashMap<String, String>();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/d0090a0c/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
index 7d7692f..d8d2689 100644
--- a/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
+++ b/server/src/com/cloud/tags/TaggedResourceManagerImpl.java
@@ -26,6 +26,7 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.context.CallContext;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
 
@@ -131,6 +132,8 @@ public class TaggedResourceManagerImpl extends ManagerBase implements
TaggedReso
     DataCenterDao _dataCenterDao;
     @Inject
     ServiceOfferingDao _serviceOffDao;
+    @Inject
+    PrimaryDataStoreDao _storagePoolDao;
 
 
     @Override
@@ -155,6 +158,8 @@ public class TaggedResourceManagerImpl extends ManagerBase implements
TaggedReso
         _daoMap.put(ResourceObjectType.RemoteAccessVpn, _vpnDao);
         _daoMap.put(ResourceObjectType.Zone, _dataCenterDao);
         _daoMap.put(ResourceObjectType.ServiceOffering, _serviceOffDao);
+        _daoMap.put(ResourceObjectType.Storage, _storagePoolDao);
+
 
         return true;
     }


Mime
View raw message