From 2279f8f9620afe558043130914f52a1bb901a4f0 Mon Sep 17 00:00:00 2001 From: Edison Su Date: Thu, 26 May 2011 22:59:56 -0400 Subject: [PATCH] fix register local storage: if host is reinstalled, local storage uuid is changed, we need to register a new local storage in db --- server/src/com/cloud/storage/LocalStoragePoolListener.java | 2 +- server/src/com/cloud/storage/dao/StoragePoolDao.java | 2 +- server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java | 6 +++++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/server/src/com/cloud/storage/LocalStoragePoolListener.java b/server/src/com/cloud/storage/LocalStoragePoolListener.java index da7e045e62c..e99e89cbc2e 100644 --- a/server/src/com/cloud/storage/LocalStoragePoolListener.java +++ b/server/src/com/cloud/storage/LocalStoragePoolListener.java @@ -82,7 +82,7 @@ public class LocalStoragePoolListener implements Listener { } try { - StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath()); + StoragePoolVO pool = _storagePoolDao.findPoolByHostPath(host.getDataCenterId(), host.getPodId(), pInfo.getHost(), pInfo.getHostPath(), pInfo.getUuid()); if (pool == null) { long poolId = _storagePoolDao.getNextInSequence(Long.class, "id"); String name = cmd.getName() == null ? (host.getName() + " Local Storage") : cmd.getName(); diff --git a/server/src/com/cloud/storage/dao/StoragePoolDao.java b/server/src/com/cloud/storage/dao/StoragePoolDao.java index 6b90267fe32..f33e26a6e0d 100644 --- a/server/src/com/cloud/storage/dao/StoragePoolDao.java +++ b/server/src/com/cloud/storage/dao/StoragePoolDao.java @@ -89,7 +89,7 @@ public interface StoragePoolDao extends GenericDao { List listByStorageHost(String hostFqdnOrIp); - StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path); + StoragePoolVO findPoolByHostPath(long dcId, Long podId, String host, String path, String uuid); List listPoolByHostPath(String host, String path); diff --git a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java index b1f8db25336..8ec1e6948ab 100644 --- a/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java +++ b/server/src/com/cloud/storage/dao/StoragePoolDaoImpl.java @@ -115,6 +115,7 @@ public class StoragePoolDaoImpl extends GenericDaoBase imp HostPathDcPodSearch.and("path", HostPathDcPodSearch.entity().getPath(), SearchCriteria.Op.EQ); HostPathDcPodSearch.and("datacenterId", HostPathDcPodSearch.entity().getDataCenterId(), Op.EQ); HostPathDcPodSearch.and("podId", HostPathDcPodSearch.entity().getPodId(), Op.EQ); + HostPathDcPodSearch.and("uuid", HostPathDcPodSearch.entity().getUuid(), Op.EQ); HostPathDcPodSearch.done(); HostPathDcSearch = createSearchBuilder(); @@ -145,6 +146,8 @@ public class StoragePoolDaoImpl extends GenericDaoBase imp sc.setParameters("uuid", uuid); return findOneIncludingRemovedBy(sc); } + + @Override public List findIfDuplicatePoolsExistByUUID(String uuid) { @@ -193,12 +196,13 @@ public class StoragePoolDaoImpl extends GenericDaoBase imp } @Override - public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path) { + public StoragePoolVO findPoolByHostPath(long datacenterId, Long podId, String host, String path, String uuid) { SearchCriteria sc = HostPathDcPodSearch.create(); sc.setParameters("hostAddress", host); sc.setParameters("path", path); sc.setParameters("datacenterId", datacenterId); sc.setParameters("podId", podId); + sc.setParameters("uuid", uuid); return findOneBy(sc); }