mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
bug 11690: don't allow to remove the cluster when it's referenced by existing storage pools
status 11690: resolved fixed
This commit is contained in:
parent
1e684beca5
commit
871f1bb6d4
@ -70,7 +70,9 @@ import com.cloud.org.Grouping;
|
||||
import com.cloud.org.Managed;
|
||||
import com.cloud.storage.GuestOSCategoryVO;
|
||||
import com.cloud.storage.StorageManager;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.storage.dao.GuestOSCategoryDao;
|
||||
import com.cloud.storage.dao.StoragePoolDao;
|
||||
import com.cloud.storage.secondary.SecondaryStorageVmManager;
|
||||
import com.cloud.user.Account;
|
||||
import com.cloud.user.AccountManager;
|
||||
@ -115,6 +117,8 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
protected HostTagsDao _hostTagsDao;
|
||||
@Inject
|
||||
protected GuestOSCategoryDao _guestOSCategoryDao;
|
||||
@Inject
|
||||
protected StoragePoolDao _storagePoolDao;
|
||||
|
||||
@Inject(adapter = Discoverer.class)
|
||||
protected Adapters<? extends Discoverer> _discoverers;
|
||||
@ -643,10 +647,21 @@ public class ResourceManagerImpl implements ResourceManager, ResourceService, Ma
|
||||
return true;
|
||||
}
|
||||
|
||||
//don't allow to remove the cluster if it has non-removed hosts
|
||||
List<HostVO> hosts = _hostDao.listByCluster(cmd.getId());
|
||||
if (hosts.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cluster: " + cmd.getId() + " still has hosts");
|
||||
s_logger.debug("Cluster: " + cmd.getId() + " still has hosts, can't remove");
|
||||
}
|
||||
txn.rollback();
|
||||
return false;
|
||||
}
|
||||
|
||||
//don't allow to remove the cluster if it has non-removed storage pools
|
||||
List<StoragePoolVO> storagePools = _storagePoolDao.listPoolsByCluster(cmd.getId());
|
||||
if (storagePools.size() > 0) {
|
||||
if (s_logger.isDebugEnabled()) {
|
||||
s_logger.debug("Cluster: " + cmd.getId() + " still has storage pools, can't remove");
|
||||
}
|
||||
txn.rollback();
|
||||
return false;
|
||||
|
||||
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.cloud.host.Status;
|
||||
import com.cloud.storage.StoragePoolStatus;
|
||||
import com.cloud.storage.StoragePoolVO;
|
||||
import com.cloud.utils.db.GenericDao;
|
||||
@ -106,5 +105,6 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
||||
long countPoolsByStatus(StoragePoolStatus... statuses);
|
||||
|
||||
List<StoragePoolVO> listByStatusInZone(long dcId, StoragePoolStatus status);
|
||||
|
||||
}
|
||||
|
||||
List<StoragePoolVO> listPoolsByCluster(long clusterId);
|
||||
}
|
||||
|
||||
@ -69,6 +69,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
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();
|
||||
@ -363,4 +364,12 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
||||
|
||||
return rs.get(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listPoolsByCluster(long clusterId) {
|
||||
SearchCriteria<StoragePoolVO> sc = AllFieldSearch.create();
|
||||
sc.setParameters("clusterId", clusterId);
|
||||
|
||||
return listBy(sc);
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user