bug 9210: remove storage pool entry if adding storage pool fails

status 9210: resolved fixed
This commit is contained in:
anthony 2011-03-29 17:43:46 -07:00
parent 0cd415c8d2
commit f71986125a
1 changed files with 3 additions and 4 deletions

View File

@ -1111,9 +1111,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
pool.setClusterId(clusterId);
pool.setStatus(StoragePoolStatus.Up);
pool = _storagePoolDao.persist(pool, details);
if (allHosts.isEmpty()) {
return pool;
}
boolean success = false;
for (HostVO h : allHosts) {
success = createStoragePool(h.getId(), pool);
@ -1123,6 +1121,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
if ( !success ) {
s_logger.warn("Can not create storage pool " + pool + " on cluster " + clusterId);
_storagePoolDao.expunge(pool.getId());
return null;
}
s_logger.debug("In createPool Adding the pool to each of the hosts");
@ -1136,7 +1135,7 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
if (poolHosts.isEmpty()) {
_storagePoolDao.expunge(pool.getId());
pool = null;
return null;
} else {
createCapacityEntry(pool);
}