From 771b53b3421fcde27e882a022e4f1b43146ca0e4 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Wed, 16 Jul 2014 16:30:15 -0700 Subject: [PATCH] CLOUDSTACK-4725: if storage pool has different path, but the uuid is the same, then treat them as the same storage pool --- .../storage/datastore/db/PrimaryDataStoreDaoImpl.java | 4 +++- server/src/com/cloud/storage/StorageManagerImpl.java | 9 +++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java index cb8ec31fdbd..0c372a5b99a 100644 --- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java +++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/PrimaryDataStoreDaoImpl.java @@ -184,7 +184,9 @@ public class PrimaryDataStoreDaoImpl extends GenericDaoBase public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) { SearchCriteria sc = AllFieldSearch.create(); sc.setParameters("hostAddress", host); - sc.setParameters("path", path); + if (path != null) { + sc.setParameters("path", path); + } sc.setParameters("datacenterId", datacenterId); sc.setParameters("podId", podId); sc.setParameters("uuid", uuid); diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 06f271852c8..2246387a5e9 100755 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -554,6 +554,15 @@ public class StorageManagerImpl extends ManagerBase implements StorageManager, C pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), "", pInfo.getUuid()); } } + if (pool == null) { + //the path can be different, but if they have the same uuid, assume they are the same storage + pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), null, + pInfo.getUuid()); + if (pool != null) { + s_logger.debug("Found a storage pool: " + pInfo.getUuid() + ", but with different hostpath " + pInfo.getHostPath() + ", still treat it as the same pool"); + } + } + DataStoreProvider provider = dataStoreProviderMgr.getDefaultPrimaryDataStoreProvider(); DataStoreLifeCycle lifeCycle = provider.getDataStoreLifeCycle(); if (pool == null) {