From d72276642728b45d6e22d5d258ac64eb04ac2bcb 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 f25196d9821..db6d5e918ca 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -2095,7 +2095,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; @@ -2161,7 +2161,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); @@ -2201,7 +2200,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); @@ -2227,7 +2225,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 201f9153eab..9aed738278c 100644 --- a/server/src/com/cloud/storage/dao/StoragePoolDao.java +++ b/server/src/com/cloud/storage/dao/StoragePoolDao.java @@ -107,4 +107,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 146d8e9d134..17b1d264f96 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) {