cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From edi...@apache.org
Subject [1/2] git commit: updated refs/heads/master to d660bc7
Date Tue, 02 Jul 2013 18:51:39 GMT
Updated Branches:
  refs/heads/master db5d52626 -> d660bc7e8


CLOUDSTACK-2571 Zone Wide Primary Storage blocker issues while Enabling in Maintenance State

Signed-off-by: Edison Su <sudison@gmail.com>


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

Branch: refs/heads/master
Commit: 2bc4cbf9fb20ff770ea672815886e2c6d9cb8276
Parents: db5d526
Author: Rajesh Battala <rajesh.battala@citrix.com>
Authored: Thu Jun 20 16:43:23 2013 +0530
Committer: Edison Su <sudison@gmail.com>
Committed: Tue Jul 2 11:49:16 2013 -0700

----------------------------------------------------------------------
 .../datastore/db/PrimaryDataStoreDao.java       | 17 +++----
 .../datastore/db/PrimaryDataStoreDaoImpl.java   |  4 +-
 .../com/cloud/storage/StorageManagerImpl.java   | 24 +++-------
 .../storage/StoragePoolAutomationImpl.java      | 47 ++++++++++++++++----
 4 files changed, 54 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bc4cbf9/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
index 99b7b9c..669dd25 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDao.java
@@ -30,24 +30,19 @@ import com.cloud.utils.db.GenericDao;
 public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO, Long> {
 
     /**
-     * @param datacenterId
-     *            -- the id of the datacenter (availability zone)
+     * @param datacenterId -- the id of the datacenter (availability zone)
      */
     List<StoragePoolVO> listByDataCenterId(long datacenterId);
 
     /**
-     * @param datacenterId
-     *            -- the id of the datacenter (availability zone)
+     * @param datacenterId -- the id of the datacenter (availability zone)
      */
-    List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId, ScopeType
scope);
+    List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId, ScopeType
scope);
 
     /**
      * Set capacity of storage pool in bytes
-     *
-     * @param id
-     *            pool id.
-     * @param capacity
-     *            capacity in bytes
+     * @param id pool id.
+     * @param capacity capacity in bytes
      */
     void updateCapacity(long id, long capacity);
 
@@ -82,7 +77,7 @@ public interface PrimaryDataStoreDao extends GenericDao<StoragePoolVO,
Long> {
      * @return List of StoragePoolVO
      */
     List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId, Map<String,
String> details,
-            ScopeType scope);
+                                           ScopeType scope);
 
     List<StoragePoolVO> findPoolsByTags(long dcId, long podId, Long clusterId, String[]
tags);
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bc4cbf9/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
index 8f7826f..96e18fc 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java
@@ -194,7 +194,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     }
 
     @Override
