incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/2] CLOUDSTACK-1426: We has strong implication that VO must implement an interface, otherwise EntityManagerImpl can't the vo
Date Fri, 08 Mar 2013 02:26:16 GMT
http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
deleted file mode 100644
index 28b4dbc..0000000
--- a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java
+++ /dev/null
@@ -1,432 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage.dao;
-
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import javax.ejb.Local;
-import javax.inject.Inject;
-import javax.naming.ConfigurationException;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
-import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
-import org.springframework.stereotype.Component;
-
-import com.cloud.host.Status;
-import com.cloud.storage.StoragePoolDetailVO;
-import com.cloud.storage.StoragePoolStatus;
-import com.cloud.utils.db.DB;
-import com.cloud.utils.db.GenericDaoBase;
-import com.cloud.utils.db.GenericSearchBuilder;
-import com.cloud.utils.db.SearchBuilder;
-import com.cloud.utils.db.SearchCriteria;
-import com.cloud.utils.db.SearchCriteria.Func;
-import com.cloud.utils.db.SearchCriteria.Op;
-import com.cloud.utils.db.SearchCriteria2;
-import com.cloud.utils.db.SearchCriteriaService;
-import com.cloud.utils.db.Transaction;
-import com.cloud.utils.exception.CloudRuntimeException;
-
-@Component
-@Local(value={StoragePoolDao.class}) @DB(txn=false)
-public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long>  implements
StoragePoolDao {
-    protected final SearchBuilder<StoragePoolVO> AllFieldSearch;
-	protected final SearchBuilder<StoragePoolVO> DcPodSearch;
-    protected final SearchBuilder<StoragePoolVO> DcPodAnyClusterSearch;
-    protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
-    protected final GenericSearchBuilder<StoragePoolVO, Long> StatusCountSearch;
-
-    
-    
-    @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) >= ?";
-	private final String ZoneWideDetailsSqlPrefix = "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.scope
= ? and (";
-	private final String ZoneWideDetailsSqlSuffix = ") GROUP BY storage_pool_details.pool_id
HAVING COUNT(storage_pool_details.name) >= ?";
-		
-	private final String FindPoolTagDetails = "SELECT storage_pool_details.name FROM storage_pool_details
WHERE pool_id = ? and value = ?";
-	
-    protected StoragePoolDaoImpl() {
-        AllFieldSearch = createSearchBuilder();
-        AllFieldSearch.and("name", AllFieldSearch.entity().getName(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("uuid", AllFieldSearch.entity().getUuid(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("datacenterId", AllFieldSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("hostAddress", AllFieldSearch.entity().getHostAddress(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("status",AllFieldSearch.entity().getStatus(),SearchCriteria.Op.EQ);
-        AllFieldSearch.and("path", AllFieldSearch.entity().getPath(), SearchCriteria.Op.EQ);
-        AllFieldSearch.and("podId", AllFieldSearch.entity().getPodId(), Op.EQ);
-        AllFieldSearch.and("clusterId", AllFieldSearch.entity().getClusterId(), Op.EQ);
-        AllFieldSearch.done();  
-        
-    	DcPodSearch = createSearchBuilder();
-    	DcPodSearch.and("datacenterId", DcPodSearch.entity().getDataCenterId(), SearchCriteria.Op.EQ);
-    	DcPodSearch.and("status", DcPodSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-    	DcPodSearch.and("scope", DcPodSearch.entity().getScope(), SearchCriteria.Op.EQ);
-    	DcPodSearch.and().op("nullpod", DcPodSearch.entity().getPodId(), SearchCriteria.Op.NULL);
-    	DcPodSearch.or("podId", DcPodSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-    	DcPodSearch.cp();
-    	DcPodSearch.and().op("nullcluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.NULL);
-    	DcPodSearch.or("cluster", DcPodSearch.entity().getClusterId(), SearchCriteria.Op.EQ);
-    	DcPodSearch.cp();
-    	DcPodSearch.done();
-    	
-    	DcPodAnyClusterSearch = createSearchBuilder();
-        DcPodAnyClusterSearch.and("datacenterId", DcPodAnyClusterSearch.entity().getDataCenterId(),
SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.and("status", DcPodAnyClusterSearch.entity().getStatus(), SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.and("scope", DcPodAnyClusterSearch.entity().getScope(), SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.and().op("nullpod", DcPodAnyClusterSearch.entity().getPodId(),
SearchCriteria.Op.NULL);
-        DcPodAnyClusterSearch.or("podId", DcPodAnyClusterSearch.entity().getPodId(), SearchCriteria.Op.EQ);
-        DcPodAnyClusterSearch.cp();
-        DcPodAnyClusterSearch.done();
-        
-        DeleteLvmSearch = createSearchBuilder();
-        DeleteLvmSearch.and("ids", DeleteLvmSearch.entity().getId(), SearchCriteria.Op.IN);
-        DeleteLvmSearch.and().op("LVM", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
-        DeleteLvmSearch.or("Filesystem", DeleteLvmSearch.entity().getPoolType(), SearchCriteria.Op.EQ);
-        DeleteLvmSearch.cp();
-        DeleteLvmSearch.done();        
-
-        
-        
-        StatusCountSearch = createSearchBuilder(Long.class);
-        StatusCountSearch.and("status", StatusCountSearch.entity().getStatus(), SearchCriteria.Op.IN);
-        StatusCountSearch.select(null, Func.COUNT, null);
-        StatusCountSearch.done();
-
-    }
-    
-	@Override
-	public List<StoragePoolVO> findPoolByName(String name) {
-		SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("name", name);
-        return listIncludingRemovedBy(sc);
-	}
-
-
-	@Override
-	public StoragePoolVO findPoolByUUID(String uuid) {
-		SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("uuid", uuid);
-        return findOneIncludingRemovedBy(sc);
-	}
-	
-	
-
-	@Override
-	public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
-		SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("uuid", uuid);
-        return listBy(sc);
-	}
-
-
-	@Override
-	public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
-		SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("datacenterId", datacenterId);
-        return listBy(sc);
-	}
-
-
-	@Override
-	public void updateAvailable(long id, long available) {
-		StoragePoolVO pool = createForUpdate(id);
-		pool.setAvailableBytes(available);
-		update(id, pool);
-	}
-
-
-	@Override
-	public void updateCapacity(long id, long capacity) {
-		StoragePoolVO pool = createForUpdate(id);
-		pool.setCapacityBytes(capacity);
-		update(id, pool);
-
-	}
-	
-    @Override
-    public List<StoragePoolVO> listByStorageHost(String hostFqdnOrIp) {
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", hostFqdnOrIp);
-        return listIncludingRemovedBy(sc);
-    }
-    
-    @Override
-    public List<StoragePoolVO> listByStatus(StoragePoolStatus status){
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-    	sc.setParameters("status", status);
-    	return listBy(sc);
-    }
-    
-    @Override
-    public List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status){
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-    	sc.setParameters("status", status);
-    	sc.setParameters("datacenterId", dcId);
-    	return listBy(sc);
-    }
-
-    @Override
-    public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String
path, String uuid) {
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", host);
-        sc.setParameters("path", path);
-        sc.setParameters("datacenterId", datacenterId);
-        sc.setParameters("podId", podId);
-        sc.setParameters("uuid", uuid);
-        
-        return findOneBy(sc);
-    }
-
-	@Override
-	public List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType
scope) {
-	    if (clusterId != null) {
-    		SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
-            sc.setParameters("datacenterId", datacenterId);
-            sc.setParameters("podId", podId);
-            sc.setParameters("status", Status.Up);
-            sc.setParameters("scope", scope);
-           
-            sc.setParameters("cluster", clusterId);
-            return listBy(sc);
-	    } else {
-	        SearchCriteria<StoragePoolVO> sc = DcPodAnyClusterSearch.create();
-	        sc.setParameters("datacenterId", datacenterId);
-	        sc.setParameters("podId", podId);
-	        sc.setParameters("status", Status.Up);
-	        sc.setParameters("scope", scope);
-	        return listBy(sc);
-	    }
-	}
-
-	@Override
-	public List<StoragePoolVO> listPoolByHostPath(String host, String path) {
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("hostAddress", host);
-        sc.setParameters("path", path);
-        
-        return listBy(sc);
-	}
-	
-	public StoragePoolVO listById(Integer id)
-	{
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("id", id);
-        
-        return findOneIncludingRemovedBy(sc);
-	}
-	
-	@Override @DB
-	public StoragePoolVO persist(StoragePoolVO pool, Map<String, String> details) {
-	    Transaction txn = Transaction.currentTxn();
-	    txn.start();
-	    pool = super.persist(pool);
-	    if (details != null) {
-    	    for (Map.Entry<String, String> detail : details.entrySet()) {
-    	        StoragePoolDetailVO vo = new StoragePoolDetailVO(pool.getId(), detail.getKey(),
detail.getValue());
-    	        _detailsDao.persist(vo);
-    	    }
-        }
-	    txn.commit();
-	    return pool;
-	}
-	
-	@DB
-	@Override
-	public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId,
Map<String, String> details, ScopeType scope) {
-	    StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
-	    if (clusterId != null) {
-	        sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND
(");
-	    }
-	    
-	    for (Map.Entry<String, String> detail : details.entrySet()) {
-	        sql.append("((storage_pool_details.name='").append(detail.getKey()).append("') AND
(storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
-	    }
-	    sql.delete(sql.length() - 4, sql.length());
-	    sql.append(DetailsSqlSuffix);
-	    Transaction txn = Transaction.currentTxn();
-	    PreparedStatement pstmt = null;
-	    try {
-	        pstmt = txn.prepareAutoCloseStatement(sql.toString());
-	        int i = 1;
-	        pstmt.setLong(i++, dcId);
-	        pstmt.setLong(i++, podId);
-	        pstmt.setString(i++, scope.toString());
-	        if (clusterId != null) {
-	            pstmt.setLong(i++, clusterId);
-	        }
-	        pstmt.setInt(i++, details.size());
-	        ResultSet rs = pstmt.executeQuery();
-	        List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
-	        while (rs.next()) {
-	            pools.add(toEntityBean(rs, false));
-	        }
-	        return pools;
-	    } catch (SQLException e) {
-	        throw new CloudRuntimeException("Unable to execute " + pstmt, e);
-	    }
-	}
-	
-	protected Map<String, String> tagsToDetails(String[] tags) {
-	    Map<String, String> details = new HashMap<String, String>(tags.length);
-	    for (String tag: tags) {
-	        details.put(tag, "true");
-	    }
-	    return details;
-	}
-	
-	@Override
-	public List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId,
String[] tags) {
-		List<StoragePoolVO> storagePools = null;
-	    if (tags == null || tags.length == 0) {
-	        storagePools = listBy(dcId, podId, clusterId, ScopeType.CLUSTER);
-	    } else {
-	        Map<String, String> details = tagsToDetails(tags);
-	        storagePools =  findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.CLUSTER);
-	    }
-
-	    return storagePools;
-	}
-	
-	@Override
-	public List<StoragePoolVO> findLocalStoragePoolsByTags(long dcId, long podId, Long
clusterId, String[] tags) {
-		List<StoragePoolVO> storagePools = null;
-	    if (tags == null || tags.length == 0) {
-	        storagePools = listBy(dcId, podId, clusterId, ScopeType.HOST);
-	    } else {
-	        Map<String, String> details = tagsToDetails(tags);
-	        storagePools =  findPoolsByDetails(dcId, podId, clusterId, details, ScopeType.HOST);
-	    }
-
-	    return storagePools;
-	}
-	
-	@Override
-	public List<StoragePoolVO> findZoneWideStoragePoolsByTags(long dcId, String[] tags)
{
-		List<StoragePoolVO> storagePools = null;
-	    if (tags == null || tags.length == 0) {
-	    	SearchCriteriaService<StoragePoolVO, StoragePoolVO> sc =  SearchCriteria2.create(StoragePoolVO.class);
-	    	sc.addAnd(sc.getEntity().getDataCenterId(), Op.EQ, dcId);
-	    	sc.addAnd(sc.getEntity().getStatus(), Op.EQ, Status.Up);
-	    	sc.addAnd(sc.getEntity().getScope(), Op.EQ, ScopeType.ZONE);
-	    	return sc.list();
-	    } else {
-	        Map<String, String> details = tagsToDetails(tags);
-	        
-	        StringBuilder sql = new StringBuilder(ZoneWideDetailsSqlPrefix);
-		    
-		    for (Map.Entry<String, String> detail : details.entrySet()) {
-		        sql.append("((storage_pool_details.name='").append(detail.getKey()).append("')
AND (storage_pool_details.value='").append(detail.getValue()).append("')) OR ");
-		    }
-		    sql.delete(sql.length() - 4, sql.length());
-		    sql.append(ZoneWideDetailsSqlSuffix);
-		    Transaction txn = Transaction.currentTxn();
-		    PreparedStatement pstmt = null;
-		    try {
-		        pstmt = txn.prepareAutoCloseStatement(sql.toString());
-		        int i = 1;
-		        pstmt.setLong(i++, dcId);
-		        pstmt.setString(i++, ScopeType.ZONE.toString());
-		        pstmt.setInt(i++, details.size());
-		        ResultSet rs = pstmt.executeQuery();
-		        List<StoragePoolVO> pools = new ArrayList<StoragePoolVO>();
-		        while (rs.next()) {
-		            pools.add(toEntityBean(rs, false));
-		        }
-		        return pools;
-		    } catch (SQLException e) {
-		        throw new CloudRuntimeException("Unable to execute " + pstmt, e);
-		    }
-	    }
-	}
-	
-	@Override
-	@DB
-	public List<String> searchForStoragePoolDetails(long poolId, String value){
-		
-	    StringBuilder sql = new StringBuilder(FindPoolTagDetails);
-
-	    Transaction txn = Transaction.currentTxn();
-		PreparedStatement pstmt = null;
-	    try {
-	        pstmt = txn.prepareAutoCloseStatement(sql.toString());
-	        pstmt.setLong(1, poolId);
-	        pstmt.setString(2, value);
-
-	        ResultSet rs = pstmt.executeQuery();
-	        List<String> tags = new ArrayList<String>();
-
-	        while (rs.next()) {
-	            tags.add(rs.getString("name"));
-	        }
-	        return tags;
-	    } catch (SQLException e) {
-	        throw new CloudRuntimeException("Unable to execute " + pstmt.toString(), e);
-	    }
-
-	}
-	
-	@Override
-	public void updateDetails(long poolId, Map<String, String> details) {
-	    if (details != null) {
-	        _detailsDao.update(poolId, details);
-	    }
-    }
-	
-	@Override
-	public Map<String, String> getDetails(long poolId) {
-		return _detailsDao.getDetails(poolId);
-	}
-    
-	@Override
-    public boolean configure(String name, Map<String, Object> params) throws ConfigurationException
{
-	    super.configure(name, params);
-	    _detailsDao.configure("DetailsDao", params);
-	    return true;
-	}
-	
-    
-    
-    @Override
-    public long countPoolsByStatus( StoragePoolStatus... statuses) {
-        SearchCriteria<Long> sc = StatusCountSearch.create();
-        
-        sc.setParameters("status", (Object[])statuses);
-        
-        List<Long> rs = customSearchIncludingRemoved(sc, null);
-        if (rs.size() == 0) {
-            return 0;
-        }
-        
-        return rs.get(0);
-    }
-    
-    @Override
-    public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
-        SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
-        sc.setParameters("clusterId", clusterId);
-        
-        return listBy(sc);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/storage/dao/StoragePoolDetailsDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/StoragePoolDetailsDao.java b/server/src/com/cloud/storage/dao/StoragePoolDetailsDao.java
deleted file mode 100644
index 34aa87f..0000000
--- a/server/src/com/cloud/storage/dao/StoragePoolDetailsDao.java
+++ /dev/null
@@ -1,28 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-package com.cloud.storage.dao;
-
-import java.util.Map;
-
-import com.cloud.storage.StoragePoolDetailVO;
-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);
-}

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
index 8cc5d7b..0d797ed 100644
--- a/server/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/StoragePoolDetailsDaoImpl.java
@@ -22,9 +22,10 @@ import java.util.Map;
 
 import javax.ejb.Local;
 
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailVO;
+import org.apache.cloudstack.storage.datastore.db.StoragePoolDetailsDao;
 import org.springframework.stereotype.Component;
 
-import com.cloud.storage.StoragePoolDetailVO;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/storage/listener/StoragePoolMonitor.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/listener/StoragePoolMonitor.java b/server/src/com/cloud/storage/listener/StoragePoolMonitor.java
index df2df7b..f957ca3 100755
--- a/server/src/com/cloud/storage/listener/StoragePoolMonitor.java
+++ b/server/src/com/cloud/storage/listener/StoragePoolMonitor.java
@@ -20,6 +20,7 @@ import java.util.List;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.engine.subsystem.api.storage.ScopeType;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.log4j.Logger;
@@ -75,7 +76,8 @@ public class StoragePoolMonitor implements Listener {
             StartupRoutingCommand scCmd = (StartupRoutingCommand)cmd;
             if (scCmd.getHypervisorType() == HypervisorType.XenServer || scCmd.getHypervisorType()
==  HypervisorType.KVM ||
                     scCmd.getHypervisorType() == HypervisorType.VMware || scCmd.getHypervisorType()
==  HypervisorType.Simulator || scCmd.getHypervisorType() == HypervisorType.Ovm) {
-                List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(),
host.getPodId(), host.getClusterId());
+                List<StoragePoolVO> pools = _poolDao.listBy(host.getDataCenterId(),
host.getPodId(), host.getClusterId(), ScopeType.CLUSTER);
+                pools.addAll(_poolDao.findZoneWideStoragePoolsByTags(host.getDataCenterId(),
null));
                 for (StoragePoolVO pool : pools) {
                     if (pool.getStatus() != StoragePoolStatus.Up) {
                         continue;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
index ed48bd1..bacca01 100755
--- a/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
+++ b/server/src/com/cloud/storage/snapshot/SnapshotManagerImpl.java
@@ -37,6 +37,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.SnapshotStrategy;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -92,7 +93,6 @@ import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.SnapshotDao;
 import com.cloud.storage.dao.SnapshotPolicyDao;
 import com.cloud.storage.dao.SnapshotScheduleDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.storage.s3.S3Manager;
@@ -158,7 +158,7 @@ public class SnapshotManagerImpl extends ManagerBase implements SnapshotManager,
     @Inject
     protected SnapshotDao _snapshotDao;
     @Inject
-    protected StoragePoolDao _storagePoolDao;
+    protected PrimaryDataStoreDao _storagePoolDao;
     @Inject
     protected EventDao _eventDao;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index 29659d3..d843dbc 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -66,6 +66,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.VolumeDataFactory;
 import org.apache.cloudstack.engine.subsystem.api.storage.VolumeInfo;
 import org.apache.cloudstack.engine.subsystem.api.storage.ZoneScope;
 import org.apache.cloudstack.framework.async.AsyncCallFuture;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -143,7 +144,6 @@ import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.LaunchPermissionDao;
 import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.StoragePoolHostDao;
 import com.cloud.storage.dao.UploadDao;
 import com.cloud.storage.dao.VMTemplateDao;
@@ -197,7 +197,7 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
     @Inject
     protected VMTemplateDetailsDao _templateDetailsDao;
     @Inject VMInstanceDao _vmInstanceDao;
-    @Inject StoragePoolDao _poolDao;
+    @Inject PrimaryDataStoreDao _poolDao;
     @Inject StoragePoolHostDao _poolHostDao;
     @Inject EventDao _eventDao;
     @Inject DownloadMonitor _downloadMonitor;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index ca9c13f..6b2f762 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -52,6 +52,7 @@ import org.apache.cloudstack.api.command.user.vmgroup.CreateVMGroupCmd;
 import org.apache.cloudstack.api.command.user.vmgroup.DeleteVMGroupCmd;
 import org.apache.cloudstack.engine.cloud.entity.api.VirtualMachineEntity;
 import org.apache.cloudstack.engine.service.api.OrchestrationService;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.log4j.Logger;
 
@@ -180,7 +181,6 @@ import com.cloud.storage.dao.DiskOfferingDao;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VMTemplateDetailsDao;
 import com.cloud.storage.dao.VMTemplateHostDao;
@@ -317,7 +317,7 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager,
Use
     @Inject
     protected ClusterDao _clusterDao;
     @Inject
-    protected StoragePoolDao _storagePoolDao;
+    protected PrimaryDataStoreDao _storagePoolDao;
     @Inject
     protected SecurityGroupManager _securityGroupMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
index f8448c0..0aeef0e 100755
--- a/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
+++ b/server/src/com/cloud/vm/VirtualMachineManagerImpl.java
@@ -37,6 +37,8 @@ import javax.inject.Inject;
 import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
+
 import com.cloud.dc.*;
 import org.apache.log4j.Logger;
 
@@ -128,7 +130,6 @@ import com.cloud.storage.VolumeManager;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSCategoryDao;
 import com.cloud.storage.dao.GuestOSDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VMTemplateDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.user.Account;
@@ -216,7 +217,7 @@ public class VirtualMachineManagerImpl extends ManagerBase implements
VirtualMac
     @Inject
     protected DataCenterDao _dcDao;
     @Inject
-    protected StoragePoolDao _storagePoolDao;
+    protected PrimaryDataStoreDao _storagePoolDao;
     @Inject
     protected HypervisorGuruManager _hvGuruMgr;
     @Inject

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
index 01f3dd3..12a0597 100644
--- a/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
+++ b/server/src/com/cloud/vm/snapshot/VMSnapshotManagerImpl.java
@@ -29,6 +29,7 @@ import javax.naming.ConfigurationException;
 
 import org.apache.cloudstack.api.command.user.vmsnapshot.ListVMSnapshotCmd;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -67,7 +68,6 @@ import com.cloud.storage.StoragePool;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -114,7 +114,7 @@ public class VMSnapshotManagerImpl extends ManagerBase implements VMSnapshotMana
     @Inject HypervisorGuruManager _hvGuruMgr;
     @Inject AccountManager _accountMgr;
     @Inject GuestOSDao _guestOSDao;
-    @Inject StoragePoolDao _storagePoolDao;
+    @Inject PrimaryDataStoreDao _storagePoolDao;
     @Inject SnapshotDao _snapshotDao;
     @Inject VirtualMachineManager _itMgr;
     @Inject DataStoreManager dataStoreMgr;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/test/com/cloud/storage/dao/StoragePoolDaoTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/storage/dao/StoragePoolDaoTest.java b/server/test/com/cloud/storage/dao/StoragePoolDaoTest.java
index e79f582..eea61a1 100644
--- a/server/test/com/cloud/storage/dao/StoragePoolDaoTest.java
+++ b/server/test/com/cloud/storage/dao/StoragePoolDaoTest.java
@@ -18,6 +18,7 @@ package com.cloud.storage.dao;
 
 import javax.inject.Inject;
 
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.test.context.ContextConfiguration;
@@ -30,7 +31,7 @@ import com.cloud.storage.StoragePoolStatus;
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = "classpath:/StoragePoolDaoTestContext.xml")
 public class StoragePoolDaoTest extends TestCase {
-    @Inject StoragePoolDaoImpl dao;
+    @Inject PrimaryDataStoreDaoImpl dao;
 
     @Test
     public void testCountByStatus() {

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java b/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
index 60161dc..de0a4ed 100644
--- a/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
+++ b/server/test/com/cloud/storage/dao/StoragePoolDaoTestConfiguration.java
@@ -19,6 +19,7 @@ package com.cloud.storage.dao;
 
 import java.io.IOException;
 
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDaoImpl;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.ComponentScan.Filter;
 import org.springframework.context.annotation.Configuration;
@@ -31,7 +32,7 @@ import com.cloud.utils.component.SpringComponentScanUtils;
 
 @Configuration
 @ComponentScan(basePackageClasses={
-        StoragePoolDaoImpl.class,
+        PrimaryDataStoreDaoImpl.class,
         StoragePoolDetailsDaoImpl.class},
         includeFilters={@Filter(value=StoragePoolDaoTestConfiguration.Library.class, type=FilterType.CUSTOM)},
         useDefaultFilters=false

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/409ec9c6/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
index 6fc6404..a238e52 100644
--- a/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
+++ b/server/test/com/cloud/vm/snapshot/VMSnapshotManagerTest.java
@@ -29,6 +29,7 @@ import java.util.List;
 
 import org.apache.cloudstack.acl.ControlledEntity;
 import org.apache.cloudstack.acl.SecurityChecker.AccessType;
+import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mock;
@@ -53,7 +54,6 @@ import com.cloud.storage.SnapshotVO;
 import com.cloud.storage.VolumeVO;
 import com.cloud.storage.dao.GuestOSDao;
 import com.cloud.storage.dao.SnapshotDao;
-import com.cloud.storage.dao.StoragePoolDao;
 import com.cloud.storage.dao.VolumeDao;
 import com.cloud.user.Account;
 import com.cloud.user.AccountManager;
@@ -84,7 +84,7 @@ public class VMSnapshotManagerTest {
     @Mock HypervisorGuruManager _hvGuruMgr;
     @Mock AccountManager _accountMgr;
     @Mock GuestOSDao _guestOSDao;
-    @Mock StoragePoolDao _storagePoolDao;
+    @Mock PrimaryDataStoreDao _storagePoolDao;
     @Mock SnapshotDao _snapshotDao;
     @Mock VirtualMachineManager _itMgr;
     @Mock ConfigurationDao _configDao;


Mime
View raw message