mirror of https://github.com/apache/cloudstack.git
bug 6139: Now we can add the same sp again, once deleted. I removed the unique key constraint on the uuid, and am making the check to ensure uniqueness based on uuid in the java layer.
status 6139: resolved fixed
This commit is contained in:
parent
b12b3bb827
commit
d4bed852c8
|
|
@ -101,5 +101,7 @@ public interface StoragePoolDao extends GenericDao<StoragePoolVO, Long> {
|
|||
List<String> searchForStoragePoolDetails(long poolId, String value);
|
||||
|
||||
long countBy(long podId, Status... statuses);
|
||||
|
||||
List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
protected final SearchBuilder<StoragePoolVO> DeleteLvmSearch;
|
||||
protected final GenericSearchBuilder<StoragePoolVO, Long> MaintenanceCountSearch;
|
||||
|
||||
|
||||
protected final 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.data_center_id = ? and (storage_pool.pod_id = ? or storage_pool.pod_id is null) and (";
|
||||
|
|
@ -144,6 +145,13 @@ public class StoragePoolDaoImpl extends GenericDaoBase<StoragePoolVO, Long> imp
|
|||
return findOneBy(sc);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> findIfDuplicatePoolsExistByUUID(String uuid) {
|
||||
SearchCriteria<StoragePoolVO> sc = UUIDSearch.create();
|
||||
sc.setParameters("uuid", uuid);
|
||||
return listActiveBy(sc);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<StoragePoolVO> listByDataCenterId(long datacenterId) {
|
||||
|
|
|
|||
|
|
@ -1364,7 +1364,7 @@ public class StorageManagerImpl implements StorageManager {
|
|||
}
|
||||
|
||||
List<StoragePoolVO> pools = _storagePoolDao.listPoolByHostPath(storageHost, hostPath);
|
||||
if (!pools.isEmpty()) {
|
||||
if (!pools.isEmpty() && pools.get(0).getRemoved()==null) {
|
||||
Long oldPodId = pools.get(0).getPodId();
|
||||
throw new ResourceInUseException("Storage pool " + uri + " already in use by another pod (id=" + oldPodId + ")", "StoragePool", uri.toASCIIString());
|
||||
}
|
||||
|
|
@ -1379,6 +1379,14 @@ public class StorageManagerImpl implements StorageManager {
|
|||
}
|
||||
long poolId = _storagePoolDao.getNextInSequence(Long.class, "id");
|
||||
String uuid = UUID.nameUUIDFromBytes(new String(storageHost + hostPath).getBytes()).toString();
|
||||
|
||||
List<StoragePoolVO> spHandles = _storagePoolDao.findIfDuplicatePoolsExistByUUID(uuid);
|
||||
if(spHandles!=null && spHandles.size()>0)
|
||||
{
|
||||
s_logger.debug("Another active pool with the same uuid already exists");
|
||||
throw new ResourceInUseException("Another active pool with the same uuid already exists");
|
||||
}
|
||||
|
||||
s_logger.debug("In createPool Setting poolId - " +poolId+ " uuid - " +uuid+ " zoneId - " +zoneId+ " podId - " +podId+ " poolName - " +poolName);
|
||||
pool.setId(poolId);
|
||||
pool.setUuid(uuid);
|
||||
|
|
|
|||
|
|
@ -907,7 +907,7 @@ CREATE TABLE `cloud`.`load_balancer` (
|
|||
CREATE TABLE `cloud`.`storage_pool` (
|
||||
`id` bigint unsigned UNIQUE NOT NULL,
|
||||
`name` varchar(255) COMMENT 'should be NOT NULL',
|
||||
`uuid` varchar(255) UNIQUE NOT NULL,
|
||||
`uuid` varchar(255) NOT NULL,
|
||||
`pool_type` varchar(32) NOT NULL,
|
||||
`port` int unsigned NOT NULL,
|
||||
`data_center_id` bigint unsigned NOT NULL,
|
||||
|
|
|
|||
Loading…
Reference in New Issue