-    public List<StoragePoolVO> listBy(long datacenterId, long podId, Long clusterId,
ScopeType scope) {
+    public List<StoragePoolVO> listBy(long datacenterId, Long podId, Long clusterId,
ScopeType scope) {
         if (clusterId != null) {
             SearchCriteria<StoragePoolVO> sc = DcPodSearch.create();
             sc.setParameters("datacenterId", datacenterId);
@@ -249,7 +249,7 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase<StoragePoolVO,
Long>
     @DB
     @Override
     public List<StoragePoolVO> findPoolsByDetails(long dcId, long podId, Long clusterId,
Map<String, String> details,
-            ScopeType scope) {
+                                                  ScopeType scope) {
         StringBuilder sql = new StringBuilder(DetailsSqlPrefix);
         if (clusterId != null) {
             sql.append("storage_pool.cluster_id = ? OR storage_pool.cluster_id IS NULL) AND
(");

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bc4cbf9/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 b64b202..bb21afb 100755
--- a/server/src/com/cloud/storage/StorageManagerImpl.java
+++ b/server/src/com/cloud/storage/StorageManagerImpl.java
@@ -400,7 +400,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
 
     @Override
     public StoragePool findStoragePool(DiskProfile dskCh, final DataCenterVO dc, HostPodVO
pod, Long clusterId, Long hostId, VMInstanceVO vm,
-            final Set<StoragePool> avoid) {
+                                       final Set<StoragePool> avoid) {
 
         VirtualMachineProfile<VMInstanceVO> profile = new VirtualMachineProfileImpl<VMInstanceVO>(vm);
         for (StoragePoolAllocator allocator : _storagePoolAllocators) {
@@ -637,7 +637,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     @Override
     @SuppressWarnings("rawtypes")
     public PrimaryDataStoreInfo createPool(CreateStoragePoolCmd cmd) throws ResourceInUseException,
IllegalArgumentException, UnknownHostException,
-    ResourceUnavailableException {
+            ResourceUnavailableException {
         String providerName = cmd.getStorageProviderName();
         DataStoreProvider storeProvider = dataStoreProviderMgr.getDataStoreProvider(providerName);
 
@@ -1181,14 +1181,13 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
     @Override
     @DB
     public PrimaryDataStoreInfo preparePrimaryStorageForMaintenance(Long primaryStorageId)
throws ResourceUnavailableException,
-    InsufficientCapacityException {
+            InsufficientCapacityException {
         Long userId = UserContext.current().getCallerUserId();
         User user = _userDao.findById(userId);
         Account account = UserContext.current().getCaller();
 
         boolean restart = true;
         StoragePoolVO primaryStorage = null;
-
         primaryStorage = _storagePoolDao.findById(primaryStorageId);
 
         if (primaryStorage == null) {
@@ -1197,15 +1196,6 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
             throw new InvalidParameterValueException(msg);
         }
 
-        List<StoragePoolVO> spes = _storagePoolDao.listBy(primaryStorage.getDataCenterId(),
primaryStorage.getPodId(), primaryStorage.getClusterId(),
-                ScopeType.CLUSTER);
-        for (StoragePoolVO sp : spes) {
-            if (sp.getStatus() == StoragePoolStatus.PrepareForMaintenance) {
-                throw new CloudRuntimeException("Only one storage pool in a cluster can be
in PrepareForMaintenance mode, " + sp.getId()
-                        + " is already in  PrepareForMaintenance mode ");
-            }
-        }
-
         if (!primaryStorage.getStatus().equals(StoragePoolStatus.Up) && !primaryStorage.getStatus().equals(StoragePoolStatus.ErrorInMaintenance))
{
             throw new InvalidParameterValueException("Primary storage with id " + primaryStorageId
+ " is not ready for migration, as the status is:"
                     + primaryStorage.getStatus().toString());
@@ -1285,8 +1275,8 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
                         // check if pool is in an inconsistent state
                         if (pool != null
                                 && (pool.getStatus().equals(StoragePoolStatus.ErrorInMaintenance)
-                                        || pool.getStatus().equals(StoragePoolStatus.PrepareForMaintenance)
|| pool.getStatus().equals(
-                                                StoragePoolStatus.CancelMaintenance))) {
+                                || pool.getStatus().equals(StoragePoolStatus.PrepareForMaintenance)
|| pool.getStatus().equals(
+                                StoragePoolStatus.CancelMaintenance))) {
                             _storagePoolWorkDao.removePendingJobsOnMsRestart(vo.getMsid(),
poolId);
                             pool.setStatus(StoragePoolStatus.ErrorInMaintenance);
                             _storagePoolDao.update(poolId, pool);
@@ -1496,7 +1486,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
 
     @Override
     public boolean storagePoolHasEnoughIops(List<Volume> requestedVolumes,
-            StoragePool pool) {
+                                            StoragePool pool) {
         if (requestedVolumes == null || requestedVolumes.isEmpty() || pool == null) {
             return false;
         }
@@ -1530,7 +1520,7 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager,
C
 
     @Override
     public boolean storagePoolHasEnoughSpace(List<Volume> volumes,
-            StoragePool pool) {
+                                             StoragePool pool) {
         if (volumes == null || volumes.isEmpty()){
             return false;
         }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2bc4cbf9/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
index 4001775..b2cb1f5 100644
--- a/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
+++ b/server/src/com/cloud/storage/StoragePoolAutomationImpl.java
@@ -18,6 +18,7 @@
  */
 package com.cloud.storage;
 
+import java.util.ArrayList;
 import java.util.List;
 
 import javax.inject.Inject;
@@ -27,6 +28,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreLifeCycle;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreManager;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProvider;
 import org.apache.cloudstack.engine.subsystem.api.storage.DataStoreProviderManager;
+import org.apache.cloudstack.engine.subsystem.api.storage.Scope;
 import org.apache.cloudstack.storage.datastore.db.PrimaryDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.StoragePoolVO;
 import org.apache.log4j.Logger;
@@ -36,8 +38,10 @@ import com.cloud.agent.AgentManager;
 import com.cloud.agent.api.Answer;
 import com.cloud.agent.api.ModifyStoragePoolCommand;
 import com.cloud.alert.AlertManager;
+import com.cloud.host.Host;
 import com.cloud.host.HostVO;
 import com.cloud.host.Status;
+import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.resource.ResourceManager;
 import com.cloud.server.ManagementServer;
 import com.cloud.storage.dao.StoragePoolHostDao;
@@ -101,7 +105,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
     @Inject
     ManagementServer server;
     @Inject DataStoreProviderManager providerMgr;
-    
+
     @Override
     public boolean maintain(DataStore store) {
         Long userId = UserContext.current().getCallerUserId();
@@ -109,9 +113,37 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
         Account account = UserContext.current().getCaller();
         StoragePoolVO pool = this.primaryDataStoreDao.findById(store.getId());
         try {
+            List<StoragePoolVO> spes = null;
+            // Handling Zone and Cluster wide storage scopes.
+            // if the storage is ZONE wide then we pass podid and cluster id as null as they
will be empty for ZWPS 
+            if (pool.getScope() == ScopeType.ZONE) {
+                spes = primaryDataStoreDao.listBy(
+                        pool.getDataCenterId(), null,
+                        null, ScopeType.ZONE);
+            }
+            else {
+                spes = primaryDataStoreDao.listBy(
+                        pool.getDataCenterId(), pool.getPodId(),
+                        pool.getClusterId(), ScopeType.CLUSTER);
+            }
+            for (StoragePoolVO sp : spes) {
+                if (sp.getStatus() == StoragePoolStatus.PrepareForMaintenance) {
+                    throw new CloudRuntimeException("Only one storage pool in a cluster can
be in PrepareForMaintenance mode, " + sp.getId()
+                            + " is already in  PrepareForMaintenance mode ");
+                }
+            }
             StoragePool storagePool = (StoragePool) store;
-            List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(
-                    pool.getClusterId(), Status.Up);
+
+            //Handeling the Zone wide and cluster wide primay storage
+            List<HostVO> hosts = new ArrayList<HostVO>();
+            // if the storage scope is ZONE wide, then get all the hosts for which hypervisor
ZWSP created to send Modifystoragepoolcommand
+            if (pool.getScope().equals(ScopeType.ZONE)) {
+                hosts = _resourceMgr.listAllUpAndEnabledHostsInOneZoneByHypervisor(pool.getHypervisor()
, pool.getDataCenterId());
+            } else {
+                hosts = _resourceMgr.listHostsInClusterByStatus(
+                        pool.getClusterId(), Status.Up);
+            }
+
             if (hosts == null || hosts.size() == 0) {
                 pool.setStatus(StoragePoolStatus.Maintenance);
                 primaryDataStoreDao.update(pool.getId(), pool);
@@ -130,11 +162,11 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
                     if (s_logger.isDebugEnabled()) {
                         s_logger.debug("ModifyStoragePool false failed due to "
                                 + ((answer == null) ? "answer null" : answer
-                                        .getDetails()));
+                                .getDetails()));
                     }
                 } else {
                     if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("ModifyStoragePool false secceeded");
+                        s_logger.debug("ModifyStoragePool false succeeded");
                     }
                 }
             }
@@ -314,7 +346,6 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
                     }
                 }
             }
-            
         } catch(Exception e) {
             s_logger.error(
                     "Exception in enabling primary storage maintenance:", e);
@@ -334,7 +365,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
         StoragePoolVO poolVO = this.primaryDataStoreDao
                 .findById(store.getId());
         StoragePool pool = (StoragePool)store;
-       
+
         List<HostVO> hosts = _resourceMgr.listHostsInClusterByStatus(
                 pool.getClusterId(), Status.Up);
         if (hosts == null || hosts.size() == 0) {
@@ -349,7 +380,7 @@ public class StoragePoolAutomationImpl implements StoragePoolAutomation
{
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("ModifyStoragePool add failed due to "
                             + ((answer == null) ? "answer null" : answer
-                                    .getDetails()));
+                            .getDetails()));
                 }
             } else {
                 if (s_logger.isDebugEnabled()) {


Mime
View raw message