From b1b11a6928096435503a84a0c903eded4b75ea9a Mon Sep 17 00:00:00 2001 From: Edison Su Date: Wed, 21 Sep 2011 16:16:03 -0700 Subject: [PATCH] bug 11047: change the put storage pool into maintenance mode: 1. only look at the available storoge pool in its own dc to decide to start vms created on it. 2. if start vm failed, don't throw exception, as these vms are marked stopped already, admin can start these vm by himself. status 11047: resolved fixed Reviewed-by: frank --- server/src/com/cloud/storage/StorageManagerImpl.java | 5 +---- server/src/com/cloud/storage/dao/StoragePoolDao.java | 2 ++ server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java | 8 ++++++++ 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 15bb604dd8b..5be61d2ff40 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -2097,7 +2097,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag // check to see if other ps exist // if they do, then we can migrate over the system vms to them // if they dont, then just stop all vms on this one - List upPools = _storagePoolDao.listByStatus(StoragePoolStatus.Up); + List upPools = _storagePoolDao.listByStatusInZone(primaryStorage.getDataCenterId(), StoragePoolStatus.Up); if (upPools == null || upPools.size() == 0) { restart = false; @@ -2163,7 +2163,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag if (_vmMgr.advanceStart(consoleProxy, null, user, account) == null) { String errorMsg = "There was an error starting the console proxy id: " + vmInstance.getId() + " on another storage pool, cannot enable primary storage maintenance"; s_logger.warn(errorMsg); - throw new CloudRuntimeException(errorMsg); } else { // update work status work.setStartedAfterMaintenance(true); @@ -2203,7 +2202,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag if (_vmMgr.advanceStart(secStrgVm, null, user, account) == null) { String errorMsg = "There was an error starting the ssvm id: " + vmInstance.getId() + " on another storage pool, cannot enable primary storage maintenance"; s_logger.warn(errorMsg); - throw new CloudRuntimeException(errorMsg); } else { // update work status work.setStartedAfterMaintenance(true); @@ -2229,7 +2227,6 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag if (_vmMgr.advanceStart(domR, null, user, account) == null) { String errorMsg = "There was an error starting the domain router id: " + vmInstance.getId() + " on another storage pool, cannot enable primary storage maintenance"; s_logger.warn(errorMsg); - throw new CloudRuntimeException(errorMsg); } else { // update work status work.setStartedAfterMaintenance(true); diff --git a/server/src/com/cloud/storage/dao/StoragePoolDao.java b/server/src/com/cloud/storage/dao/StoragePoolDao.java index 93beee39ce0..83e01d41d61 100644 --- a/server/src/com/cloud/storage/dao/StoragePoolDao.java +++ b/server/src/com/cloud/storage/dao/StoragePoolDao.java @@ -105,4 +105,6 @@ public interface StoragePoolDao extends GenericDao { long countPoolsByStatus(StoragePoolStatus... statuses); + List listByStatusInZone(long dcId, StoragePoolStatus status); + } diff --git a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java index 025be60cd14..f406348fb85 100644 --- a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java +++ b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java @@ -167,6 +167,14 @@ public class StoragePoolDaoImpl extends GenericDaoBase imp sc.setParameters("status", status); return listBy(sc); } + + @Override + public List listByStatusInZone(long dcId, StoragePoolStatus status){ + SearchCriteria 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) {